\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{inputenc}
\usepackage{geometry}
\usepackage{cancel}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}

\begin{document}

	\title{MITx 15.455x Mathematical Methods for Quantitative Finance
	 \\
	\begin{large}
		Recitation 5
	\end{large} }

	\maketitle

	\section*{Module 2: Expectations from Browninan integrals}

Let's look at more expectations involving
our stochastic processes.
We know that $dB$ is a Gaussian random variable
with a mean $0$ and variance $dt$.

$$ dB \sim N(0,dt) $$

We also know that if we integrate $\int_{0}^{t} dB$ , and for convenience, I can write this as:

$$  \int_{0}^{t} dB = B_t - B_0 \sim N(0,t ) $$

Let's agree that $B_0=0$.

So since that is the case, we have an easy way that we can write things.
We know that the expectation of $B$ is going to be 0.
We know that its variance is going to be $t$.

So let's just replace the random variable $B_t-B_0$ by $\sqrt{t}z$ where $z \sim N(0,1)$

Where $z$ doesn't have any time dependence.  So that's just simplifying things and putting everything
in an even more standard form. But it also makes explicit the time dependent.
And it's the scaling with time that's going to be important for a lot of financial applications, and for risk management.
So, what that means is that any time
where we see a $B_t$, or a $B_t$ minus $B_0$,
we can replace it by that function.
So if we want to compute the expectation of some function, we can just write: $$E[f(B_t-B_0)] = E[f(\sqrt{t} z)]$$  and compute that.

And remember, these are our Gaussian intervals. So we just need to do an integral. That's all it is. So this is equal:

 $$E[f(B_t-B_0)] = E[f(\sqrt{t} z)] = \frac{1}{\sqrt{2\pi}} \int e^{-z^2/2}f(\sqrt{t}z) dz$$

Easy.

So for example, suppose we wanted to compute the expectation of the fourth power.
 $$ f(x) = x^4$$
So we'd like to compute:

 $$E[f(B_t-B_0)] = E[(B_t-B_0)^4] = E[(\sqrt{t} z)^4] = t^2 E[z^4] = 3t^2 $$

We can pull out $\sqrt{t}$,which is nonstochastic to get $t^2 E[z^4]$
, $E[z^4]$ is a well-known Gaussian integal that we use in the kurtosis.
It's just equal to 3.

All right.

So this way of standardizing things and writing things
in terms of $z$ when we work in the integral form,
when we integrate our processes, is very convenient.
Let's do an example, and I want to review
a very useful trick with you.
So let's take a look.

\subsection*{Example}
Suppose we wanted to compute
$$ E[e^{6X}] \text{ where }  dX = \mu dt + \sigma dB $$

where $dX$, let's just say it's ordinary Brownian motion.

OK, because it's on this form, you can integrate as:

$$ \text{integrate:}  X_t-X_0 = \mu t + \sigma \sqrt{t} z $$

So if we go to compute the expectation :

$$ E[e^{6(\mu t + \sigma \sqrt{t} z)}] = e^{6\mu t}  E[e^{6 \sigma \sqrt{t} z}]  $$

\subsubsection*{Useful Formula}

Suppose that we have $E[e^{\alpha z + \beta}]$. And this shows up a lot in particular in asset
pricing formulas.
So this is clearly equal to

$$ $$

\begin{equation*}
	\begin{split}
		E[e^{\alpha z + \beta}]  & = e^{\beta} E[e^{\alpha z }]  \\
                                 & = \frac{e^{\beta}}{\sqrt{2 \pi}} \int e^{-z^2/2}e^{\alpha z} dz \\
                                 & = \frac{e^{\beta}}{\sqrt{2 \pi}} \int e^{-z^2/2 + \alpha z - \alpha^2/2 + \alpha^2/2 } dz \\
                                 & = \frac{e^{\beta}}{\sqrt{2 \pi}} \int e^{-(z^2 - 2 \alpha z + \alpha^2)/2 + \alpha^2/2 } dz \\
                                 & = \frac{e^{\beta}}{\sqrt{2 \pi}} \int e^{-(z-\alpha)^2/2 + \alpha^2/2} dz \\
                                  & = e^{\beta+ \alpha^2/2} \Big[\frac{1}{\sqrt{2 \pi}} \int e^{-(z-\alpha)^2/2 } dz \Big]
	\end{split}
\end{equation*}

We do the Gaussian integral, with the trick of completing the square in the exponent.
And because the integral goes from minus infinity to infinity, the difference in the exponential between $z$
and $z-\alpha$ makes no difference at all.
If you'd like, you can shift the variable of integration.
The integral inside the square brackets
with $\frac{1}{\sqrt{2 \pi}}$ in front is equal to 1.
So our final result, our final useful formula, is that:

$$ E[e^{\alpha z + \beta}]  = e^{\beta+ \alpha^2/2}$$

Now, let's apply that to our example.

$$	E[e^{6X}]   = E[e^{ 6\mu t + 6 \sigma \sqrt{t} z}]   $$

with $\alpha=6 \sigma \sqrt{t}$ and $\beta = 6 \mu t$ , we apply $ E[e^{\alpha z + \beta}]  = e^{\beta+ \alpha^2/2}$

\begin{equation*}
	\begin{split}
		E[e^{6X}] &= e^{6 \mu t + (6 \sigma \sqrt{t})^2/2}  \\
	    &= e^{6 \mu t + 18 \sigma^2 t}
	\end{split}
\end{equation*}

So there's our answer for finding this expectation.
And this works, generally, for a larger class
of functions that show up for different kinds of Ito
processes.

	\section*{Module 3: Solutions to the diffusion equation}

Let's take a closer look at the diffusion equation. So the general diffusion equation is given right here.

So we say that we have a function $p(z,t)$,
$$ p(z,t) = \int p_0(z-w,t)f(w)dw $$

and they need to satisfy this differential equation.
$$ \frac{\partial p}{\partial t} - \frac{1}{2} \frac{\partial ^2 p}{\partial z^2} = 0 $$

And we've seen that there's a very special solution, $p_0$, that satisfies that equation, which
we can find by plugging it in and taking some derivatives. So here's our $p_0$.

$$ p_0 = \frac{1}{\sqrt{2 \pi t}} e^{-\frac{z^2}{2t}} $$

Now, I claimed that if we construct this integral on top,
that this is the solution to the equation.
So what I'd like to do is, let's check that,
and then let's apply it.
So the first thing to do is to check it.
And the way we do it is we take derivatives.
And what we find is that if we take that integral expression,
and we stick it into the differential equation, what
we'll do is, we'll move the differential operators inside.
So for example,

$$ \frac{\partial}{\partial t} p(z,t) = \int \frac{\partial}{\partial t} \Big[  p_0(z-w,t)f(w)dw \Big] $$

But where is the $t$ dependence?
The $t$ dependence is only in one place.
It's in $p_0$.

And similarly,

$$ \Big( \frac{\partial}{\partial t} -\frac{1}{2} \frac{\partial^2}{\partial z^2} \Big)p(z,t) = \int  \Big[  \frac{\partial}{\partial t} -\frac{1}{2} \frac{\partial^2}{\partial z^2}  \Big]  p_0(z-w,t)f(w)dw $$

\subsection*{Exercise}

Suppose that

$$ f(z) = z^2 $$
$$ p(z,0) = z^2 $$
$$ \text{find } p(z,t) $$

So what we need to do is, we've got a formula.
Let's just plug and chug.

\begin{equation*}
	\begin{split}
		p(z,t) &= \int p_0(z-w,t)f(w)dw  \\
		       &= \int  \frac{1}{\sqrt{2 \pi t}} e^{-\frac{(z-w)^2}{2t}} w^2 dw
	\end{split}
\end{equation*}

Remember, it's a Gaussian where the variance is $t$.
So it's not completely standardized.
So there is $t$ dependence in this.
How do we do this integral?
Well, let's change variables. So what we'd like to do is, let's simplify the exponent
and pick a new variable.

$$ \text{let } u=\frac{w-z}{\sqrt{t}}  \implies  du=\frac{dw}{\sqrt{t}} $$
$$ \implies  w=u \sqrt{t} + z $$

So let's make those substitutions.

\begin{equation*}
	\begin{split}
		p(z,t) &=   \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty}  e^{-\frac{u^2}{2}} (u \sqrt{t} + z)^2 du
	\end{split}
\end{equation*}

Because now we almost have things in standardized form
for a Gaussian interval, let's just expand that out.

\begin{equation*}
	\begin{split}
		p(z,t) &=   \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty}  e^{-\frac{u^2}{2}} (u^2t + 2u \sqrt{t}z + z^2) du  \\
		 &=   t \Big[\frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty}  e^{-\frac{u^2}{2}} u^2 \Big] + 0 +
		 z^2 \cancelto{1}{\Big[\frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty}  e^{-\frac{u^2}{2}} u^2 \Big]}
	\end{split}
\end{equation*}

Let's look at each of these terms.
The first term,  is going to be $u^2t$.
Remember, $t$ is a constant with respect
to the variable of integration.
The second term, $ 2u \sqrt{t}z$, is going to vanish.
Because it's linear in $u$, this is an odd function in $u$.
We're going from minus infinity to infinity.
And odd functions are going to have varnishing integrals.
It's just a plus sign to the minus sign
are going to cancel each other out.
And then, the last term, $z^2$, that's just going to be multiplied by a constant a constant equal to 1.

Because $\frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty}  e^{-\frac{u^2}{2}} u^2$ is just the variance
of the standardized Gaussian distribution.

So we do the integrals. And what we're left with is :

	$$ p(z,t) = z^2+t $$

And we can check that it satisfies our differential
equation.

$$ \frac{\partial p}{\partial t} = 1 \text{ , } \frac{1}{2} \frac{\partial ^2 p}{\partial z} = 1 $$

And if we subtract the two of them, we get 0.
So we're done.
So this is the answer.
Let's do one more exercise.

\subsection*{Exercise}

Slightly different version of the one that we did in lecture.
But now, don't refer back to the lecture.
Just take a look at what we've done for the integrals.
And do this one yourself.
So what I'd like to do is introduce the Gaussian
cumulative distribution function,
which is going to be useful and show up in a few places.
I will call this $\Phi(x)$.
It's going to be defined as:

