% !TEX root = main.tex
%----------------------------------------------------------------------

%----------------------------------------------------------------------
\chapter{The Bivariate Normal Distribution}

%The normal distribution is based on the Gaussian integral
%\[
%\int_{-\infty}^{\infty} e^{-x^2} = \sqrt{\pi},
%\]

%----------------------------------------------------------------------
\section{Bivariate transformations}

% definition
\begin{definition}\label{def:jacobian}
Let $h:\R^2\to\R^2$ and let $(u,v) = h(x,y)$. The \emph{Jacobian determinant} of the transformation $h$ is the determinant of its $2\times 2$ matrix of partial derivatives:
\[
J = \begin{vmatrix}
\displaystyle\frac{\partial u}{\partial x} & \displaystyle\frac{\partial u}{\partial y} \\[2ex]
\displaystyle\frac{\partial v}{\partial x} & \displaystyle\frac{\partial v}{\partial y} \\[2ex]
\end{vmatrix}
\]
\end{definition}

% theorem: continuous
\begin{theorem}\label{thm:bivariate_transformation_pdf}
Let $U$ and $V$ be jointly continuous random variables, let $f_{U,V}$ be their joint PDF, let $g:\R^2\to\R^2$ be an injective transform over the support of $f_{U,V}$ and let $(X,Y) = g(U,V)$. Then the joint PDF of $X$ and $Y$ is given by
\[
f_{X,Y}(x,y) = |J| f_{U,V}\big[ g^{-1}(x,y) \big]
\]
where $J$ is the Jacobian determinant of the transformation $g^{-1}$,
\[
J =
\begin{vmatrix}
\displaystyle\frac{\partial u}{\partial x} & \displaystyle\frac{\partial u}{\partial y} \\[2ex]
\displaystyle\frac{\partial v}{\partial x} & \displaystyle\frac{\partial v}{\partial y} \\[2ex]
\end{vmatrix}
\]
where $(u,v) = g^{-1}(x,y)$.
\end{theorem}

% remark
\begin{remark}
The absolute value $|J|$ is a scale factor, which ensures that the transformed PDF $f_{X,Y}(x,y)$ integrates to one.
\end{remark}

% example: jointly continuous
\begin{example}
Let $U$ and $V$ be continuous random variables, and let $X=U+V$ and $Y=U-V$.
\ben
\it Find the joint PDF of $X$ and $Y$ in terms of the joint PDF of $U$ and $V$.
\it If $U,V\sim\text{Exponential}(1)$ are independent, find the joint PDF of $X$ and $Y$.
\een
\end{example}

\begin{solution}
\ben

\it % <<< (i)
\bit
\it The transformation $g:\R^2\to\R^2$ is defined by $g(u,v) = (u+v,u-v)$.
\it To compute the inverse transformation $g^{-1}:\R^2\to\R^2$, we solve the equations %$x=u+v$ and $y=u-v$ for $u$ and $v$.
\[
x=u+v \quad\text{and}\quad y=u-v.% \quad \text{for $u$ and $v$.}
\]
\it This yields $u = \frac{1}{2}(x+y)$ and $v = \frac{1}{2}(x-y)$.
\it Thus the inverse transformation is
\[
(u,v) = g^{-1}(x,y) = \left[\frac{1}{2}(x+y),\frac{1}{2}(x-y)\right].
\]
\eit
The Jacobian determinant is given by
\[
J =
\begin{vmatrix}
\displaystyle\frac{\partial u}{\partial x} & \displaystyle\frac{\partial u}{\partial y} \\[2ex]
\displaystyle\frac{\partial v}{\partial x} & \displaystyle\frac{\partial v}{\partial y} \\
\end{vmatrix}
=
\begin{vmatrix}
1/2	& 1/2 \\
1/2 & -1/2 \\
\end{vmatrix}
= -\frac{1}{4} - \frac{1}{4} = -\frac{1}{2}.
\]
Hence the joint PDF of $X$ and $Y$ is
\begin{align*}
f_{X,Y}(x,y)
	& = |J|f_{U,V}(u,v) \\
	& = \left|-\frac{1}{2}\right| f_{U,V}\left[\frac{1}{2}(x+y),\frac{1}{2}(x-y)\right] \\
	& = \frac{1}{2}f_{U,V}\left[\frac{1}{2}(x+y),\frac{1}{2}(x-y)\right].
\end{align*}

\it % <<< (ii)
Let $U$ and $V$ be independent with $U,V\sim\text{Exponential}(1)$.

By independence, the joint PDF of $U$ and $V$ is
\[
f_{U,V}(u,v)
	= \begin{cases}
		e^{-(u+v)}		& u,v > 0 \\
		0				& \text{otherwise.}
\end{cases}
\]
To compute the support of $f_{X,Y}$, since $u>0$ and $v>0$ we have $x>0$, so
\bit
\it $\min(y) = \min(u-v) = -x$ (which occurs when $u=0$ and $v=x$), and
\it $\max(y) = \max(u-v) = x$ (which occurs when $u=x$ and $v=0$).
\eit
Thus, substituting for $u+v = \frac{1}{2}(x+y) + \frac{1}{2}(x-y) = x$, we obtain
\[
f_{X,Y}(x,y) = \begin{cases}
	\frac{1}{2}e^{-x}	& \text{for } x > 0 \text{ and } -x < y < x, \\
	0					& \text{otherwise.}
\end{cases}
\]
\een
\end{solution}

%----------------------------------------------------------------------
\section{The bivariate normal distribution}
%----------------------------------------------------------------------

%%----------------------------------------------------------------------
%\section{The sum of two random variables}
%%----------------------------------------------------------------------
%% theorem
%\begin{theorem}\label{thm:convolution}
%Let $X$ and $Y$ be jointly continuous random variables, and let $f_{X,Y}$ be their joint PDF. The random variable $X+Y$ has the following PDF:
%\[
%f_{X+Y}(t)
%	= \int_{-\infty}^{\infty} f_{X,Y}(x,t-x)\,dx
%	= \int_{-\infty}^{\infty} f_{X,Y}(t-y,y)\,dy.
%\]
%\end{theorem}
%
%\begin{proof}
%Let $A = \{(x,y):x+y\leq z\}\subset\R^2$. Then
%\[
%\prob(X+Y\leq z)
%	= \iint_A f(x,y)\,dxdy
%	= \int_{x=-\infty}^{\infty} \int_{y=-\infty}^{z-x}f_{X,Y}(x,y)\,dy\,dx
%\]
%We change the variable of integration (in the inner integral), making the substitution $y=t-x$:
%\begin{align*}
%F_{X+Y}(z) = \prob(X+Y\leq z)
%	& = \int_{x=-\infty}^{\infty} \int_{t=-\infty}^{z}f_{X,Y}(x,t-x)\,dt\,dx \\
%	& = \int_{t=-\infty}^{z} \int_{x=-\infty}^{\infty}f_{X,Y}(x,t-x)\,dx\,dt
%\end{align*}
%where the final equality follows by reversing the order of integration. Thus the PDF of $X+Y$ is
%\[
%f_{X+Y}(t) = \int_{-\infty}^{\infty} f_{X,Y}(x,t-x)\,dx \qquad\text{as required.}
%\]
%\end{proof}
%
%% corollary
%\begin{corollary}\label{cor:convolution_independent}
%If $X$ and $Y$ are independent, the PDF of $X+Y$ is the \emph{convolution} of the marginal PDFs:
%\[
%f_{X+Y}(t)
%	= \int_{-\infty}^{\infty} f_X(x)f_Y(t-x)\,dx
%	= \int_{-\infty}^{\infty} f_X(t-y)f_Y(y)\,dy.
%\]
%\end{corollary}

%\begin{remark}
%The function $f_{X+Y}$ is called the \emph{convolution} of $X$ and $Y$, and is often written as $f_{X+Y}=f_X\ast f_Y$.
%\end{remark}

%%----------------------------------------------------------------------
%\section{The sum of two standard normal variables}
%%----------------------------------------------------------------------
%% lemma: sums of normal random variables}
%\begin{lemma}\label{lem:sum_of_standard_normal_variables}
%If $U,V\sim N(0,1)$ are independent, then $U+V\sim N(0,2)$.
%\end{lemma}
%
%\begin{proof}
%Since $U$ and $V$ are independent, their joint PDF is
%\[
%f(u,v)=f_U(u)f_V(v) = \frac{1}{2\pi}\exp\left(-\frac{1}{2}(u^2 + v^2)\right) \qquad  u,v\in\R.
%\]
%
%Let $W=U+V$. Since $U$ and $V$ are independent, by Corollary~\ref{cor:convolution_independent} we have
%\begin{align*}
%f_W(w)
%	& = \int_{-\infty}^{\infty} f_U(u)f_V(w-u)\,du \\
%	& = \frac{1}{2\pi} \int_{-\infty}^{\infty} \exp\left[-\frac{1}{2}\left(u^2 + (w-u)^2\right)\right]\,du \\
%	& = \frac{1}{2\pi} e^{-\frac{1}{4}w^2} \int_{-\infty}^{\infty} \exp\left[-\left(u-\frac{w}{2}\right)^2\right]\,du
%\end{align*}
%We change the variable of integration, by making the substitution $t = \displaystyle\sqrt{2}\left(u-\frac{w}{2}\right)$:
%\[
%f_W(w)
%	= \frac{1}{2\sqrt{\pi}} e^{-\frac{1}{4}w^2} \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}w^2}\,dv
%	= \frac{1}{2\sqrt{\pi}} e^{-\frac{w^2}{4}},
%\]
%which is the PDF of the $N(0,2)$ distribution
%\end{proof}
%
%Lemma~\ref{lem:sum_of_standard_normal_variables} is a special case of the following theorem.
%% theorem

%%----------------------------------------------------------------------
%\section{The standard bivariate normal distributrion}
%%----------------------------------------------------------------------

\begin{theorem}\label{thm:sum_of_normal_variables}
if $X\sim N(\mu_1,\sigma_1^2)$ and $Y\sim N(\mu_2,\sigma_2^2)$ are independent, then
\[
X+Y\sim N(\mu_1+\mu_2, \sigma_1^2+\sigma_2^2).
\]
\end{theorem}

%The following corollary will be useful later on:
% corollary
\begin{corollary}\label{cor:lin_comb_std_normal}
If $U,V\sim N(0,1)$ are independent, then $aU+bV\sim N(0,a^2+b^2)$ for all $a,b\in\R$.
\end{corollary}
%If $U$ and $V$ are independent standard normal variables, their joint PDF of is
%
%\[
%f(u,v)=f_U(u)f_V(v) = \frac{1}{2\pi}\exp\left(-\frac{1}{2}(u^2 + v^2)\right) \qquad  u,v\in\R.
%\]

% definition: standard bivariate normal
\begin{definition}\label{def:standard_bivariate_normal}
A pair of random variables $U$ and $V$ have the \emph{standard bivariate normal distribution} if their joint PDF $f:\R^2\to[0,\infty)$ can be written as
\[
f_{U,V}(u,v) = \frac{1}{2\pi\sqrt{1-\rho^2}}\exp\left(-\frac{1}{2(1-\rho^2)}\big(u^2 - 2	\rho uv + v^2\big)\right)
\]
where $\rho$ is a constant satisfying $-1 < \rho < 1$.
\end{definition}

% definition: bivariate normal
\begin{definition}\label{def:bivariate_normal}
A pair of random variables $X$ and $Y$ are said to have \emph{bivariate normal distribution} with means $\mu_1$ and $\mu_2$, variances $\sigma_1^2$ and $\sigma_2^2$ and correlation $\rho$, if their joint PDF can be written as
%\small
\[
f_{X,Y}(x,y)
	= \frac{1}{2\pi\sigma_1\sigma_2\sqrt{1-\rho^2}}
		\exp\left(-\frac{1}{2(1-\rho^2)}\left[\left(\frac{x-\mu_1}{\sigma_1}\right)^2
			-2\rho\left(\frac{x-\mu_1}{\sigma_1}\right)\left(\frac{y-\mu_2}{\sigma_2}\right)
				+\left(\frac{y-\mu_2}{\sigma_2}\right)^2 \right]\right)
\]
\normalsize
\end{definition}

% technical result
The following lemma can be used to derive many properties of the bivariate normal distribution.
\begin{lemma}\label{lem:trick}
Let $U,V\sim N(0,1)$ be independent, let $\rho\in(-1,+1)$. Then the random variables
\begin{align*}
X & = \mu_1 + \sigma_1 U, \\
Y & = \mu_2 + \sigma_2\big(\rho U +\sqrt{1-\rho^2}V\big)
\end{align*}
have bivariate normal distribution with means $\mu_1$ and $\mu_2$, variances $\sigma_1^2$ and $\sigma_2^2$, and correlation $\rho$.
\end{lemma}

% proof
\begin{proof}
To find the joint PDF of $X$ and $Y$, let $g(u,v)$ denote the transformation:
\[
g(u,v) = \big[\mu_1 + \sigma_1 u, \mu_2 + \sigma_2(\rho u +\sqrt{1-\rho^2}v)\big].
\]
The inverse transformation is
\[
g^{-1}(x,y)
	= \left(\frac{x-\mu_1}{\sigma_1}, \frac{1}{\sqrt{1-\rho^2}}
  \left[\left(\frac{y-\mu_2}{\sigma_2}\right) -\rho\left(\frac{x-\mu_1}{\sigma_1}\right)\right]\right)
\]
The joint PDF of $X$ and $Y$ is $f_{X,Y}(x,y) = |J|f_{U,V}(u,v)$, where $J$ is the Jacobian determinant of the inverse transformation:
\[
J=\begin{vmatrix}
\displaystyle\frac{\partial u}{\partial x}  & \displaystyle\frac{\partial u}{\partial y}  \\[2ex]
\displaystyle\frac{\partial v}{\partial x}  & \displaystyle\frac{\partial v}{\partial y}
\end{vmatrix}
=
\begin{vmatrix}
\displaystyle\frac{1}{\sigma_1}  		& \displaystyle0 \\[2ex]
\displaystyle\frac{1}{\rho\sigma_1}	& \displaystyle\frac{1}{\sigma_2\sqrt{1-\rho^2}}
\end{vmatrix}
=
\frac{1}{\sigma_1\sigma_2\sqrt{1-\rho^2}}
\]

Because $U$ and $V$ are independent,
\[
f_{U,V}(u,v)=f_U(u)f_V(v) = \frac{1}{2\pi}\exp\left(-\frac{1}{2}(u^2 + v^2)\right) \qquad  u,v\in\R.
\]
and since
\begin{align*}
u^2 +v^2
	&  = \left(\frac{x-\mu_1}{\sigma_1}\right)^2
			+ \frac{1}{1-\rho^2}\left[
				\left(\frac{y-\mu_2}{\sigma_2}\right)^2
					- 2\rho\left(\frac{x-\mu_1}{\sigma_1}\right)\left(\frac{y-\mu_2}{\sigma_{2}}\right)
						+\rho^2\left(\frac{x-\mu_1}{\sigma_1}\right)^2 \right]  \\
	& =  \frac{1}{1-\rho^2}\left[\left(\frac{x-\mu_1}{\sigma_1}\right)^2
				-2\rho\left(\frac{x-\mu_1}{\sigma_1}\right)\left(\frac{y-\mu_2}{\sigma_2}\right)
					+\left(\frac{y-\mu_2}{\sigma_2}\right)^2\right]