$$ \Phi(x) =  \frac{1}{\sqrt{2 \pi}}\int_{-\infty}^{x} e^{-z^2/2} dz = Prob(Z<x) $$

So I compute the left side of the integral
of the bell curve for the Gaussian distribution
up to some point $x$.
So in terms of Gaussian probabilities,
this is the same thing as the probability
that a Gaussian random variable $Z$ is less
than some particular value $x$.
Now, from the fundamental theorem of calculus of course,
I know that :

$$ \frac{d}{dx}\Phi(x) =  \frac{1}{\sqrt{2 \pi}} e^{-x^2/2} $$

So I can differentiate or I can integrate.
I can go back and forth.
But this basic idea that it's an incomplete integral.
So I integrate from minus infinity
up to a particular value $x$ that's defined out here.
It's going to be useful, and we'll
see that it shows up in a bunch of places.
Here's a really simple example.

\begin{equation*}
	f(w) =
	\begin{cases}
		1 & \text{if $w<\kappa$ }\\
		0 & \text{if $w>\kappa$}
	\end{cases}
\end{equation*}

$ f(w) = p(w,0)$  find $p(z,t)$

So the question is, find $p(z,t)$,

So at time 0, it's a step function.
It's either 0 or 1 depending on the value of its argument.

So what we'd like to do is, we want to find $p(z,t)$
for the general case.
So take a moment, see if you can work it out
from our general definition.

Remember that our definition is, we integrate $p_0$
against $p_0$ evaluated at $z-2$ against the function $f(w)$.
And we integrate that over $w$ in an explicit expression
in terms of $z$.
Go take a moment to do that.
And then, we'll take a look at this together.

OK?
Let's go.
Let's just work from the definition.
The reason why this is particularly nice
is the integrand is either 1 or 0.
So there's an interesting generalization
that's important for the Black-Scholes case, where
we might-- instead of 1 or 0, we might
like to let it be 0 in the lower case, but $\kappa-w$
in the upper case.
So after you've done this one, I'd
suggest trying that one as an extension.
But this one's fairly straightforward.
So let's do this one together just
to make sure we've got the concepts and our definitions
of the integral.

So this is going to be:

$$	p(z,t) =    \int_{-\infty}^{\kappa} \frac{1}{\sqrt{2 \pi t}} e^{-\frac{(z-w)^2}{2t}} dw  $$

$$ \text{let } u = \frac{w-z}{\sqrt{t}}  \implies du = \frac{dw}{\sqrt{t}}$$

In addition, our upper limit of integration is $w=\kappa$.
And that's going to translate into an upper limit of
$$u* = \frac{\kappa-z}{\sqrt{t}} $$

So, now we have:

\begin{equation*}
	\begin{split}
		p(z,t) &=   \int_{-\infty}^{\frac{\kappa-z}{\sqrt{t}}} \frac{1}{\sqrt{2 \pi }} e^{-\frac{u^2}{2}} du \\
		&=   \Phi \Big(\frac{\kappa-z}{\sqrt{t}} \Big)
	\end{split}
\end{equation*}

Which is a very well behaved function
for positive values of $t$.
And it would be interesting to take a look
and plot this as t goes to 0.
But right now, we have the result that we saw it.
And we can check this, again, by differentiating and putting it
into the differential equation, and verifying that it satisfies
the equation, and verifying that it
satisfies the initial conditions a $t$ equals 0.
Which as I said, it requires taking a limit,
because we can't immediately set $t$ equals 0
in this case in the way we did previously.

\end{document}


\documentclass[pdftex,a4paper,12pt]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage{lmodern} % Latin Modern font

\usepackage{amsmath,amssymb,amsthm}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage[capitalise]{cleveref}
\usepackage{tikz}
\usetikzlibrary{cd}
%\usepackage{algpseudocode}

%%%
%%% THEOREM ENVIRONMENTS (amsthm.sty)
%%%
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}

\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newtheorem{problem}{Problem}

\theoremstyle{remark}
\newtheorem{example}[theorem]{Example}
\newtheorem{remark}[theorem]{Remark}
\newtheorem*{notation}{Notation}

\numberwithin{equation}{section}

%%%
%%% Article data
%%%
\title{Technical Materials}
\author{Jun Yoshida}
\date{\today}

\begin{document}
\maketitle

In this note, we explain some technical materials used in the codes.

\tableofcontents

\section{On the second fundamental forms}

\subsection{Definition}

\begin{definition}
Let $M$ be an orientable $n$-dimensional manifold embedded in the Euclidean space $\mathbb R^{n+1}$.
Then, a \emph{normal vector field} is a section $\mathbf n$ of the vector bundle $\left.T\mathbb R^{n+1}\right|_M\to M$ such that, for each $p\in M$, we have
\begin{equation}
\label{eq:normal-vf}
T\mathbb R^{n+1}= T_pM\oplus \mathbb R\mathbf n(p)
\quad.
\end{equation}
We in addition say that $\mathbf n$ is positive provided the identity \eqref{eq:normal-vf} respects the orientation.
\end{definition}

Note that every $M$ as in the definition above admits a unique normal vector field of constant length $1$; indeed, the standard metrin con $\mathbb R^{n+1}$ and the orientation on $M$ determine a splitting of the following short exact sequence of vector bundles:
\[
0\to TM\to \left.T\mathbb R^{n+1}\right|_M \to \nu M\to 0
\quad,
\]
where $\nu M$ is the normal bundle of the embedding $M\hookrightarrow\mathbb R^{n+1}$.
On the other hand, since $M$ is orientable, the bundle $\nu M$ is orientable and hence a trivial bundle.
Thus, one can choose a nowhere-vanishing section $s:M\to \nu M$, and a unit normal vector field $\mathbf n$ is obtained by normalizing $s$; here is only one choice of $\mathbf n$ so that it is positive.

In the case above, let us denote by $S\mathbb R^{n+1}$ the unit sphere bundle associated to the tangent bundle $\mathbb R^{n+1}$; hence, if $\mathbf n$ is a positive normal vector field on $M$, then the assignment
\[
M \to S\mathbb R^{n+1}
\ ;\quad p\mapsto \frac{\mathbf n(p)}{\|\mathbf n(p)\|}
\]
defines a section of the bundle $\left. S\mathbb R^{n+1}\right|_M\to M$.
Since $S\mathbb R^{n+1}$ has a canonical trivialization, this gives rise to a smooth map $\nu:M\to S^n$, which we call the \emph{Gauss map}.

\begin{definition}
Let $\nu$ be the Gauss map on $M$.
Then, the \emph{second fundamental form} is the bilinear form
\[
\mathbf{II}_M:TM\otimes_M TM\to\underline{\mathbb R}_M
\]
given by
\[
\mathbf{II}_M(v,w)
\coloneqq -\langle d\nu(v),w\rangle
\quad.
\]
\end{definition}

\begin{example}
In case $n=1$, let $\gamma=(\gamma_1,\gamma_2):(-\varepsilon,\varepsilon)\to M\subset\mathbb R^2$ be a regular curve which gives a coordinate around a point $\gamma(0)=p\in M$.
Then, we have a positive normal vector field on the coordinate given by
\[
\gamma^\perp(t)\coloneqq \left(-\frac{d\gamma_2}{dt}(t),\frac{d\gamma_1}{dt}(t)\right)
\quad.
\]
In particular, if $\gamma$ is parametrized by arc-length, $\gamma^\perp$ gives the Gauss map as $\nu\gamma=\gamma^\perp$.
It follows that
\[
d\nu\left(\frac{d\gamma}{dt}(0)\right)
= \frac{d\gamma^\perp}{dt}(0)
= \left(-\frac{d^2\gamma_2}{dt^2}(0),\frac{d^2\gamma_1}{dt^2}(0)\right)
\]
and the second fundamental form is determined by the equation
\[
\mathbf{II}_\gamma\left(\frac{d\gamma}{dt}(0),\frac{d\gamma}{dt}(0)\right)
= \frac{d^2\gamma_2}{dt^2}(0)\frac{d\gamma_1}{dt}(0) - \frac{d^2\gamma_1}{dt^2}(0)\frac{d\gamma_2}{dt}(0)
= \left\langle \frac{d^2\gamma}{dt^2}(0), \gamma^\perp(0)\right\rangle
\quad.
\]
Note that, since $\gamma$ has a constant velocity, namely $\|d\gamma/dt\|\equiv1$, the vector $d^2\gamma/dt^2(0)$ is parallel to $\gamma^\perp$.
Hence, we have
\[
\mathbf{II}_\gamma\left(\frac{d\gamma}{dt}(0),\frac{d\gamma}{dt}(0)\right)\cdot\gamma^\perp(0)
= \frac{d^2\gamma}{dt^2}(0)
\quad,
\]
which is exactly the curvature vector of the curve $\gamma$.
\end{example}

\subsection{Formula for the regular level sets}