\end{align*}
it follows that
%\small
\[
f_{X,Y}(x,y)
	= \frac{1}{2\pi\sigma_1\sigma_1\sqrt{1-\rho^2}}
		\exp\left(\frac{-1}{2(1-\rho^2)}\left[\left(\frac{x-\mu_1}{\sigma_1}\right)^2
			-2\rho\left(\frac{x-\mu_1}{\sigma_1}\right)\left(\frac{y-\mu_2}{\sigma_2}\right)
				+\left(\frac{y-\mu_2}{\sigma_2}\right)^2 \right]\right)
\]
\normalsize
as required.
\end{proof}

The following theorem shows that if $X$ and $Y$ have bivariate normal distribution, then any linear combination of $X$ and $Y$ is normally distributed.
% theorem: linear combination
\begin{theorem}\label{thm:lin_comb_bivar_normal}
Let $X$ and $Y$ have bivariate normal distribution with means $\mu_1$ and $\mu_2$, variances $\sigma_1^2$ and $\sigma_2^2$, and correlation $\rho$. Then
%If $X\sim N(\mu_1,\sigma_1^2)$ and $Y\sim N(\mu_2,\sigma_2^2)$ then
\[
aX + bY \sim N\big(a\mu_1 + b\mu_2, a^2\sigma_1^2 + 2ab\sigma_1\sigma_2\rho + b^2\sigma_2^2\big)
\]
\end{theorem}
\begin{proof}
Let $Z=aX+bY$, let $U$ and $V$ be independent standard normal random variables, and let
\begin{align*}
X' & = \mu_1 + \sigma_1 U \\
Y' & = \mu_2 + \sigma_2\big(\rho U +\sqrt{1-\rho^2}V\big)
\end{align*}

By Lemma~\ref{lem:trick}, $X$ and $Y$ have the same joint distribution as $X'$ and $Y'$, so $Z=aX+bY$ has the same distribution as
\[
Z' = aX'+bY' = (a\mu_1 + b\mu_2) + (a\sigma_1 + b\sigma_2\rho)U + b\sigma_2\sqrt{1-\rho^2} V
\]

Because $U,V\sim N(0,1)$ are independent, it follows by Corollary~\ref{cor:lin_comb_std_normal} that
\[
Z' \sim N\left(a\mu_1 + b\mu_2, a^2\sigma_1^2 + 2ab\sigma_1\sigma_2\rho + b^2\sigma_2^2\right),
\]
so $Z=aX+bY$ has normal distribution, as required.
\end{proof}

%----------------------------------------------------------------------
\section{Properties of the bivariate normal distribution}
%----------------------------------------------------------------------

% theorem: properties
\begin{theorem}
Let $X$ and $Y$ have bivariate normal distribution with means $\mu_1$ and $\mu_2$, variances $\sigma_1^2$ and $\sigma_2^2$, and correlation $\rho$. Then
\ben
\it $X\sim N(\mu_1,\sigma_1^2)$ and $Y\sim N(\mu_2,\sigma_2^2)$,
\it $\rho$ is the correlation coefficient of $X$ and $Y$, and
\it $X$ and $Y$ are independent if and only if $\rho=0$.
\een
\end{theorem}

% proof
\begin{proof}
%By Lemma~\ref{lem:trick}, let us write
Let $U,V\sim N(0,1)$ and define
\begin{align*}
X & = \mu_1 + \sigma_1 U \\
Y & = \mu_2 + \sigma_2\big(\rho U +\sqrt{1-\rho^2}V\big)
\end{align*}

\ben
\it % (i)
In the proof of Theorem~\ref{thm:lin_comb_bivar_normal}:
\bit
\it taking $a=1$ and $b=0$ yields $X\sim N(\mu_1,\sigma_1^2)$, and
\it taking $a=0$ and $b=1$ yields $Y\sim N(\mu_2,\sigma_2^2)$.
\eit
\it % (ii)
Using the fact that $\cov(aX+b,cY+d)=ac\cov(X,Y)$ for all $a,b,c,d\in\R$,
\begin{align*}
\cov(X,Y)
	& = \cov\big[\mu_1 + \sigma_1 U, \mu_2 + \sigma_2(\rho U + \sqrt{1-\rho^2}V)\big] \\
	& = \sigma_1\sigma_2\cov(U, \rho U + \sqrt{1-\rho^2}V) \\
	& = \sigma_1\sigma_2\big[\rho\expe(U^2) + \sqrt{1-\rho^2}\expe(UV)\big] \\
	& = \sigma_1\sigma_2\rho.
\end{align*}
Thus $\rho = \displaystyle\frac{\cov(X)}{\sqrt{\var(X)}\sqrt{\var(Y)}}$ as required.

\it % (iii)
If $X$ and $Y$ are independent, they are uncorrelated. If $X$ and $Y$ are uncorrelated then $\rho=0$, so the joint PDF of $X$ and $Y$ satisfies
\begin{align*}
f_{X,Y}(x,y)
	& = \frac{1}{2\pi\sigma_1\sigma_2}\exp\left(-\frac{1}{2}\left[\left(\frac{x-\mu_1}{\sigma_1}\right)^2 + \left(\frac{y-\mu_2}{\sigma_2}\right)^2 \right]\right) \\
	& = \frac{1}{\sqrt{2\pi}\sigma_1}\exp\left(-\frac{1}{2}\left(\frac{x-\mu_1}{\sigma_1}\right)^2\right)
			\times \frac{1}{\sqrt{2\pi}\sigma_2}\exp\left(-\frac{1}{2}\left(\frac{y-\mu_2}{\sigma_2}\right)^2\right) \\
	& = f_X(x)f_Y(y).
\end{align*}
Because this holds for all $x,y\in\R$, it follows that $X$ and $Y$ are independent.
\een
\end{proof}

%----------------------------------------------------------------------
\section{Conditional distributions}
%----------------------------------------------------------------------

% theorem
\begin{theorem}
Let $X$ and $Y$ have bivariate normal distribution with means $\mu_1$ and $\mu_2$, variances $\sigma_1^2$ and $\sigma_2^2$, and correlation $\rho$.
Then the conditional distribution of $Y$ given $X=x$ is also normal, with conditional mean and variance given by
\begin{align*}
\expe(Y|X=x)	& = \mu_2 + \rho\left(\frac{\sigma_2}{\sigma_1}\right)(x - \mu_1), \\[2ex]
\var(Y|X=x) 	& = \sigma_2^2(1-\rho^2),
\end{align*}
and the conditional mean and variance of $Y$ given $X$ is
\begin{align*}
\expe(Y|X)	& = \expe(Y) + \frac{\cov(X,Y)}{\var(X)}\big[X - \expe(X)\big], \\[2ex]
\var(Y|X) 	& = \var(Y)(1-\rho^2).
\end{align*}
\end{theorem}

% proof
\begin{proof}
Let $U,V\sim N(0,1)$ be independent, and define the random variables
\begin{align*}
X & = \mu_1 + \sigma_1 U, \\
Y & = \mu_2 + \sigma_2\big[\rho U +\sqrt{1-\rho^2}V\big] \\
	& = \mu_2 + \sigma_2\left[\rho \left(\frac{X-\mu_1}{\sigma_1}\right) +\sqrt{1-\rho^2}V\right].
\end{align*}
If $X$ is fixed at $x$, then $Y$ is a linear transformation of $V$, so the conditional distribution of $Y$ given that $X=x$ is a normal distribution.
Furthermore, since $\expe(V)=0$ and $\var(V)=1$ we have
\begin{align*}
\expe(Y|X=x) 	& = \mu_2 + \rho\left(\frac{\sigma_2}{\sigma_1}\right)(x - \mu_1) \\[2ex]
\var(Y|X=x)	& = \sigma_2^2(1-\rho^2)
\end{align*}
as required.
\end{proof}

% remarks
\begin{remark}
\bit
\it
Given $X=x$, the conditional mean is obtained by adjusting $\expe(Y)$ by an amount proportional to the difference between $X=x$ and its mean $\expe(X)$. The size of this adjustment is determined by (1) the size of $Y$ relative to $X$, expressed by the ratio $\sigma_2/\sigma_1$, and (2) the correlation coefficient $\rho$, which quantifies the linear dependence between $X$ and $Y$. Note that $\rho=0$ implies that $\expe(Y|X=x)=0$ for all $x$ (which is not surprising, given that uncorrelated normal variables are independent).
\it
The conditional variance $\var(Y|X=x)$ quantifies the variability in $Y$ that is \emph{not} explained by the fact that $X$ takes the value $x$. The squared correlation coefficient $\rho^2$ thus quantifies the proportion of the overall variance $\var(Y)$ accounted for by the fact that $X=x$.
\it
This idea of `explained' and `unexplained' variance is apparent in the law of total variance:
\[
\var(Y) = \expe\big[\var(Y|X)\big] + \var\big[\expe(Y|X)\big]
\]
	\bit
	\it $\var(Y)$ is the total variance,
	\it $\expe\big[\var(Y|X)\big]$ is the variance explained by $X$, and
	\it $\var\big[\expe(Y|X)\big]$ is the variance not explained by $X$.
	\eit
\eit
\end{remark}

%----------------------------------------------------------------------
\section{Mulivariate transformations}
%----------------------------------------------------------------------

% definition
\begin{definition}\label{def:jacobian}
Let $h:\R^n\to\R^n$ be a transformation of $n$ variables, and let $(x_1,x_2,\ldots,x_n) = h(y_1,y_2,\ldots,y_n)$. The \emph{Jacobian} (or \emph{Jacobian determinant}) of the transformation $h$ is the determinant of its $n\times n$ matrix of partial derivatives:
\[
J =
\begin{vmatrix}
\displaystyle\frac{\partial x_1}{\partial y_1} & \displaystyle\frac{\partial x_1}{\partial y_2} & \cdots &  \displaystyle\frac{\partial x_1}{\partial y_n}\\[2ex]
\displaystyle\frac{\partial x_2}{\partial y_1} & \displaystyle\frac{\partial x_2}{\partial y_2} & \cdots &  \displaystyle\frac{\partial x_2}{\partial y_n}\\[2ex]
\vdots & \vdots & \ddots & \vdots \\[2ex]
\displaystyle\frac{\partial x_n}{\partial y_1} & \displaystyle\frac{\partial x_n}{\partial y_2} & \cdots &  \displaystyle\frac{\partial x_n}{\partial y_n}\\[2ex]
\end{vmatrix}
\]
\end{definition}

% theorem: continuous
\begin{theorem}\label{thm:transf_injective_joint_continuous}
Let $X=(X_1,X_2,\ldots,X_n)$ be a vector of continuous random variables, let $f_X(x_1,x_2\ldots,x_n)$ be their joint PDF, let $g:\R^n\to\R^n$ be an injective transformation, and let $Y=(Y_1,Y_2,\ldots,Y_n)$ be the continuous random vector defined by $Y=g(X)$, i.e.\
\[
(Y_1,Y_2,\ldots,Y_n) = g(X_1,X_2,\ldots,X_n)
\]
If the Jacobian of the inverse transformation $g^{-1}$ is continuous and non-zero over the range of the transformation, the joint PDF of $Y$ is
\[
f_Y(y_1,y_2,\ldots,y_n) = |J| f_X(x_1,x_2,\ldots,x_n)
\]
where
\[
(x_1,x_2,\ldots,x_n)=g^{-1}(y_1,y_2,\ldots,y_n)
\]
is the solution of $(y_1,y_2,\ldots,y_n)=g(x_1,\ldots,x_n)$.
\end{theorem}

% remark
\begin{remark}
The scale factor $|J|$ ensures that $f_Y(y_1,y_2,\ldots,y_n)$ integrates to one.
\end{remark}

%==================================================================================================
\section{The multivariate normal distribution}
%==================================================================================================
The bivariate normal distribution can be formulated using matrix notation. Let
\[
\mathbf{Z}		= \begin{pmatrix} X \\ Y \end{pmatrix},\quad
\mathbf{\mu}	= \begin{pmatrix} \mu_1 \\ \mu_2 \end{pmatrix}\quad\text{and}\quad
\Sigma			= \begin{pmatrix} \sigma^2_1 & \rho\sigma_1\sigma_2 \\ \rho\sigma_1\sigma_2 & \sigma^2_2 \end{pmatrix}
\]

The matrix $\Sigma$ is called the \emph{variance-covariance} matrix.
\bit
\it The determinant of $\Sigma$ is
\[
|\Sigma| = (1-\rho^2)\sigma^2_1\sigma^2_2.
\]
\it The inverse of $\Sigma$ is
\[
\Sigma^{-1} = \frac{1}{(1-\rho^2)\sigma^2_1\sigma^2_2}
\begin{pmatrix}
	\sigma^2_2  				& -\rho\sigma_1\sigma_2 \\
	-\rho\sigma_1\sigma_2	& \sigma^2_1
\end{pmatrix}.
\]
\eit

Let $\mathbf{z} = (x,y)^T$ and consider the quadratic form
\begin{align*}
\big(\mathbf{z}-\mathbf{\mu})^T \Sigma^{-1}(\mathbf{z}-\mathbf{\mu}\big)
	& = 	\frac{1}{(1-\rho^2)\sigma^2_1\sigma^2_2}\
			\begin{pmatrix} x-\mu_1 \\ y-\mu_2	\end{pmatrix}^T
			\begin{pmatrix} \sigma^2_2 & -\rho\sigma_1\sigma_2 \\ -\rho\sigma_1\sigma_2 & \sigma^2_1 \end{pmatrix}
			\begin{pmatrix} x-\mu_1 \\ y-\mu_2	\end{pmatrix} \\
	& = \frac{1}{(1-\rho^2)}\left[\left(\frac{x-\mu_1}{\sigma_1}\right)^2
			 -2\rho\left(\frac{x-\mu_1}{\sigma_1}\right)\left(\frac{y-\mu_2}{\sigma_2}\right)
			 	+\left(\frac{y-\mu_2}{\sigma_2}\right)^2\right]
\end{align*}

The PDF $f(x,y)$ of the bivariate normal distribution can therefore be written as
\[
f(x,y) = \frac{1}{2\pi|\Sigma|^{1/2}}\exp\left(-\frac{1}{2}(\mathbf{z}-\mathbf{\mu})^T \Sigma^{-1} (\mathbf{z}-\mathbf{\mu})\right).
\]

Using this notation, we define the \emph{multivariate normal distribution} as follows.

% definition: multivariate normal
\begin{definition}
A random vector $\mathbf{Z}=(X_1,X_2,\ldots,X_n)^T$ is said to have \emph{multivariate normal distribution} with mean vector $\mathbf{\mu}= (\mu_1,\mu_2,\ldots,\mu_n)^T$ and variance-covariance matrix
\[
\Sigma			= \begin{pmatrix}
	\sigma^2_1		 			& \rho_{12}\sigma_1\sigma_2  	& \ldots & \rho_{1n}\sigma_1\sigma_n \\
	\rho_{21}\sigma_1\sigma_2 	& \sigma^2_2					& \ldots & \rho_{2n}\sigma_2\sigma_n \\
	\vdots						& \vdots						& \ddots & \vdots \\
	\rho_{n1}\sigma_1\sigma_n		 	& \rho_{n2}\sigma_n\sigma_2	& \ldots & \sigma^2_n \\
	\end{pmatrix}
\]
if its joint density function can be written as
\[
f(\mathbf{z}) = \frac{1}{2\pi|\Sigma|^{1/2}}\exp\left(-\frac{1}{2}(\mathbf{z}-\mathbf{\mu})^T \Sigma^{-1} (\mathbf{z}-\mathbf{\mu})\right)
\]
\end{definition}

where $\mu_i = \expe(X_i)$, $\sigma_i^2 = \var(X_i)$ and $\rho_{ij} = \displaystyle\frac{\expe(X_iX_j)}{\sigma_i\sigma_j}$.

\begin{exercise}
\begin{questions}
%----------------------------------------
% GS p100
\question
Let $X$ and $Y$ have standard bivariate normal distribution, with joint PDF given by
%\[
%f(x,y)
%	= \frac{1}{2\pi\sigma_1\sigma_2\sqrt{1-\rho^2}}
%		\exp\left(-\frac{1}{2(1-\rho^2)}\left[\left(\frac{x-\mu_1}{\sigma_1}\right)^2
%			-2\rho\left(\frac{x-\mu_1}{\sigma_1}\right)\left(\frac{y-\mu_2}{\sigma_2}\right)
%				+\left(\frac{y-\mu_2}{\sigma_2}\right)^2 \right]\right)
%\]
\[
f(x,y) = \frac{1}{2\pi\sqrt{1-\rho^2}}\exp\left(-\frac{1}{2(1-\rho^2)}(x^2 - 2\rho xy + y^2)\right)
\]
where $\rho$ is a constant satisfying $-1 < \rho < 1$.
\begin{parts}
\part
Check that $f(x,y)$ is indeed a joint PDF, by verifying that $f(x,y)\geq 0$ and $\displaystyle\int_{-\infty}^{\infty}\int_{-\infty}^{\infty} f(x,y)\,dxdy = 1$.
\begin{answer}
TODO
\end{answer}
\part
Check that $\cov(X,Y) = \displaystyle\int_{-\infty}^{\infty}\int_{-\infty}^{\infty} xy f(x,y)\,dxdy = \rho$.
\begin{answer}
TODO
\end{answer}
\part
Show that if $X$ and $Y$ are uncorrelated, then they are independent.
\begin{answer}
TODO
\end{answer}
\end{parts}
%----------------------------------------
\question
% GS p110
Let $X$ and $Y$ have standard bivariate normal distribution. Find the conditional distribution of $Y$ given $X=x$, and hence show that $\expe(Y|X) = \rho X$.
\begin{answer}
The conditional distribution of $Y$ given $X=x$ is $N(\rho x, 1-\rho^2)$.
\end{answer}
%----------------------------------------
% GS 4.7.5
\question
Let $X$ and $Y$ have standard bivariate normal distribution. Show that $X$ and $\displaystyle Z=\frac{Y-\rho X}{\sqrt{1-\rho^2}}$ are independent standard normal random variables.
\begin{answer}
TODO
\end{answer}
%----------------------------------------
% GS 4.7.6
\question
Let $X$ and $Y$ have standard bivariate normal distribution, and let $Z=\max\{X,Y\}$. Show that $\expe(Z)=\sqrt{(1-\rho)/\pi}$ and $\expe(Z^2)=1$.
\begin{answer}
TODO
\end{answer}
%----------------------------------------
\question
Let $U,V\sim N(0,1)$. Show that the random variables $X = U+V$ and $Y = U-V$ are independent.

\begin{answer}
\bit
\it The transformation is $g(u,v) = (u+v,u-v)$.
\it To compute the inverse transformation, consider $x=u+v$ and $y=u-v$.
\it Solving these, we obtain $u = \frac{1}{2}(x+y)$ and $v = \frac{1}{2}(x-y)$.
\it Thus the inverse transformation is $(u,v) = g^{-1}(x,y) = \left(\frac{1}{2}(x+y),\frac{1}{2}(x-y)\right)$
\eit

The Jacobian determinant of $g^{-1}(x,y)$ is
\[
J =
\begin{vmatrix}
\frac{\partial u}{\partial x}  & \frac{\partial u}{\partial y}  \\
\frac{\partial v}{\partial x}  & \frac{\partial v}{\partial y}
\end{vmatrix}
=
\begin{vmatrix}[r]
\frac{1}{2}   &  \frac{1}{2} \\
\frac{1}{2}  & -\frac{1}{2}
\end{vmatrix}
=
-\frac{1}{2}
\]
The joint PDF of $U$ and $V$ is
\[
f(u,v) = \frac{1}{2\pi \sqrt{1-\rho ^{2}}} \exp\left( -\frac{u^2 + v^2 - 2\rho uv}{2(1-\rho^2)} \right)
\]

Now,
\begin{align*}
u^2 + v^2 - 2\rho uv
	& = \left(\frac{1}{2}(x+y)\right)^2 +\left(\frac{1}{2}(x-y)\right)^2 - 2\rho\left(\frac{1}{2}(x+y)\right)\left(\frac{1}{2}(x-y)\right) \\
	& = \frac{1}{2}x^2(1-\rho ) + \frac{1}{2}y^2(1+\rho )
\end{align*}

The joint PDF of $X$ and $Y$ is therefore
\begin{align*}
f(x,y)
	& = \frac{1}{2} \frac{1}{2\pi\sqrt{1-\rho ^{2}}}\exp\left( -\frac{x^{2} (1-\rho )}{4(1-\rho ^{2} )} -\frac{y^{2} (1+\rho )}{4(1-\rho ^{2})}\right) \\
	& = \frac{1}{\sqrt{4\pi(1+\rho)}}\exp\left(-\frac{x^{2}}{4(1+\rho)}\right) \times \frac{1}{\sqrt{4\pi(1-\rho)}}\exp\left(-\frac{y^{2}}{4(1-\rho )}\right) \\
\end{align*}
This is the product of the PDF of a $N\big(0,2(1+\rho)\big)$ variable and the PDF of a $N\big(0,2(1-\rho)\big)$ variable. Thus $X$ and $Y$ are independent.
\end{answer}

\question
Let $X$ and $Y$ have bivariate normal distribution with means $\mu_1$ and $\mu_2$, variances $\sigma_1^2$ and $\sigma_2^2$, and correlation $\rho$. Show that the conditional distribution of $Y$ given $X=x$ is
\[
N\left(\mu_2 + \rho\left(\frac{\sigma_2}{\sigma_1}\right)(x-\mu_1), \sigma_2^2(1-\rho^2)\right).
\]
\begin{answer}
TODO
\end{answer}
%----------------------------------------
\question
\begin{parts}
\part % << (i)
Let $X$ and $Y$ be jointly continuous random variables, and let $f_{X,Y}$ be their joint PDF. Show that the PDF of the random variable $X+Y$ can be written as
\[
f_{X+Y}(t)
	= \int_{-\infty}^{\infty} f_{X,Y}(x,t-x)\,dx
	= \int_{-\infty}^{\infty} f_{X,Y}(t-y,y)\,dy.
\]
\begin{answer}
Let $A = \{(x,y):x+y\leq z\}\subset\R^2$. Then
\[
\prob(X+Y\leq z)
	= \iint_A f(x,y)\,dxdy
	= \int_{x=-\infty}^{\infty} \int_{y=-\infty}^{z-x}f_{X,Y}(x,y)\,dy\,dx
\]
We change the variable of integration (in the inner integral), making the substitution $y=t-x$:
\begin{align*}
F_{X+Y}(z) = \prob(X+Y\leq z)
	& = \int_{x=-\infty}^{\infty} \int_{t=-\infty}^{z}f_{X,Y}(x,t-x)\,dt\,dx \\
	& = \int_{t=-\infty}^{z} \int_{x=-\infty}^{\infty}f_{X,Y}(x,t-x)\,dx\,dt
\end{align*}
where the final equality follows by reversing the order of integration. Thus the PDF of $X+Y$ is
\[
f_{X+Y}(t) = \int_{-\infty}^{\infty} f_{X,Y}(x,t-x)\,dx \qquad\text{as required.}
\]
\end{answer}
\part % << (ii)
Hence, or otherwise, show that if $U,V\sim N(0,1)$ are independent, then $U+V\sim N(0,2)$. (This is a special case of Theorem~\ref{thm:sum_of_normal_variables}.)
\begin{answer}
By part (a), if two random variables $X$ and $Y$ are independent, the PDF of $X+Y$ is the \emph{convolution} of the marginal PDFs:
\[
f_{X+Y}(t)
	= \int_{-\infty}^{\infty} f_X(x)f_Y(t-x)\,dx
	= \int_{-\infty}^{\infty} f_X(t-y)f_Y(y)\,dy.
\]
$U$ and $V$ are independent, so their joint PDF is
\[
f(u,v)=f_U(u)f_V(v) = \frac{1}{2\pi}\exp\left(-\frac{1}{2}(u^2 + v^2)\right) \qquad  u,v\in\R.
\]
Let $W=U+V$. Then because $U$ and $V$ are independent,
\begin{align*}
f_W(w)
	& = \int_{-\infty}^{\infty} f_U(u)f_V(w-u)\,du \\
	& = \frac{1}{2\pi} \int_{-\infty}^{\infty} \exp\left[-\frac{1}{2}\left(u^2 + (w-u)^2\right)\right]\,du \\
	& = \frac{1}{2\pi} e^{-\frac{1}{4}w^2} \int_{-\infty}^{\infty} \exp\left[-\left(u-\frac{w}{2}\right)^2\right]\,du
\end{align*}
We change the variable of integration, by making the substitution $t = \displaystyle\sqrt{2}\left(u-\frac{w}{2}\right)$:
\[
f_W(w)
	= \frac{1}{2\sqrt{\pi}} e^{-\frac{1}{4}w^2} \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}w^2}\,dv
	= \frac{1}{2\sqrt{\pi}} e^{-\frac{w^2}{4}},
\]
which is the PDF of the $N(0,2)$ distribution
\end{answer}
\end{parts}

%----------------------------------------
\end{questions}
\end{exercise}
%----------------------------------------------------------------------


\subsection{Frequent patterns}

\subsubsection{Frequent patterns}

A frequent itemset is one where the support is above a minimum.

We know that if an itemset is frequent, then all its subsets are also frequent.

We look for frequent patterns, \(F\), between the items \(I\).

An example of a frequent pattern is \(\{a,b\}\).


%gln
\section{General linear group}

As the most prominent example of a functor, we will now discuss the following construction. Let $R$, again, denote a unital commutative ring.
\begin{defi}
Let $\mathfrak{F}$ be a finite category and $\mathrm{UCRng}$ the category of unital commutative rings. The bifunctor
$$\bao{rrcl}
\mathrm{Gl} : &\mathfrak{F} \times \mathrm{UCRng} &\longrightarrow &\mathrm{Grp},\\
& (I,R) &\longmapsto& Gl(I,R) := Gl_{|I|}(R),\\
\ea$$
is a pairing of a finite set $I$, a ring $R$ and its group of $R$ module automorphism on the generic module $R^I$.
\end{defi}
\begin{coro}
We  immediately get
$$\bao{rcl}
Gl_0(R) &=& Gl(\emptyset,R) = \{1_R\} \ \mathrm{and}\\
Gl_1(R) &=& Gl(\mathcal{P}(\emptyset),R)\\ &=& R^\times = U(R)\\ &:=& \{r \in R : \exists r' \in R,\ r r' = 1\}.\\
\ea\\$$
\end{coro}
Both statements are clearly a consequence of our above definition.
\begin{theo}
Let $I \in \mathfrak{F}$ be fixed with $|I| = i$ and let $R \in \mathrm{UCRng}$ be an ID then
$$\mathrm{Gl}_i \simeq \mathrm{Hom}_{\mathrm{UCRng}}(\mathbb{Z}[X,Y]/\left<\det X \cdot Y - 1\right>,\ \cdot\ )$$
as functors.
\end{theo}
Before we proceed in proofing the theorem, let us dwell in the above formular for a moment. Firstly, $X$ stands for $\{X_{kl} : 1 \leq k, l \leq i\}$ - a set of $i^2$ variables and
$$\mathbb{Z}[X,Y]/\left<\det X \cdot Y - 1\right> = \mathbb{Z}[X_{kl},Y : 1 \leq k, l \leq i]/\left<\det \left(\bao{ccc}
X_{11} & \ldots & X_{1i}\\
\vdots&&\vdots\\
X_{i1}&\ldots&X_{ii}\ea\right) \cdot Y - 1\right>$$
for the ring of the polynomial ring over $\mathbb{Z}$ in $i^2 + 1$ indeterminants, factored out the ideal generated by $\det X \cdot Y - 1$. Thus, the right hand side claims that the class of all (unital commutative) ring homomorphisms into some ring $R$ are functorially isomorphic to $i$-th general linear group $\mathrm{Gl}_i(R)$. %In classical algebraic geometry we would get the zero set:

%$$Z(\det X \cdot Y - 1) = \left\{x \in \mathbb{A}^{i^2}_R \simeq M_i(R) : \det x \in \mathrm{Gl}_1(R)\right\}$$
%and its spectral interpretation:
%$$\mathfrak{Z}(\det X \cdot Y - 1) = \left\{\prm \in \mathrm{Spec}(\mathbb{Z}[X,Y]/\left<\det X Y - 1\right>) : \det X Y - 1 \in \prm\right\}$$

Given some ring homomorphism $\varphi : A := \mathbb{Z}[X,Y]/\left<\det X Y - 1\right> \longrightarrow R$, we get
$$\mathrm{Spec}(\varphi) = \left[\prm \in \mathrm{Spec}(R) \longmapsto \varphi^{-1}(\prm) := \{f \in A : \varphi(f) \in \prm\}\right],$$
in particular
$$\varphi^{-1}(\prm) \in \mathrm{Spec}(A).$$
Clearly, $\mrm{Spec}(A)$ contains the elements
$$\prm_\mu :=  \left\{\sum_{kl} \lambda_{kl} (X_{kl} - \mu_{kl}) : \mu = \left(\bao{ccc}\mu_{11}&\ldots&\mu_{1i}\\\vdots&&\vdots\\\mu_{i1}&\ldots&\mu_{ii}\\\ea\right), \lambda_{kl} \in A,\ \lambda_\mu (X - \mu) \in \ker eval_{\mu}\right\}$$
mapping the monomial $X$ to $\mu$. As $A$ is a UFD and $(X_{kl} - \mu_{kl})$ cannot have any other divisors we conclude $$\ker eval_\mu \in \spec{A},$$
as $\det \mu \cdot Y - 1 \in R[Y]$ has roots in $R$ (i.e.: for all $\det \mu \in \mrm{Gl}_1(R)$) and more importantly, $(0) \in \spec{R}$.
Here, we are using the following diagram:
$$\xymatrix{
A \ar[rr]^{eval_\mu}\ar[rrd]_f&&R[Y]\ar[d]^{eval_{\det \mu^{-1}}}\\
&&R.\\
}$$
Thus, the pairing
$$\bao{rrcl}
V :& \mrm{Gl}_i(R) \subset \affr{i^2+1} &\longrightarrow& \spec{\zz[X,Y]},\\
&\left(\mu_{k,l},\frac{1}{\det \mu}\right)_{1\leq k,l \leq i} &\longmapsto& \left<X_{kl} - \mu_{kl}, Y - \det \mu^{-1}\right>
\ea$$
lets us consider all points in $\mrm{Gl}_i(R)$ as an algebraic set also as (families of) prime ideals in $\zz[X,Y]$.


\section{How fast will Raft elect a leader when split votes are possible?}
\label{leaderelection:split:total}