We now compute the second fundamental form for the regular level set of a function.
Let $f:\mathbb R^{n+1}\to\mathbb R$ be a smooth function with $0\in\mathbb R$ as a regular value.
We compute the second fundamental form on the submanifold
\[
M\coloneqq\{x\in\mathbb R^{n+1}\mid f(x)=0\}
\quad.
\]
It directly follows from the definition that the following is an exact sequence of vector bundles over $M$:
\[
0\to TM\hookrightarrow \left.T\mathbb R^{n+1}\right|_M \xrightarrow{df} \underline{\mathbb R}_M\to 0
\quad,
\]
where $\underline{\mathbb R}_M$ is the trivial bundle with fiber $\mathbb R$.
In other words, a vector $a_0\frac\partial{\partial x_0}+\dots+a_n\frac\partial{\partial x_n}$ on $\mathbb R^{n+1}$ is tangent to $M$ if and only if the vector
\begin{equation}
\label{eq:df-normal}
df\left(\sum_{i=0}^n a_i\frac\partial{\partial x_i}\right)
= \sum_{i=0}^n a_i\frac{\partial f}{\partial x_i}
\end{equation}
vanishes.
This implies that, for each $\vec x=(x_0,\dots,x_n)\in M$, the vector
\[
df^\ast(\vec x)
\coloneqq \left(\frac{\partial f}{\partial x_0}(\vec x),\dots,\frac{\partial f}{\partial x_n}(\vec x)\right)
\]
is normal to $M$.
We endow $M$ with the orientation so that $\mathbf n_f$ is positive.
Then, for the Gauss map $\nu$, we have
\begin{equation}
\label{eq:f-Gauss}
d_{\vec x}\nu\left(\sum_{i=0}^n a_i\frac\partial{\partial x_i}\right)
= \sum_{i=0}^n a_i \left.\frac{\partial}{\partial x_i}\right|_{\vec x} \frac{df^\ast}{\|df^\ast\|}
\quad.
\end{equation}
Note that the equation \eqref{eq:df-normal} implies that
\begin{equation}
\label{eq:diff-normrec}
\begin{split}
\sum_{i=0}^n a_i\left.\frac{\partial}{\partial x_i}\right|_{\vec x}
\frac1{\|df^\ast\|}
&= \sum_{i=0}^n a_i\left.\frac{\partial}{\partial x_i}\right|_{\vec x}\left(\sum_{j=0}^n\left(\frac{\partial f}{\partial x_j}\right)^2\right)^{-1/2} \\
& = -\frac1{2\|df^\ast(\vec x)\|^3} \sum_{i=0}^n\sum_{j=0}^n 2a_i\frac{\partial f}{\partial x_j}(\vec x)\frac{\partial^2f}{\partial x_i\partial x_j}(\vec x) \\
& = -\frac1{\|df^\ast(\vec x)\|^3}\sum_{j=0}^n \frac{\partial f}{\partial x_j}(\vec x)\left.\frac{\partial}{\partial x_j}\right|_{\vec x} \sum_{i=0}^n a_i\frac{\partial f}{\partial x_i} \\
& = 0
\quad.
\end{split}
\end{equation}
Combining \eqref{eq:f-Gauss} and \eqref{eq:diff-normrec}, we obtain
\begin{equation}
\label{eq:f-II-form}
\mathbf{II}_{\{f=0\}}\left(\sum_{i=0}^na_i\frac{\partial}{\partial x_i},\sum_{j=0}^nb_j\frac\partial{\partial x_j}\right)
= -\frac{1}{\|df^\ast\|}\sum_{i=0}^n\sum_{j=0}^n a_ib_j\frac{\partial^2f }{\partial x_i\partial x_j}
\quad.
\end{equation}
If we denote by $H_f$ the Hessian matrix, then the bilinear form $\mathbf{II}_{\{f=0\}}$ is represented by the matrix $H_f/\|df^\ast\|$.

\begin{example}
\label{ex:II-on-circle}
For a positive real number $r$, define $f:\mathbb R^2\to\mathbb R$ by
\begin{equation}
\label{eq:circle-deffun}
f(x,y)\coloneqq x^2+y^2-r^2
\quad.
\end{equation}
Put $C\coloneqq\{f=0\}$ the zero-set; i.e. the circle of radius $r$.
For each $(x,y)\in C$, we have
\[
df^\ast(x,y) = (2x,2y)
\ ,\quad
\|df^\ast(x,y)\| = \sqrt{4x^2 + 4y^2} = 2r
\quad.
\]
On the other hand, $C$ is parametrized by the map
\[
\gamma:\mathbb R\to C
\ ;\quad \theta\mapsto \left(r\cos\frac\theta{r},r\sin\frac\theta{r}\right)
\]
so that $\|d\gamma/d\theta\|\equiv 1$.
We have
\[
\mathbf{II}_C\left(\frac{d\gamma}{dt}(\theta),\frac{d\gamma}{dt}(\theta)\right)
= \frac1{2r}\left(2\left(-\sin\frac\theta{r}\right)^2 + 2\left(\cos\frac\theta{r}\right)^2\right) = \frac1{r}
\quad.
\]
Note that the vector
\begin{equation}
\label{eq:II-curvature}
\mathbf{II}_C\left(\frac{d\gamma}{dt}(\theta),\frac{d\gamma}{dt}(\theta)\right)\cdot \frac{df^\ast}{\|df^\ast\|}
= -\frac{1}{r^2}\gamma(\theta)
\end{equation}
equals the curvature vector of $C$.
\end{example}

\begin{remark}
If a codimension $1$ submanifold $M\subset\mathbb R^{n+1}$ is defined as a zero-set of a function $f$, then the orientation on $M$ does depend on $f$.
For example, to define the same submanifold $C$ as in \cref{ex:II-on-circle}, one can take a function $g:\mathbb R^2\to\mathbb R^2$ given by
\[
g(x,y)\coloneqq -x^2-y^2+r^2
\]
instead of $f$ in \eqref{eq:circle-deffun}.
Then, the induced orientation on $C$ is reversed; so we have
\[
\mathbf{II}_{\{g=0\}}\left(\frac{d\gamma}{dt}(\theta),\frac{d\gamma}{dt}(\theta)\right)
= -\frac1{r}
\quad.
\]
In contrast, since $df^\ast = -dg^\ast$, the curvature vector \eqref{eq:II-curvature} is invariant of the choice of the defining function.
\end{remark}

More generally, we have the following result in the $2$-dimensional cases.

\begin{proposition}
\label{prop:f-curvature}
Let $f:\mathbb R^2\to\mathbb R$ be a smooth function with $0\in\mathbb R$ being a regular value; put $C\coloneqq\{(x,y)\mid f(x,y)=0\}$.
Then, the curvature vector $\kappa$ of $C$ is, as a function on $C$, given by
\[
\kappa
= -\left(
\left(\frac{\partial f}{\partial y}\right)^2\frac{\partial^2 f}{\partial x^2}
-2\frac{\partial f}{\partial x}\frac{\partial f}{\partial y}\frac{\partial^2 f}{\partial x\partial y}
+\left(\frac{\partial f}{\partial x}\right)^2\frac{\partial^2 f}{\partial y^2}
\right)\cdot
\frac{df^\ast}{\|df^\ast\|^4}
\]
\end{proposition}
\begin{proof}
We set
\[
df^\perp(x,y)
\coloneqq \left(-\frac{\partial f}{\partial y}(x,y), \frac{\partial f}{\partial x}(x,y)\right)
\quad.
\]
It is easily verify that, if $(x,y)\in C$, then $df^\perp(x,y)$ is a tangent vector at $(x,y)$.
We also have $\|df^\perp(x,y)\|=\|df^\ast(x,y)\|$.
Hence, using the formula \eqref{eq:f-II-form}, we obtain
\[
\begin{split}
\kappa
&= -\mathbf{II}_C\left(\frac{df^\perp}{\|df^\perp\|},\frac{df^\perp}{\|df^\perp\|}\right)\cdot\frac{df^\ast}{\|df^\ast\|} \\
&= -\left(
\left(\frac{\partial f}{\partial y}\right)^2\frac{\partial^2 f}{\partial x^2}
-2\frac{\partial f}{\partial x}\frac{\partial f}{\partial y}\frac{\partial^2 f}{\partial x\partial y}
+\left(\frac{\partial f}{\partial x}\right)^2\frac{\partial^2 f}{\partial y^2}
\right)\cdot
\frac{df^\ast}{\|df^\ast\|^4}
\quad.
\end{split}
\]
\end{proof}

\begin{example}
Let $f:\mathbb R^2\to\mathbb R$ be a quadratic function of the form
\[
f(x,y)=ax^2+by^2-c
\]
with $ab\neq 0$ and $c\neq 0$.
Then,
\[
df^\ast(x,y) = (2ax, 2by)
\ ,\quad
\|df^\ast(x,y)\| = 2\sqrt{a^2x^2+b^2y^2}
\quad;
\]
so in particular, $0\in\mathbb R$ is a regular value of $f$.
By virtue of \cref{prop:f-curvature}, we obtain
\[
\kappa(x,y)
= -\frac{8ab^2y^2+8a^2bx^2}{16(a^2x^2+b^2y^2)^2}(2ax,2by)
= -\frac{abc}{(a^2x^2+b^2y^2)^2}(ax,by)
\quad.
\]
For example, if $a=b=1$ and $c=r^2$, this agrees with the computation in \cref{ex:II-on-circle}.
\end{example}