Given a split vote rate, we can estimate the total election time.
Raft will elect a leader as soon as an election term
successfully completes without a split vote. When a split vote occurs,
it's likely that all servers have reset their timers, since servers do
this when they grant a vote (this isn't quite true when logs
differ; see Section~\ref{leaderelection:logsdiff}). Thus, the
next election term has the same probability of success as an entirely
new election and will take just as long. In other words, each election
term is essentially memoryless, and the number of election terms
required in an election can be modeled as a geometric distribution,
where the probability of success is the probability that a split vote
does not occur. Therefore, Raft elections are expected to complete in
$\dfrac{1}{1-\text{split vote rate}}$ election terms on average.

If a split vote occurs in a particular election term, the election term
takes about $1+M_s$ time units plus a one-way network latency to reset
the server's election timers. We do not include the time for the
candidate to record its own vote on disk, since this time can be
overlapped with the RequestVote messages (with this optimization, the
candidate may not count its own vote towards leadership until the vote
is durably recorded). After the vote is split, the cluster must wait
another election timeout before the next election term begins. This
repeats for each split vote, then the time for an election with no split
votes (from Section~\ref{leaderelection:nosplit}) is additional. Thus, the
total time for an election, $E_s$, is:
\begin{align*}
E_s &= \Big(\sum_\text{split votes} \text{time for split vote}\Big)
 +
  \Big(\text{time for election with no split vote}\Big) \\
%
E_s &= \Big(\sum_\text{split votes} (1 + M_s + L)\Big)
 +
  \Big(1 + M_s + 2L + W - U(0,\dfrac{1}{2})\Big) & \\
%
\Ex[E_s] &= \Big((\frac{1}{1-\text{split vote rate}} - 1) \times
            (1 + \frac{1}{s+1} + \Ex[L])\Big)
 +
  \Big(1 + \frac{1}{s+1} + 2\Ex[L] + \Ex[W] - \dfrac{1}{4}\Big) \\
%
\Ex[E_s] &= \frac{1}{1-\text{split vote rate}} \times
            \Big(1 + \frac{1}{s+1} + \Ex[L]\Big)
            + \Ex[L] + \Ex[W] - \dfrac{1}{4}
\end{align*}
where $L$ is the one-way network latency and $W$ is the latency for a
durable disk write.

Howard~\cite{Howard:2014} suggests an optimization to decrease the time
for an election after split votes occur. The optimization separates
followers' timeouts from candidates' timeouts, where candidates select
smaller timeouts from a distribution with a smaller range. This results
in faster iterations once split votes have occurred, though it risks
additional split votes. The remainder of this chapter does not use this
optimization.

\begin{figure}
\centering
\includegraphics[height=5.5in]{leaderelection/overall}
\hspace{-2em}
\vcaption[expected overall election time]{
The expected total election times for various clusters,
as defined by $\Ex[E_s]$, with a fixed one-way network latency.
It excludes the time to write to stable
storage (which is usually negligible). The timeout range and
expected overall election time are presented as multiples of the one-way
network latency ($l$), since $l$ is typically fixed in a given
deployment.
}
\label{fig:leaderelection:theory:overall}
\end{figure}

Figure~\ref{fig:leaderelection:theory:overall} plots the expected time to
elect a leader when the network latency is fixed, by combining the
formula for $\Ex[E_s]$ with the formula for $Pr(D_{c,s} \leq l)$.
From the graphs, a Raft cluster with a sufficiently broad timeout range
will usually elect a leader within 20 times the one-way network latency,
even when running with a bare majority of available servers. This
suggests that most datacenter Raft deployments should be able to achieve
typical leader election times under \SI{100}{\milli\second}. Even worst
case global deployments, with one-way latencies of
\SI{200}{\milli\second},
should be able to typically elect leaders within \SI{4}{seconds}. (Election
times may be larger if some servers are deployed on other planets.)

Each of the curves has a knee. If the timeout range is chosen to be too
short, too many servers time out before others are able to collect
votes, resulting in poor election times. Once timeout ranges are
sufficiently large (about 3--8 times the network latency, depending on
the cluster), the curves become linear with a slight upward slope:
elections complete after few or no split votes, but they must wait
longer for each timeout to elapse.

The graphs provide insight into how to configure election timeouts: a
conservative setting is probably best in practice. The minimum point on
the graphs represents the best average election time possible for each
given cluster configuration. However, attaining this minimum time is
quite risky, since the minimum is close to the knee in the curve. If the
network latency turns out to be slightly higher than anticipated in
practice, that might push the system into the left region of the graph
where election times skyrocket. It is better to configure systems
farther to the right, trading off a slightly higher average election
time in exchange for a more robust system. Thus, we recommend using a
timeout range that is ten times the one-way network latency (even if the
true network latency is five times greater than anticipated, most clusters would
still be able to elect a leader in a timely manner).


%% -*- coding:utf-8 -*-
\chapter{Tensor product. Structure of finite K-algebras}
This is a digression on commutative algebra. We introduce and study
the notion of tensor product of modules over a ring. We prove a
structure theorem for finite algebras over a field (a version of the
well-known "Chinese remainder theorem").

\section{Definition of tensor product}

\subsection{Summary for previous lectures}
We considered finite \mynameref{def:fextension1} $L$ i.e
$\left[L:K\right] < \infty$. We also saw that if
$L$ is generated by a finite number of \mynameref{def:degsepelem}s
$\alpha_1, \dots, \alpha_r$ then the number of
\mynameref{def:homomorphism}s over $K$ from $L$ to $\bar{K}$ denoted by
$\left|Hom_K\left(L, \bar{K}\right)\right|$ is equal to
$\left[L:K\right]$. In general
\[
\left[L:K\right]_{sep} =
\left|Hom_K\left(L, \bar{K}\right)\right| \le
\left[L:K\right].
\]

For $L = K\left(\alpha\right)$ it is clear because the number of
homomorphisms is equal to the number of roots of the
\mynameref{def:minpolynomial} $P_{min}\left(\alpha, K\right)$. In
general one can use induction and multiplicativity of the degree
$\left[L:K\right]$ and number of homomorphisms (see theorem
\mynameref{thm:lec3_3}). Thus  separable extension was exactly an
extension  which had the right number of homomorphisms into the
algebraic closure.

Our next goal is to characterize the separability in the terms of
tensor product.

\subsection{Tensor product}

\begin{definition}[Tensor product]
  Let $A$ is a ring, $N$, $M$ are $A$-\mynameref{def:module}s. The
  tensor product $M \otimes_A N$
  is another $A$-\mynameref{def:module} together with an
  $A$-bilinear map $\phi: M \times N \to M \otimes_A N$ which has
  ``\mynameref{def:universalproperty}'' defined below
  \label{def:tensorproduct}
\end{definition}

\begin{definition}[Universal property]
  $A$-bilinear map $\phi: M \times N \to M \otimes_A N$ has
  ``universal property'' if
  $\forall P$ - $A$-\mynameref{def:module} and
  for $A$-bilinear $f: M \times N \to P$ (
  i.e.
  \(
  \forall m, f_m:
  N \xrightarrow[n \to f(m,n)]{} P
  \)
  and
  \(
  \forall n, f_n:
  M \xrightarrow[m \to f(m,n)]{} P
  \)
  are \mynameref{def:homomorphism}s of $A$-modules
  ), then
  $\exists! \tilde{f}$ - homomorphism of $A$-modules such that
  $f = \tilde{f} \circ \phi$
  \footnote{
    That means that we have a \mynameref{def:commutativediagram} there
  }

  \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
    \matrix (m) [matrix of math nodes, row sep=3em,
      column sep=2.5em, text height=1.5ex, text depth=0.25ex]
            { M \times N & & P \\
              & M \otimes_A N & \\ };
            %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
            \path[->]
            (m-1-1) edge node[auto] {$ f $} (m-1-3)
            edge node[auto] {$ \phi $} (m-2-2)
            (m-2-2) edge node[auto] {$ \tilde{f} $} (m-1-3);
  \end{tikzpicture}
  \label{def:universalproperty}
\end{definition}

The property characterize the pair
$\left(\phi, M \otimes N\right)$.
Really if have another pair
$\left(\overline{\phi}, \overline{M \otimes N}\right)$
like this one then by definition we have mutually inverse
homomorphisms of $A$-modules between them

\begin{lemma}[About uniqueness of object defined by universal
    property]
  \footnote{
    It is out of the lecture video and can be considered as an
    explanation for the claim about having mutually inverse
    homomorphisms of $A$-modules. The proof was taken from
    \cite{bib:KeithConradTensorProduct1}.
  }
  If we have two objects $\left(\phi, M \otimes N\right)$
  and $\left(\overline{\phi},\overline{M \otimes N}\right)$
  which both satisfies \mynameref{def:universalproperty} than there is
  an unique \mynameref{def:isomorphism} between them:
  \[
  \left(\phi, M \otimes N\right) \cong \left(\overline{\phi},
  \overline{M \otimes N}\right)
  \]
\begin{proof}
Let $P = \overline{M \otimes N}$ and $f =
\overline{\phi}$. In
the case we can consider the following diagram

\begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
  \matrix (m) [matrix of math nodes, row sep=3em,
    column sep=2.5em, text height=1.5ex, text depth=0.25ex]
          { & & M \otimes_A N & \\
            M \times N & & \overline{M \otimes_A N} \\
            & & M \otimes_A N & \\ };
          %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
          \path[->]
          (m-2-1) edge node[auto] {$ \phi $} (m-1-3)
          (m-1-3) edge node[auto] {$ g = \tilde{\overline{\phi}} $} (m-2-3)
          (m-2-1) edge node[auto] {$ \overline{\phi} $} (m-2-3)
          (m-2-1) edge node[auto] {$ \phi $} (m-3-3)
          (m-2-3) edge node[auto] {$ \bar{g} = \tilde{\phi} $} (m-3-3);
\end{tikzpicture}

As soon as we fixed $\overline{ M \otimes_A N}$
we 2 unique homomorphisms (which are defined by the fixed
$\overline{ M \otimes_A N}$) -
$g :  M \otimes_A N \to \overline{ M \otimes_A N}$
and
$\bar{g} :  \overline{M \otimes_A N} \to M \otimes_A N$.
Both $g$ and $\bar{g}$ are linear and, as mentioned above, the pair is
unique (if we fix $g$ we will have only one $\bar{g}$ that corresponds
to $g$). The composition $g \circ \bar{g}$ maps $M \otimes_A N$ to
itself. I.e. $\forall x \in M \times N$ we have
$\bar{g}\left(g\left(\phi\left(x\right)\right)\right) =
\phi\left(x\right)$. If $y = \phi\left(x\right)$ then
$\bar{g}\left(g\left(y\right)\right) = y$. The last equation holds
$\forall y \in Im\left(\phi\right)$ i.e. $\forall y \in M \otimes_A
N$. Therefore $\bar{g} = g^{-1}$.
\footnote {
  Another explanation is the following: thus if we fix $g$ and choose
  $\bar{g} = g^{-1}$ we will get $g \circ \bar{g} = id_{M \otimes_A
    N}$ that satisfied all requirements. The choice is final because
  we don't have a possibility to choose any other $\bar{g}$ (it should
  be unique).
}

Thus we have an
\mynameref{def:isomorphism} and the isomorphism is unique as soon as the
function $g$ is unique due the \mynameref{def:universalproperty}.

We just prove an isomorphism existence between
$M \otimes N$ and $\overline{M \otimes N}$ but the tensor product is
characterized not only by the module $M \otimes N$
but also a bilinear map $\phi$. Let $P = \overline{M \otimes N}$ thus
we can get that $\bar{\phi} = \tilde{\bar{\phi}} \circ \phi$ is
determined by the unique
relation $\phi \to \bar{\phi}$ as soon as
$\tilde{\bar{\phi}}$ is unique.
Analogues one can get the unique relation
$\bar{\phi} \to \phi$.
\end{proof}
\label{lem:universalpropertyuniqueness}
\end{lemma}

The uniqueness does not mean existence and we should proof that such
object exists.
\begin{lemma}[About tensor product existence]
  Tensor product defined via \mynameref{def:universalproperty} exists
  \begin{proof}
    Lets consider $\mathcal{E}$ the maps (functions) from
    $M \times N$ to $A$ as sets which are $0$ almost everywhere
    (i.e. outside of a finite set). For example we can consider delta
    functions:
    \[
    \delta_{m,n} : M \times N \to A
    \]
    such that
    \begin{eqnarray}
      \delta_{m,n}(m,n) = 1,
      \nonumber \\
      \delta_{m,n}(m',n') = 0 \mbox{ if } (m,n) \ne (m',n')
      \nonumber
    \end{eqnarray}
    Then $\mathcal{E}$ is a A-\mynameref{def:freemodule} with basis
    $\delta_{m,n}$. Thus we have a map of sets $M \times N \to
    \mathcal{E}$ such that $(m,n) \to \delta_{m,n}$ which is not bilinear
    but we can make it bilinear by means of changing $\mathcal{E}$.

    Let $\mathcal{F} \subset \mathcal{E}$ a submodule generated by
    $\delta_{m+m',n} - \delta_{m,n} - \delta_{m',n}$,
    $\delta_{m,n+n'} - \delta_{m,n} - \delta_{m,n'}$,
    $\delta_{am,n} - a\delta_{m,n}$,
    $\delta_{m,an} - a\delta_{m,n}$.
    \footnote{
      The basis is chosen to be a bilinear $\mod \mathcal{F}$, for instance
      $\delta_{m+m',n} = \delta_{m,n} + \delta_{m',n} \mod \mathcal{F}$
    }

    It can be shown that $M \times N \to \mathcal{E}/\mathcal{F}$ is
    bilinear
    \footnote{
      Follows from the basis choice
    }
    and has the desired \mynameref{def:universalproperty}.

    Really lets we have the following bilinear map:
    $f: M \times N \to P$. Then we can consider the following linear
    map (\mynameref{def:homomorphism})
    $f': \mathcal{E} \to P$ that sends $\delta_{m,n}$ to
    $f(n,m)$. Using the fact that $f$ is bilinear we can get
    \begin{eqnarray}
      f'(\delta_{m+m',n}) =
      f(m+m', n) = f(m, n) + f(m', n) =
      \nonumber \\
      =
      f'(\delta_{m,n}) + f'(\delta_{m',n}).
      \nonumber
    \end{eqnarray}
    With the same approach one can get the following relations
    \begin{eqnarray}
      f'(\delta_{m,n+n'}) = f'(\delta_{m,n}) + f'(\delta_{m,n'}),
      \nonumber \\
      f'(\delta_{am,n}) =  a f'(\delta_{m,n}),
      \nonumber \\
      f'(\delta_{m,an}) = a f'(\delta_{m,n})
      \nonumber
    \end{eqnarray}
    with the $f'$ linearity we have
    \begin{eqnarray}
      f'(\delta_{m+m',n}) = f'(\delta_{m,n} + \delta_{m',n}),
      \nonumber \\
      f'(\delta_{m,n+n'}) = f'(\delta_{m,n} + \delta_{m,n'}),
      \nonumber \\
      f'(\delta_{am,n}) =  a f'(\delta_{m,n}),
      \nonumber \\
      f'(\delta_{m,an}) = a f'(\delta_{m,n})
      \nonumber
    \end{eqnarray}

    The kernel $\ker f' = \mathcal{F}$ thus if we want to have a
    homomorphism to $P$ we have to replace $\mathcal{E}$ with
    $\mathcal{E}/\mathcal{F}$ that is also denoted by
    $M \otimes_A N$. In the case we will replace $f'$ with
    $\tilde{f}\left(\delta_{m,n} \mod \mathcal{F}\right) = f(m,n)$. As
    soon as the images for the basis is fixed the mapping is unique.
  \end{proof}
  \label{lem:tensorproductexistence}
\end{lemma}

We will denote $\phi\left(m,n\right) = \delta_{m,n} \mod \mathcal{F}$ as
$m \otimes n$. I.e our tensor product can be considered as the
$\left(\otimes, M \otimes_A N\right)$ pair.

\begin{remark}
  Wrong idea is to define $M \otimes_A N$
  as a set of $m \otimes n$. I.e.
  $M \otimes_A N \neq \{m \otimes n\}$. The $M \otimes_A N$ is
  generated by $m \otimes n$ i.e.
  $\forall x \in M \otimes_A N$ we have
  $x = \sum_{i = 1}^k m_i \otimes n_i$ i.e. each element is a finite
  sum of $m \otimes n$ and I cannot reduce these further
  \footnote{
    i.e. $\exists x \in M \otimes_A N$ such that
    $\exists! m \in M, n \in N: x = m \otimes n$ but
    $\exists m_1, \dots, m_k \in M, n_1, \dots, n_k \in N :
    x = \sum_{i = 1}^k m_i \otimes n_i$
  }.

\end{remark}

\section{Tensor product of modules}

\subsection{Advantages of the universal property}
Now, you can ask  why haven't I just defined the tensor product by
this construction? Why am I talking of this universal property?
And the answer is because it is easier to prove things this way.
So advantages of the universal property is as follows: the proofs
become easy.

\subsection{Several examples of universal property usage}

\begin{example}[Commutativity proof]
  We want to prove that
  \[
  M \otimes_A N \cong N \otimes_A M
  \]

  We have the following bilinear map:
  $M \times N \to N \otimes_A M$ for which the pair
  $(m,n)$ is mapped to $n \otimes m$. Thus from
  \mynameref{def:universalproperty} we have that there is a linear map
  (homomorphism)
  $\alpha: M \otimes_A N \to N \otimes_A M$:

  \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
    \matrix (m) [matrix of math nodes, row sep=3em,
      column sep=2.5em, text height=1.5ex, text depth=0.25ex]
            { M \times N & & N \otimes_A M \\
              & M \otimes_A N & \\ };
            %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
            \path[->]
            (m-1-1) edge node[auto] {$ (m,n) \to n \otimes m $} (m-1-3)
            (m-1-1) edge node[description] {$ (m,n) \to m \otimes n $} (m-2-2)
            (m-2-2) edge node[description] {$ \alpha $} (m-1-3);
  \end{tikzpicture}

  With the same
  construction we can also get the inverse map $a^{-1}$ that sends
  $N \otimes_A M$ to $M \otimes_A N$:

  \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
    \matrix (m) [matrix of math nodes, row sep=3em,
      column sep=2.5em, text height=1.5ex, text depth=0.25ex]
            { M \times N & & M \otimes_A N \\
              & N \otimes_A M & \\ };
            %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
            \path[->]
            (m-1-1) edge node[auto] {$ (m,n) \to m \otimes n $} (m-1-3)
            (m-1-1) edge node[description] {$ (m,n) \to n \otimes m $} (m-2-2)
            (m-2-2) edge node[description] {$ \alpha^{-1} $} (m-1-3);
  \end{tikzpicture}

\end{example}

Also
\begin{corollary}
\[
A \otimes_A M \cong M
\]
\begin{proof}
  For the proof
  \footnote{
    The proof is missed in the lectures
  }
  lets look at $A$.
  Really $A$ can be considered as $A$-module because all
  requirements from definition \ref{def:module} are satisfied. The
  following diagrams shows that there exist 2 homomorphisms:
  $\alpha: A \otimes_A M \to M$ and
  $\alpha^{-1}: M \to A \otimes_A M$ as result there is a homomorphism
  $A \otimes_A M \cong M$:

  \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
    \matrix (m) [matrix of math nodes, row sep=3em,
      column sep=2.5em, text height=1.5ex, text depth=0.25ex]
            { A \times M & & M \\
              & A \otimes_A M & \\ };
            %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
            \path[->]
            (m-1-1) edge node[auto] {$ (a,m) \to a \cdot m $} (m-1-3)
            (m-1-1) edge node[description] {$ (a,m) \to a \otimes_A m $} (m-2-2)
            (m-2-2) edge node[description] {$ \alpha $} (m-1-3);
  \end{tikzpicture}
  \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
    \matrix (m) [matrix of math nodes, row sep=3em,
      column sep=2.5em, text height=1.5ex, text depth=0.25ex]
            { A \times M & & A \otimes_A M \\
              & M & \\ };
            %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
            \path[->]
            (m-1-1) edge node[auto] {$ (a,m) \to a \otimes_A m $} (m-1-3)
            (m-1-1) edge node[description] {$ (a,m) \to a \cdot m $} (m-2-2)
            (m-2-2) edge node[description] {$ \alpha^{-1} $} (m-1-3);
  \end{tikzpicture}

  In the diagrams $m \in M$, as usual, and $a \in A$.

\end{proof}
\end{corollary}

If we have that $M$ is generated by $e_1, e_2, \dots$ and
$N$ is generated by $\epsilon_1, \epsilon_2, \dots$ than
$M \otimes_A N$ is generated by pairs $e_i \otimes \epsilon_j$. It's
obvious.