\section{Quadratic B\'ezier triangles}
\label{sec:qbeztri}

\subsection{Definition}

Let $V$ be a (finite dimensional) real vector space, so there is a canonical identification $TV=V\times V$.
We write
\[
\Delta^2\coloneqq\{(t_0,t_1,t_2)\in\mathbb R^3\mid t_0+t_1+t_2=1,\,t_i\ge0\ \text{for $i=0,1,2$}\}
\]
the (geometric) $2$-simplex.

\begin{definition}
A \emph{quadratic B\'ezier triangle} in $V$ is a map $p:\Delta^2\to V$ of the form
\[
p(t_0,t_1,t_2)
= \sum_{i=0}^2 t_i^2 v^{(i)}+2\sum_{\{i,j,k\}=\{0,1,2\}} t_i t_je^{(k)}
\]
for six points $v^{(0)},v^{(1)},v^{(2)},e^{(0)},e^{(1)},e^{(2)}\in V$, which are called the \emph{control points} of $p$.
\end{definition}

It is easily seen that
\[
p(1,0,0) = v^{(0)}
\ ,\quad p(0,1,0) = v^{(1)}
\ ,\quad p(0,0,1) = v^{(2)}
\ ,
\]
while the image $p(\Delta^2)$ may not contain the points $e^{(0)}$, $e^{(1)}$, and $e^{(2)}$.

\begin{lemma}
A quadratic B\'ezier triangle restricts to a quadratic B\'ezier curve on each edge of $\Delta^2$.
\end{lemma}
\begin{proof}
Note that an edge of $\Delta^2$, namely
\[
\partial_i\Delta^2\coloneqq \{(t_0,t_1,t_2)\in\Delta^2\mid t_i=0\}
\]
for $i=0,1,2$, is parametrized so that, with cyclic indices,
\[
t_i=0
,\,
t_{i+1}=t
,\,
t_{i+2}=1-t
\quad.
\]
In this point of view, we have
\[
\left.p\right|_{\partial_i\Delta^2}(t)
= t^2v^{(i+1)} + 2t(1-t) e^{(i)} + (1-t)^2 v^{(i+2)}
\quad.
\]
\end{proof}

\subsection{Tangent space}
\label{sec:Beztri:tangent}

We compute the tangent spaces of quadratic B\'ezier triangles.
We fix a quadratic B\'ezier triangle $p:\Delta^2\to V$ with control points $v^{(0)},v^{(1)},v^{(2)},e^{(0)},e^{(1)},e^{(2)}\in V$.

First observe that, a vector
\[
X=a\frac\partial{\partial t_0}+b\frac\partial{\partial t_1}+c\frac\partial{\partial t_2}
\]
on a point of $\Delta^2$ is tangent to $\Delta^2$ if and only if $a+b+c=0$.
We in particular set
\[
X^{ij}\coloneqq  \frac12\left(\frac\partial{\partial t_i}-\frac\partial{\partial t_j}\right)
\quad.
\]
Then, for each point $\vec t\in\Delta^2$, the tangent space $T_{\vec t}\Delta^2$ is spanned by two vectors $X^{ij}$ and $X^{ik}$ provided $\{i,j,k\}=\{0,1,2\}$.
On the other hand, we have
\[
p_\ast\left(\frac\partial{\partial t_i}\right)
= 2t_iv^{(i)}+2t_je^{(k)}+2t_ke^{(j)}
\]
and hence
\begin{equation}
\label{eq:dpX}
\begin{split}
p_\ast(X^{ij})
&= t_iv^{(i)}-t_jv^{(j)}+(t_j-t_i)e^{(k)}+t_k(e^{(j)}-e^{(i)}) \\
&= t_i(v^{(i)}-e^{(k)})+t_j(e^{(k)}-v^{(j)})+t_k(e^{(j)}-e^{(i)})
\quad.
\end{split}
\end{equation}
Putting $w_{ij}\coloneqq e^{(k)}-v^{(i)}$, one also obtains
\begin{equation}
\label{eq:dpX-inw}
p_\ast(X^{ij})
= -t_iw_{ij}+t_jw_{ji}+t_k(w_{ki}-w_{kj})
\quad.
\end{equation}

\subsection{Singular loci}
\label{sec:Beztri:sing}

We are interested in the singular locus of a quadratic B\'ezier triangle $p:\Delta^2\to V$ for $\dim V\ge 2$.
In view of the previous section, a point $\vec t=(t_0,t_1,t_2)\in\Delta^2$ is a critical point of $p$ if and only if two vectors $p_\ast(X^{ij})$ and $p_\ast(X^{ik})$ are in parallel for $\{i,j,k\}=\{0,1,2\}$.
Using the exterior product $V\wedge V$, this is equivalent to the equation
\[
p_\ast(X^{ij})\wedge p_\ast(X^{ik})=0
\quad.
\]
On the other hand, by virtue of the equation \eqref{eq:dpX-inw}, we have
\begin{equation}
\label{eq:singlocus-def}
\begin{split}
& p_\ast(X^{ij})\wedge p_\ast(X^{ik}) \\
&= \left(-t_iw_{ij}+t_jw_{ji}+t_k(w_{ki}-w_{kj})\right)\wedge\left(-t_iw_{ik}+t_j(w_{ji}-w_{jk})+t_kw_{ki}\right) \\
&=
\begin{multlined}[t]
t_i^2 w_{ij}\wedge w_{ik}-t_j^2w_{ji}\wedge w_{jk}-t_k^2w_{kj}\wedge w_{ki}
- t_it_j\left(w_{ij}\wedge(w_{ji}-w_{jk})+w_{ji}\wedge w_{ik}\right) \\
- t_jt_k\left(w_{ki}\wedge w_{jk}+w_{kj}\wedge(w_{ji}-w_{jk})\right)
- t_it_k\left(w_{ij}\wedge w_{ki}+(w_{ki}-w_{kj})\wedge w_{ik}\right)
\quad.
\end{multlined}
\end{split}
\end{equation}
It follows that the quadratic form \eqref{eq:singlocus-def} together with the linear equation $t_i+t_j+t_K=1$ defines the singular locus of $p$.
Note that, if $\dim V=n$, then $V\wedge V$ is of dimension $n(n-1)/2$; so we have $n(n-1)/2$ defining polynomials.
In particular, there is generically no critical point of $p$ except in the case $n=2$ where they form a $1$-dimensional submanifold of $\Delta^2$.

\section{On quadratic curves}

\subsection{Definition}

Recall that a \emph{quadratic form} on $\mathbb R^n$ is nothing but a real homogeneous polynomial of degree $2$ with $n$ variables.
More precisely, it is a polynomial of the form
\begin{equation}
\label{eq:quad-form-alph}
q(x_1,\dots,x_n)
= \sum_{i=1}^n A_ix_i^2+2\sum_{1\le i<j\le n} B_{ij}x_ix_j
\quad.
\end{equation}
For a quadratic form $q$ on $\mathbb R^n$, we define the associated matrix $M_q$ to be
\[
\begin{bmatrix}
A_1 & B_{12} & \cdots & B_{1n} \\
B_{12} & A_2 & \cdots & B_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
B_{1n} & B_{2n} & \cdots & A_n
\end{bmatrix}
\quad.
\]
Then, we can write
\begin{equation}
\label{eq:quad-form-mat}
q(x_1,\dots,x_n)
= \vec x^{\mathsf T} M_q\vec x
=
\begin{bmatrix}
x_1 & \cdots & x_n
\end{bmatrix}
M_q
\begin{bmatrix}
x_1 \\ \vdots \\ x_n
\end{bmatrix}
\quad.
\end{equation}

\begin{definition}
A quadratic form $q$ on $\mathbb R^n$ is said to be \emph{non-degenerate} (resp. \emph{degenerate}) if $\det M_q\neq 0$ (resp. $\det M_q=0$).
\end{definition}

\begin{lemma}
If $q$ is a non-degenerate quadratic form on $\mathbb R^n$, then for the map
\[
f_q:\mathbb R^{n-1}\to\mathbb R\ ;\quad (y_1,\dots,y_{n-1}) \mapsto q(y,\dots ,y_{n-1},1)
\quad,
\]
$0\in\mathbb R$ is a regular value of $f_q$.
\end{lemma}
\begin{proof}
We prove the contraposition; in particular, we show that if $\vec y=(y_1,\dots,y_{n-1})\in\mathbb R^{n-1}$ is a critical point of $f_q$ with $f_q(\vec y)=0$, then the vector $(y_1,\dots,y_{n-1},1)$ belongs to the kernel of $M_q$.

The direct computation shows that the total derivative $df:\mathbb R^{n-1}\to T^\ast\mathbb R^{n-1}$ is given by
\[
df_q(y_1,\dots,y_{n-1})
= \sum_{i=1}^{n-1}\left(\vec e^{(i)\mathsf T} M_q\widehat y+\widehat y^{\mathsf T} M_q e_i\right) dy_i \\
= 2 \sum_{i-1}^{n-1} \vec e^{(i)\mathsf T}M_q\widehat y\, dy_i
\quad,
\]
here $\widehat y=(y_1,\dots,y_{n-1},1)$ and $\vec e^{(i)}=(0,\dots,\overset{\substack{i\\\smash\smile}}{1},\dots,0)$ seen as column vectors.
Under the canonical identification $T^\ast\mathbb R^{n-1}\cong \mathbb R^{n-1}\times\mathbb R^{n-1}$, it turns out that $df$ can be seen as the map given by
\begin{equation}
\label{eq:prf:fq-diff}
df_q(y_1,\dots,y_{n-1})
= 2M_q'\vec y+ 2v_q
\quad,
\end{equation}
where $\vec y=(y_1,\dots,y_{n-1},0)$ and $M_q'$ and $v_q$ are defined so that
\[
M_q =
\left[
\begin{array}{c|c}
  M_q' & v_q  \rule[-1.5ex]{0pt}{4ex}\\\hline\rule[-1.5ex]{0pt}{4ex}
  v_q^{\mathsf T} & A_n
\end{array}
\right]
\quad.
\]
On the other hand, we have
\[
\begin{split}
f_q(y_1,\dots,y_{n-1})
&= q(y_1,\dots,y_{n-1},1) \\
&= \widehat y^{\mathsf T} M_q\widehat y \\
&= \vec y^{\mathsf T} M_q'\vec y + 2v_q^{\mathsf T}\vec y + A_n
\quad.
\end{split}
\]
Hence, for $(y_1,\dots,y_{n-1})\in\mathbb R^{n-1}$ with $df(y_1,\dots,y_{n-1})=0$, we have
\begin{equation}
\label{eq:prf:fq-critv}
f_q(y_1,\dots,y_{n-1})
= v_q^{\mathsf T}\vec y + A_n
\quad.
\end{equation}
Combining \eqref{eq:prf:fq-diff} and \eqref{eq:prf:fq-critv}, we obtain $M_q\widehat y=0$ provided $df_q(y_1,\dots,y_{n-1})=f_q(y_1,\dots,y_{n-1})=0$.
This is exactly what we want to show.
\end{proof}

\begin{definition}
A \emph{(real) quadratic curve} is a curve $C$ in $\mathbb R^2$ such that
\[
C=\{(x,y)\in\mathbb R^2\mid q(x,y,1)=0\}
\]
for a quadratic form $q(x,y,z)$ on $\mathbb R^3$.
\end{definition}

\begin{remark}
It is easily seen that a quadratic form actually defines an algebraic function on the projective space $\mathbb P^n$.
One may sometimes use the word ``quadratic curves'' to refer algebraic subsets of the projective space $\mathbb P^2$ defined by quadratic forms of three variables.
In such cases, ``quadratic curves'' are always compact while ours might not.
\end{remark}

\subsection{The srandard forms}

\begin{proposition}
\label{prop:quad-standard}
Let $q$ be a quadratic form on $\mathbb R^n$ with matrices $M_q$ and $M'_q$ as in the previous section.
Suppose both the determinants $\det M_q$ and $\det M_q$ are non-zero.
Then, there is an orthogonal matrix $P\in\mathcal O(n-1)$ such that
\begin{gather}
\label{eq:M'-diag}
M'_q = P
\begin{bmatrix}
\lambda_1 && O \\
& \ddots & \\
O && \lambda_{n-1}
\end{bmatrix}
P^{\mathsf T}
\qquad\text{with $\lambda_i\in\mathbb R$}
\quad;
\\
\label{eq:q-standard}
q(y_1,\dots,y_{n-1},1)
= \sum_{i=1}^{n-1} \lambda_i\left(Y_i+\frac{\widetilde B_{i n}}{\lambda_i}\right)^2 + \frac{\det M_q}{\det M'_q}
\quad,
\end{gather}
where
\[
\begin{bmatrix}
Y_1\\\vdots\\ Y_{n-1}
\end{bmatrix}
\coloneqq P^{\mathsf T}
\begin{bmatrix}
y_1\\\vdots\\ y_{n-1}
\end{bmatrix}
\quad, \qquad
\begin{bmatrix}
\widetilde B_{1n} \\ \vdots \\ \widetilde B_{(n-1)n}
\end{bmatrix}
\coloneqq P^{\mathsf T}
\begin{bmatrix}
B_{1n} \\ \vdots \\ B_{(n-1)n}
\end{bmatrix}
\]
\end{proposition}
\begin{proof}
Since $M'_q$ is a symmetric matrix, we can take an orthogonal matrix $P$ satisfying \eqref{eq:M'-diag}.
Then, we have
\[
\begin{split}
& q(y_1,\dots,y_{n-1},1) \\
&=
\begin{bmatrix}
y_1 & \cdots & y_{n-1} & 1
\end{bmatrix}
\left[
\begin{array}{c|c}
  P
  \begin{bmatrix}
  \lambda_1 && \\
  & \ddots & \\
  && \lambda_{n=1}
  \end{bmatrix}
     P^{\mathsf T}
  &
    \begin{matrix}
    B_{1n} \\ \vdots \\ B_{(n-1)n}
    \end{matrix}
  \\\hline
  \begin{matrix}
  B_{1n} & \cdots & B_{(n-1)n}
  \end{matrix}
      & A_n
\end{array}
\right]
\begin{bmatrix}
y_1 \\ \vdots \\ y_{n-1} \\ 1
\end{bmatrix}
\\
&=
\begin{bmatrix}
Y_1 & \cdots & Y_{n-1} & 1
\end{bmatrix}
\left[
\begin{array}{c|c}
  \begin{matrix}
  \lambda_1 && \\ & \ddots & \\ && \lambda_{n-1}
  \end{matrix}
             & P^{\mathsf T}
               \begin{bmatrix}
               B_{1n} \\ \vdots \\ B_{(n-1)n}
               \end{bmatrix}
  \\\hline
  \begin{bmatrix}
  B_{1n} & \cdots & B_{(n-1)n}
  \end{bmatrix} P
                 & A_n
\end{array}
\right]
\begin{bmatrix}
Y_1 \\ \vdots \\ Y_{n-1} \\ 1
\end{bmatrix}
\\
&=
\begin{bmatrix}
Y_1 & \cdots & Y_{n-1} & 1
\end{bmatrix}
\begin{bmatrix}
\lambda_1  && &\widetilde B_{1n} \\
& \ddots && \vdots \\
&& \lambda_{n-1} & \widetilde B_{(n-1)n} \\
\widetilde B_{1n} & \cdots & \widetilde B_{(n-1)n} & A_n
\end{bmatrix}
\begin{bmatrix}
Y_1 \\ \vdots \\ Y_{n-1} \\ 1
\end{bmatrix}
\\
&= \sum_{i=1}^{n-1} (\lambda_i Y_i^2 + 2\widetilde B_{in}Y_i) + A_n
\\
\end{split}
\]
We denote by $\widetilde M_q$ the middle matrix in the fourth line.
Then, we have $\det M_q = \det \widetilde M_q$ and $\det M'_q =\lambda_1\dots\lambda_{n-1}$.
The asumption $\det M'_q=0$ guarantees that all of $\lambda_i$'s are non-zero.
Hence, we obtain
\[
\begin{split}
q(y_1,\dots,y_{n-1},1)
&= \sum_{i=1}^{n-1} \lambda_i\left(Y_i + \frac{\widetilde B_{in}}{\lambda_i}\right)^2
+ A_n-\sum_{i=1}^{n-1}\frac{B_{in}^2}{\lambda_i} \\
&= \sum_{i=1}^{n-1} \lambda_i\left(Y_i + \frac{\widetilde B_{in}}{\lambda_i}\right)^2 + \frac{\det M_q}{\det M'_q}
\end{split}
\]
as required.
\end{proof}

\begin{corollary}
Let $q$ be a quadratic form on $\mathbb R^n$ with $\det M_q\neq 0$ and $\det M'_q\neq 0$.
Set $\Lambda_-\subset\mathbb R$ the set of those eigen values of $M'_q$ which have different signs from the number $(\det M_q)/(\det M'_q)$, and for each $\lambda\in\Lambda_-$, fix an eigenvector $v_\lambda\in\mathbb R^{n-1}$ of $M'_q$ associated to $\lambda$.
We define an affine subspace $H\subset\mathbb R^{n-1}$ by
\[
H
\coloneqq\left\{
\vec y\in\mathbb R^{n-1}\mid \forall\lambda\in\Lambda_-:\langle v_\lambda,M'_q\vec y+\vec B_n\rangle=0
\right\}
\quad,
\]
where $\vec B_n \coloneqq (B_{11},\dots,B_{(n-1)n})$.
Then, we have
\[
H\cap\{(y_1,\dots,y_{n-1})\in\mathbb R^{n-1}\mid q(y_1,\dots,y_{n-1},1)=0\}
= \varnothing
\quad.
\]
\end{corollary}
\begin{proof}
Let $\lambda_1\le\dots\lambda_{n-1}$ be the eigen values of $M'_q$ and $v^{(1)},\dots,v^{(n-1)}\in\mathbb R^{n-1}$ associated unit eigenvectors which are mutually orthogonal.
Then, the matrix $M'_q$ is diagonalized by the orthogonal matrix
\[
P =
\begin{bmatrix}
v^{(1)} & \cdots & v^{(n-1)}
\end{bmatrix}
\quad.
\]
Set $Y_i$ and $\widetilde B_i$ as in \cref{prop:quad-standard}, so we have
\[
Y_i = \langle v^{(i)},\vec y\rangle
\ ,\quad \widetilde B_i = \langle v^{(i)},\vec B_n\rangle
\]
and hence
\[
\langle v^{(i)},M'_q\vec y + \vec B_n\rangle
= \langle M'_q v^{(i)},\vec y\rangle + \langle v^{(i)},\vec B_n\rangle
= \lambda_i Y_i + \widetilde B_n
\quad.
\]
It follows that, if $\vec y\in H$, then all the terms in the sum \eqref{eq:q-standard} have the same sign, which implies the result.
\end{proof}

\begin{example}
Define $q:\mathbb R^3\to\mathbb R$ by
\[
q(x,y,z)
\coloneqq 2(x-z)(y-z) - 2z^2 = 2xy - 2xz - 2yz
\quad.
\]
The associated matrices are given by
\[
M_q =
\begin{bmatrix}
0 & 1 & -1 \\
1 & 0 & -1 \\
-1 & -1 & 0
\end{bmatrix}
\quad,\qquad
M'_q =
\begin{bmatrix}
0 & 1 \\ 1 & 0
\end{bmatrix}
\quad.
\]
It turns out that the eigenvalues of $M'_q$ are $1$ and $-1$ for which associated eigenvectors are given by
\[
v_\pm =
\begin{bmatrix}
1 \\ \pm 1
\end{bmatrix}
\quad.
\]
We also have
\[
\det M_q = 2
\ ,\quad
\det M'_q = -1
\quad.
\]
Now, we set
\[
\begin{split}
H
&\coloneqq\left\{
(x,y)\in\mathbb R^2
\;\middle|\;
\left\langle v_+,M'_q\begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} -1 \\ -1 \end{bmatrix}\right\rangle
\right\}
\\
&= \left\{
(x,y)\in\mathbb R^2
\;\middle|\;
x+y-2 = 0
\right\}
\end{split}
\quad,
\]
then $H$ does not intersect to the zero-set $\{(x,y)\mid q(x,y,1)=0\}$, which is a hyperbolic curve.
\end{example}

Note that the equation $q(\vec y,1)=0$ is invariant under reflections along the eigenvectors of $M'_q$.
In particular, if $H$ is of codimension $1$, then it separates the two connected components of the zero-set.

\subsection{Intersections with segments}

We next discuss the intersections of quadratic curves with line segments.
Recall that, for two points $v,w\in\mathbb R^{n-1}$ in the Euclidean space, the line segment connecting them is given as the function $\gamma_{vw}:[0,1]\to\mathbb R^{n-1}$ with
\[
\gamma_{vw}(t)\coloneqq (1-t)v + tw
\quad.
\]

\begin{lemma}
Let $q$ be a quadratic form on $\mathbb R^n$ and $v,w\in\mathbb R^{n-1}$.
Then, the line segment $\gamma_{vw}$ intersects with the set
\[
Q\coloneqq \left\{(y_1,\dots,y_{n-1})\mid q(y_1,\dots,y_{n-1},1)=0\right\}
\]
at a parameter $t\in[0,1]$ if and only if $t$ is the solution of the following equation:
\[
\left((w-v)^{\mathsf T}M'_q(w-v)\right)t^2
+ 2\left((w-v)^{\mathsf T}(M'_q v + v_q)\right)t
+ \widehat v^{\mathsf T}M_q \widehat v
= 0
\quad,
\]
where $M_q$, $M'_q$, and $v_q$ are defined as in the previous section.
\end{lemma}
\begin{proof}
We put $f_q(y_1,\dots,y_{n-1})\coloneqq q(y_1,\dots,y_{n-1},1)$, then we have to solve the equation $f_q(\gamma_{vw}(t))=0$.
Since $f_q$ is a polynomial of degree at most $2$, computing the Taylor series of the composition $f_q\gamma_{vw}$, we obtain
\[
\begin{split}
&[f_q\circ\gamma_{vw}](t) \\
&= f_q(v+t(w-v)) \\
&= f_q(v)
+ t\cdot\left(\left.\frac{d}{dt}\right|_{t=0} f_q(v+t(w-v))\right)
+ \frac{t^2}{2}\left(\left.\frac{d^2}{dt^2}\right|_{t=0} f_q(v+t(w-v))\right)
\quad.
\end{split}
\]
On the other hand, we have
\[
(\gamma_{vw})_\ast\left(\frac{d}{dt}\right)
= \sum_{i=1}^{n-1} (v_i-w_i)\frac\partial{\partial y_i}
\quad.
\]
Thus, combining with the equation \eqref{eq:prf:fq-diff}, one obtains the result.
\end{proof}

\section{Rendering ridgelines of quadratic B\'ezier triangles}

\subsection{Problem}

Suppose we are given a quadratic B\'ezier triangle $u:\Delta^2\to\mathbb R^3$ in the $3$-dimensional Euclidean space.
The main problem in the section is the following.

\begin{problem}
For a given surjective $\mathbb R$-linear map $P:\mathbb R^3\to\mathbb R^2$, render the boundary of the image $Pu(\Delta^2)\subset\mathbb R^2$.
\end{problem}

Note that, since the composition $Pu$ is again a B\'ezier triangle, it is easy to render the images of the image$Pu(\partial\Delta^2)$.
On the other hand, the boundary $Pu(\Delta^2)$ may contain points coming from the interior of $\Delta^2$.
In fact, they are critical values of the map $Pu$; they form a closed subset of $\mathbb R^2$ whose connected components we call the \emph{ridgelines} of the B\'ezier triangle $Pu$.
This observation shows that the boundary of $Pu(\Delta^2)$ is contained in the union of following materials:
\begin{itemize}
  \item the B\'ezier curves $\left.Pu\right|_{\partial_i\Delta^2}$ for $i=0,1,2$;
  \item the ridgelines.
\end{itemize}
Since the former is obvious, we discuss the second in the following subsections.

\subsection{Ridgelines and quadratic curves}

As a result of \cref{sec:Beztri:sing}, the critical locus of a B\'ezier triangle in $\mathbb R^2$ is defined by a quadratic function.
Hence, since ridgelines are images of critical loci, the problem is now reduced to the following more general one.

\begin{problem}
Let $f:\mathbb R^2\to\mathbb R$ be a quadratic function.
Given triangle $T\subset\mathbb R^2$, render the subset
\[
T\cap\{(x,y)\mid f(x,y)=0\}\subset T
\quad.
\]
\end{problem}

In other words, we want to render the intersection of a triangle with a quadratic curve.
We concentrate on the case where $0\in\mathbb R$ is a regular value of the quadratic function $f$.
We write $C\coloneqq \{f=0\}$, which is a $1$-dimensional submanifold of $\mathbb R$.
We render $T\cap C$ in the following steps.
\begin{enumerate}[label=\underline{\textit{Step~\arabic*}}:\:,leftmargin=\widthof{\itshape Step00:}]
  \item Compute the subset $S\subset \partial T\cap C$ of points $c\in\partial T\cap C$ such that
\begin{itemize}
  \item $C$ intersects to an edge of $T$ at $c$ transversely;
  \item in case where $c$ is a vertex of $T$, the tangent line of $C$ at $c$ either contains an edge of $T$ or separates the other two vertices.
\end{itemize}
  \item Divide $S$ into pairs $\{c_1,c_2\}$ so that $c_1$ and $c_2$ belong to the same connected component of $T\cap C$.
  \item For each pair $\{c_1,c_2\}$, render the curves connecting $c_1$ and $c_2$.
\end{enumerate}

The first and the last steps are obvious.
To achieve the second, we can make use of the following results.

\begin{lemma}
\label{lem:S-bndry}
There is a $1$-dimensional submanifold $C'\subset T$ such that $S= \partial C'$.
Consequently, the number of elements in the subset $S\subset\partial T\cap C$ is even and at most six.
\end{lemma}
\begin{proof}
It is seen that the intersection $T\cap C$ consists of a submanifold $C'\subset T$ together with isolated points.
We claim that $\partial C'=S$.
It is obvious that $S\subset\partial C'$.
Conversely, let $c\in \partial C'$; we hence have $c\in\partial T$ since $C$ has no boundary.
If $c$ is a vertex of $T$, then it is clear that $c\in S$.
On the other hand, suppose $c$ lies in the interior of an edge, say $e$, of $T$; hence $c$ belongs to the intersection of $C\cap \operatorname{int}e$.
This implies that $c$ is specified by a quadratic equation so that $e$ is tangent to $C$ at $c$ if and only if the equation has a double root.
It follows that the intersection is transverse as soon as $c\in\partial C'$.
Thus, we also obtain $\partial C'\subset S$, so $\partial C'=S$.
In particular, $S$ consists of even number of elements.
Moreover, the above observation also shows that that each edge of $T$ has at most two intersections with $C$, so $\partial T\cap C$ and hence $S$ consist of at most six elements.
\end{proof}

\begin{lemma}
\label{lem:comp-curve}
For every pair $c_1,c_2\in S$, either of the following holds:
\begin{enumerate}[label=\upshape(\roman*)]
  \item if $v=c_2-c_1\in\mathbb R^2$, then $\langle\kappa(c_1),v\rangle > 0$, here $\kappa(c_1)$ is the curvature vector of $C$ at $c_1$;
  \item the curve $C$ is a hyperbola, and $c_1$ and $c_2$ lie in the different components.
\end{enumerate}
\end{lemma}

\begin{corollary}
If $c_1,c_2\in S$ lie in the same component of $T\cap C$, then they are consequtive in $\partial T\cong S^1$.
\end{corollary}
\begin{proof}
This follows from \cref{lem:S-bndry}, \cref{lem:comp-curve}, and the observation that $C'$ has no self-intersection.
\end{proof}

Now, fix a numbering on the vertices of $T$ to write $\{p_0,p_1,p_2\}$.
We say an element $c\in S$ is \emph{positive} (resp. \emph{negative}) if it belongs to an edge spanned by $p_i$ and $p_{i+1}$ and transverse to $C$ at $c$ such that
\[
\langle\kappa(c),p_{i+1}-p_i\rangle > 0
\quad\text{(resp. } \langle\kappa(c),p_{i+1}-p_i\rangle < 0\text{ )}
\quad,
\]
here we use the cyclic indexing modulo $3$.
Note that, even if $c=p_k$, the definition does not depend on the choice of the edge.
Indeed, thanks to the definition of $S$, we have
\[
\langle\kappa(c),p_k-p_{k-1}\rangle\cdot\langle\kappa(c),p_{k+1}-p_k\rangle\ge 0
\quad.
\]
On the other hand, we consider the cyclic ordering on $\partial T$ with $p_{i-1}<p_i<p_{i+1}$ and restrict it to $S$.
For $c_1,c_2\in S$, we write $c_1\lessdot c_2$ if $c_2$ is the ``next'' element of $c_1$ in this cyclic order.

\begin{lemma}
For two elements $c_1,c_2\in S$, the following statements are all equivalent:
\begin{enumerate}[label=\upshape(\alph*)]
  \item $c_1$ and $c_2$ belong to the same connected component of $T\cap C$;
  \item either $c_1\lessdot c_2$ with $c_1$ negative or $c_2\lessdot c_1$ with $c_2$ negative;
  \item either $c_1\lessdot c_2$ with $c_2$ positive or $c_2\lessdot c_1$ with $c_1$ positive;
\end{enumerate}
\end{lemma}

\section{Intersections of B\'ezier curves}

In this section, we explain the \emph{B\'ezier clipping algorithm} developed in \cite{NishitaTakitaNakamae1992} to find intersection of B\'ezier curves.

\subsection{Generalized binomial coefficients}

We first extend the binomial coefficients.

\begin{definition}
Let $R$ be an integral domain of charateristic $0$.
For an element $\alpha\in R$ and an arbitrary integer $n\in\mathbb Z$, we set
\[
\binom{\alpha}{n}
\coloneqq
\begin{cases}
\displaystyle\frac{\alpha(\alpha-1)\dots(\alpha-n+1)}{n!} & n> 0\quad, \\
1 & n = 0\quad, \\
0 & n < 0 \quad,
\end{cases}
\]
as long as it exists in $R$.
\end{definition}

\begin{remark}
The binomial coefficients may not exist.
For example, we have
\[
\binom{\sqrt{-1}}{2}
= \frac{\sqrt{-1}(\sqrt{-1}-1)}2
= \frac{-1-\sqrt{-1}}2
\quad,
\]
which does not belong to the ring $\mathbb Z[\sqrt{-1}]$.
\end{remark}

\begin{lemma}
\label{lem:binom-recurrence}
Let $R$ be an integral domain of characterstic $0$.
Then, for each $\alpha\in R$ and $n\in\mathbb Z$, we have
\begin{equation}
\label{eq:binom-recur}
\binom{\alpha}{n} = \binom{\alpha-1}{n} + \binom{\alpha-1}{n-1}
\end{equation}
whenever each term makes sense.
\end{lemma}
\begin{proof}
If $n\le 1$, the equation \eqref{eq:binom-recur} is obvious.
In case $n\ge 2$, unwinding the definition, we have the following equalities in the field of fractions $F$ of $R$:
\[
\begin{split}
\text{RHS}
&= \frac{(\alpha-1)\dots(\alpha-k)}{k!} + \frac{(\alpha-1)\dots(\alpha-k+1)}{(k-1)!} \\
&= \frac{(\alpha-1)\dots(\alpha-k+1)}{(k-1)!}\left(\frac{\alpha-k}{k}+1\right) \\
&= \frac{(\alpha-1)\dots(\alpha-k+1)}{(k-1)!}\cdot\frac{\alpha}{k} \\
&= \binom{\alpha}{k}
\quad.
\end{split}
\]
Since $R$ is an integral domain, the map $R\to F$ is injective; hence the result follows.
\end{proof}

\begin{lemma}
\label{lem:binom-altsum}
Let $R$ be an above, and let $\alpha\in R$ and $n\in\mathbb Z$
Then, for every non-negative integer $k$, we have
\begin{equation}
\label{eq:binom-altsum}
\binom{\alpha}{n}
= \sum_{i=0}^k (-1)^{k-i}\binom{k}{i}\binom{\alpha+i}{n+k}
\quad.
\end{equation}
\end{lemma}
\begin{proof}
We prove the result by induction on the non-negative integer $k$.
In the base case where $k=0$, there is nothing to prove.
On the other hand, if $k\ge 1$, the induction hypothesis implies that
\[
\begin{split}
\binom{\alpha}{n}
&= \sum_{i=0}^{k-1}(-1)^{k-1-i}\binom{k-1}{i}\binom{\alpha+i}{n+k-1} \\
&= \sum_{i=0}^{k-1}(-1)^{k-1-i}\binom{k-1}{i}\left(\binom{\alpha+i+1}{n+k}-\binom{\alpha+i}{n+k}\right) \\
&= \sum_{i=1}^k(-1)^{k-i}\binom{k-1}{i-1}\binom{\alpha+i}{n+k} - \sum_{i=0}^{k-1}(-1)^{k-1-i}\binom{k-1}{i}\binom{\alpha+i}{n+k} \\
&= \sum_{i=0}^k (-1)^{k-i}\left(\binom{k-1}{i-1}+\binom{k-1}{i}\right)\binom{\alpha+i}{n+k} \\
&= \sum_{i=0}^k (-1)^{k-i}\binom{k}{i}\binom{\alpha+i}{n+k}
\quad.
\end{split}
\]
\end{proof}

\subsection{Clipping B\'ezier curves}

We discuss clipping a piece of a B\'ezier curve.
More precisely, suppose $\gamma:[0,1]\to\mathbb R^n$ is a B\'ezier curve with control points $\beta_0,\dots,\beta_d$; i.e.
\[
\gamma(t)
= \sum_{i=0}^n \beta_i\binom{n}{i}t^i(1-t)^{n-i}
\quad.
\]
For a subinterval $I=[a,b]\subset[0,1]$, we want a B\'ezier curve $\gamma_I$ satisfying the following equation:
\[
\gamma_I(t) = \gamma(a+(b-a)t)
\quad;
\]
in other words, $\gamma_I$ is obtained by normalizing the parameter of the composition
\[
I\hookrightarrow[0,1]\xrightarrow{\gamma}\mathbb R^n
\quad.
\]

\begin{proposition}[De Casteljau's algorithm]
\label{prop:de-casteljau}
Let $\gamma$ be a B\'ezier curve with control points $\beta_0,\dots,\beta_d$.
For each $0\le a\le 1$, the restrictions $\left.\gamma\right|_{[0,a]}$ and $\left.\gamma\right|_{[a,1]}$ are again B\'ezier curves of the same degree after appropriate normalizations of parameters.
Furthermore, the following hold:
\begin{itemize}
  \item on the left half $[0,a]$, $\left.\gamma\right|_{[0,a]}$ has control points $\beta^L_0,\dots,\beta^L_d$ with
\[
\beta^L_j = \sum_{i=0}^j\beta_i\binom{j}{i}a^i(1-a)^{j-i}
\quad;
\]
  \item on the right half $[a,0]$, $\left.\gamma\right|_{[a,1]}$ has control points $\beta^R_0,\dots,\beta^R_d$ with
\[
\beta^R_j = \sum_{i=j}^d\beta_i\binom{d-j}{i-j}a^{i-j}(1-a)^{d-i}
\quad.
\]
\end{itemize}
\end{proposition}

In view of De Casteljau's algorithm, it is convenient to represent a B\'ezier curve as a $n\times (d+1)$-matrix
\[
\begin{bmatrix}\beta_0 & \cdots & \beta_d\end{bmatrix}
\]
by arranging the control points as column vectors.
Then, the ``left-half'' in \cref{prop:de-casteljau} is obtained by the matrix multiplication
\[
\begin{bmatrix}\beta^L_0 & \cdots & \beta^L_d\end{bmatrix}
= \begin{bmatrix}\beta_0 & \cdots & \beta_d\end{bmatrix}
\begin{bmatrix}
1 & \cdots & b^j & \cdots & b^d \\
& \ddots & \vdots && \vdots\\
&& \binom{j}{i}a^ib^{j-i} & \cdots & \binom{d}{i}a^ib^{d-i} \\
&&& \ddots & \vdots \\
&&&& a^d
\end{bmatrix}
\quad,
\]
where $a+b=1$, while the ``right-half'' is
\[
\begin{bmatrix}\beta^R_0 & \cdots & \beta^R_d\end{bmatrix}
= \begin{bmatrix}\beta_0 & \cdots & \beta_d\end{bmatrix}
\begin{bmatrix}
b^d &&&& \\
\vdots & \ddots &&& \\
\binom{d}{i}a^ib^{d-i} & \cdots & \binom{d-j}{i-j}a^{i-j}b^{d-i} && \\
\vdots && \vdots & \ddots & \\
a^d & \cdots & a^{d-j} & \cdots & 1
\end{bmatrix}
\quad.
\]
To simplify the notation, we denote them by $S^L(a,b)$ and $S^R(a,b)$ respectively.
Specifically,
\[
\begin{split}
S^L(a,b)_{ij} &=
\begin{cases}
\displaystyle\binom{j}{i}a^ib^{j-i} & j\ge i\\
\ 0 & j < i
\end{cases}
\quad,
\\
S^R(a,b)_{ij} &=
\begin{cases}
\displaystyle\binom{d-j}{i-j}a^{i-j}b^{d-i} & j \le i\\
\ 0 & j > i
\end{cases}
\quad.
\end{split}
\]
Finally, for a subinterval $I=[a_0,a_1]\subset[0,1]$, we can realize the clipped B\'ezier curve $\gamma_I$ by the control points
\[
\begin{bmatrix}
\beta^I_0,\dots,\beta^I_d
\end{bmatrix}
=
\begin{bmatrix}
\beta_0,\dots,\beta_d
\end{bmatrix}
S^L(a_1,b_1)S^R\bigl(\frac{a_0}{a_1},b_0-\frac{a_0b_1}{a_1}\bigr)
\]
with $a_i+b_i=0$ for $i=0,1$.
Note that we have
\[
\begin{split}
&\left(S^L(a_1,b_1)S^R\bigl(\frac{a_0}{a_1},b_0-\frac{a_0b_1}{a_1}\bigr)\right)_{ij}
= \sum_{k=0}^d S^L(a_1,b_1)_{ik}S^R\bigl(\frac{a_0}{a_1},b_0-\frac{a_0b_1}{a_1}\bigr)_{kj} \\
&= \sum_{k=\max\{i,j\}}^d\binom{k}{i}a_1^ib_1^{k-i}\cdot\binom{d-j}{k-j}\left(\frac{a_0}{a_1}\right)^{k-j}\left(b_0-\frac{a_0b_1}{a_1}\right)^{d-k} \\
&= a_1^{i+j-d}\sum_{k=\max\{i,j\}}^d\binom{k}{i}\binom{d-j}{k-j}a_0^{k-j}b_1^{k-i}(a_1b_0-a_0b_1)^{d-k} \\
&= a_1^{i+j-d}\sum_{k=\max\{i,j\}}^d\binom{k}{i}\binom{d-j}{k-j}a_0^{k-j}b_1^{k-i}\sum_{l=0}^{d-k}\binom{d-k}{l}(a_1b_0)^l(-a_0b_1)^{d-k-l} \\
&= a_1^{i+j-d}\sum_{k=\max\{i,j\}}^d\sum_{l=0}^{d-k} (-1)^{d-k-l}\binom{k}{i}\binom{d-j}{k-j}\binom{d-k}{l}a_0^{d-j-l}a_1^lb_0^lb_1^{d-i-l}
\quad.
\end{split}
\]
Using the equality $\binom{N}{n}\binom{N-n}{m} = \binom{N}{m}\binom{N-m}{n}$, we further have
\[
\begin{split}
&\mathrm{RHS} \\
&= a_1^{i+j-d}\sum_{l=0}^{d-\max\{i,j\}}\sum_{k=\max\{i,j\}}^{d-l} (-1)^{d-k-l}\binom{k}{i}\binom{d-j}{l}\binom{d-j-l}{k-j}a_0^{d-j-l}a_1^lb_0^lb_1^{d-i-l}
\quad.
\end{split}
\]
Therefore, putting
\begin{equation}
\label{eq:def-Cijn}
\begin{split}
C_{i,j,n}
&\coloneqq \sum_{k=\max\{i,j\}}^n (-1)^{n-k}\binom{k}{i}\binom{n-j}{k-j} \\
&=
\sum_{k'=\max\{i-j,0\}}^{n-j}(-1)^{n-j-k'}\binom{j+k'}{i}\binom{n-j}{k'}
\quad,
\end{split}
\end{equation}
then we obtain the following equation:
\begin{equation}
\label{eq:clip-coeff}
\left(S^L(a_1,b_1)S^R\bigl(\frac{a_0}{a_1},b_0-\frac{a_0b_1}{a_1}\bigr)\right)_{ij}
= a_1^{i+j-d}\sum_{l=0}^{d-\max\{i,j\}}\binom{d-j}{l}C_{i,j,d-l}a_0^{d-j-l}a_1^lb_0^lb_1^{d-i-l}
\end{equation}

\begin{lemma}
\label{lem:formula-Cijn}
For every non-negative integers $i,j$ and for every integer $n$, we have
\begin{equation}
\label{eq:formula-Cijn}
C_{i,j,n} = \binom{j}{i+j-n} = \binom{j}{n-i}
\quad.
\end{equation}
\end{lemma}
\begin{proof}
Notice that, for each $0\le k'\le \max\{i-j,0\}-1$, we have
\[
\binom{j+k'}{i}=0
\]
since $j+k'$ is a non-negative integer less than $i$.
Hence, by \eqref{eq:def-Cijn}, we actually have
\[
C_{i,j,n}
= \sum_{k'=0}^{n-j}(-1)^{n-j-k'}\binom{j+k'}{i}\binom{n-j}{k'}
\]
no matter which of $i$ and $j$ is larger.
The result then follows directly from \cref{lem:binom-altsum}.
\end{proof}

Substituting \eqref{eq:formula-Cijn} into \eqref{eq:clip-coeff}, we finally get
\[
\begin{split}
&\left(S^L(a_1,b_1)S^R\bigl(\frac{a_0}{a_1},b_0-\frac{a_0b_1}{a_1}\bigr)\right)_{ij} \\
&= a_1^{i+j-d}\sum_{l=0}^{d-\max\{i,j\}}\binom{d-j}{l}\binom{j}{d-l-i}a_0^{d-j-l}a_1^lb_0^lb_1^{d-i-l} \\
&= a_1^{i+j-d}\sum_{l=d-i-j}^{d-\max\{i,j\}}\binom{d-j}{l}\binom{j}{d-l-i}a_0^{d-j-l}a_1^lb_0^lb_1^{d-i-l} \\
&= a_1^{i+j-d}\sum_{l'=0}^{\min\{i,j\}}\binom{d-j}{d-i-j+l'}\binom{j}{j-l'}a_0^{i-l'}a_1^{d-i-j+l'}b_0^{d-i-j+l'}b_1^{j-l'} \\
&= \sum_{l'=0}^{\min\{i,j\}}\binom{d-j}{i-l'}\binom{j}{j-l'}a_0^{i-l'}a_1^{l'}b_0^{d-i-j+l'}b_1^{j-l'}
\end{split}
\]

\begin{thebibliography}{99}
  \bibitem{NishitaTakitaNakamae1992} T.~Nishita, S.~Takita, and E.~Nakamae, ``Hidden Curve Elimination of Trimmed Surfaces Using Bezier Clipping,'' CG International'92, 1992-6, pp.595--619.
\end{thebibliography}
\end{document}


\documentclass{article}

\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithm}
\usepackage{booktabs}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage[font=small]{caption}
%\usepackage{subcaption}
%\expandafter\def\csname ver@subfig.sty\endcsname{}
\usepackage{tabularx}
\usepackage{subfig}
\usepackage{pgffor}
\usepackage{hyperref}
\usepackage{soul}

% for tables
\newcommand{\centertab}[1]{\multicolumn{1}{|c|}{\textbf{#1} }}
\newcommand{\bigcell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}

\begin{document}
\input{math_definitions}

\section{Basic Linear Algebra}
\begin{itemize}
  \item $ \vA^{-T} \triangleq \group{\vA^T}^{-1} = \group{\vA^{-1}}^{T} $
  \item $ (\vA \vB)^{T} = \vB^{T} \vA^{T} $
  \item $ (\vA \vB)^{-1} = \vB^{-1} \vA^{-1} $,
    iff $ \vA$ and $\vB$ are invertible
  \item Frobenius norm $ \fnorm{\vA} = \sqrt{\Tr{\vA \vA^T}}$
  \item \textbf{trace:}
  \begin{itemize}
    \let\labelitemii\labelitemi
    \item $ \Tr{\vA^{T}} = \Tr{\vA} $
    \item $ \Tr{\vA + \vB} = \Tr{\vA} + \Tr{\vB} $
    \item $ \Tr{\vA \vB^{T}} = \Tr{\vA^{T} \vB} =
      \sum_{i,j}{\group{\vA \circ \vB}_{(i,j)}} $
    \item $ \Tr{\vA \vB \vC} = \Tr{\vC \vA \vB} = \Tr{\vB \vC \vA} $
  \end{itemize}
  \item \textbf{determinant:}
  \begin{itemize}
    \item $ \det{\vA^T} = \det{\vA} $
    \item $ \det{\vA^{-1}} = \group{\det{\vA}}^{-1} $
    \item $ \func{\det}{\vA \vB} = \func{\det}{\vA} \func{\det}{\vB} $,
      for square matrices of equal size.
    \item If $\vA$ is a triangular matrix (lower triangular or upper triangular),
    $$ \det{\vA} = \prod_i{A_{(i,i)}}$$
  \end{itemize}
\end{itemize}

\section{Cholesky decomposition}
The Cholesky decomposition of a positive-definite matrix A is a decomposition
  of the form:
$$ \vSigma = \vL \vL^{T} $$
where $\vL$ is a lower triangular matrix
\begin{itemize}
  \item $\vSigma^{-1} = \group{\vL \vL^{T}}^{-1} = \vL^{-T} \vL^{-1}$
  \item $\vL \solve \vx \triangleq \vL^{-1} \vx$
  \item $\vSigma^{-1} \vx = \vL^{T} \solve \vL \solve \vx$
  \item $\vx^T \vSigma^{-1} \vx = \ltwogroup{ \vL \solve \vx}^2 $
  \item $\Tr{\vSigma_b^{-1} \vSigma_a} = \fnorm{\vL_b \solve \vL_a}^2 $\\
    Proof:
    \begin{align*}
      \Tr{\vSigma_b^{-1} \vSigma_a}
        & = \Tr{\group{\vL_b \vL_b^T}^{-1} \vL_a \vL_a^T} \\
        & = \Tr{\vL_b^{-T} \vL_b^{-1} \vL_a \vL_a^T}
          = \Tr{ \vL_a^T \vL_b^{-T} \vL_b^{-1} \vL_a } \\
        & = \Tr{ \group{\vL_b^{-1} \vL_a}^T  \group{\vL_b^{-1} \vL_a} }
          = \fnorm{\vL_b \solve \vL_a}^2
    \end{align*}
  \item $\func{\log}{\abs{\vSigma}}
    = 2 \sum_i \func{\log}{L_{(i,i)}}
    = 2 \Tr{ \func{\log}{\vL} }$
\end{itemize}

\section{Inverse}
  \begin{flalign}
    & \group{\eye + \vP}^{-1} = \eye - \group{\eye + \vP}^{-1} \vP &
    \label{eq:inv_identity_1} \\
    & \group{\eye + \vP \vQ}^{-1} \vP = \vP \group{\eye + \vQ \vP}^{-1} &
    \label{eq:inv_identity_2}
  \end{flalign}

\subsection{Matrix inversion lemma (Sherman-Morrison-Woodbury)}
\begin{itemize}
  \item
    \begin{flalign}
      & \group{\vA + \vB \vC \vD}^{-1} =
      \vA^{-1} - \vA^{-1} \vB \group{\vC^{-1} + \vD \vA^{-1} \vB}^{-1} \vD \vA^{-1} &
      \label{eq:inv_identity_3}
    \end{flalign}
  \item $ \group{\vA + \vB \vC \vD}^{-1} =
    \vA^{-1} - \vA^{-1} \vB \group{\eye + \vC \vD \vA^{-1} \vB}^{-1} \vC \vD \vA^{-1}
    $
  \item $ \group{\vA + \vX \vB \vX^T}^{-1} =
    \vA^{-1} - \vA^{-1} \vX \group{\vB^{-1} + \vX^T \vA^{-1} \vB}^{-1} \vX^T \vA^{-1}
    $
  \item $ \group{\vA + \vB \vC \vD}^{-1} \vB \vC =
    \vA^{-1} \vB \group{\vC^{-1} + \vD \vA^{-1} \vB}^{-1} $,
    using \ref{eq:inv_identity_3} and \ref{eq:inv_identity_1} \ref{eq:inv_identity_2}
  \item $ \group{\vA + \vB}^{-1} = \vA^{-1} \group{\vA^{-1} + \vB^{-1}}^{-1} \vB^{-1} $
  \item $ \group{\vA^{-1} + \vB^{-1}}^{-1} = \vA \group{\vA^{-1} + \vB^{-1}} \vB $

  where $\vA$ and $\vB$ are square and invertible matrices.
\end{itemize}

\section{square}
\begin{align}
  \vx^T \vM \vx - 2 \vb^T \vx =
    \group{\vx - \vM^{-1} \vb}^T \vM \group{\vx - \vM^{-1} \vb}
    - \vb^T \vM^{-1} \vb
\end{align}

\appendix
\section{Notation}
\begin{table}[h]
\centering
\begin{tabular}{| c | c |}
 \hline
 \bigcell{c}{\textbf{Notation}}  & \textbf{Description} \\
 \hline \rule{0pt}{3ex}
 $\tX \in \reals^{I_1 \times I_2 \times \cdots \times I_N}$ & Tensor of order $N$  \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $x, \vx, \vX$ & \bigcell{c}{Scalar, vector and matrix. \\ Non-bold letters do not strictly represent scalars, \\in many cases their meaning should be extracted \\from context}  \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $x_{i_1,i_2, ..., i_N}, \; \tX_{(i_1,i_2, ..., i_N)} $ & $(i_1, i_2, ..., i_N)$th entry of $\tX$  \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\vx_{:,i}, \; \vX_{(:,i)} $ & \bigcell{c}{$i$th column of the matrix $\vX$. \\Colons are used for indexing an entire dimension.} \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\vx_{:,i_2, ..., i_N}, \; \tX_{(:,i_2, ..., i_N)} $ & Mode-1 fiver of $\tX$  \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\vX_{:,:, ..., i_N}, \; \tX_{(:, :, ..., i_N)} $ & Frontal slice of $\tX$  \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\tX_{(+, :, \ldots, :)} $ & Partial sum-reduction over first dimension \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\tX_{(+)}$ & Sum-reduction over all elements in the tensor \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\ones$ & \bigcell{c}{Tensor whose elements are equal to one. \\ Their order and size is usually extracted from context}  \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\tA \odot \tB$ & \bigcell{c}{Element-wise product between tensors $\tA$ and $\tB$}  \\[0.3cm]
 \hline \rule{0pt}{3ex}
 $\tC_{(i,j)} = \tA_{(i,k)} \tB_{(k,j)}$ & \bigcell{c}{ Tensor contraction using Einstein notation. \\ In this case is just the matrix multiplication \\ between $\tA$ and $\tB$}  \\[0.3cm]
 \hline

\end{tabular}
\caption{ Notation for vectors, matrices and tensors }\label{table:tensor_notation}
\end{table}

\end{document}