More complex fact is the following
\begin{proposition}
  Let $M$ and $N$ are \mynameref{def:freemodule}s
  with corresponding basises $e_1, e_2, \dots, e_n$ and
  $\epsilon_1, \epsilon_2, \dots, \epsilon_m$ than
  $M \otimes_A N$ is also free module with basis $e_i \otimes
  \epsilon_j$ where $1 \le i \le n$ and
  $1 \le j \le m$.
  \begin{proof}
    Lets define
    $f_{i_0,j_0}: M \times N \to A$ as a map that sends
    $\left(\sum a_i e_i, \sum b_j \epsilon_j\right)$ to
    $a_{i_0} b_{j_0}$. It's bilinear
    \footnote{
      for example
      $\left(\sum (a_i + a_i') e_i, \sum b_j \epsilon_j\right)$ is
      sent to  $(a_{j_0} + a_{j_0}') b_{j_0}$.
    }
    so it factors through the tensor product
    $\tilde{f}_{i_0, j_0} : M \otimes_A N \to A$. The map
    $\tilde{f}_{i_0, j_0}$ sends $e_{i_0} \otimes \epsilon_{j_0}$ to 1
    and all others to 0.
    \footnote{
      Because $f_{i_0, j_0} = \tilde{f}_{i_0, j_0} \phi$ i.e.
      \begin{eqnarray}
      a_{i_0} b_{j_0} =
      f_{i_0,j_0}\left(\sum a_i e_i, \sum b_j\epsilon_j\right) =
      \nonumber \\
      =  \tilde{f}_{i_0,j_0}\left(
      \phi\left(\sum a_i e_i, \sum b_j\epsilon_j\right)\right) =
      \nonumber \\
      =
      \tilde{f}_{i_0,j_0}\left(\sum a_i e_i \otimes \sum b_j
      \epsilon_j\right) =
      \sum_{i,j} a_i b_j \tilde{f}_{i_0,j_0}(e_i \otimes \epsilon_j).
      \nonumber
      \end{eqnarray}
    }
    So if
    \[
    \sum \alpha_{ij} e_i \otimes \epsilon_j = 0
    \]
    then applying $\tilde{f}_{i_0, j_0}$ for all indices one can get
    that $\forall i,j: \alpha_{ij} = 0$.
    \footnote{
      because $\tilde{f}$ should be linear.
    }
  \end{proof}
  \label{prop:lec4_1}
\end{proposition}

In particular for the \mynameref{def:vectorspace} the tensor product is
defined in the same way (as just proved in the proposition
\ref{prop:lec4_1}): the tensor product of 2 vector spaces with
basises $e_1, e_2, \dots, e_n$ and
$\epsilon_1, \epsilon_2, \dots, \epsilon_m$ is another vector space
with the following basis $e_i \otimes \epsilon_j$ i.e. the definition
does not take into consideration the \mynameref{def:universalproperty}.

\begin{proposition}[Associative]
  \[
  \left(M_1 \otimes_A M_2\right) \otimes_A M_3
  \cong
  M_1 \otimes_A \left(M_2 \otimes_A M_3\right)
  \]
  \begin{proof}
    There is just a scratch of the proof.
    Introduce
    $M_1 \otimes_A M_2 \otimes_A M_3$
    as a universal object for 3-linear maps and show that 2 considered
    parts are isomorphic each other.
  \end{proof}
  \label{prop:lec4_Associative}
\end{proposition}

\section{Base change}

Let $A$ is a \mynameref{def:ring} and $B$ is $A$-algebra. Let also $M$
is an $A$-\mynameref{def:module} and $N$ is $B$-module.

I can of course make $N$ into $A$-module (just forgetting the
additional $A$-algebra structure). But we can also make $B$-module on
$M$ (that is not a trivial thing) by considering $B \otimes_A M$
\footnote{
  In other words we can make a $B$-module from $A$-module $M$
}
.
We can introduce $B$-module structure on $B \otimes_A M$ by
\footnote{
  I.e. we introduced $B$-algebra operations for objects from
  $B \otimes_A M$. See also definition \ref{def:kalgebra}.
}
\[
b \cdot \left(b' \otimes m \right) = \left( b \cdot b' \right) \otimes m
\]

\begin{example}[The complexification of a real vector space]
  We can ``make'' $\mathbb{R}^{2n}$ from $\mathbb{C}^n$ by forgetting
  the complex structure.
  \footnote{
    In the case we have ring $A = \mathbb{R}$ and $B = \mathbb{C}$ -
    $A$ algebra. $A$ - module is the following vector space
    $M = \mathbb{R}^{n}$ and $B$ - module is $N = \mathbb{C}^n$.
  }
  The $\mathbb{C}^n$ has the following basis $e_1, \dots, e_n$.
  The $\mathbb{R}^{2n}$ has the following one
  $e_1, \dots, e_n, i e_1, \dots, i e_n$. Now we forgot about
  multiplication rules for $i = \sqrt{-1}$ and denote $i e_i$ as
  $v_i$. In the case the basis for $\mathbb{R}^{2n}$ is the following
  one: $e_1, \dots, e_n, v_1, \dots, v_n$.

  But we can also do the following constructions
  \[
  \mathbb{R}^n \rightarrow
  \mathbb{C}^n = \mathbb{C} \otimes \mathbb{R}^n \rightarrow
  \mathbb{R}^{2n}
  \]
  for the $\mathbb{C}^n$ basis we have
  $1_{\mathbb{C}} \otimes e_1, \dots, 1_{\mathbb{C}} \otimes e_n$ and
  for
  $\mathbb{R}^{2n}$ -
  $1 \otimes e_1, \dots, 1 \otimes e_n, i \otimes e_1, \dots, i
  \otimes e_n$.
  \footnote{
    some additional clarification:
    $\forall x \in \mathbb{C} \otimes \mathbb{R}^n$ we have
    \[
    x = \sum_{i=1}^n c_i \otimes r_i e_i =
    \sum_{i=1}^n c_i r_i 1_{\mathbb{C}} \otimes e_i =
    \sum_{i=1}^n c_i' 1_{\mathbb{C}} \otimes e_i,
    \]
    where $c_i,c_i'=c_i r_i \in \mathbb{C}, r_i \in \mathbb{R}$. Thus
    we just got $\mathbb{C}^n$.
    From other side we can write $c_i$
    as follows: $c_i = a_i + i b_i$, where $a_i, b_i \in \mathbb{R}$.
    Therefore
    \[
    x = \sum_{i=1}^n a_i r_i 1 \otimes e_i + \sum_{i=1}^n b_i r_i i \otimes e_i.
    \]
    I.e. $x \in \mathbb{R}^{2n}$ and the basis in $\mathbb{R}^{2n}$ is
    formed by $1 \otimes e_1, \dots, 1 \otimes e_n, i \otimes e_1,
    \dots, i \otimes e_n$.
  }

\end{example}

\begin{proposition}
In general we have the following. If $M$ - free $A$ - module with
basis $e_1, \dots, e_n$ then $B \otimes_A M$ is a free $B$ module with
basis $1_B \otimes e_1, \dots, 1_B \otimes e_n$.
\label{prop:lec4_Addon}
\begin{proof}
  The proof is the same as at proposition \ref{prop:lec4_1}. Again we
  construct certain bilinear maps and say that those factor over the
  tensor product and this implies that certain families are linearly
  independent.

  Really lets define bilinear map $f_{i_0}: B \times M \to A$ such that
  \[
  f_{i_0}\left(b, \sum_{i=1}^n m_i e_i\right) = b m_{i_0} e_{i_0}
  \]
  so there exists a linear map $\tilde{f}_{i_0}$ (homomorphism) such
  that $f_{i_0} = \tilde{f}_{i_0} \phi$ or
  \begin{eqnarray}
    f_{i_0}\left(b, \sum_{i=1}^n m_i e_i\right) =
    \tilde{f}_{i_0} \left(
    \phi\left(b, \sum_{i=1}^n m_i e_i\right)
    \right)
    \nonumber \\
    =
    \tilde{f}_{i_0}\left(b \otimes \sum_{i=1}^n m_i e_i\right) =
    b \tilde{f}_{i_0}\left(1_B \otimes \sum_{i=1}^n m_i e_i \right) =
    b m_{i_0}
    \nonumber
  \end{eqnarray}
  i.e. it sends $1_B \otimes e_{i_0}$ to 1 and all others $1_B \otimes
  e_i$ to 0.
  Thus the following sum $\sum \alpha_i 1_B \otimes e_i$ is equal to 0
  if and only if $\alpha_i = 0$ i.e. $\alpha_i 1_B \otimes e_i$ forms a basis.
\end{proof}
\end{proposition}

\begin{remark}
We have the following maps.
\begin{itemize}
  \label{item:lec4_maps}
\item For A - modules:
  $\alpha: M \xrightarrow[m  \to 1_B \otimes_A m]{} B \otimes_A M$
  which makes a $B$-module from an $A$-module.
\item For B - modules:
  $\mu: B \otimes_A N \xrightarrow[b \otimes n \to b n]{} N$.
\end{itemize}
\label{rem:lec4_maps}
\end{remark}

\begin{theorem}[Base-change]
  Let $A$ is a \mynameref{def:ring} and $B$ is $A$-algebra. Let also $M$
  is an $A$-\mynameref{def:module} and $N$ is $B$-module.
  \[
  Hom_A\left(M, N\right)
  \leftrightarrow
  Hom_B\left(B \otimes_A M, N\right)
  \]
  I.e. the homomorphisms
  \footnote{
    $A$-homomorphisms between $A$ modules $Hom_A\left(M, N\right)$ are the
    same as $B$-homomorphisms between $B$ modules
    $Hom_B\left(B \otimes_A M, N\right)$.
  }
  are the same or in other words the
  corresponding groups of homomorphisms are isomorphic:
  \[
  Hom_A\left(M, N\right)
  \cong
  Hom_B\left(B \otimes_A M, N\right)
  \]
  \label{thm:basechange}

  \begin{proof}
    First of all we have
    \footnote{
      One homomorphism from  $Hom_B\left(B \otimes_A M, N\right)$
    }
    \mynameref{def:homomorphism} $f: B \otimes_A M \to N$. We also have
    the following map (see remark \ref{rem:lec4_maps}):
    $\alpha: M \to B \otimes_A M$.
    Thus $f \cdot \alpha: M \to N$ i.e.
    we can set the following relation
    \[
    \hat{f} : Hom_B\left(B \otimes_A M, N\right)
    \to Hom_A\left(M, N\right)
    \]
    such that $\hat{f}\left(f\right) = f \alpha$.

    In other direction we have $g: M \to N$ thus
    $id_B \otimes g: B \otimes_A M \to B \otimes_A N$ but
    ( see remark \ref{rem:lec4_maps}) we have
    $\mu: B \otimes_A N \to N$ i.e. we have the following relation
    \[
    \hat{g} : Hom_A\left(M, N\right) \to
    Hom_B\left(B \otimes_A M, N\right)
    \]
    such that
    \[
    \hat g(g) = \mu \cdot (id_B \otimes g).
    \]
    And we can check that those maps ($\hat{f}$ and $\hat{g}$) are
    mutually inverse. For the proof
    \footnote{
      It's missed in the lectures
    }
    the fact consider the following diagram

    \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
      \matrix (m) [matrix of math nodes, row sep=3em,
        column sep=2.5em, text height=1.5ex, text depth=0.25ex]
              { M  & &  N \\
                & B \otimes_A M & & B \otimes_A N \\ };
              %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
              \path[->]
              ([yshift=1ex]m-1-1.east) edge node[description] {$ f \alpha $}
              ([yshift=1ex]m-1-3.west);
              \path[->]
              ([yshift=-1ex]m-1-1.east) edge node[description] {$ g $}
              ([yshift=-1ex]m-1-3.west);
              \path[->]
              (m-1-1) edge node[description] {$ \alpha $} (m-2-2)
              (m-2-2) edge node[description] {$ f $} (m-1-3)
              (m-2-2) edge node[description] {$ id_B \otimes g $}
              (m-2-4)
              (m-2-4) edge node[description] {$ \mu $} (m-1-3)
              ;
    \end{tikzpicture}

    One can conclude, as soon as the diagram commutes

        \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
      \matrix (m) [matrix of math nodes, row sep=3em,
        column sep=2.5em, text height=1.5ex, text depth=0.25ex]
              { M  & &  N \\
                & B \otimes_A M & & B \otimes_A N \\ };
              %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
              \path[->]
              ([yshift=-1ex]m-1-1.east) edge node[description] {$ g $}
              ([yshift=-1ex]m-1-3.west);
              \path[->]
              (m-1-1) edge node[description] {$ \alpha $} (m-2-2)
              (m-2-2) edge node[description] {$ id_B \otimes g $}
              (m-2-4)
              (m-2-4) edge node[description] {$ \mu $} (m-1-3)
              ;
    \end{tikzpicture}

    \[
    \hat{f}\left(\hat{g}\left(g\right)\right) =
    \mu \cdot (id_B \otimes g) \cdot \alpha = g.
    \]
    I. e. $\hat{f}\circ\hat{g} = id$
    \footnote {
      Operation $\circ$ is defined as follows $(\hat{a} \circ \hat{b})(x) =
      \hat{a}(\hat{b}(x))$ where $\hat{a}, \hat{b}$ are 2 maps acting
      on a set $X$ and $x \in X$.
    }
    or in other words $\hat{f}$ and
    $\hat{g}$ are mutually inverse.
  \end{proof}
\end{theorem}

\section{Examples. Tensor product of algebras}

\begin{proposition}
  If $I \subset A$ - is an \mynameref{def:ideal} so my $B$ - $A$ algebra
  will be $B = A/I$ then
  \[
  A/I \otimes_A M \cong M/IM
  \]
  where $IM$ is a sub-module of $M$.
  \label{prop:lec4_prop2}
  \begin{proof}
    We have map $\alpha: M \to B \otimes_A M = A/I \otimes_A M$
    (see remark \ref{rem:lec4_maps})
    which sends $m$ to $\bar{1} \otimes m$.
    \footnote{
      $\bar{1} = 1_A + I$
    }
    The map sends $IM$ to $0$
    because
    $\forall i \in I, m \in M : im \to \bar{1} \otimes im = \bar{i} \otimes m$
    because the tensor product is over $A$ and everything is $A$
    linear and as result $\bar{1} \otimes im = \bar{i} \otimes m$,
    but $\bar{i} \otimes m = \bar{0} \otimes m = 0$.
    \footnote{
      because
      $\bar{i} = 0 \mod I$
    }
    Thus $\alpha$ sends $IM$ to 0. So $\alpha$ induces
    $\bar{\alpha}: M/IM \to A/I \otimes_A M$ such that
    $\bar{\alpha}\left(\bar{m}\right) = \bar{1} \otimes m$.

    For other direction we apply \mynameref{thm:basechange}. The
    following map (projection) of $A$-modules
    \[
    M \xrightarrow{m \to \bar{m}} M/IM
    \]
    gives us the following map of $B$-modules
    \footnote{
      the \mynameref{thm:basechange} says that homomorphism of
      $A$-modules $M \to N$ is isomorphic to homomorphism of $B$
      modules $B\otimes_A M \to N$. Using $N = M/IM$ we can get that
      $B\otimes_A M \to M/IM$ is isomorphic (i.e. the same) to
      $M \to M/IM$. We also can get the same result just ignore $B$:
      $B \otimes_A M \to M \to M/IM$.
    }
    \[
    \bar{\beta}: B \otimes_A M \to M/IM
    \]
    i.e.
    \[
    \bar{\beta}: A/I \otimes_A M \to M/IM
    \]
    that sends $\bar{a} \otimes m$ to $\bar{am}$
    Ones check again that this inverse to $\bar{\alpha}$.
    \footnote{
      For example
      \(
      \bar{\beta}\left(\bar{\alpha}\left(\bar{m}\right)\right) =
      \bar{\beta}\left(\bar{1} \otimes m\right) = \overline{1 \cdot m} = \bar{m}
      \)
    }
  \end{proof}
\end{proposition}

Several examples:
\begin{example}
  Let $\mathbb{Z}/2\mathbb{Z} \otimes_\mathbb{Z}
  \mathbb{Z}/3\mathbb{Z}$ what will we obtain?
  \[
  \mathbb{Z}/2\mathbb{Z} \otimes_\mathbb{Z} \cong
  ^{\mathbb{Z}/3\mathbb{Z}}/_{(2) \cdot \mathbb{Z}/3\mathbb{Z}}
  \]
  but 2 is invertible: $2^{-1} = -1 \mod 3$
  \footnote{
    I.e. there exist an invertible element $2^{-1} \in
    \mathbb{Z}/3\mathbb{Z} = \mathbb{F}_3$ therefore
    $1_{\mathbb{F}_3} \in 2 \cdot \mathbb{F}_3$ or
    $2 \cdot \mathbb{F}_3 = \mathbb{F}_3$ and as result
    $(2) \cdot \mathbb{F}_3 = \mathbb{F}_3$. I.e. $(2)$ is not a
    \mynameref{def:properideal} in $\mathbb{F}_3$ because it is equal
    to $\mathbb{F}_3$.
  }
  thus
  $(2)\mathbb{Z}/3\mathbb{Z} =\mathbb{Z}/3\mathbb{Z}$ and as result
   \[
  \mathbb{Z}/2\mathbb{Z} \otimes_\mathbb{Z} \cong
  ^{\mathbb{Z}/3\mathbb{Z}}/_{ \mathbb{Z}/3\mathbb{Z}} = 0
  \]
\end{example}

\begin{example}
  Another obvious example
  \footnote {
    $B \otimes_A A\left[X\right]$ has the following $B$-basis:
    $\{1_B \otimes X^i\}$ thus
    $\forall b \in B \otimes_A A\left[X\right]$ we can get
    \[
    b = \sum b_i \cdot 1_B \otimes X^i
    \]
    and there is an obvious isomorphism
    \[
    f: B \otimes_A A\left[X\right]
    \xrightarrow[b \to \sum b_i X^i]{}
    B\left[X\right]
    \]
  }
  \[
  B \otimes_A A\left[X\right] \cong B\left[X\right]
  \]
  and more interesting one
  \[
  B \otimes_A A\left[X\right]/(P) \cong B\left[X\right]/(P),
  \]
  there $(P)$ becomes an ideal generated by $P$ in
  $B\left[X\right]$.
  \label{ex:lec4_1}
\end{example}

\subsection{Tensor product of A-algebras}

Let $B, C$ are $A$-algebras. The following maps form an algebra
structure on $A$:
\[
\alpha: A \to B
\]
\[
\beta: A \to C
\]
New $A$-algebra $B \otimes_A C$: is a ring with respect to the
following operation
\footnote{
  that makes it $A$-algebra (see \mynameref{def:kalgebra})
}
\begin{equation}
\left(b \otimes c \right) \cdot \left(b' \otimes c'\right) =
\left(b \cdot b'\right) \otimes \left(c \cdot c'\right)
\label{eq:lec4_algebra_tensor_product}
\end{equation}

The tensor product has the following
\begin{definition}[Universal property]
  Let we have the following maps
  \begin{eqnarray}
    \alpha: A \to B,
    \nonumber \\
    \beta: A \to C,
    \nonumber \\
    \phi: B \xrightarrow[b \to b \otimes 1_C ]{} B \otimes_A C,
    \nonumber \\
    \psi: C \xrightarrow[c \to 1_B \otimes c ]{} B \otimes_A C
    \nonumber
  \end{eqnarray}

  Then for any $A$-algebra $D$ one has
  \[
  Hom_A\left(B \otimes_A C, D\right)
  \leftrightarrow
  Hom_A\left(B, D\right) \times
  Hom_A\left(C, D\right)
  \]
  i.e. if I have some \mynameref{def:homomorphism}
  $h \in Hom_A\left(B \otimes_A C, D\right)$ this is the same as
  giving 2 homomorphisms
  $f \in Hom_A\left(B, D\right)$ and
  $g \in Hom_A\left(C, D\right)$ such that all maps in the following
  diagram commute (see \mynameref{def:commutativediagram}).

  \begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
    \matrix (m) [matrix of math nodes, row sep=3em,
      column sep=2.5em, text height=1.5ex, text depth=0.25ex]
            { D & & B \otimes C & \\
              & B & & C & \\
              & & A & & \\
            };
            %\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
            \path[->]
            (m-2-2) edge node[description] {$ \phi $} (m-1-3)
            (m-2-4) edge node[description] {$ \psi $} (m-1-3)
            (m-3-3) edge node[description] {$ \alpha $} (m-2-2)
            (m-3-3) edge node[description] {$ \beta $} (m-2-4)
            (m-1-3) edge [bend right=15] node[description]  {$ h $}
            (m-1-1);
            \path[->, dashed]
            (m-2-2) edge [bend left=15] node[description] {$ f $} (m-1-1)
            (m-2-4) edge [bend left=15] node[description] {$ g $} (m-1-1)
            ;
  \end{tikzpicture}

  Thus if we have $h$ then we can define
  $f = h \cdot \phi$ and $g = h \cdot \psi$. And conversely if I have
  $f$ and $g$ then I can define $h$ by the following rule:
  \[
  h\left(b \otimes c\right) = f(b) \cdot g(c)
  \]
\end{definition}
The main point for us is that the tensor product of the $A$-algebras is
itself an $A$-algebra by this very simple rule, component-wise
multiplication (see (\ref{eq:lec4_algebra_tensor_product})).

Let consider next example.
We will start with the following
\[
\mathbb{C} \cong {\mathbb{R}\left[X\right]}/{\left(X^2 + 1\right)}
\]
therefore with result from example \ref{ex:lec4_1} one can get
\[
\mathbb{C} \otimes_\mathbb{R} \mathbb{C}
\cong
\mathbb{C} \otimes_\mathbb{R}
{\mathbb{R}\left[X\right]}/{\left(X^2 + 1\right)}
\cong
^{\mathbb{C}\left[X\right]}/_{\left(X^2 + 1\right)}
\]
but by \mynameref{thm:chineseremainder}
\[
^{\mathbb{C}\left[X\right]}/_{\left(X^2 + 1\right)}
\cong
^{\mathbb{C}\left[X\right]}/_{\left(X + i\right)}
\times
^{\mathbb{C}\left[X\right]}/_{\left(X - i\right)}
\cong
\mathbb{C} \times \mathbb{C}
\]
As result we have that
$\mathbb{C} \otimes_\mathbb{R} \mathbb{C}$ is not a field
because it
has zero divisors. How we can get the zero divisors?
The element $\overline{X + i}$ is a zero divisor
in
\(
^{\mathbb{C}\left[X\right]}/_{\left(X^2 + 1\right)}
\)
because
\[
\left(X + i\right) \left(X - i\right) \equiv 0 \mod {\left(X^2 + 1\right)}
\].

Another proof (not a part of the lecture) of the fact that $\mathbb{C}
\otimes_\mathbb{R} \mathbb{C}$ is not a field consider the following
one
\[
\mathbb{C}
\otimes_\mathbb{R} \mathbb{C}
\cong
^{\mathbb{C}\left[X\right]}/_{\left(X^2 + 1\right)}
\]
but the polynomial $X^2 + 1 = \left(X + i\right)\left(X - i \right)$
is reducible in $\mathbb{C}\left[X\right]$ i.e. is not a
\mynameref{def:maxideal} (see theorem \ref{thm:irreducibleideal}) and
with the theorem \ref{thm:maxideal} the quotient by the polynomial is
not a field (see also claim \ref{claim:lec1_sec14}).

\section{Relatively prime ideals. Chinese remainder theorem}

\begin{definition}[Relatively prime ideals]
  Let $A$ - \mynameref{def:ring} and $I,J$ are \mynameref{def:ideal}s.
  $I$ and $J$ are relatively prime if $I + J = A$.
  \label{def:relprimeideals}
\end{definition}

\begin{lemma}
  \begin{enumerate}
  \item If $I,J$ are relatively prime then $IJ = I \cap J$
  \item If $I_1, \dots, I_k$ relatively prime with $J$ then
    $\prod_{i =1}^k I_i = I_1 \dots I_k$ is also
    relatively prime with $J$.
  \item If $I, J$ relatively prime then $I^k$ and $J^l$ are also
    relatively prime for any $l$ and $k$.
  \end{enumerate}
  \begin{proof}
    \begin{enumerate}
    \item
      The following one  $IJ \subset I \cap J$ is clear
      \footnote {
        Assuming that $I$ and $J$ commute we have if
        $x \in IJ$ then $x \in I$ and if
        $x \in JI$ then $x \in J$ i.e. $x \in I \cap J$.
      }
      If $I$ and $J$ are relatively prime then $1_A = i + j$ for some
      $i \in I$ and $j \in J$. Thus $\forall x \in I \cap J$ we have the
      following ones:
      $x i \in IJ$ and $x j \in IJ$ and as result
      \[
      x = x i + x j \in IJ
      \]
      i.e. $I \cap J \subset IJ$.
    \item Suppose for simplicity that $k = 2$. In the case we have
      $1_A = i_1 + j_1 = i_2 + j_2$ where $i_1 \in I_1, i_2 \in I_2$ and
      $j_1, j_2 \in J$.
      we also have
      \[
      1_A = \left(i_1 + j_1\right) \left(i_2 + j_2\right) =
      i_1 i_2 + \left(j_1 i_2 + j_2 i_1 + j_1 j_2\right)
      \in I_1 I_2 + J
      \]
      thus $\forall x \in A$ we have
      \[
      x = 1_A x =
      i_1 i_2 x + \left(j_1 i_2 + j_2 i_1 + j_1 j_2\right) x
      \in I_1 I_2 + J,
      \]
      i.e. $I_1 I_2 + J = A$ therefore $I_1 I_2$ and $J$ are
      relatively prime.
    \item is obvious
      \footnote{
        It follows from the 2 because we can assume $I_i = I$ and will
        get that $\forall k, I^k$ is relatively prime with $J$. From
        other side we can assume $I_i = J$ and $J = I^k$ and conclude
        that $J^l$ is relatively prime with $I^k$.
      }
    \end{enumerate}
  \end{proof}
  \label{lem:aboutrelprimeideals}
\end{lemma}

\begin{theorem}[Chinese remainder]
  \label{thm:chineseremainder}

  Let $I_1, \dots, I_n$ - ideals and map
  $\pi: A \to A/I_1 \times \dots \times A/I_n$ defined as follows
  \begin{equation}
    \pi(a) = \left(a \mod I_1, \dots, a \mod I_n\right)
    \label{eq:lec4_crt_map}
  \end{equation}
  The kernel $\ker \pi = I_1 \cap \dots \cap I_n$.

  The $\pi$ is \mynameref{def:surjection} if and only if $I_1, \dots,
  I_n$ are pairwise relatively prime.

  In that case
  \[
  A/\cap I_k
  \cong
  A/\prod I_k
  \cong
  \prod \left(A/I_k\right)
  \]
  \footnote{
    See \mynameref{thm:firstisomorphism} where
    $G = A$,
    $H = A/I_1 \times \dots \times A/I_n$, $\phi = \pi$ and  with
    lemma \ref{lem:aboutrelprimeideals} (as soon as $I_k$ pairwise
    relatively prime)
    \[
    \ker \phi = \ker \pi = I_1 \cap \dots \cap I_n = I_1 \dots I_n.
    \]
  }
  \begin{proof}
    Let $\pi$ is \mynameref{def:surjection}. In the case
    $\exists a_i \in A$ such that
    \[
    \pi(a_i) = \left(0, \dots, 1 (\mbox{ in }i\mbox{-th place }),
    0, \dots, 0\right)
    \]
    i.e.
    $a_i \mod I_j = 0$ or $a_i \in I_j$ for $i \ne j$. We also have
    $a_i \mod I_i = 1$ thus $1 - a_i = k I_i$ i.e. $1 - a_i \in I_i$.
    Thus $\forall j, \exists a_i \in I_j, a_k \in I_i$ such that
    $1 = a_i + a_k$ thus $A = I_j + I_i$ i.e. $I_i$ relatively prime
    with any $I_j$.

    Conversely if $I_i$ is relatively prime with any $I_j$ where $j
    \ne i$ then it also relatively prime with the product (see lemma
    \ref{lem:aboutrelprimeideals}) $\prod_{j \ne i} I_j$. In the case
    $\exists x_i \in I_i, y_i \in \prod_{j \ne i} I_j$ such that
    $1 = x_i + y_i$ in the case
    \[
    \pi(y_i) = \left(0, \dots, 1 (\mbox{ in }i\mbox{-th place }),
    0, \dots, 0\right)
    \]
    and $\forall b_i \in A/I_i$
    \[
    \pi \left(\sum_{i = 1}^n b_i y_i\right) =
    \left(b_1, \dots, b_n\right)
    \]
    i.e. $\pi$ is surjective.
  \end{proof}
\end{theorem}

Let $K$ is a field and $A$ is a finite (finite dimensional vector
space) $K$-algebra.

\begin{proposition}
  \begin{enumerate}
    \item If $A$ is an \mynameref{def:integraldomain} then $A$ is a
      field.
    \item (replacing the first one) Any
      \mynameref{def:primeideal} of $A$ is a \mynameref{def:maxideal}
  \end{enumerate}
  \begin{proof}
     Well, I shall prove only the first part, the second part is just
     a consequence of definitions. In fact, a factor over a prime
     ideal, a quotient over a prime ideal is an integral domain, and a
     quotient over a maximal ideal is a field.
     \footnote{
       i.e. prime ideal is a maximal ideal
     }
     If you don't know this,
     please look it up in any book.

     Lets prove the first part. \mynameref{def:integraldomain} means
     that there is no zero divisors i.e. $\forall a \in A$
     \footnote{
       $a \ne 0_A$
     }
     multiplication by $a$ is \mynameref{def:injection}. $A$ is finite
     dimensional \mynameref{def:vectorspace} (see above) that implies
     that $\times a$ is an
     \mynameref{def:isomorphism},
     \footnote{
       $\times a$ sends a vector space  into another vector space with
       the same dimension. But with \mynameref{lem:vsisomorphism} one
       can get that the spaces are isomorphic each others and as
       result the operation $\times a$ is an \mynameref{def:isomorphism}.
     }
     in particular \mynameref{def:surjection} i.e. $\exists b \in A$
     such that $b \times a = 1$ i.e. $a$ is invertible therefore
     $A$ is field.
  \end{proof}
  \label{prop:lec4_ideals}
\end{proposition}

\section{Structure of finite algebras over a field. Examples}

\begin{myremark}
  Let $A$ is a $K$-algebra and $m$ is a maximal ideal of $A$. Then
  $A/m$ is also $K$-algebra.
  \label{rem:lec5_quotientkalgebra}
  \begin{proof}
    Lemma \ref{lem:lec1_homkalgebra} says that there is a ring homomorphism
    between $K$ and $A$: $f_K: K \to A$. There is also a canonical
    homomorphism $f_A: A \xrightarrow[a \to \bar{a}]{} A/m$. Therefore
    we can define $f = f_A f_K: K \to A/m$ and therefore with
    lemma about \mynameref{lem:lec1_homkalgebra} can conclude that $A/m$ is a
    $K$-algebra.
    \footnote{
      Thanks Zonglin Jiang for the proof.
    }

    Note that if $A$ is a field then $f_A$ is injection, $m=\{0_K\}$
    and $A = A/m$.
  \end{proof}
\end{myremark}

\begin{theorem}[Structure of finite $K$-algebra]
  Let $A$ be a finite $K$-algebra i.e.
  $\dim_K A < \infty$. Then
  \begin{enumerate}
  \item There are only finitely many \mynameref{def:maxideal}s
    $m_1, \dots, m_r$ in $A$
  \item Let $J = m_1 \cap \dots \cap m_r = m_1 \dots m_r$.
    \footnote{
      Since the ideals are relatively prime the intersection is the
      same as the product of the ideals
    }
    Then
    $J^n = 0$ for some $n$
  \item
    $A \cong A/{m_1^{n_1}} \times \dots \times A/{m_r^{n_r}}$ for
    some $n_1, \dots, n_r$.
  \end{enumerate}
  \label{thm:structurefinitekalgebra}
  \begin{proof}
    \begin{enumerate}
    \item
      Let $m_1, \dots, m_i$ are maximal ideals. By
      \mynameref{thm:chineseremainder} we have
      \footnote{
        Maximal ideals are relatively prime because
        in a commutative ring with unity, every
        \mynameref{def:maxideal} is a
        \mynameref{def:primeideal} see also proposition
        \ref{prop:lec4_ideals}.
      }
      \[
      A/m_1 \dots m_i \cong
      A/m_1 \times \dots \times A/m_i.
      \]
      We know that $A$ as well as $A/m_1 \dots m_i$ and $A/m_k$ are
      finite dimensional $K$-\mynameref{def:vectorspace}
      \footnote {
        See remark \ref{rem:lec5_quotientkalgebra} and take into
        consideration
        the theorem statement (see above) that says
        $\dim_K A < \infty$. $A/m_1$ is a projection i.e.
        $\dim_K A/m_1 < \dim_K A < \infty$.
      }
      thus we have the
      following relations
      \[
      \dim_K A \ge \dim_K  A/m_1 \dots m_i  =
      \sum_{j=1}^i dim_K A/m_j \ge i.
      \]
      Therefore if $N$ the number of maximal ideals then
      $\dim_K A \ge N$ i.e. the number of maximal ideal is limited by
      the vector space dimension.
    \item
      $J = m_1 \cap \dots \cap m_r = m_1 \dots m_r$ is finite
      dimensional vector space over $K$
      \footnote{
        We have $m_i \subset A$ i.e. $\dim_K m_i \le \dim_K A <
        \infty$. From other side $J = m_1 \dots m_r = (m_1 \cap \dots \cap
        m_r) \subset m_i, \forall i \in \{1, \dots, r\}$.
        Thus $\dim_K J \le \dim_K m_i \le \dim_K A <
        \infty\le $
      }
      as well as its powers
      $J^k$.
      We have the following sequence
      \footnote {
        Let $j \in J \subset A$ and $x \in JJ$.
        Then $\exists j \in J$ such that $x = j j$
        but $j j \in J$ because $\forall y \in J: j y \in J$.
        As result $J^2 \subseteq J$.
      }
      \[
      \dots \subseteq J^k \subseteq \dots \subseteq
      J^2 \subseteq J.
      \]
      and the sequence should stop somewhere
      \footnote {
        On each step we should decrease the dimension if we don't
        stop. The dimension is limited and as result the sequence
        should stop.
      }
      i.e.
      $\exists n$ such that $J^n = J^{n+1}$. We claim that $J^n = 0$
      in the case. Indeed if not we have the following basis of $J^n$:
      $e_1, \dots, e_s$. And as soon as $J^n = J J^n$ we can write a
      vector $e_i \in J^n$ as a vector from $J^n$ multiplied on an
      object from $J$ i.e.
      \[
      e_i = \sum \lambda_{ij} e_j,
      \]
      there $e_j \in J^n, \lambda_{ij} \in J$. Thus if
      $M = id - \lambda_{ij}$
      \[
      M \cdot \left(
      \begin{array}{c}
        e_1 \\
        \vdots \\
        e_s
      \end{array}
      \right) = 0.
      \]
      It's possible over ring
      to find a matrix $\tilde{M}$ such that
      \(
      \tilde{M} M = \det M \cdot id,
      \)
      \footnote{
        If $M$ is a matrix over a field we can consider the following
        2 cases:
        \begin{enumerate}
        \item $\det M = 0$: we can assume that $\tilde{M} = 0$
        \item $\det M \ne 0$: at the case $\exists M^{-1}$ and
          therefore $\tilde{M} =
          \det M \cdot M^{-1}$ will work.
        \end{enumerate}
        For more common case we have to look at Adjugate matrix
        \cite{wiki:adjugatematrix}
      }
      i.e.
      \begin{equation}
      \det M \cdot \left(
      \begin{array}{c}
        e_1 \\
        \vdots \\
        e_s
      \end{array}
      \right) = 0.
      \label{eq:lec4_det}
      \end{equation}
      But $\det M = 1 + \lambda$ where $\lambda \in J$.
      \footnote{
        Because the $\det$ consists of the following
        items $\prod (1-\lambda_{ii}) = 1 + (-1)^s\prod \lambda_{ii}$
        and $\prod \lambda_{ij}$. The sum of the items ($\det$)
        consists of $1$ and another sum in which all items are from
        $J$. Thus the second sum is an element of $J$ i.e.
        $\det M = 1 + \sum \prod \lambda_{ij} = 1 + \lambda$.
      }
      Since  $J = m_1 \cap \dots \cap m_r$ then
      $\forall i: \lambda \in m_i$
      so $\nexists i$ such that $1 + \lambda \in m_i$
      \footnote{
        We have that $m_i$ is a \mynameref{def:maxideal} and therefore (by
        its definition) it is a \mynameref{def:properideal} i.e.
        $1 \notin m_i$. From other side if $1 + \lambda \in m_i$ then
        $1 + \lambda - \lambda \in m_i$ as soon as $\lambda \in
        m_i$. I.e. we have a contradiction.
      }
      thus $1 + \lambda$ is invertable
      \footnote {
        $0 \in m_i$ thus if $1 + \lambda \notin m_i$ then
        $1 + \lambda \ne 0$.
      }
      therefore $e_1 = \dots = e_s = 0$
      \footnote{
        Because $\det M = 1 + \lambda \ne 0$
      }
    \item Using part 2
      $\exists n_1, \dots, n_r$ such that
      $m_1^{n_1} \dots m_r^{n_r} = 0$ (for example we can assume
      $n_i = n$). Then by \mynameref{thm:chineseremainder}
      \[
      A \cong
      A/{m_1^{n_1}} \times \dots \times A/{m_r^{n_r}}.
      \]
      We used the following facts:
      \begin{itemize}
      \item $A = A /m_1^{n_1} \dots m_r^{n_r}$
        \footnote{
          Because $A = A/\{0\}$. For example if $I = \{0\}$ and
          $x \in A$ then $\bar{x} \in A/I$ if $\bar{x} = x + I$. In
          our case $\bar{x} = x + \{0\} = x$ i.e. $\forall x \in A$ we
          have $x \in A/\{0\}$.
          (See also \mynameref{def:quotientring})
        }
      \item $m_i^{n_i}$ are pairwise relatively prime
        \footnote{
          As soon as $\{m_i\}$ - \mynameref{def:maxideal}s and as result
          \mynameref{def:primeideal}s then with lemma
          \ref{lem:aboutrelprimeideals} one can get that
          $\forall i \ne j$ $m_i^{n_i}$ is relatively prime with
          $m_j^{n_j}$.
        }
      \end{itemize}
    \end{enumerate}
  \end{proof}
\end{theorem}

\begin{remark}
  The $n_i$s are not uniquely defined. For example (see also example
  \ref{ex:lec5_1})
  \[
  A = ^{K\left[X\right]}/_{\left(X^2 \left(X+1\right)^3\right)}.
  \]
  We have 2 ideals there:
  $m_1 = (X)$ and $m_2 = (X+1)$.
  We of course have
  \[
  A \cong A/m_1^2 \times A/m_2^3
  \]
  but also we have
  \[
  A \cong A/m_1^3 \times A/m_2^3
  \]
  as soon as $m_1^2 = m_1^3$ in $A$:
  $(X)^2 \subset (X)^3$ but also
  $(X)^3 \subset (X)^2$
  \footnote{
    $(X)^3 \subset (X)^2$ - this is true for any polynomial
    $P\left(X\right)$ because if
    $P\left(X\right) \in (X)^3$ then
    $P\left(X\right) = X^3 P'\left(X\right) =
    X^2 \bar{P}\left(X\right) \in (X)^2$ where
    $\bar{P}\left(X\right) = X P'\left(X\right)$

    $(X)^2 \subset (X)^3$ is the more complex one and it does not true
    for any polynomial ring but this is true for our $A$.
    Let $P\left(X\right) \in \left(X\right)^2 \subset
    K\left[X\right]$ then
    $P\left(X\right) = X^2 P'\left(X\right)$ but
    $X^2 P'\left(X\right) \equiv 0 \mod X^2$.
    From other side
    $X^4 P'\left(X\right) \equiv 0 \mod X^2$
    therefore
    \[
    P\left(X\right) \equiv X^3 X P'\left(X\right) \mod X^2
    \]
    i.e. $P\left(X\right) \in (X)^3$.
  }
  \label{rem:lec5_4}
\end{remark}

Several examples:
\[
\mathbb{C} \otimes_\mathbb{R} \mathbb{C} =
\mathbb{C} \times \mathbb{C}.
\]

Another example
\[
\mathbb{Q}\left(\sqrt{2}\right)
\otimes_{\mathbb{Q}}
\mathbb{Q}\left(\sqrt{3}\right) =
\mathbb{Q}\left(\sqrt{2}, \sqrt{3}\right)
\]
And you see that those algebras are Cartesian products of fields.
So all $n_i$'s may be taken equal to 1
\footnote{
  Because $A/m^n$ (where $m$ is a maximal ideal) is a field if $n=1$
}.
In other words, we don't have
\mynameref{def:nilpotent}s in our algebra
\footnote{
  Cartesian products of fields has no nilpotent elements except 0
  \cite{ribenboim2001classical}.
}. So, it is a reduced
algebras. Reduced, by definition, is without nilpotents.
It's general phenomena because the presence of nilpotents is due to the
inseparability of extensions come from inseparable extensions.


% LaTeX file for a 1 page document
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{physymb}
\usepackage{braket}
\usepackage{array}
\title{EP 307 Assignment 4}

\author{Manish Goregaokar\\120260006}

\begin{document}
\maketitle

\section*{Problem 1}
$$\prod_{i\neq s}\frac{\hat A-a_i}{a_s-a_i}$$

If $\Ket{a}=\sum c_i\Ket{a_i}$, applying this operator we have \begin{align*}
\prod_{i\neq s}\frac{\hat A-a_i}{a_s-a_i}\left(\sum c_i\Ket{a_i}\right)&=\sum_j\left(\prod_{i\neq s}\frac{\hat A-a_i}{a_s-a_i}\right)c_j\Ket{a_j}\\
&=\left(\prod_{i\neq s}\frac{\hat A-a_i}{a_s-a_i}\right)c_s\Ket{a_s}\\&\qquad\text{Since the other terms have numerator cancelling out for $i=j$}\\
&=\left(\prod_{i\neq s}\frac{a_s-a_i}{a_s-a_i}\right)c_s\Ket{a_s}\\
&=c_s\Ket{a_s}
\end{align*}
Thus the operator is $\frac{\Ket{a_s}\Bra{a_s}}{\Braket{a_s|a_s}}=p_s$ (projection operator)
\section*{Problem 2}
\newcommand{\Tr}{\mathrm{Tr}}
To prove:
$$\Tr(XY)=\Tr(YX)$$

The trace of an operator can be denoted by $\sum_i \Braket{i|A|i}$, where $\Bra{i},\Ket{i}$ are basis vectors corresponding to the $i$th element being $1$ and the rest $0$.

Thus,

\begin{align*}
\Tr(AB)
&= \sum_i \Braket{i|AB|i}\\
&= \sum_i  \Braket{i|AIB|i}\\
&= \sum_i\sum_j  \Braket{i|A\Ket{j}\Bra{j}B|i}\\
&= \sum_i\sum_j  \Braket{j|A\Ket{i}\Bra{i}B|j}\\
&= \sum_j  \Braket{j|BIA|j}\\
&= \Tr(BA)
\end{align*}

\section*{Problem 7}

Applying $\hat{A}=\hat{Q}\hat{C}+\hat{C}\hat{Q}$ to an eigenstate $\Ket{\psi_q}$, we get:

\begin{align*}
\hat{A}\Ket{\psi_q} &=(\hat{Q}\hat{C}+\hat{C}\hat{Q})\Ket{\psi_q}\\
&= \hat{Q}\hat{C}\Ket{\psi_q}+\hat{C}\hat{Q}\Ket{\psi_q} \\
&= \hat{Q}\Ket{\psi_{-q}}+q\hat{C}\Ket{\psi_q}\\
&= -q\Ket{\psi_{-q}}+q\Ket{\psi_{-q}}\\
&=0
\end{align*}

If $\hat A\Ket{\psi_q}=0$, then $\hat A\left(\sum a_q\Ket{\psi_q}\right)=0$. We can say that the eigenvalue of $\hat A$ is 0.

For a state $\Ket{\psi_q}$ to be an eigenstate of $\hat C$, $c\Ket{\psi_q}=\hat C\Ket{\psi_q}=\Ket{\psi_{-q}}$

Since $\Ket{\psi_{-q}},\Ket{\psi_q}$ have different eigenvalues (except when $q=0$), they are linearly independent, and thus the  only possible value of $c$ is 0, which isn't an eigenstate.

So the only common eigenstate is $\Ket{\psi_0}$, provided that it is not a null vector.
\section*{Problem 9}
\newcommand{\kpsi}{\Ket{\psi}}
\begin{align*}
[\hat x, \exp\left(\frac{i\hat p a}{\hbar}\right)]\kpsi &= [\hat x, \exp\left(\frac{i(-i)\hbar\partial_x a}{\hbar}\right)]\kpsi\\
&=[\hat x, \exp(a\partial_x)]\kpsi\\
&=  x \sum_i \frac1{i!}a^i\partial^i_x\kpsi - \sum_i\frac1{i!} a^i\partial^i_x (x\kpsi) \\
&=  x \sum_i \frac1{i!}a^i\partial^i_x\kpsi - \sum_i\frac1{i!} a^i(x\partial^i_x (\kpsi) + \partial_x^{i-1}i\kpsi)\\
&= - \sum_i\frac1{i!} a^i \partial_x^{i-1}i\kpsi\\
&= - \sum_i\frac1{(i-1)!} a^i \partial_x^{i-1}\kpsi\\
&= - a\exp(a\partial_x)\Ket{\psi}\\
&= -a\exp\left(ia\frac{\hat p}{\hbar}\right)\kpsi\\
\therefore [\hat x, \exp\left(\frac{i\hat p a}{\hbar}\right)] &= -a\exp\left(ia\frac{\hat p}{\hbar}\right)
\end{align*}

\section*{Problem 11}
The first allowed state (ground state) in the new system will be the first odd wavefunction, i.e. when $n=1$. We need to calculate the probability that the current state ($n=0$) becomes $n=1$ in that region. Note that since the space is halved over a symmetric function, the wavefunctions will be normalized by an extra factor of $\frac1{\sqrt2}$

So, the overlap is
\begin{align*}
\int_0^\infty \psi_0(x)\frac1{\sqrt2}\psi_1(x)
&= \int_0^\infty  \left(\frac{\alpha}{\sqrt{\pi}}\right)^{\frac12}e^{-\alpha^2x^2/2}H_0(\alpha x)\left(\frac{\alpha}{\sqrt{\pi}2}\right)^\frac12 e^{-\alpha^2x^2/2}H_2(\alpha x)\\
&= \frac{\alpha}{\sqrt\pi\sqrt2}\cdot \int_0^\infty e^{-\alpha^2x^2}\cdot 2\alpha x\\
&=\frac{2\alpha^2}{\sqrt{2\pi}} \int_0^\infty e^{-\alpha^2x^2}\cdot  x\\
&=\frac{2\alpha^2}{\sqrt{2\pi}}\frac{1}{2\alpha^2}
&=\frac{1}{\sqrt{2\pi}}
\end{align*}

Thus the probability is $\left(\frac1{\sqrt{2\pi}}\right)^2=\boxed{\frac{1}{2\pi}}$

\section*{Problem 13}
$$\hat{A}=\begin{pmatrix}a&0&0\\0&-a&0\\0&0&-a\end{pmatrix},\quad\hat{B}=\begin{pmatrix}b&0&0\\0&0&ib\\0&ib&0\end{pmatrix}$$

To find eigenvectors of $\hat B$, we can multiply it with the vector $X=\begin{pmatrix}x\\y\\z\end{pmatrix}$. We get $\hat BX=\begin{pmatrix}bx\\ibz\\iby\end{pmatrix}=cX$, so for an eigenvector we either have $c=b,ibz=y,iby=z$ (giving $y=z=0$ for a general $b$, and eigenvector $\begin{pmatrix}1\\0\\0\end{pmatrix}$. If $c\neq b$ we have $x=0$, and $y=\pm z$ with eigenvalues $\pm ib$

Therefore the eigenvectors are:

\begin{enumerate}
\item $\begin{pmatrix}1\\0\\0\end{pmatrix}$  or $\Ket{1}$ with eigenvalue $b$
\item $\begin{pmatrix}0\\1\\1\end{pmatrix}$ or $\Ket{2}+\Ket{3}$ with eigenvalue $ib$
\item $\begin{pmatrix}0\\1\\-1\end{pmatrix}$ or $\Ket{2}-\Ket{3}$ with eigenvalue $-ib$
\end{enumerate}
\hfill Ans. (a)

Now,
$$\hat A\hat B=\left(
\begin{array}{ccc}
 a & 0 & 0 \\
 0 & -a & 0 \\
 0 & 0 & -a \\
\end{array}
\right) \left(
\begin{array}{ccc}
 b & 0 & 0 \\
 0 & 0 & i b \\
 0 & i b & 0 \\
\end{array}
\right)=\left(
\begin{array}{ccc}
 a b & 0 & 0 \\
 0 & 0 & 0 \\
 0 & 0 & 0 \\
\end{array}
\right)$$

and

$$\hat B\hat A= \left(
\begin{array}{ccc}
 b & 0 & 0 \\
 0 & 0 & i b \\
 0 & i b & 0 \\
\end{array}
\right)\left(
\begin{array}{ccc}
 a & 0 & 0 \\
 0 & -a & 0 \\
 0 & 0 & -a \\
\end{array}
\right)=\left(
\begin{array}{ccc}
 a b & 0 & 0 \\
 0 & 0 & 0 \\
 0 & 0 & 0 \\
\end{array}
\right)$$

As $\hat A\hat B=\hat B\hat A$ in matrix form, the operators commute.
\hfill Ans. (b)

The eigenkets of $\hat A$ can be easily seen to be $\Ket{1}$ with eigenvalue $a$, and $l\Ket{2}+m\Ket{3}$ with eigenvalue $-a$ ($\forall~l,m$)

We can see that the eigenkets of $B$ are also eigenkets of $A$. They are also orthogonal, after normalizing we have:\\~\\

\begin{tabular}{ >{$}c<{$} >{$}c<{$}  >{$}c<{$} }
\text{Orthonormal Eigenket} & \text{Eigenvalue with }\hat A & \text{Eigenvalue with }\hat B \\
\Ket{1} & b & a\\
\frac{\Ket{2}+\Ket{3}}{\sqrt{2}} & ib & -a\\
\frac{\Ket{2}-\Ket{3}}{\sqrt{2}} & -ib & -a
\end{tabular}

The eigenkets are not completely determined from the eigenvalues from individual eigenvalues, as the eigenvalue $-a$ has multiplicity 2 and thus has an entire space of eigenkets.

However, knowing the eigenvalues from both operators completely specifies the eigenket, barring a constant.
\hfill Ans. (c)
\section*{Problem 16}

$\psi(x)=\frac{1}{\sqrt{2a}}$ in $[-a,a]$. The momentum space function can be found via the fourier transform, \begin{align*}
\tilde{\psi}(p)&=\frac1{\sqrt{2\pi}}\int_{-\infty}^\infty e^{-ikx}\psi(x)dx\\
&= \frac1{\sqrt{2\pi}}\int_{-a}^a\frac{1}{\sqrt{2a}} e^{-ikx}dx\\
&=\frac{i}{2k\sqrt{a\pi}} \left.e^{-ikx}\right|_{-a}^a\\
&=\frac{i}{2k\sqrt{a\pi}} \left(e^{-ika}-e^{ika}\right)\\
&=\frac{i}{2k\sqrt{a\pi}} \cdot -2i\sin ka\\
\therefore \tilde{\psi}(p)&=\frac{\sin \left(\frac{ap}{\hbar} \right)}{p\sqrt{a\pi}}\qquad\text{(Already normalized)}
\end{align*}
\hfill Ans.

Now, \begin{align*}\sigma_x&=\sqrt{\Braket{x^2}-\Braket{x}^2}\\
&=\sqrt{\int \psi^*(x)x^2\psi(x)dx-0}\\
&= \sqrt{\int_{-a}^a \left(\frac{1}{\sqrt{2 a}}\right)^2 x^2 dx}\\
&= \frac{a}{\sqrt{3}}
\end{align*}

And

\begin{align*}\sigma_p&=\sqrt{\Braket{p^2}-\Braket{p}^2}\\
&=\sqrt{\int \tilde{\psi}^*(p)p^2\tilde{\psi}(p)dp-0}\\
&= \sqrt{\int_{-\infty}^\infty \left(\frac{\sin \left(\frac{a p}{\hbar }\right)}{\sqrt{\pi } \sqrt{a} p}\right)^2 p^2 dp - 0}\qquad\text{(The wavefunction is odd so the second term vanishes)}\\
&=\sqrt{\infty}
\end{align*}

The product of the two uncertantainties is greater than $\frac\hbar2$
\section*{Problem 17}

$$\psi(x,t)=\frac{1}{\sqrt{2 \pi  \hbar }}\int_{-\infty }^{\infty }  \phi(p)  e^{-\frac{t \left(i p^2\right)}{2 m}+i p x} \, dp$$

Now, we can rewrite this as $\frac{1}{\sqrt{2 \pi  \hbar }}\int_{-\infty }^{\infty } e^{i p x} \left(\phi(p)  e^{-\frac{t \left(i p^2\right)}{2 m}}\right) \, dp$

which is an inverse fourier transform.

Thus, $\tilde{\psi}(p,t)=\mathcal F(\psi(x,t))=\phi(p)  e^{-\frac{t \left(i p^2\right)}{2 m}}$\\
Now,
\begin{align*}
\Braket{p}&=\int \tilde{\psi}^*(p,t)p\tilde{\psi}(p,t)dp\\
&=\int \phi^*(p)  e^{\frac{t \left(i p^2\right)}{2 m}}p\phi(p)  e^{-\frac{t \left(i p^2\right)}{2 m}}dp\\
&= \int \phi^*(p) p \phi(p) dp
\end{align*}

Thus, $\Braket{\hat p}$ is independant of time\hfill Ans. (a)

Note that $\phi(p)=\tilde{\psi}(p,t=0)$
Now,

\begin{align*}
\Braket{x}= \int \tilde{\psi}^*(p,t)i\hbar\ud{}{p}\tilde{\psi}(p,t)dp\\
&=\int \phi^*(p)e^{\frac{t \left(i p^2\right)}{2 m}}i\hbar\left(\pd{\phi}{p}e^{-\frac{t \left(i p^2\right)}{2 m}}+\phi(p)\frac{2pt}{2m}e^{-\frac{t \left(i p^2\right)}{2 m}}\right)dp\\
&=\int\left( \phi^*(p)i\hbar\pd{\phi}{p} + \frac{t}{m}\phi^*(p)p\phi(p)\right) dp\\
&= \Braket{i\hbar\pd{}{p}}_{t=t_0} + \frac{t}{m}\Braket{p}_{t=t_0}\\
\therefore \Braket{x}&=\Braket{x}_{t=0} + \frac{t}{m}\Braket{p}_{t=0}
\end{align*}

Since this is linear, we can shift by $t_0$ to get $\boxed{\Braket{x}=\Braket{x}_{t=t_0} + \frac{t-t_0}{m}\Braket{p}_{t=t_0}}$\hfill Ans. (b)
\section{Problem 19}
$$\hat H = \frac{\hat p^2}{2m}+V(x)$$

\begin{align*}
[H,\hat x]&=\frac{\hat p^2}{2m}x+V(x)x-x\frac{\hat p^2}{2m}+xV(x)\\
&=-x\frac{\hat p^2}{2m}\\
[[H,\hat x],x]&=-x\frac{\hat p^2}{2m}x - -x^2\frac{\hat p^2}{2m}\\
&=\frac{x^2\hat p^2}{2m}
\end{align*}
\end{document}

Course material/EP 307 - Quantum Mechanics/Assignment 4/assign4.tex