\section{Coordinates, Differentials and Gradients}
\subsection{Differentials and First-Order Changes}
Recall that if $f=f(u_1,\ldots,u_n)$, then we write $\mathrm df=(\partial f/\partial u_i)\,\mathrm du_i$ (the summation convention is being used).
Those $\mathrm du_i$ are formal objects called differential forms which are quite abstract geometrical notions that are way beyond the scope of this course.
These differential forms are taken as linearly independent the same way as vectors are.
Similarly, if $\underline{x}=\underline{x}(u_1,u_2,\ldots,u_n)$, then $\mathrm d\underline{x}=(\partial \underline{x}/\partial u_i)\,\mathrm du_i$.
\begin{example}
    If $f(u,v,w)=u^2-v^2+e^w$, then $\mathrm df=2u\,\mathrm du-2v\,\mathrm dv+e^w\,\mathrm dw$.
    If $\underline{x}=(u^2,v^2,w^2)^\top$, then $\mathrm d\underline{x}=(2u\,\mathrm du,2v\,\mathrm dv,2w\,\mathrm dw)^\top$.
\end{example}
Differential forms give a great tool to describe first-order changes.
If we perturb a multivariable function $f(u_1,\ldots,u_n)$, then we can have
$$f(u_1+\epsilon_1,\ldots,u_n+\epsilon_n)=f(u_1,\ldots,u_n)+\frac{\partial f}{\partial u_i}\epsilon_i+o(\|\underline{\epsilon}\|)$$
We can get the chain rule ``for free'' by using this notion.
Suppose we change our coordinates by $v_i=v_i(u_1,\ldots,u_n)$ and $F(u_1,\ldots,u_n)=f(v_1,\ldots,v_n)$, so
$$\frac{\partial F}{\partial u_i}\,\mathrm du_i=dF=df=\frac{\partial f}{\partial v_j}\,\mathrm dv_j=\frac{\partial f}{\partial v_j}\frac{\partial v_j}{\partial u_i}\,\mathrm du_i$$
Therefore
\begin{theorem}
    $$\frac{\partial F}{\partial u_i}=\frac{\partial f}{\partial v_j}\frac{\partial v_j}{\partial u_i}$$
\end{theorem}
Note that the summation convention is implicitly used.
\subsection{Coordinates in Line Elements}
Say $u,v$ are coordinates for $\mathbb R^2$ by relating them to Cartesians in the form $x=x(u,v),y=y(u,v)$ such that these smooth functions can be inverted smoothly to give $u=u(x,y),v=v(x,y)$.
\begin{example}
    Consider the polar coordinate $(r,\theta)$ with the relationship $x=r\cos\theta,y=r\sin\theta$.
    We can invert to have $r=\sqrt{x^2+y^2},\tan\theta=x/y$.
    \footnote{This is not quite invertible at $(x,y)=(0,0)$.
    Just saying.}
\end{example}
\begin{example}
    1. The Cartesian coordinate in $\mathbb R^2$ is $\underline{x}=\underline{x}(x,y)=(x,y)^\top$.
    \footnote{For future reference, any column vector in this course are implicitly written as per the standard basis unless otherwise specified.}
    Note that $\underline{x}_x,\underline{x}_y$ give the standard basis, so $\mathrm d\underline{x}=(\mathrm dx,\mathrm dy)^\top$.\\
    2. The polar coordinate defined above, $\underline{x}=(r\cos\theta,r\sin\theta)^\top$ has
    $$\underline{x}_r=(\cos\theta,\sin\theta),\underline{x}_\theta=(-r\sin\theta,r\cos\theta)$$
    which becomes an orthonormal basis (which depends on $(r,\theta)$) if we normalize.
    So the line element has
    $$\mathrm d\underline{x}=\begin{pmatrix}
        \cos\theta\\\sin\theta
    \end{pmatrix}\,\mathrm dr+r\begin{pmatrix}
        -\sin\theta\\\cos\theta
    \end{pmatrix}\,\mathrm d\theta$$
    So small change in the line element can result in a large change in the coordinate $\mathrm d\theta$.
    The basis vectors above give the rotation basis.
\end{example}
\begin{definition}
    We say $u,v,w$ are set of orthogonal curvilinear coordinates for $\mathbb R^3$ if the unit vectors $\underline{e}_u=\underline{x}_u/\|\underline{x}_u\|,\underline{e}_v=\underline{x}_v/\|\underline{x}_v\|,\underline{e}_w=\underline{x}_w/\|\underline{x}_w\|$ always forms a right-handed system of orthonormal vectors.
\end{definition}
\begin{definition}
    The scale factors are
    $$h_{u}=\left|\frac{\partial \underline{x}}{\partial u}\right|,h_{v}=\left|\frac{\partial \underline{x}}{\partial v}\right|,h_{w}=\left|\frac{\partial \underline{x}}{\partial w}\right|$$
\end{definition}
So the factors are the scaling factors for a little change in the corresponding coordinates.
\begin{definition}
    The cylindral polar coordinates are $(\rho,\phi,z)$ where
    $$\underline{x}=\underline{x}(\rho,\phi,z)=(\rho\cos\phi,\rho\sin\phi,z)^\top$$
\end{definition}
\begin{definition}
    The spherical polar coordinates are $(r,\theta,\phi)$ where
    $$\underline{x}=\underline{x}(r,\theta,\phi)=(r\cos\phi\sin\theta, r\sin\phi\sin\theta,r\cos\theta)$$
\end{definition}
\subsection{The Gradient Operator}
For $f:\mathbb R^3\to\mathbb R$, define the gradientof $f$, $\nabla f$, by
$$f(\underline{x}+\underline{h})=f(\underline{x})+\nabla f(\underline{x})\cdot\underline{h}+o(\underline{h})$$
\begin{definition}
    The directional derivative of $f$ in direction $\underline{v}$ by
    $$D_{\underline{v}}f(\underline{x})=\lim_{t\to 0}\frac{f(\underline{x}+t\underline{v})-f(\underline{x})}{t}$$
    So $f(\underline{x}+t\underline{v})=f(\underline{x})+tD_{\underline{v}}f(\underline{x})+o(t)$.
\end{definition}
So if we let $\underline{h}=t\underline{v}$, we have
$$f(\underline{x}+t\underline{v})=f(\underline{x})+\nabla f(\underline{x})\cdot t\underline{v}+o(t)$$
So we have $\nabla f(\underline{x})\cdot \underline{v}=D_{\underline{v}}f(\underline{x})$.
By Cauchy-Schwartz, to maximize a dot product we will have to make the two vectors parallel, so
\begin{proposition}
    $\nabla f(\underline{x})$ is the direction of greatest increase of $f$ at $\underline{x}$.
\end{proposition}
\begin{proof}
    Cauchy-Schwartz.
\end{proof}
\begin{example}
    1. $f(\underline{x})=|\underline{x}|^2/2$, so
    $$f(\underline{x}+\underline{h})=(\underline{x}+\underline{h})\cdot(\underline{x}+\underline{h})/2=f(\underline{x})+\underline{x}\cdot\underline{h}+o(\underline{h})$$
    Hence $\nabla f(\underline{x})=\underline{x}$.\\
    2. For generic curve $t\mapsto \underline{x}(t)$ and a function $F$, we want to evaluate $(F\circ \underline{x})^\prime$, so
    $$F(\underline{x}(t+\delta t))=F(\underline{x}(t)+\underline{\delta x})=F(\underline{x}(t))+\nabla f(\underline{x}(t))\cdot\underline{\delta x}+o(\underline{\delta x})$$
    where $\underline{\delta x}=\underline{x}(t+\delta t)-\underline{x}(t)=t\underline{x}^\prime(t)+o(t)$.
    So plugging it in we have
    $$\frac{\mathrm dF}{\mathrm dt}=\nabla F(\underline{x}(t))\cdot \underline{x}^\prime(t)$$
    3. Consider a surface in $\mathbb R^3$ by $S=\{\underline{x}:f(\underline{x})=0\}$ where $f:\mathbb R^3\to\mathbb R$.
    Take curve $t\mapsto \underline{x}(t)$ such that $\underline{x}\in S$ for all $t$, then $0=\underline{x}^\prime(t)\cdot\nabla F(\underline{x}(t))$, so $\nabla F$ is perpendicular to the tangent to the curve.
    Hence necessarily $\nabla F$ is the normal to $S$.
\end{example}
\subsection{Computing the Gradient}
For general orthogonal curvilinear coordinate, it might be hard to calculate $\nabla f$ since we do not usually know how to change the coordinates to accomodate the change $\underline{h}$.\\
But it is easy in Cartesians.
Just evaluating the directional derivatives at the basis vectors reveals:
\begin{proposition}
    $$\nabla f=\begin{pmatrix}
        \partial f/\partial x\\
        \partial f/\partial y\\
        \partial f/\partial z
    \end{pmatrix}$$
\end{proposition}
\begin{proof}
    We have
    $$(\nabla f(\underline{x}))_i=\nabla f(\underline{x})\cdot\underline{e_i}=D_{\underline{e_i}}f(\underline{x})$$
    As desired.
\end{proof}
\begin{example}
    Again we take $f(\underline{x})=|\underline{x}|^2/2$, then $(\nabla f(\underline{x}))_i=x_i$, so $\nabla f(\underline{x})=\underline{x}$ as before.
\end{example}
In Cartesians, we know the line elements $\mathrm d\underline{x}=\mathrm dx_i\underline{e_i}$ which allows us to calculate easily.
But we have $\mathrm df=D_{\underline{e_i}}f\,\mathrm dx_i$ in any coordinate.
So immediately we have
\begin{proposition}
    $\mathrm df=\nabla f\cdot\mathrm d\underline{x}$
\end{proposition}
which is coordinate independent.
\begin{proof}
    Just calculate the right hand side.
\end{proof}
\begin{proposition}
    Let $u,v,w$ be a set of curvilinear coordinates, then we have
    $$\nabla f=\frac{1}{h_u}\frac{\partial f}{\partial u}\underline{e_u}+\frac{1}{h_v}\frac{\partial f}{\partial v}\underline{e_v}+\frac{1}{h_w}\frac{\partial f}{\partial w}\underline{e_w}$$
\end{proposition}
\begin{proof}
    $\mathrm df=\nabla f\cdot\mathrm d\underline{x}$ independent of coordinate.
    We also know that $\mathrm d\underline{x}=h_u\underline{e_u}\,\mathrm du+h_v\underline{e_v}\,\mathrm dv+h_w\underline{e_w}\,\mathrm dw$.
    Write $\nabla f=(\nabla f)_u\underline{e_u}+(\nabla f)_v\underline{e_v}+(\nabla f)_w\underline{e_w}$, then
    $$\nabla f\cdot \mathrm d\underline{x}=h_u(\nabla f)_u\,\mathrm du+h_v(\nabla f)_v\,\mathrm dv+h_w(\nabla f)_w\,\mathrm dw$$
    In addition,
    $$\mathrm df=\frac{\partial f}{\partial u}\,\mathrm du+\frac{\partial f}{\partial v}\,\mathrm dv+\frac{\partial f}{\partial w}\,\mathrm dw$$
    But they are equal.
    Since $\mathrm du,\mathrm dv,\mathrm dw$ are linearly independent, we have
    $$(\nabla f)_u=\frac{1}{h_u}\frac{\partial f}{\partial u},(\nabla f)_v=\frac{1}{h_v}\frac{\partial f}{\partial v},(\nabla f)_w=\frac{1}{h_w}\frac{\partial f}{\partial w}$$
    As desired.
\end{proof}
\begin{example}
    1. For cylindral coordinates $(\rho,\phi,z)$, we have
    $$\nabla f=\frac{\partial f}{\partial\rho}\underline{e_\rho}+\frac{1}{\rho}\frac{\partial f}{\partial\phi}\underline{e_\phi}+\frac{\partial f}{\partial z}\underline{e_z}$$
    Then in the previous example where $f(\underline{x})=|\underline{x}|^2/2=(\rho^2+z^2)/2\implies\nabla f=\rho\underline{e_\rho}+z\underline{e_z}=\underline{x}$\\
    2. For spherical coordinates $(r,\theta,\phi)$, we can do the same thing,
    $$\nabla f=\frac{\partial f}{\partial r}\underline{e_r}+\frac{1}{r}\frac{\partial f}{\partial\theta}\underline{e_\theta}+\frac{1}{r\sin\theta}\frac{\partial f}{\partial \phi}\underline{e_\phi}$$
    Using the same example $f(\underline{x})=r^2/2\implies \nabla f=r\underline{e_r}=\underline{x}$.
\end{example}
\begin{note}
    We talked about the functions about position vectors under different coordinates,
    $$f(\underline{x})=f(\underline{x}(x,y,z))=f(\underline{x}(r,\theta,\phi))$$
    So when we are talking about $f$, sometimes we are telling
    $$\tilde{f}(x,y,z)=f(\underline{x}(x,y,z)),\tilde{\tilde{f}}(r,\theta,\rho)=f(\underline{x}(r,\theta,\rho))$$
    Or other coordinate we might find interesting.
    We are actually talking about a pullback here which might be clear in a couple of years' time.
\end{note}


\problemname{Limbo: Part 1}

\noindent Dominick Cobb and Arthur are ``extractors" who perform corporate espionage. Using experimental military technology that gives them access to shared dream worlds, they infiltrate their targets' subconscious to extract valuable information. Cobb and his entourage are contacted by a mysterious Japanese syndicate and given a seemingly impossible task: instead of extracting information, do the opposite -- plant a new idea in the target's mind.\\

Cobb notes that when using dream-sharing technology, time slows down by different factors depending on whose dream is being entered. Their target is to convince Cepshun, the heir of an energy conglomerate, to dissolve his father's company. Before Cobb starts, he notes that it would be important to figure out the passage of time to ensure that the operation can be completed smoothly.\\

In Cepshun's dreams, there are multiple different layers of consciousness, each of which controls a different area of Cepshun's dreams and memories. Cobb needs to move between several dreams to reach his destination dream -- some of them belonging to Cepshun, and some of them belonging to his entourage. The factor by which time slows down on each level is best visualized by all of the positive integers arranged in an infinite triangle, where the first row has the single integer $1$, the second row has the next two integers, the third row has the next three, and so forth. The first $4$ levels are depicted below:

\begin{verbatim}
      1
     2 3
    4 5 6
   7 8 9 10
    etc...
\end{verbatim}

The initial time factor for reality is $1$. To enter the next dream level, Cobb can either descend left (into a dream by Cepshun) or right (into a dream by his entourage). For example, if he descends right, left, right, then he'll end up at dreams with time factors of $3$, then $5$, and finally $9$. Note the interesting property that for any pair of whole numbers $L$ and $R$, Cobb will always end up on the same time factor if he moves left $L$ times total and right $R$ times total, regardless of the order in which he makes the moves.\\

Cobb wants to know the slowness of time inside his target dream, which he can reach by descending left $L$ times and right $R$ times.

\section*{Input}
The first line of input consists of a single integer $T$ ($1 \leq T \leq 100$), the number of test cases.\\
$T$ lines follow, each of which is a test case consisting of two space-separated integers, $L$ and $R$ ($0 \leq L, R \leq 10^{9}$), specifying the number of times Cobb needs to descend left and right, respectively.

\section*{Output}
For each test case, print, on a separate line, the factor by which time slows down in the target's dream at $(L, R)$.\\
Note: the answer can be large, and may not necessarily fit in a 32-bit integer.\\


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Written By Michael Brodskiy
% Class: Analytic Geometry & Calculus III (Math-292)
% Professor: V. Cherkassky
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[12pt]{article}
\usepackage{alphalph}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\usepackage{titling}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage[super]{nth}
\usepackage{everysel}
\usepackage{ragged2e}
\usepackage{geometry}
\usepackage{fancyhdr}
\geometry{top=1.0in,bottom=1.0in,left=1.0in,right=1.0in}
\newcommand{\subtitle}[1]{%
  \posttitle{%
    \par\end{center}
    \begin{center}\large#1\end{center}
    \vskip0.5em}%

}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,
citecolor=blue,
}

\urlstyle{same}

\title{Lecture XI Notes}
\date{\today}
\author{Michael Brodskiy\\ \small Professor: V. Cherkassky}

% Mathematical Operations:

% Sum: $$\sum_{n=a}^{b} f(x) $$
% Integral: $$\int_{lower}^{upper} f(x) dx$$
% Limit: $$\lim_{x\to\infty} f(x)$$

\begin{document}

\maketitle

\subsection{Second Order Partial Derivatives}

Although the order of second partial differentiation usually does not matter, sometimes the second order partial derivatives may not be equal. Differentiating $\frac{\partial f}{\partial x}$ by $\frac{\partial}{\partial y}$ results in $\frac{\partial^2f}{\partial y \partial x}$. If one differentiates in the reversed order, this yields $\frac{\partial^2f}{\partial x \partial y}$, where the order of partial differentiation is read from right to left.\\

\textit{Example Where $\frac{\partial^2f}{\partial y \partial x}=\frac{\partial^2f}{\partial x \partial y}$:}

$$f(x,y)=x^3+x^2y^3-2y^2$$
$$\frac{\partial f}{\partial x}=3x^2+2xy^3$$
$$\frac{\partial f}{\partial y}=3x^2y^2-4y$$
$$\frac{\partial^2f}{\partial y \partial x}=6xy^2$$
$$\frac{\partial^2f}{\partial x \partial y}=6xy^2$$
\begin{center}$\therefore \frac{\partial^2f}{\partial x \partial y}=\frac{\partial^2f}{\partial y \partial x}$\footnote{In most cases, $\frac{\partial^2f}{\partial x \partial y}=\frac{\partial^2f}{\partial y \partial x}$}\end{center}

\subsection{Clairaut's Theorem}

If $\frac{\partial^2f}{\partial x \partial y}$ and $\frac{\partial^2f}{\partial y \partial x}$ are continuous at point $(a, b)$, then $\frac{\partial^2f}{\partial x \partial y}=\frac{\partial^2f}{\partial y \partial x}$ at $(a, b)$\footnote{This rule applies to any nth order derivative}

\subsection{Laplace's Differential Equations}

Named after Pierre Laplace, the partial differential equation looks like this:

$$\frac{\partial^2u}{\partial x^2} + \frac{\partial^2u}{\partial y^2}=0$$

Any function that fits the criteria is called a \bold{harmonic function}

\subsection{Wave Equations}

Any wave, whose displacement is defined by the function $u(x,t)$ must satisfy the wave equation:

$$\frac{\partial^2u}{\partial t^2}=a^2\frac{\partial^2u}{\partial x^2}$$

\section{Tangent Plane Approximation and Total Differentials $-$ 14.4}

The tangent plane approximation function is given by:

$$z-z_o=f_x(x_o,y_o)(x-x_o)+f_y(x_o,y_o)(y-y_o)$$

The definition of a total differential is:

$$dz = \frac{\partial z}{\partial x}dx + \frac{\partial z}{\partial y}dy$$

$dz$ represents the change in the plane approximation

\end{document}


% This is part of the TFTB Reference Manual.
% Copyright (C) 1996 CNRS (France) and Rice University (US).
% See the file refguide.tex for copying conditions.

\markright{renyi}
\section*{\hspace*{-1.6cm} renyi}

\vspace*{-.4cm}
\hspace*{-1.6cm}\rule[0in]{16.5cm}{.02cm}
\vspace*{.2cm}

{\bf \large \sf Purpose}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
Measure Renyi information.
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Synopsis}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
R = renyi(tfr)
R = renyi(tfr,t)
R = renyi(tfr,t,f)
R = renyi(tfr,t,f,alpha)
\end{verbatim}
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Description}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
        {\ty renyi} measures the Renyi information relative to a 2-D
        density function {\ty tfr} (which can be eventually a
        time-frequency representation). Renyi information of order $\alpha$
        is defined as\,:
\begin{eqnarray*}
R_x^{\alpha} = \frac{1}{1-\alpha}\
log_2\left\{\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty}
\mbox{tfr}_x^{\alpha}(t,\nu)\ dt\ d\nu\right\}
\end{eqnarray*}

The result produced by this measure is expressed in {\it bits} : if one
elementary signal yields zero bit of information ($2^0$), then two well
separated elementary signals will yield one bit of information ($2^1$),
four well separated elementary signals will yield two bits of information
($2^2$), and so on.\\

\hspace*{-.5cm}\begin{tabular*}{14cm}{p{1.5cm} p{8.5cm} c}
Name & Description & Default value\\
\hline
        {\ty tfr} & {\ty (M,N)} 2-D density function (or mass function). Eventually
             {\ty tfr} can be a time-frequency representation, in which case
             its first row must correspond to the lower frequencies\\
        {\ty t} & abscissa vector parametrizing the {\ty tfr} matrix. {\ty t} can be a
            non-uniform sampled vector (eventually a time vector)
                                                & {\ty (1:N)}\\
        {\ty f} & ordinate vector parametrizing the {\ty tfr} matrix. {\ty f} can be a
            non-uniform sampled vector (eventually a frequency vector)
                                                & {\ty (1:M)}\\
        {\ty alpha} & rank of the Renyi measure        & {\ty 3}\\
 \hline {\ty R} & the alpha-rank Renyi measure (in bits if {\ty tfr} is a time-
            frequency matrix).\\
\hline
\end{tabular*}

\end{minipage}

\newpage

{\bf \large \sf Examples}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}

\begin{verbatim}
         s=atoms(64,[32,.25,16,1]); [tfr,t,f]=tfrsp(s);
         R1=renyi(tfr,t,f,3)
         ans =
               0.9861

         s=atoms(64,[16,.2,16,1;48,.3,16,1]); [tfr,t,f]=tfrsp(s);
         R2=renyi(tfr,t,f,3)
         ans =
               1.9890

\end{verbatim}
We can see that if {\ttfamily R} is set to 0 for one elementary atom by
subtracting {\ttfamily R1}, we obtain a result close to 1 bit for two atoms
({\ttfamily R2-R1}=1.0029).
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Reference}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
[1] W. Williams, M. Brown, A. Hero III, ``Uncertainty, information and
   time-frequency distributions'', SPIE Advanced Signal Processing
   Algorithms, Architectures and Implementations II, Vol. 1566,
   pp. 144-156, 1991.
\end{minipage}


\subsection{Chapter 2}

\begin{p}%{55}
{Given a manifold $M$, define charts for $TM$ starting from charts $\varphi_\alpha:U_\alpha\rightarrow \R^n$ as follows. Let $V_\alpha$ be the subset of $TM$ given by $V_\alpha=\{v\in TM:\pi(v)\in U_\alpha\}$. Show that every point in $TM$ lies in some set $V_\alpha$. Define
maps $\psi_\alpha:V_\alpha\rightarrow \R^n\times \R^n$ by $\psi_\alpha(v)=(\varphi_\alpha(\pi(v)),(\varphi_\alpha)_*v)$, where we think of $(\varphi_\alpha)_*v$, which is really a tangent vector to $\R^n$, as
a vector in $\R^n$. Give $TM$ the topology in which open sets are the unions of sets of the form $O\subset V_\alpha$ such that $\psi_\alpha(O)\subset \R^n\times \R^n$ is open. Check that $\psi_\alpha$ are charts, so that $TM$ is a manifold. Check that $\pi:TM\rightarrow M$ is smooth.}
\end{p}
{Every point $v$ in $TM$ is in some $V_\alpha$ since $v$ is the tangent vector at some point $p$ (as given by $p=\pi(v)$), and every point $p$ is in some set $U_\alpha$. To establish that $\psi_\alpha$ are charts and $TM$ is a smooth manifold, note that $\varphi_\alpha$ is smooth and so is the pushforward, so $\psi_\alpha$ is smooth, too. Transition functions
from one chart to another are likewise smooth, since these are compositions of smooth $\psi_\alpha$ and $\psi^{-1}_\beta$ which overlap on some open set. The projection $\pi$ is smooth because we can define
the $\R^{2n}\rightarrow \R^n$ version of the map by just ignoring the last $n$ coordinates. But this map is just $\varphi_\alpha\circ\pi\circ\psi_\alpha^{-1}$, so $\pi$ must be smooth.}

\begin{p}%{56}
{Given bundles $\pi:E\rightarrow M$ and $\pi':E'\rightarrow M'$, show that the maps $\psi:E\rightarrow E'$ and $\phi:M\rightarrow M'$ are a bundle morphism iff $\pi'\circ\psi=\phi\circ\pi$. Show that
$\psi$ uniquely determines $\phi$.}
\end{p}
{Bundle morphisms respect the bundle structure, i.e.~the split into fiber and base. If $\pi'\circ\psi=\phi\circ\pi$, then the fiber in $E$ over $p$ must be mapped to the fiber in $E'$ over $p'=\phi(p)$, or else the relationship would not hold. Conversely, if the fibers are mapped to the appropriate base
points, then it doesn't matter if we do the tangent space map first or second.}

\begin{p}%{57}
{Check that $\phi_*$ is smooth when we make the tangent bundle into a manifold as in the previous exercise.}
\end{p}
{(typo on the ``previous'' exercise?) A map between two manifolds is smooth if it takes smooth functions on the first manifold to smooth functions on the second. Points in the manifold in
question are vectors $v$, so functions of them are 1-forms $\om$. Using an exact 1-form $df$ we have
$df(v)=v(f)$. When $v=\phi_*(u)$ we get $df(\phi_*(u))=\phi_*(u)(f)=u(\phi^*f))=u(f\circ\phi)$, which is
smooth.}

\begin{p}%{58}
{Show that if $\phi:M\rightarrow M'$ is a diffeomorphism, then $\phi_*:TM\rightarrow TM'$ is a bundle isomorphism.}
\end{p}
{When $\phi$ is an isomorphism, the tangent spaces $T_pM$ and $T_\phi(p)M'$ are
isomorphic, since the smooth functions on $M$ get mapped isomorphically to smooth functions on $M'$. Since
the pushforward is smooth and linear, it's an isomorphism of the tangent spaces.}

\begin{p}%{59}
{Show that for any manifold $M$, the tangent bundle $\pi:TM\rightarrow M$ is locally trivial.}
\end{p}
{The induced charts $\psi_\alpha$ give us a trivialization, with $\R^n$ as the standard fiber.}

\begin{p}%{60}
{Describe a bundle that is not locally trivial.}
\end{p}
{}

\begin{p}%{61}
{Check that the tangent bundle of a manifold is a vector bundle.}
\end{p}
{To be a vector bundle, the
local trivialization must be fiberwise linear. The standard fiber for a tangent bundle is $\R^n$, and the
trivialization is linear because it is just the pushforward (exercise 17, part I).}

\begin{p}%{62}
{A 1-dimensional bundle is called a (real or complex) line bundle. Check that the M\"obius strip is a real line bundle if we regard the standard fiber as being $\R$.}
\end{p}
{Locally the M\"obius strip is just $\R^2$, so the trivialization is linear.}

\begin{p}%{63}
{Show that if a vector bundle morphism is a diffeomorphism, its inverse is a vector bundle morphism.}
\end{p}
{}

\begin{p}%{64}
{Show that a (smooth (typo?)) section of the tangent bundle is a vector field.}
\end{p}
{A section of the tangent bundle
assigns to each point in the base space vector in its tangent space. From this we obtain a
vector field from the pointwise action of the tangent vectors. The output of the vector field is again a
smooth function since the
section is smooth; the directional derivative (function value) changes smoothly from point to point since
the tangent vectors do.}

\begin{p}%{65}
{Show that $\Gamma(E)$ is a module over $C^\infty(M)$.}
\end{p}
{The first two conditions are defined
in the text. The other two are simply: $(fg)s=f(gs)$ since $(fg)s:=((fg)s)(p)=(fg)(p)s(p)=f(p)g(p)s(p)=f(gs)(p)$ for
$f,g\in C^\infty (M)$. }

\begin{p}%{66}
{Show that every section of the M\"obius strip (viewed as a real line bundle over $S^1$) vanishes somewhere. Conclude that hte M\"obius strip hos no basis of sections, hence is not trivial.}
\end{p}
{can't cut the M\"obius strip and make a cylinder unless there's a zero somewhere.}

\begin{p}%{67}
{Show that the dual vector bundle really is a vector bundle. Also, show that given a basis
of section $e_i$ of a vector bundle $E$, there is a unique dual basis $e^i$ of sections of $E^*$ such that for each point $p\in M$, $e^i(p)$ is the basis of $E^*_p$ dual to the basis $e_i(p)$ of $E_p$.}
\end{p}
{The basic idea, I think, is that since $E|_U$ is locally equivalent to
$U\times \mathbb{R}^n$ for any open set $U$, then since $E^*$ just replaces
$E_p$ with $E^*_p$ everywhere,
$E^*|_U$ must be locally equivalent to $U\times (\mathbb{R}^n)^*=U\times \mathbb{R}^n$.
This makes $E^*$ a manifold. To see that it is a vector bundle, just use the canonical dual basis when
mapping $E_p^*$ to $\mathbb{R}^n$.
}

\begin{p}%{68}
{Show that if $s$ is a section of a vector bundle $E$ over $M$ and $\lambda$ is a
section of $E^*$, there is a smooth function $\lambda(s)$ on $M$ given by
\[\lambda(s)(p)=\lambda(p)(s(p))\] for all $p\in M$. Show that $\lambda(s)$ depends $C^\infty(M)$-linearly on $\lambda$ and $s$.}
\end{p}
{Locally, the vector bundles are trivial, so locally the section
looks like a function from $M$ to $V$ ($V^*$), where $E_p=\{p\}\times V$. We can then
apply $\lambda$ to $s$ pointwise to obtain the function. It is smooth since the sections are smooth.
$\lambda(s)$ is linear over $\lambda$ and $s$ since the action of the cotangent vector on the tangent vector is linear in each argument. We get the $C^\infty(M)$ part since the action is pointwise and smooth.}

\begin{p}%{69}
{Show that a section of the cotangent bundle is the same as a 1-form.}
\end{p}
{A 1-form is a
map taking vector fields to functions on the manifold. Interpreting vector fields as sections of
the tangent bundle, means that a 1-form is a map from sections of $TM$ to functions on $M$. By the
previous exercise we see that a section of $T^*M$ is just such a map, so a section of the cotangent
bundle is a 1-form.}

\setcounter{p}{76}

\begin{p}%{77}
{Show that the conditions $g_{\alpha\alpha}=1$ and $g_{\alpha\beta}g_{\beta\gamma}g_{\gamma\alpha}=1$ imply $g_{\beta\alpha}^{-1}=g_{\alpha\beta}$. Show that for any sequences $\alpha_1,\dots,\alpha_n$ and $\beta_1,\dots,\beta_m$ with $\alpha_1=\beta_1$ and $\alpha_n=\beta_m$, they
imply $$g_{\alpha_1\alpha_2}\cdots g_{\alpha_{n-1}\alpha_n}=g_{\beta_1\beta_2}\cdots g_{\beta_{m-1}\beta_m}.$$
}
\end{p}
{Letting $\gamma=\alpha$ in the cocyle condition yields $g_{\alpha\beta}g_{\beta\alpha}g_{\alpha\alpha}=1$. Then using $g_{\alpha\alpha}=1$ we obtain
$g_{\alpha\beta}g_{\beta\alpha}=1$, so $g_{\beta\alpha}^{-1}=g_{\alpha\beta}$. Now
observe that $g_{\alpha_1\alpha_{n-1}}g_{\alpha_{n-1}\alpha_n}=g_{\alpha_1\alpha_n}$ since
multiplying by the inverse of the righthandside gives $g_{\alpha_1\alpha_{n-1}}g_{\alpha_{n-1}\alpha_n}g_{\alpha_n\alpha_1}=1$. By induction we can expand this expression to
$g_{\alpha_1\alpha_2}\cdots g_{\alpha_{n-1}\alpha_n}$. Similarly, we can start with
$g_{\beta_1\beta_{m-1}}g_{\alpha_{m-1}\beta_m}=g_{\alpha_1\alpha_n}$ and obtain $g_{\beta_1\beta_2}\cdots g_{\beta_{m-1}\beta_m}$, so they must be equal.}

\newpage
\includepdf[pages=-]{src/gfkg223.pdf}
\includepdf[pages=-]{src/gfkg224.pdf}
\includepdf[pages=-]{src/gfkg225.pdf}

\setcounter{p}{85}
\begin{p}%86
{Using a local trivialization of $E$ over $U_\alpha\subseteq M$ write the $G$-connection $D$ as the standard flat connection plus a vector potential: $D=D^0+A$. Show that the vector potential $A'$ for $D'$ is given in local coordinates by $$A'_\mu=gA_\mu g^{-1}+g\partial\mu g^{-1}.$$ Show that
since $A_\mu$ lives in $\mathfrak{g}$, so does $A_\mu'$. (Hint: show that if $A_\mu$ lives in $\mathfrak{g}$ and $g\in G$, then $g A_\mu g^{-1}$ lives in $\mathfrak{g}$. Also show that if
$g\in\mathcal{G}$, $g\partial_\mu g^{-1}$ lives in $\mathfrak{g}$.) Conclude that $D'$ is a $G$-connection.}
\end{p}
{$D'_\mu(s)=gD_\mu(g^{-1}s)=gD_\mu^0(g^{-1}s)+gA_\mu(g^{-1}s)$. The local trivialization
means that we have chosen a basis of sections $\{e_j\}$ such that $D_\mu^0(s^je_j)=(\partial_\mu s^j)e_j$. The action of $g$ can be represented by $g=\rho(g)^j_k e_j\otimes e^k$ and the corresponding
flat covariant derivative is just $D_\mu^0(g)=(\partial_\mu \rho(g)^j_k)e_j\otimes e^k$. Inserting these expressions into $D'_\mu(s)$ gives
\begin{align}
D'_\mu(s)&=g D_\mu(g^{-1}s)=gD_\mu^0(g^{-1}s)+gA_\mu(g^{-1}s)\\
&=g\left(\partial_\mu \rho(g^{-1})^k_j s^j\right) e_k+gA_\mu g^{-1}s
=D_\mu^0(s)+g\left(\partial_\mu \rho(g^{-1})^k_j \right)s^j e_k+gA_\mu g^{-1}s\\
&=D_\mu^0(s)+gD_\mu^0(g^{-1})s+gA_\mu g^{-1}s=D_\mu^0(s)+(g\partial_\mu g^{-1})s+gA_\mu g^{-1}s,
\end{align}
where in the last equality we've abuse notation somewhat. Hence the vector potential has changed
according to the prescribed form. For $g\in\mathcal{G}$, $g\partial_\mu g^{-1}$ lives in $\mathfrak{g}$ for the following reason. Really this expression is $\rho(g)^j_\ell \partial_\mu \rho(g^{-1})^{\ell}_k(x^\nu)$ and $\rho(g)(x^\nu)=\exp\left(-c_j(x^\nu)h^j\right)$, where
$h^j$ is a generator set for the Lie algebra $\mathfrak{g}$. Thus, $g\partial_\mu g^{-1}=(\partial_\mu c_j(x^\nu))g h^jg^{-1}$, which is
an element of $\mathfrak{g}$.
 }

 \begin{p}%87
 \end{p}

 \newpage

\includepdf[pages=-]{src/gfkg226.pdf}


\documentclass[a4paper,12pt]{extarticle}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}

\renewcommand\familydefault{\sfdefault}
\usepackage{tgheros}
\usepackage[defaultmono]{droidmono}

\usepackage{amsmath,amssymb,amsthm,textcomp}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tikz}

\usepackage{geometry}
\geometry{left=25mm,right=25mm,%
bindingoffset=0mm, top=20mm,bottom=20mm}

\linespread{1.3}

\newcommand{\linia}{\rule{\linewidth}{0.5pt}}

% custom theorems if needed
\newtheoremstyle{mytheor}
    {1ex}{1ex}{\normalfont}{0pt}{\scshape}{.}{1ex}
    {{\thmname{#1 }}{\thmnumber{#2}}{\thmnote{ (#3)}}}

\theoremstyle{mytheor}
\newtheorem{defi}{Definition}

% my own titles
\makeatletter
\renewcommand{\maketitle}{
\begin{center}
\vspace{2ex}
{\huge \textsc{\@title}}
\vspace{1ex}
\\
\linia\\
\@author \hfill \@date
\vspace{4ex}
\end{center}
}
\makeatother
%%%

% custom footers and headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{Intro to Kalman Filter}
\cfoot{}
\rfoot{Page \thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%

% code listing settings
\usepackage{listings}
\lstset{
    language=Python,
    basicstyle=\ttfamily\small,
    aboveskip={1.0\baselineskip},
    belowskip={1.0\baselineskip},
    columns=fixed,
    extendedchars=true,
    breaklines=true,
    tabsize=4,
    prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
    frame=lines,
    showtabs=false,
    showspaces=false,
    showstringspaces=false,
    keywordstyle=\color[rgb]{0.627,0.126,0.941},
    commentstyle=\color[rgb]{0.133,0.545,0.133},
    stringstyle=\color[rgb]{01,0,0},
    numbers=left,
    numberstyle=\small,
    stepnumber=1,
    numbersep=10pt,
    captionpos=t,
    mathescape=true,
    escapeinside={\%*}{*)}
}

%%%----------%%%----------%%%----------%%%----------%%%

\begin{document}

\title{ Kalman Filter }

\author{ Dhruv Patel }

\maketitle

\section*{ What is Kalman Filter ? }

Kalman Filter or simply \emph{KF}, is one of the many techniques to implement Bayes Filters. It was invented by Swerling (1958) and Kalman (1960) as a technique for filtering and prediction in \emph{linear Gaussian Systems}. The Kalman Filter implements belief computation for continuous states. It is not applicable to discrete or hybrid state spaces.

% Pseudo Code - Kalman Filter

\begin{lstlisting}
Algorithm Kalman Filter($\mu_{t-1}, \Sigma_{t-1}, u_t, z_t$):
	# Prediction Step : ref. as Motion Model
	$\overline{\mu}_t =  A_t * \mu_{t-1}  + B_t * u_t$
	$\overline{\Sigma}_t = A_t * \Sigma_{t-1} * A_t^T  +  R_t$
	# Update Step : ref. as Measurement Model
	$K_t = \overline{\Sigma}_t * C_t^T * (C_t * \Sigma_t * C_t^T  +  Q_t)^{-1}$
	$\mu_t = \overline{\mu}_t + K_t * (z_t - C_t * \overline{\mu}_t)$
	$\Sigma_t = ( I - K_t * C_t ) * \overline{\Sigma}_t$
	return $\mu_t , \Sigma_t$

\end{lstlisting}

The Kalman Filter represents beliefs by the moments parameterization : At time $t$, the belief $bel(x_t)$is represented by the mean $\mu_t$ and the covariance $\Sigma_t$. The input of the Kalman filter is the belief at time $t-1$, represented by $\mu_{t-1}$ and $\Sigma_{t-1}$. To update these parameters, Kalman filters require the control $u_t$ and the measurement $z_t$. The output is the belief at time $t$, represented by $\mu_t$ and $\Sigma_t$. This predicted belief $\mu_t$ and $\Sigma_t$ is calculated representing the belief $\overline{bel}(x_t)$ one time step later, but before incorporating the measurement $z_t$. This belief is obtained by incorporating the control $u_t$. The update of the covariance considers the fact that states depend on previous states through the linear matrix $A_t$. This matrix is multiplied twice into the covariance, since the covariance is a quadratic matrix.

The belief $\overline{bel}(x_t)$ is subsequently transformed into the desired belief $bel(x_t)$, by incorporating the measurement $z_t$. The variable $K_t$, is called \emph{Kalman Gain}. It specifies the degree to which the measurement is incorporated into the new state estimate. The key concept here is the \emph{innovation}, which is the difference between the actual measurement $z_t$ and the expected measurement $C_t$. Finally, the new covariance of the posterior belief is calculated, adjusting for the information gain resulting from the measurement.

The \emph{Kalman Filter} is computationally quite efficient. In many applications - such as the robot mapping applications - the measurement space is much lower dimensional than the state space, and the update is dominated by the $O(n^2)$ operations.

\section*{ A brief explanation about the variables }

The state transition probability $ p( x_t | u_t, x_{t-1} ) $ must be a linear function in its arguments with added Gaussian noise. This is expressed by the following equation :
\begin{equation} \label{eq1}
x_t =  A_t * x_{t-1}  +  B_t * u_t  +  \varepsilon_t
\end{equation}
Here, $x_t$ and $x_{t-1}$ are state vectors, and $u_t$ is the control vector at time $t$. These vectors are column vectors. They are of the form
\begin{equation}
x_t = \left( \begin{array}{c} x_{1,t} \\ x_{2,t} \\ . \\ . \\  x_{n,t} \end{array} \right)
\mbox{~and~}
u_t = \left( \begin{array}{c} u_{1,t} \\ u_{t,2} \\ . \\ . \\ u_{m,t} \end{array} \right)
\end{equation}
$A_t$ and $B_t$ are matrices. $A_t$ is a square matrix of size $ n \times n $, where $n$ is the dimension of the state vector $x_t$. $B_t$ is of size $ n \times m$, with $m$ being the dimension of the control vector $u_t$. By multiplying the state and control vector with the matrices $A_t$ and $B_t$, respectively, the state transition function becomes \emph{linear} in its arguments. Thus, Kalman Filters assume linear system dynamics.

The random variable $\varepsilon_t$ in (1) is a Gaussian random vector that models the uncertainty introduced by the state transition. It is of the same dimension as the state vector. It has zero mean, and its covariance will be denoted by $R_t$. A state transition probability of the form (1) is called a \emph{linear Gaussian}, to reflect the fact that it is linear in its arguments with additive Gaussian noise.

The measurement probability $ p(z_t | x_t ) $ must also be \emph{linear} in its arguments, with added Gaussian noise :
\begin{equation}
z_t = C_t * x_t + \delta_t
\end{equation}
Here, $C_t$ is a matrix of size $k \times n$, where $k$ is the dimension of the measurement vector $z_t$. The vector $\delta_t$ describes the measurement noise. The distribution of $\delta_t$ is a multivariate Gaussian with zero mean and covariance $Q_t$.

\vfill

\section*{ Given Problem }

Here, we have been given a simple target tracking problem in one-dimensional space. The state contains three components : position (one-dimensional), velocity and acceleration and it can be expressed as below.
\begin{equation}
x = \left( \begin{array}{c} x_k \\ \dot{x}_k \\ \ddot{x}_k \end{array} \right)
\end{equation}
where, $x_k$ is the position, $\dot{x}_k$ is the velocity and $\ddot{x}_k$ is the acceleration at time '$k$'. $T$ is the size of sample time step.

The process equation for target motion is given by the following kinematic equation:
\begin{equation}
\left[ \begin{array}{c} x_k \\ \dot{x}_k \\ \ddot{x}_k \end{array} \right] =
\left[ \begin{array}{ccc} 1 & T & \frac1{2}T^2 \\ 0 & 1 & T \\ 0 & 0 & 1  \end{array} \right] * \left[ \begin{array}{c} x_{k-1} \\ \dot{x}{k-1} \\ \ddot{x}{k-1} \end{array} \right] + \upsilon_{k-1}
\end{equation}
and
\begin{equation}
\upsilon_{k-1} \sim N(0, Q)
\end{equation}
where,
$ Q = \sigma^2 * \left[ \begin{array}{ccc} \frac{T^4}{4} & \frac{T^3}{2} & \frac{T^2}{2} \\ \frac{T^3}{2} & 2T^3 & T^2 \\ \frac{T^2}{2} & T^2 & T^2  \end{array} \right] $, $\sigma$ represents intensity of Gaussian noise.

Targets are usually tracked with the help of sensors such as radars or lidars which provide the position of the target. Hence, the measurement equation can be written as:
\begin{equation}
y_k =
\left[ \begin{array}{ccc} 1 & 0 & 0 \end{array} \right] * \left[ \begin{array}{c} x_k \\ \dot{x}_k \\ \ddot{x}_k \end{array} \right] + \omega
\end{equation}
where, $y_k$ is the measurement and $\omega \sim N(0, R) $ is the measurement noise.

\hfill

For the given problem, obtain the estimate of its state over a period of $ 20 ~sec $. Assume time step $ T = 0.1 ~sec $.

\end{document}


\chapter{Fourier Transform}
\begin{enumerate}
	\item Let $F(k)$ is the Fourier exponential transform of $f(x)$ and $G(k)$ be the Fourier Transform of $g(x)=f(x+a)$. Then $G(k)$ is given by
	(Use the Fourier integral $F(k)=\frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{+\infty} f(x) e^{i k x} d x$ )
	 \begin{tasks}(2)
		\task[\textbf{a.}]$e^{i a k} f(k)$
		\task[\textbf{b.}]$e^{-i a k} F(-k)$
		\task[\textbf{c.}] $e^{-i a k} F(k)$
		\task[\textbf{d.}] $e^{-i a k} f(k)$
	\end{tasks}
	\item The value of a function is given by $f(x)=\left\{\begin{array}{cc}1 & 0<x<1 \\ -1 & 1<x<2 \\ 0 & x>2\end{array}\right.$, the Fourier cosine transform of $f(x)$ is
	 \begin{tasks}(2)
		\task[\textbf{a.}]$\sqrt{\frac{2}{\pi}}\left(\frac{2 \sin \omega+\sin 2 \omega}{\omega}\right)$
		\task[\textbf{b.}]$\sqrt{\frac{2}{\pi}}\left(\frac{2 \sin \omega-\sin 2 \omega}{\omega}\right)$
		\task[\textbf{c.}]$\sqrt{\frac{2}{\pi}}\left(\frac{\sin \omega-\sin 2 \omega}{\omega}\right)$
		\task[\textbf{d.}] $\sqrt{\frac{2}{\pi}}\left(\frac{2 \sin \omega}{\omega}\right)$
	\end{tasks}
	\item Consider the function $\delta_{n}(x)=\frac{n}{\sqrt{\pi}} \exp \left(-n^{2} x^{2}\right)$. For $n \rightarrow \infty$ The Fourier transform of the function is given by
	 \begin{tasks}(2)
		\task[\textbf{a.}]$\delta(x)=\int_{-\infty}^{+\infty} e^{-i k x} d k$
		\task[\textbf{b.}]$\delta(x)=\frac{1}{2 \pi} \int_{-\infty}^{+\infty} e^{i k x} d k$
		\task[\textbf{c.}]$\delta(x)=\frac{1}{2 \pi} \int_{-\infty}^{+\infty} e^{-i k x} d k$
		\task[\textbf{d.}] 0
	\end{tasks}
	\item For the function $f(t)=\delta(t-x)$, the Fourier cosine integral is defined as $g_{c}(\omega)=\sqrt{\frac{2}{\pi}} \int_{0}^{\infty} f(t) \cos \omega t d t$. Its Fourier transform is:
	 \begin{tasks}(2)
		\task[\textbf{a.}] $\sqrt{\frac{2}{\pi}} \cos \omega x$
		\task[\textbf{b.}]$\sqrt{\frac{2}{\pi}}$
		\task[\textbf{c.}]$\sqrt{\frac{2}{\pi}} \sin \omega x$
		\task[\textbf{d.}] $i \sqrt{\frac{2}{\pi}}$
	\end{tasks}
	\item Inverse cosine transform of $g_{c}(\omega)=\sqrt{\frac{2}{\pi}} \cos \omega x$ is:
	 \begin{tasks}(2)
		\task[\textbf{a.}]$\delta(t+x)$
		\task[\textbf{b.}]$\delta(t-x)$
		\task[\textbf{c.}]$\delta(t-x)(t+x)$
		\task[\textbf{d.}] $\delta^{2}(x-t)(x+t)$
	\end{tasks}
	\item $f(t)=\frac{\hbar}{2 \pi i} \int_{-\infty}^{+\infty} \frac{e^{-i \omega t} d \omega}{\left(E_{0}-i \Gamma / 2-\hbar \omega\right)}$ The value of $f(t)$ is given by
	 \begin{tasks}(2)
		\task[\textbf{a.}](a) $f(t)= \begin{cases}e^{-\Gamma t / 2 \hbar} e^{-i E_{0} t / \hbar} & , t>0 \\ 0 & , t<0\end{cases}$
		\task[\textbf{b.}]$f(t)= \begin{cases}e^{\sqrt{1 / 2 \hbar}} e^{-1 E_{0} t / \hbar} & , t>0 \\ 0 & , t<0\end{cases}$
		\task[\textbf{c.}]$f(t)= \begin{cases}e^{-\Gamma t / 2 \hbar} e^{-i E_{0} t / \hbar} & , t>0 \\ 0 & , t<0\end{cases}$
		\task[\textbf{d.}] $f(t)= \begin{cases}e^{-\Gamma t / 2 h} e^{-i E_{0} t / h} & , t>0 \\ e^{-i E_{0} t / \hbar} & , t<0\end{cases}$
	\end{tasks}
	\item The Fourier transform of function $h(t)=t e^{-t^{2}}$ is
	 \begin{tasks}(2)
		\task[\textbf{a.}] $j \pi f e^{-\pi^{2} f^{2}}$
		\task[\textbf{b.}]$-j \pi f e^{-\pi^{2} f^{2}}$
		\task[\textbf{c.}]$j \pi f e^{-\pi^{2} f^{2} / 4}$
		\task[\textbf{d.}] $-j \pi f e^{-\pi^{2} f^{2} / 4}$
	\end{tasks}
	\item The graph of a real periodic function $f(x)$ for the range $[-\infty, \infty]$ is shown below
	\begin{figure}[H]
		\centering
		\includegraphics[height=3cm,width=5cm]{FT-Assignment-05}
	\end{figure}
	Which of the following graphs represents the real part of its Fourier transform?
	 \begin{tasks}(2)
		\task[\textbf{a.}]
		\begin{figure}[H]
			\centering
			\includegraphics[height=2.2cm,width=3cm]{FT-Assignment-01}
		\end{figure}
		\task[\textbf{b.}]
			\begin{figure}[H]
			\centering
			\includegraphics[height=2.2cm,width=3cm]{FT-Assignment-02}
		\end{figure}
		\task[\textbf{c.}]
			\begin{figure}[H]
			\centering
			\includegraphics[height=2.2cm,width=3cm]{FT-Assignment-03}
		\end{figure}
		\task[\textbf{d.}]
			\begin{figure}[H]
			\centering
			\includegraphics[height=2.2cm,width=3cm]{FT-Assignment-04}
		\end{figure}
	\end{tasks}
	\item The Fourier transform of the function $h(t)=\left\{\begin{array}{cc}\beta e^{-a t}, & t>0 \\ 0, & t<0\end{array}\right.$, is given by
	 \begin{tasks}(2)
		\task[\textbf{a.}]$H(f)=\frac{\alpha}{\sqrt{\alpha^{2}+(2 \pi f)^{2}}} e^{j \tan ^{-1}\left[-2 \pi f^{\prime \alpha]}\right.}$
		\task[\textbf{b.}]$H(f)=\frac{\beta}{\sqrt{\alpha^{2}+(2 \pi f)^{2}}} e^{j \tan ^{-1}[-2 \pi f / \beta]}$
		\task[\textbf{c.}]$H(f)=\frac{\beta}{\sqrt{\alpha^{2}+(2 \pi f)^{2}}} e^{\tan ^{-1}[2 \pi f / \alpha]}$
		\task[\textbf{d.}] $H(f)=\frac{\beta}{\sqrt{\alpha^{2}+(2 \pi f)^{2}}} e^{j \tan ^{-1}[-2 \pi f / \alpha]}$
	\end{tasks}
	\item The Fourier transform of $f(x)=\left\{\begin{array}{cl}-1 & -1<x<0 \\ 1 & 0<x<1 \\ 0 & \text { otherwise }\end{array}\right.$ is
	 \begin{tasks}(2)
		\task[\textbf{a.}] $\frac{i}{\omega} \sqrt{\frac{2}{\pi}}(\cos \omega+1)$
		\task[\textbf{b.}] $\frac{i}{\omega} \sqrt{\frac{2}{\pi}}(\cos \omega-1)$
		\task[\textbf{c.}]$-\frac{i}{\omega} \sqrt{\frac{2}{\pi}}(1+\cos \omega)$
		\task[\textbf{d.}] $\frac{i}{\omega} \sqrt{\frac{2}{\pi}}(1-\cos \omega)$
	\end{tasks}
	\item The Fourier transform of $f(x)= \begin{cases}x, & 0<x<a \\ 0, & \text { otherwise }\end{cases}$ is
	 \begin{tasks}(2)
		\task[\textbf{a.}]$\frac{1}{\sqrt{2 \pi} \cdot \omega^{2}}\left[e^{-i \omega n a}(1+i a \omega)-1\right]$
		\task[\textbf{b.}]$\frac{1}{\sqrt{2 \pi} \cdot \omega^{2}}\left[e^{-i \omega a}(1-i a \omega)-1\right]$
		\task[\textbf{c.}] $\frac{1}{\sqrt{2 \pi} \cdot \omega^{2}}\left[e^{-1 \text { tox }}(1+i a \omega)+1\right]$
		\task[\textbf{d.}] $\frac{1}{\sqrt{2 \pi} \cdot \omega^{2}}\left[e^{-i \omega a}(1-i a \omega)+1\right]$
	\end{tasks}

\end{enumerate}

CSIR- Mathematical Physics/chapter/Assignments/Assignment-Fourier Transform.tex


\chapter{Unique factorization (finally!)}
Took long enough.

\section{Motivation}
Suppose we're interested in solutions to the
Diophantine equation $n = x^2 + 5y^2$ for a given $n$.
The idea is to try and ``factor'' $n$ in $\ZZ[\sqrt{-5}]$,
for example \[ 6 = (1+\sqrt{-5})(1-\sqrt{-5}). \]
Unfortunately, this is not so simple, because as I've said before
we don't have unique factorization of elements:
\[ 6 = 2 \cdot 3 = \left( 1+\sqrt{-5} \right)\left( 1-\sqrt{-5} \right). \]
One reason this doesn't work is that we don't have a notion of a
\emph{greatest common divisor}.
We can write $(35, 77) = 7$, but what do we make of $(3, 1+\sqrt{-5})$?

The trick is to use ideals as a ``generalized GCD''.
Recall that by $(a,b)$ I mean the ideal $\{ax + by \mid x,y \in \ZZ[\sqrt{-5}] \}$.
You can see that $(35, 77) = (7)$,
but $(3, 1+\sqrt{-5})$ will be left ``unsimplified'' because it doesn't
represent an actual value in the ring.
Using these \emph{sets} (ideals) as elements,
it turns out that we can develop a full theory
of prime factorization, and we do so in this chapter.

In other words, we use the ideal $(a_1, \dots, a_m)$
to interpret a ``generalized GCD'' of $a_1$, \dots, $a_m$.
In particular, if we have a number $x$ we want to represent,
we encode it as just $(x)$.

Going back to our example of $6$,
\[ (6) = (2) \cdot (3)
	= \left( 1+\sqrt{-5} \right) \cdot \left( 1-\sqrt{-5} \right). \]
Please take my word for it that in fact,
the complete prime factorization of $(6)$ into prime ideals is
\[
	(6)
	= (2,1-\sqrt{-5})^2 (3,1+\sqrt{-5})(3,1-\sqrt{-5})
	= \kp^2 \kq_1 \kq_2. \]
In fact, $(2) = \kp^2$, $(3) = \kq_1 \kq_2$,
$(1+\sqrt{-5}) = \kp \kq_1$, $(1-\sqrt{-5}) = \kp \kq_2$.
So $6$ indeed factorizes uniquely into ideals,
even though it doesn't factor into elements.

As one can see above,
ideal factorization is more refined than element factorization.
Once you have the factorization into \emph{ideals},
you can from there recover all the factorizations into \emph{elements}.
The upshot of this is that if we want to write $n$ as $x^2+5y^2$,
we just have to factor $n$ into ideals,
and from there we can recover all factorizations into elements,
and finally all ways to write $n$ as $x^2+5y^2$.
Since we can already break $n$ into rational prime factors
(for example $6 = 2 \cdot 3$ above)
we just have to figure out how each rational prime $p \mid n$ breaks down.
There's a recipe for this, \Cref{thm:factor_alg}!
In fact, I'll even tell you what is says in this special case:
\begin{itemize}
	\ii If $t^2+5$ factors as $(t+c)(t-c) \pmod p$,
	then $(p) = (p, c+\sqrt{-5})(p, c-\sqrt{-5})$.
	\ii Otherwise, $(p)$ is a prime ideal.
\end{itemize}
In this chapter we'll develop this theory of unique factorization in full generality.

%We saw earlier that in rings, such as $\ZZ[\sqrt{-5}]$, unique factorization can fail:
%\[ 6 = 2 \cdot 3 = \left( 1 - \sqrt{-5} \right)\left( 1 + \sqrt{5} \right). \]
%I mentioned that we thus turned to the notion of \emph{ideals},
%and defined the notion of a prime ideal.
%Then I said
%\begin{quote}
%	I now must regrettably inform you that prime factorization is still
%	not true even with the notion of a ``prime'' ideal
%	(though not I haven't told you how to multiply two ideals yet).
%	But it will work in the situations we care about most:
%	this is covered in the chapter on Dedekind domains.
%\end{quote}
%I can be precise about what's going to happen now.
%We'll define a Dedekind domain, which in particular includes all rings of integers $\OO_K$.
%Then prime factorization will work in Dedekind domains, and we'll throw a small party.

\begin{remark}
	In this chapter, I'll be using the letters $\ka$, $\kb$, $\kp$, $\kq$
	for ideals of $\OO_K$.
	When fractional ideals arise, I'll use $I$ and $J$ for them.
\end{remark}

\section{Ideal arithmetic}
\prototype{$(x)(y) = (xy)$. In any case, think in terms of generators.}
First, I have to tell you how to add and multiply two ideals $\ka$ and $\kb$.
\begin{definition}
	Given two ideals $\ka$ and $\kb$ of a ring $R$, we define
	\begin{align*}
		\ka + \kb &\defeq \left\{ a+b \mid a \in \ka, b \in \kb \right\} \\
		\ka \cdot \kb &\defeq \left\{ a_1b_1 + \dots + a_n b_n
			\mid a_i \in \ka, b_i \in \kb \right\}.
	\end{align*}
\end{definition}
(Note that infinite sums don't make sense in general rings, which is why in $\ka \cdot \kb$
we cut off the sum after some finite number of terms.)
You can readily check these are actually ideals.
This definition is more natural if you think about it in terms of
the generators of $\ka$ and $\kb$.
\begin{proposition}[Ideal arithmetic via generators]
	Suppose $\ka = \left( a_1, a_2, \dots, a_n \right)$
	and $\kb = \left( b_1, \dots, b_m \right)$ are ideals in a ring $R$.
	Then
	\begin{enumerate}[(a)]
		\ii $\ka + \kb$ is the ideal generated by $a_1, \dots, a_n, b_1, \dots, b_m$.
		\ii $\ka \cdot \kb$ is the ideal generated by $a_i b_j$,
		for $1 \le i \le n$ and $1 \le j \le m$.
	\end{enumerate}
\end{proposition}
\begin{proof}
	Pretty straightforward; just convince yourself that this result is correct.
\end{proof}
In other words, for sums you append the two sets of generators together,
and for products you take products of the generators.
Note that for principal ideals, this coincides with ``normal'' multiplication,
for example
\[ (3) \cdot (5) = (15) \]
in $\ZZ$.
\begin{remark}
Note that for an ideal $\ka$ and an element $c$,
the set \[ c \ka = \left\{ ca \mid a \in \ka \right\} \]
is equal to $(c) \cdot \ka$.
So ``scaling'' and ``multiplying by principal ideals'' are the same thing.
This is important, since we'll be using the two notions interchangably.
\end{remark}

Finally, since we want to do factorization we better have some notion of divisibility.
So we define:
\begin{definition}
	We say $\ka$ divides $\kb$ and write $\ka \mid \kb$ if $\ka \supseteq \kb$.
\end{definition}
Note the reversal of inclusions!
So $(3)$ divides $(15)$, because $(15)$ is contained in $(3)$;
every multiple of $15$ is a multiple of $3$.

Finally, the \vocab{prime ideals} are defined as in \Cref{def:prime_ideal}:
$\kp$ is prime if $xy \in \kp$ implies $x \in \kp$ or $y \in \kp$.
This is compatible with the definition of divisibility:
\begin{exercise}
	A nonzero proper ideal $\kp$ is prime
	if and only if whenever $\kp$ divides $\ka \kb$,
	$\kp$ divides one of $\ka$ or $\kb$.
\end{exercise}
As mentioned in \Cref{rem:unit_sign_issue},
this also lets us ignore multiplication by units: $(-3) = (3)$.

\section{Dedekind domains}
\prototype{Any $\OO_K$ is a Dedekind domain.}
We now define a Dedekind domain as follows.
\begin{definition}
	An integral domain $\mathcal A$ is a \vocab{Dedekind domain}
	if it is Noetherian, integrally closed, and
	\emph{every nonzero prime ideal of $\mathcal A$ is in fact maximal}.
	(The last condition is the important one.)
\end{definition}
Here there's one new word I have to define for you, but we won't make much use of it.
\begin{definition}
	Let $R$ be an integral domain and let $K$ be its field of fractions.
	We say $R$ is \vocab{integrally closed} if
	the only elements $a \in K$ which are roots of \emph{monic} polynomials in $R$
	are the elements of $R$ (which are roots of the trivial $x-r$ polynomial).
\end{definition}
The \emph{interesting} condition in the definition
of a Dedekind domain is the last one: prime ideals and maximal ideals
are the same thing.
The other conditions are just technicalities,
but ``primes are maximal'' has real substance.
\begin{example}[$\ZZ$ is a Dedekind domain]
	The ring $\ZZ$ is a Dedekind domain.
	Note that
	\begin{itemize}
		\ii $\ZZ$ is Noetherian (for obvious reasons).
		\ii $\ZZ$ has field of fractions $\QQ$.
		If $f(x) \in \ZZ[x]$ is monic, then by the rational root theorem
		any rational roots are integers
		(this is the same as the proof that $\ol\ZZ \cap \QQ = \ZZ$).
		Hence $\ZZ$ is integrally closed.
		\ii The nonzero prime ideals of $\ZZ$ are $(p)$,
		which also happen to be maximal.
	\end{itemize}
\end{example}

The case of interest is a ring $\OO_K$ in which we wish to do factorizing.
We're now going to show that for any number field $K$, the ring $\OO_K$ is a Dedekind domain.
First, the boring part.
\begin{proposition}[$\OO_K$ integrally closed and Noetherian]
	For any number field $K$, the ring $\OO_K$ is integrally closed and Noetherian.
\end{proposition}
\begin{proof}
	Boring, but here it is anyways for completeness.

	Since $\OO_K \cong \ZZ^{\oplus n}$, we get that it's Noetherian.

	Now we show that $\OO_K$ is integrally closed.
	Suppose that $\eta \in K$ is the root of some polynomial with coefficients in $\OO_K$.
	Thus
	\[ \eta^n = \alpha_{n-1} \cdot \eta^{n-1} + \alpha_{n-2} \cdot \eta^{n-2}
		+ \dots + \alpha_0 \]
	where $\alpha_i \in \OO_K$. We want to show that $\eta \in \OO_K$ as well.

	Well, from the above, $\OO_K[\eta]$ is finitely generated\dots
	thus $\ZZ[\eta] \subseteq \OO_K[\eta]$ is finitely generated.
	So $\eta \in \ol\ZZ$, and hence $\eta \in K \cap \ol\ZZ = \OO_K$.
\end{proof}
Now let's do the fun part.
We'll prove a stronger result, which will re-appear repeatedly.
\begin{theorem}[Important: prime ideals divide rational primes]
	Let $\OO_K$ be a ring of integers
	and $\kp$ a nonzero prime ideal inside it.
	Then $\kp$ contains a rational prime $p$.
	Moreover, $\kp$ is maximal.
\end{theorem}
\begin{proof}
	Take any $\alpha \neq 0$ in $\kp$.
	Its Galois conjugates are algebraic integers
	so their product $\Norm(\alpha)/\alpha$ is in $\OO_K$
	(even though each individual conjugate need not be in $K$).
	Consequently, $\Norm(\alpha) \in \kp$,
	and we conclude $\kp$ contains some integer.

	Then take the smallest positive integer in $\kp$, say $p$.
	We must have that $p$ is a rational prime, since otherwise $\kp \ni p = xy$
	implies one of $x,y \in \kp$.
	This shows the first part.

	We now do something pretty tricky to show $\kp$ is maximal.
	Look at $\OO_K / \kp$;
	since $\kp$ is prime it's supposed to be an integral domain\dots\
	but we claim that it's actually finite!
	To do this, we forget that we can multiply on $\OO_K$.
	Recalling that $\OO_K \cong \ZZ^{\oplus n}$ as an abelian group,
	we obtain a map
	\[ {\FF_p}^{\oplus n} \cong \OO_K / (p) \surjto \OO_K / \kp. \]
	Hence $\left\lvert \OO_K / \kp \right\rvert \le p^n$ is \emph{finite}.
	Since finite integral domains are fields (\Cref{prob:finite_domain_field})
	we are done.
\end{proof}
Since every nonzero prime $\kp$ is maximal, we now know that $\OO_K$ is a Dedekind domain.
Note that this tricky proof is essentially inspired by the solution to \Cref{prob:dedekind_sample}.

\section{Unique factorization works}
Okay, I'll just say it now!
\begin{moral}
	Unique factorization works perfectly in Dedekind domains!
\end{moral}
\begin{theorem}[Prime factorization works]
	Let $\ka$ be a nonzero proper ideal of a Dedekind domain $\mathcal A$.
	Then $\ka$ can be written as a finite product of nonzero prime ideals $\kp_i$, say
	\[ \ka = \kp_1^{e_1} \kp_2^{e_2} \dots \kp_g^{e_g} \]
	and this factorization is unique up to the order of the $\kp_i$.

	Moreover, $\ka$ divides $\kb$ if and only if for every prime ideal $\kp$,
	the exponent of $\kp$ in $\ka$ is less than the corresponding exponent in $\kb$.
\end{theorem}
%% Ofer joke
% As ideals, you and I are coprime because together we are (1).

I won't write out the proof, but I'll describe the basic method of attack.
Section 3 of \cite{ref:ullery} does a nice job of explaining it.
When we proved the fundamental theorem of arithmetic, the basic plot was:
\begin{enumerate}[(1)]
	\ii Show that if $p$ is a rational prime\footnote{
		Note that the kindergarten definition of a prime is
		that ``$p$ isn't the product of two smaller integers''.
		This isn't the correct definition of a prime:
		the definition of a prime is that $p \mid bc$
		means $p \mid b$ or $p \mid c$.
		The kindergarten definition is something called ``irreducible''.
		Fortunately, in $\ZZ$, primes and irreducibles are the same thing,
		so no one ever told you that your definition of ``prime'' was wrong.}
	then $p \mid bc$ means $p \mid b$ or $p \mid c$.  (This is called Euclid's Lemma.)
	\ii Use strong induction to show that every $N > 1$ can be written as the product of primes (easy).
	\ii Show that if $p_1 \dots p_m = q_1 \dots q_n$ for some primes (not necessarily unique),
	then $p_1 = q_i$ for some $i$, say $q_1$.
	\ii Divide both sides by $p_1$ and use induction.
\end{enumerate}
What happens if we try to repeat the proof here?
We get step 1 for free, because we're using a better definition of ``prime''.
We can also do step 3, since it follows from step 1.
But step 2 doesn't work,
because for abstract Dedekind domains
we don't really have a notion of size.
And step 4 doesn't work because we don't yet have a
notion of what the inverse of a prime ideal is.

Well, it turns out that we \emph{can} define the inverse $\ka\inv$ of an ideal,
and I'll do so by the end of this chapter.
You then need to check that $\ka \cdot \ka\inv = (1) = \mathcal A$.
In fact, even this isn't easy.
You have to check it's true for prime ideals $\kp$,
\emph{then} prove prime factorization,
and then prove that this is true.
Moreover, $\ka\inv$ is not actually an ideal, so you need to
work in the field of fractions $K$ instead of $\mathcal A$.

So the main steps in the new situation are as follows:
\begin{enumerate}[(1)]
	\ii First, show that every ideal $\ka$ divides $\kp_1 \dots \kp_g$
	for some finite collection of primes.
	(This is an application of Zorn's Lemma.)
	\ii Define $\kp\inv$ and show that $\kp \kp\inv = (1)$.
	\ii Show that a factorization exists (again using Zorn's Lemma).
	\ii Show that it's unique, using the new inverse we've defined.
\end{enumerate}

Finally, let me comment on how nice this is if $\mathcal A$ is a PID (like $\ZZ$).
Thus every element $a \in \mathcal A$ is in direct correspondence with an ideal $(a)$.
Now suppose $(a)$ factors as a product of ideals $\kp_i = (p_i)$, say,
\[ (a) = (p_1)^{e_1} (p_2)^{e_2} \dots (p_n)^{e_n} . \]
This verbatim reads \[ a = u p_1^{e_1} p_2^{e_2} \dots p_n^{e_n} \]
where $u$ is some unit (recall \Cref{def:unit}).
Hence, Dedekind domains which are PID's satisfy unique factorization
for \emph{elements}, just like in $\ZZ$.
(In fact, the converse of this is true.)

\section{The factoring algorithm}
Let's look at some examples from quadratic fields.
Recall that if $K = \QQ(\sqrt{d})$, then
\[
	\OO_K =
	\begin{cases}
		\ZZ[\sqrt d] & d \equiv 2,3 \pmod 4 \\
		\ZZ\left[ \frac{1+\sqrt d}{2} \right] & d \equiv 1 \pmod 4.
	\end{cases}
\]
Also, recall that the norm of $a+b\sqrt{-d}$ is given by $a^2+db^2$.

%In what follows, we are going to often use the trick that
%\[ \ZZ[\alpha] \cong \ZZ[x] / (f) \]
%where $f$ is the minimal polynomial of $\alpha$.

\begin{example}[Factoring $6$ in the integers of $\QQ(\sqrt{-5})$]
	Let $\OO_K = \ZZ[\sqrt{-5}]$ arise from $K = \QQ(\sqrt{-5})$.
	We've already seen that
	\[ (6) = (2) \cdot (3) = \left( 1+\sqrt{-5} \right)\left( 1-\sqrt{-5} \right) \]
	and you can't get any further with these principal ideals.
	But let
	\[ \kp = \left( 1+\sqrt{-5}, 2 \right) = \left( 1-\sqrt{-5}, 2 \right)
		\quad\text{and}\quad \kq_1 = (1+\sqrt{-5},3),
		\; \kq_2 = (1-\sqrt{-5},3). \]
	Then it turns out $(6) = \kp^2\kq_1\kq_2$.
	More specifically, $(2) = \kp^2$, $(3) = \kq_1\kq_2$,
	and $(1+\sqrt{-5}) = \kp\kq_1$ and $(1-\sqrt{-5}) = \kp\kq_2$.
	(Proof in just a moment.)
\end{example}
I want to stress that all our ideals are computed relative to $\OO_K$.
So for example, \[ (2) = \left\{ 2x \mid x \in \OO_K \right\}. \]

How do we know in this example that $\kp$ is prime/maximal?
(Again, these are the same since we're in a Dedekind domain.)
Answer: look at $\OO_K / \kp$ and see if it's a field.
There is a trick to this: we can express
\[ \OO_K = \ZZ[\sqrt{-5}] \cong \ZZ[x] / (x^2+5). \]
%\begin{ques}
%	Convince yourself this is true.
%	(More generally, if $\theta \in \ol\ZZ$ has minimal polynomial $p$,
%	then $\ZZ[\theta] \cong \ZZ[x] / (p)$).
%\end{ques}
So when we take \emph{that} mod $\kp$, we get that
\[ \OO_K / \kp = \ZZ[x] / (x^2+5, 2, 1+x) \cong \FF_2[x] / (x^2+5,x+1) \]
as rings.
\begin{ques}
	Conclude that $\OO_K / \kp \cong \mathbb F_2$,
	and satisfy yourself that $\kq_1$ and $\kq_2$ are also maximal.
\end{ques}
I should give an explicit example of an ideal multiplication: let's compute
\begin{align*}
	\kq_1\kq_2 &= \left( (1+\sqrt{-5})(1-\sqrt{-5}), 3(1+\sqrt{-5}), 3(1-\sqrt{-5}), 9 \right) \\
	&= \left( 6, 3+3\sqrt{-5}, 3-3\sqrt{-5}, 9 \right) \\
	&= \left( 6, 3+3\sqrt{-5}, 3-3\sqrt{-5}, 3 \right) \\
	&= (3)
\end{align*}
where we first did $9-6=3$ (think Euclidean algorithm!),
then noted that all the other generators don't contribute
anything we don't already have with the $3$
(again these are ideals computed in $\OO_K$).
You can do the computation for $\kp^2$, $\kp\kq_1$, $\kp\kq_2$ in the same way.

Finally, it's worth pointing out that we should quickly
verify that $\kp \neq (x)$ for some $x$;
in other words, that $\kp$ is not principal.
Assume for contradiction that it is.
Then $x$ divides both $1+\sqrt{-5}$ and $2$, in the sense
that $1+\sqrt{-5} = \alpha_1 x$ and $2 = \alpha_2 x$
for some $\alpha_1, \alpha_2 \in \OO_K$.
(Principal ideals are exactly the ``multiples'' of $x$, so $(x) = x \OO_K$.)
Taking the norms, we find that $\Norm_{K/\QQ}(x)$ divides both
\[ \Norm_{K/\QQ}(1+\sqrt{-5}) = 6 \quad\text{and}\quad \Norm_{K/\QQ}(2) = 4. \]
Since $\kp \neq (1)$, $x$ cannot be a unit, so its norm must be $2$.
But there are no elements of norm $2 = a^2+5b^2$ in $\OO_K$.

\begin{example}[Factoring $3$ in the integers of $\QQ(\sqrt{-17})$]
	Let $\OO_K = \ZZ[\sqrt{-17}]$ arise from $K = \QQ(\sqrt{-17})$.
	We know $\OO_K \cong \ZZ[x] / (x^2+17)$.
	Now
	\[
		\OO_K / 3\OO_K \cong \ZZ[x] / (3,x^2+17)
		\cong \FF_3[x] / (x^2-1).
	\]
	This already shows that $(3)$ cannot be a prime (i.e.\ maximal) ideal,
	since otherwise our result should be a field.
	Anyways, we have a projection
	\[ \OO_K \surjto \FF_3[x] / \left( (x-1)(x+1) \right). \]
	Let $\kq_1$ be the pre-image of $(x-1)$ in the image, that is,
	\[ \kq_1 = (3, \sqrt{-17}-1). \]
	Similarly, \[ \kq_2 = (3, \sqrt{-17}+1). \]
	We have $\OO_K / \kq_1 \cong \FF_3$, so $\kq_1$ is maximal (prime).
	Similarly $\kq_2$ is prime.
	Magically, you can check explicitly that
	\[ \kq_1 \kq_2 = (3). \]
	Hence this is the factorization of $(3)$ into prime ideals.
\end{example}

The fact that $\kq_1 \kq_2 = (3)$ looks magical, but it's really true:
\begin{align*}
	\kq_1\kq_2
	&= (3, \sqrt{-17}-1) (3, \sqrt{-17}+1) \\
	&= (9, 3\sqrt{-17}+3, 3\sqrt{-17}-3, 18) \\
	&= (9, 3\sqrt{-17}+3, 6) \\
	&= (3, 3\sqrt{-17}+3, 6) \\
	&= (3).
\end{align*}
In fact, it turns out this always works in general:
given a rational prime $p$, there is an algorithm
to factor $p$ in any $\OO_K$ of the form $\ZZ[\theta]$.

\begin{theorem}[Factoring algorithm / Dedekind-Kummer theorem]
	\label{thm:factor_alg}
	Let $K$ be a number field.
	Let $\theta \in \OO_K$ with $[\OO_K : \ZZ[\theta]] = j < \infty$,
	and let $p$ be a prime not dividing $j$.
	Then $(p) = p \OO_K$ is factored as follows:
	\begin{quote}
		Let $f$ be the minimal polynomial of $\theta$ and
		factor $\ol f$ mod $p$ as
		\[ \ol f \equiv \prod_{i=1}^g (\ol f_i)^{e_i} \pmod p. \]
		Then $\kp_i = (f_i(\theta), p)$ is prime for each $i$
		and the factorization of $(p)$ is
		\[ \OO_K \supseteq (p) = \prod_{i=1}^g \kp_i^{e_i}. \]
	\end{quote}
	In particular, if $K$ is monogenic with $\OO_K = \ZZ[\theta]$ then $j=1$
	and the theorem applies for all primes $p$.
\end{theorem}
In almost all our applications in this book, $K$ will be monogenic; i.e.\ $j=1$.
Here $\ol \psi$ denotes the image in $\FF_p[x]$ of a polynomial $\psi \in \ZZ[x]$.

\begin{ques}
	There are many possible pre-images $f_i$ we could have chosen
	(for example if $\ol{f_i} = x^2+1 \pmod 3$, we could pick $f_i = x^2 + 3x + 7$.)
	Why does this not affect the value of $\kp_i$?
\end{ques}

Note that earlier, we could check the factorization worked
for any particular case.
The proof that this works is much the same, but we need one extra tool, the ideal norm.
After that we leave the proposition as \Cref{prob:prove_factoring_algorithm}.

This algorithm gives us a concrete way to compute prime factorizations of $(p)$
in any monogenic number field with $\OO_K = \ZZ[\theta]$. To summarize the recipe:
\begin{enumerate}
	\ii Find the minimal polynomial of $\theta$, say $f \in \ZZ[x]$.
	\ii Factor $f$ mod $p$ into irreducible polynomials
	${\ol f_1}^{e_1} {\ol f_2}^{e_2} \dots {\ol f_g}^{e_g}$.
	\ii Compute $\kp_i = (f_i(\theta), p)$ for each $i$.
\end{enumerate}
Then your $(p) = \kp_1^{e_1} \dots \kp_g^{e_g}$.

\begin{exercise}
	Factor $(29)$ in $\QQ(i)$ using the above algorithm.
\end{exercise}

%\begin{remark}
%	What if $K$ isn't monogenic?
%	It turns out that we can still apply the
%	factoring algorithm to ``almost all primes'' as follows.
%	Suppose $K$ is a number field and $\alpha \in \OO_K$ such that
%	$[\OO_K : \ZZ[\alpha]] = j < \infty$.
%	Then as long as $p \nmid j$, we can apply the above algorithm
%	with $f$ the minimal polynomial of $\alpha$.
%	The formulation we presented above was the special case where $j=1$.
%\end{remark}

\section{Fractional ideals}
\prototype{Analog to $\QQ$ for $\ZZ$, allowing us to take inverses of ideals.
Prime factorization works in the nicest way possible.}
We now have a neat theory of factoring ideals of $\mathcal A$,
just like factoring the integers.
Now note that our factorization of $\ZZ$ naturally gives a way to factor
elements of $\QQ$; just factor the numerator and denominator separately.

Let's make the analogy clearer.
The analogue of a rational number is as follows.

\begin{definition}
	Let $\mathcal A$ be a Dedekind domain with field of fractions $K$.
	A \vocab{fractional ideal} $J$ of $K$ is a set of the form
	\[ J = \frac{1}{x} \cdot \ka \quad \text{where $x \in \mathcal A$, and $\ka$ is an integral ideal.} \]
	For emphasis, ideals of $\mathcal A$ will be sometimes referred to as \vocab{integral ideals}.
\end{definition}

You might be a little surprised by this definition:
one would expect that a fractional ideal should be of the form $\frac{\ka}{\kb}$
for some integral ideals $\ka$, $\kb$.
But in fact, it suffices to just take $x \in \mathcal A$ in the denominator.
The analogy is that when we looked at $\OO_K$, we found that we only needed
integer denominators: $\frac{1}{4-\sqrt3} = \frac{1}{13}(4+\sqrt3)$.
Similarly here, it will turn out that we only need to look at $\frac1x \cdot \ka$
rather than $\frac{\ka}{\kb}$, and so we define it this way from the beginning.
See \Cref{prob:fractional_ideal_alt_def} for a different equivalent definition.

\begin{example}[$\frac52\ZZ$ is a fractional ideal]
	The set \[ \frac52 \ZZ = \left\{ \frac52n \mid n \in \ZZ \right\} = \half (5) \]
	is a fractional ideal of $\ZZ$.
\end{example}

Now, as we prescribed, the fractional ideals form a multiplicative group:
\begin{theorem}[Fractional ideals form a group]
	Let $\mathcal A$ be a Dedekind domain and $K$ its field of fractions.
	For any integral ideal $\ka$, the set
	\[ \ka\inv = \left\{ x \in K
			\mid x\ka \subseteq (1) = \mathcal A \right\} \]
	is a fractional ideal with $\ka \ka\inv = (1)$.
\end{theorem}
\begin{definition}
	Thus nonzero fractional ideals of $K$ form a group under multiplication
	with identity $(1) = \mathcal A$.
	This \vocab{ideal group} is denoted $J_K$.
\end{definition}

\begin{example}[$(3)\inv$ in $\ZZ$]
	Please check that in $\ZZ$ we have
	\[ (3)\inv = \left\{ \frac 13 n \mid n \in \ZZ \right\} = \frac 13 \ZZ. \]
\end{example}

It follows that every fractional ideal $J$ can be uniquely written as
\[ J = \prod_i \kp_i^{n_i} \cdot \prod \kq_i^{-m_i} \]
where $n_i$ and $m_i$ are positive integers.
In fact, $\ka$ is an integral ideal if and only if all its exponents are nonnegative,
just like the case with integers.
So, a perhaps better way to think about fractional ideals is
as products of prime ideals, possibly with negative exponents.

\section{The ideal norm}
One last tool is the ideal norm,
which gives us a notion of the ``size'' of an ideal.
\begin{definition}
	The \vocab{ideal norm} (or absolute norm)
	of a nonzero ideal $\ka \subseteq \OO_K$ is defined as
	$\left\lvert \OO_K / \ka \right\rvert$ and denoted $\Norm(\ka)$.
\end{definition}
\begin{example}[Ideal norm of $(5)$ in the Gaussian integers]
	Let $K = \QQ(i)$, $\OO_K = \ZZ[i]$.
	Consider the ideal $(5)$ in $\OO_K$.
	We have that
	\[ \OO_K / (5) \cong \{ a+bi \mid a,b \in \Zc5 \} \]
	so $(5)$ has ideal norm $25$,
	corresponding to the fact that $\OO_K/(5)$ has $5^2=25$ elements.
\end{example}

\begin{example}[Ideal norm of $(2+i)$ in the Gaussian integers]
	You'll notice that \[ \OO_K / (2+i) \cong \FF_5 \]
	since mod $2+i$ we have both $5 \equiv 0$ and $i \equiv -2$.
	(Indeed, since $(2+i)$ is prime we had better get a field!)
	Thus $\Norm\left( (2+i) \right) = 5$; similarly $\Norm\left( (2-i) \right) = 5$.
\end{example}

Thus the ideal norm measures how ``roomy'' the ideal is:
that is, $(5)$ is a lot more spaced out in $\ZZ[i]$ than it is in $\ZZ$.
(This intuition will be important when we will actually view $\OO_K$ as a lattice.)

\begin{ques}
	What are the ideals with ideal norm one?
\end{ques}
% Regrettably, ideals with more elements have smaller norms.

Our example with $(5)$ suggests several properties of the ideal norm
which turn out to be true:
\begin{lemma}[Properties of the absolute norm]
	Let $\ka$ be a nonzero ideal of $\OO_K$.
	\begin{enumerate}[(a)]
		\ii $\Norm(\ka)$ is finite.
		\ii For any other nonzero ideal $\kb$, $\Norm(\ka\kb) = \Norm(\ka)\Norm(\kb)$.
		\ii If $\ka = (a)$ is principal, then $\Norm(\ka) = \Norm_{K/\QQ}(a)$.
		% \ii The ideal norm $\Norm(\ka)$ equals the GCD of $\Norm_{K/\QQ}(\alpha)$ across
		% all $\alpha \in \ka$. In particular, if $\ka = (\alpha)$ is principal
		% then $\Norm(\ka) = \Norm_{K/\QQ}(\alpha)$.
	\end{enumerate}
\end{lemma}
I unfortunately won't prove these properties, though we already did (a) in our proof that $\OO_K$
was a Dedekind domain.
% Anyways, this lemma provides another way to show an ideal isn't principal.

%\begin{example}[Example of an Ideal Norm]
%	Let $K = \QQ(\sqrt 3)$, so $\OO_K = \ZZ[\sqrt 3]$.
%	% \ii The norm of the principal ideal $(4+\sqrt 3)$ is the norm of the element, $(4+\sqrt3)(4-\sqrt3) = 13$.
%	% \ii
%	Consider $\ka = (2, \sqrt3)$.
%		We need to have
%		\[ \Norm(\ka) \mid \gcd(\Norm_{K/\QQ}(2), \Norm_{K/\QQ}(3)) = \gcd(4, 3) = 1. \]
%		So in fact, $\Norm(\ka) = 1$. Surprise!
%		This actually means $\ka = (1)$,
%		which in hindsight also follows from the fact that
%		$\sqrt 3 \in \ka$, thus $\sqrt 3 \cdot \sqrt 3 \in \ka$ and $3 \in \ka$;
%		but $2 \in \ka$ so $1 \in \ka$.
%\end{example}

The fact that $\Norm$ is completely multiplicative lets us also consider the norm
of a fractional ideal $J$ by the natural extension
\[ J = \prod_i \kp_i^{n_i} \cdot \prod_i \kq_i^{-m_i}
	\quad \implies \quad
	\Norm(J) \defeq \frac{\prod_i \Norm(\kp_i)^{n_i}}{\prod_i \Norm(\kq_i)^{m_i}}. \]
Thus $\Norm$ is a natural group homomorphism $J_K \to \QQ \setminus \{0\}$.

\section\problemhead
\begin{problem}
	Show that there are three different factorizations of $77$ in $\OO_K$,
	where $K = \QQ(\sqrt{-13})$.
\end{problem}

\begin{problem}
	Let $K = \QQ(\cbrt 2)$;
	take for granted that $\OO_K = \ZZ[\cbrt 2]$.
	Find the factorization of $(5)$ in $\OO_K$.
\end{problem}

\begin{problem}
	[Fermat's little theorem]
	Let $\kp$ be a prime ideal in some ring of integers $\OO_K$.
	Show that for $\alpha \in \OO_K$,
	\[ \alpha^{\Norm(\kp)} \equiv \alpha \pmod{\kp}. \]
	\begin{hint}
		Copy the proof of the usual Fermat's little theorem.
	\end{hint}
	\begin{sol}
		If $\alpha \equiv 0 \pmod{\kp}$ it's clear, so assume this isn't the case.
		Then $\OO_K/\kp$ is a finite field with $\Norm(\kp)$ elements.
		Looking at $(\OO_K/\kp)^\ast$, it's a multiplicative group with $\Norm(\kp)-1$ elements,
		so $\alpha^{\Norm(\kp)-1} \equiv 1 \pmod{\kp}$, as desired.
	\end{sol}
\end{problem}

\begin{dproblem}
	Let $\mathcal A$ be a Dedekind domain with field of fractions $K$,
	and pick $J \subseteq K$.
	Show that $J$ is a fractional ideal if and only if
	\begin{enumerate}[(i)]
		\ii $J$ is closed under addition and multiplication
		by elements of $\mathcal A$, and
		\ii $J$ is finitely generated as an abelian group.
	\end{enumerate}
	More succinctly: $J$ is a fractional ideal $\iff$ $J$ is a finitely generated $\mathcal A$-module.
	\label{prob:fractional_ideal_alt_def}
	\begin{hint}
		Clear denominators!
	\end{hint}
	\begin{sol}
		Suppose it's generated by some elements in $K$; we can write them as
		$\frac{\beta_i}{\alpha_i}$ for $\alpha_i, \beta_i \in \mathcal A$.
		Hence
		\[ J = \left\{ \sum_i \gamma_i \cdot \frac{\beta_i}{\alpha_i}
		\mid \alpha_i, \beta_i, \gamma_i \in \OO_K \right\}. \]
		Now ``clear denominators''. Set $\alpha = \alpha_1 \dots \alpha_n$,
		and show that $\alpha J$ is an integral ideal.
	\end{sol}
\end{dproblem}

\begin{problem}
	\label{prob:prove_factoring_algorithm}
	In the notation of \Cref{thm:factor_alg}, let $I = \prod_{i=1}^g \kp_i^{e_i}$.
	Assume for simplicity that $K$ is monogenic, hence $\OO_K = \ZZ[\theta]$.
	\begin{enumerate}[(a)]
		\ii Prove that each $\kp_i$ is prime.
		\ii Show that $(p)$ divides $I$.
		\ii Use the norm to show that $(p) = I$.
	\end{enumerate}
	\begin{hint}
		(a) is straightforward.
		For (b) work mod $p$.
		For (c) use norms.
	\end{hint}
	\begin{sol}
	For part (a), note that the $\kp_i$ are prime
	just because
	\[ \OO_K / \kp_i
		\cong (\ZZ[x] / f) / (p, f_i)
		\cong \FF_p[x] / (f_i) \]
	is a field, since the $f_i$ are irreducible.

	We check (b).
		Computing the product modulo $p$ yields\footnote{%
			For example, suppose we want to know that $(3, 1+\sqrt{7})(3, 1-\sqrt{7})$ is contained in $(3)$.
			We could do the full computation and get $(9, 3+3\sqrt{7}, 3-3\sqrt{7}, 6)$.
			But if all we care about is that every element is divisible by $3$, we could have just taken ``mod $3$''
			at the beginning and looked at just $(1+\sqrt{7})(1-\sqrt{7}) = (6)$;
			all the other products we get will obviously have factors of $3$.
		}
		\[ \prod_{i=1}^{g} (f_i(\theta))^{e_i}
			\equiv (f(\theta)) \equiv 0 \pmod p \]
		so we've shown that $I \subseteq (p)$.

	Finally, we prove (c) with a size argument.
		The idea is that $I$ and $(p)$ really should have the same size;
		to nail this down we'll use the ideal norm.
		Since $(p)$ divides $I$, we can write
		$ (p) = \prod_{i=1}^g \kp_i^{e_i'} $
		where $e_i' \le e_i$ for each $i$.
		Remark $\OO_K / (p) \cong \Zc p[x] / (f)$ has size $p^{\deg f}$.
		Similarly, $\OO_K / (\kp_i)$ has degree $p^{\deg f_i}$ for each $i$.
		Compute $\Norm( (p) )$ using the $e_i'$ now and compare the results.
%		Hence
%		\[ p^{\deg f} = \Norm(p)
%		= \prod_{i=1}^r \Norm(\kp_i)^{e_i'}
%		= p^{e_1' \deg f_1 + \dots + e_g' \deg f_g}. \]
%		Hence
%		\[ e_1' \deg f_1 + \dots e_g' \deg f_g = \deg f. \]
%		On the other hand, it's obvious that \[ \deg f = e_1 \deg f_1 + \dots + e_g \deg f_g. \]
%		As $e_i' \le e_i$ for each $i$, we can only have $e_i = e_i'$.
	\end{sol}
\end{problem}


\documentclass{article}

\begin{document}

\section*{1.}

\[ (1 + i_1)^{m_1} =  (1 + i_2)^{m_2} \]

\[ (1 + 0.18)^{1} =  (1 + i_2)^{12} \]

\[ (1 + 0.18)^{1/12} =  1 + i_2 \]

\[ (1 + 0.18)^{1/12} - 1 = i_2 \]

\section*{2.}

\end{document}


\documentclass[twoside]{MATH77}
\usepackage{multicol}
\usepackage[fleqn,reqno,centertags]{amsmath}
\begin{document}
\begmath 10.2 Trigonometric, Cosine, and Sine Fourier Transforms

\silentfootnote{$^\copyright$1997 Calif. Inst. of Technology, \thisyear \ Math \`a la Carte, Inc.}

\subsection{Purpose}

This subroutine computes discrete trigonometric, cosine, and sine transforms
in up to six dimensions using the FFT. In the one dimensional case, the
values $y$ and the Fourier coefficients $\alpha $ and $\beta $ are related
by:
\begin{multline}
y_j=\frac 12\alpha _0+\,\sum_{k=1}^{(N/2)-1}\left[ \alpha _k\cos \frac{2\pi
jk}N+\beta _k\sin \frac{2\pi jk}N\right]\\
+\frac 12\alpha _{N/2}(-1)^j,\quad j=0,1,...,N-1\tag{1S}
\end{multline}\vspace{-10pt}
\renewcommand{\theequation}{\arabic{equation}A}
\begin{equation}
\begin{split}
\alpha _k&=\frac 2N\sum_{j=0}^{N-1}y_j\cos \frac{2\pi jk}N,\quad
k=0,1,...,\frac N2\\
\beta _k&=\frac 2N\sum_{j=0}^{N-1}y_j\sin \frac{2\pi jk}N,\quad
k=1,2,...,\frac N2-1
\end{split}
\end{equation}\vspace{-10pt}
\begin{multline}
y_j=\frac 12\alpha _0+\sum_{k=1}^{N-1}\alpha _k\cos \frac{\pi jk}N+\frac
12\alpha _N(-1)^j,\\
j=0,1,...,N\tag{2S}
\end{multline}\vspace{-20pt}
\begin{multline}
\alpha _k=\frac 2N\left[ \frac 12y_0+\sum_{j=1}^{N-1}y_j\cos \frac{\pi jk}%
N+\frac 12y_N(-1)^k\right] ,\\
k=0,1,...,N
\end{multline}\vspace{-20pt}
\begin{equation}
\hspace{-5pt}y_j=\sum_{k=1}^{N-1}\beta _k\sin \frac{\pi jk}N,\quad j=1,2,...,N-1%
\tag{3S}
\end{equation}\vspace{-10pt}
\begin{equation}
\hspace{-5pt}\beta _k=\frac 2N\sum_{j=1}^{N-1}y_j\sin
\frac{\pi jk}N,\quad k=1,2,...,N-1
\end{equation}
where $N =2^{\text{M}(1)}$, ($N_i=2^{\text{M}(i)}$, $i=1$, ..., ND in the
multi-dimensional case.) In the equation labels above, the numeral 1, 2,
or~3 denotes the Trigonometric, Cosine, or Sine transform, respectively,
while the letter S or A denotes Synthesis or Analysis.
\renewcommand{\theequation}{\arabic{equation}}

\subsection{Usage}

\subsubsection{Program Prototype, Single Precision, One-Dimensional Transform}

\begin{description}
\item[\bf INTEGER]  \ {\bf M}(1){\bf , ND, MS}
\item[\bf REAL]  \ {\bf A}$(\geq \mu $)\quad $[\mu =2^{\text{M}(1)}+1$
for a Cosine transform, and $=2^{\text{M}(1)}$ for a Trigonometric transform or
Sine transform.]
\item[\bf REAL]  \ {\bf S}$(\geq \nu {-}1$)\quad $[\nu =2^{\text{M}(1)-2}$ for
a Trigonometric transform and $=2^{\text{M}(1)-1}$ for a Cosine or Sine
transform.]
\item[\bf CHARACTER TCS, MODE]  \
\end{description}

On the initial call set MS to~0 to indicate the array S() does not yet
contain a sine table. Assign values to A(), TCS, MODE, M(), and ND = 1
for a one-dimensional transform.
$$
\fbox{{\bf CALL STCST(A, TCS, MODE, M, ND, MS, S)}}
$$
On return A() will contain computed values. S() will contain the sine
table used in computing the Fourier transform. MS may have been changed.

\subsubsection{Argument Definitions}

\begin{description}
\item[A()]  [inout] If MODE selects analysis, A() contains $y$ on input and $%
\alpha $\ and/or\ $\beta $ on output. If MODE selects synthesis, A()
contains $\alpha $\ and/or\ $\beta $ on input and $y$ on output. Let $N
=2^{\text{M}(1)}.$

When A() contains $y$'s, the element $y_j$ is stored in A($j+1)$.
The range of $j$ is $[0, N-1]$ for the Trigonometric transform, $%
[0, N]$ for the Cosine transform, and $[1, N-1]$ for
the Sine transform.

For the Trigonometric transform, the $\alpha $'s and $\beta $'s
are stored as A($1)=\alpha _0$, A($2)=\alpha _{N/2}$, and ${%
\textstyle A}(2k+1)=\alpha _k$, A($2k+2)=\beta _k$, $k=1$, 2, ..., ($N/2)-1.$

For the Cosine transform, the $\alpha $'s are stored as A($k+1)=\alpha _k$,
$k=0$, 1, ..., $N$.

For the Sine transform, the $\beta $'s are stored as A($k+1)=\beta
_k$, $k=1$, 2, ..., $N-1$. Although the value contained in A(1) is
irrelevant for the Sine transform, the subroutine does access this location,
so A(1) must contain a valid floating-point number on entry and its value
will generally be changed on return.

\item[TCS]  [in] The character variable TCS selects the type of transform to
be done.

$^{\prime }\text{T}^{\prime }$ or $^{\prime }\text{t}^{\prime }$ selects the Trigonometric
transform (Formula 1A or~1S).

$^{\prime }\text{C}^{\prime }$ or $^{\prime }\text{c}^{\prime }$ selects the Cosine
transform (Formula 2A or~2S).

$^{\prime }\text{S}^{\prime }$ or $^{\prime }\text{s}^{\prime }$ selects the Sine
transform (Formula 3A or~3S).

\item[MODE]  [in] The character variable MODE selects Analysis or Synthesis.

$^{\prime }\text{A}^{\prime }$ or $^{\prime }\text{a}^{\prime }$ selects Analysis (Formula
1A, 2A, or~3A).

$^{\prime }\text{S}^{\prime }$ or $^{\prime }\text{s}^{\prime }$ selects Synthesis
(Formula 1S, 2S, or~3S).

\item[M()] [in] Defines $N=2^{\text{M}(1)}$.  The number of real data
points is $N$+1, $N$, and $N{-}$1, for the Cosine, Trigonometric, and Sine
transforms respectively.  Require 0~$\leq \text{M(1)} \leq 31\ (\leq 30$
for the cosine or sine transform).  If M(1) is~0, no action is taken.

\item[ND]  [in] Number of dimensions, =1 for one-dimensional transforms.

\item[MS]  [inout] Gives the state of the sine table in S().  Let
$\text{MS}_{in}\text{ and MS}_{out}$ denote the values of MS on entry
and return respectively. If the sine table has not previously been
computed, set $\text{MS}_{in} = 0$ or $-$1 before the call. Otherwise
the value of $\text{MS}_{out}$ from the previous call using the same
S() array can be used as $\text{MS}_{in}$ for the current call.

Certain error conditions described in Section E cause the subroutine
to set $\text{MS}_{out} = -2$ and return.  Otherwise, with M(1) $>$ 0, the
subroutine sets $\text{MS}_{out} = \max (\text{M}(1), \text{MS}_{in})$
for the Trigonometric transforms and to $\text{MS}_{out} = \max
(\text{M}(1)+1, \text{MS}_{in})$ for the Cosine or Sine transforms.

If $\text{MS}_{out} > \max (2, \text{MS}_{in}),$ the subroutine sets
NT = $2^{\text{MS}_{out}-2}$ and fills S() with NT $-$ 1 sine values.

If $\text{MS}_{in}=-1$, the subroutine returns after the above
actions, not transforming the data in A().  This is intended to allow
the use of the sine table for data alteration before a subsequent Fourier
transform, as discussed in Section G of Chapter~16.0.

\item[S()]  [inout] When the sine table has been computed, S($j)=\sin \pi
j/(2\times \text{NT})$, $j=1$, 2, ..., NT $-$ 1, see MS above.
\end{description}

\subsubsection{Program Prototype, Multi-dimensional Transforms}

{\bf INTEGER} \ {\bf M}($\geq $ ND){\bf , ND, MS}

{\bf REAL} \ {\bf A}($\mu _1$, $\mu _2$, ..., $\geq \mu _{ND})$\quad $[\mu
_k=2^{\text{M}(k)}+1$ for a Cosine transform and $=2^{\text{M}(k)}$ for a
Trigonometric or Sine transform.]

{\bf REAL} \ {\bf S}($\geq \max (\nu _1$, $\nu _2$, ..., $\nu _{ND})-1)$%
\quad $[\nu _k=2^{\text{M}(k)-2}$ for a Trigonometric transform
and $=2^{\text{M}(k)-1}$
for a Cosine or Sine transform.]

{\bf CHARACTER TCS*($\geq $ ND), MODE*($\geq $ ND)}

On the initial call set MS to~0 to indicate the array S() does not yet
contain a sine table. Assign values to A(), TCS, MODE, M(), and ND.
$$
\fbox{{\bf CALL STCST(A, TCS, MODE, M, ND, MS, S)}}
$$
On return A() contains the transformed data and S() contains the sine table
used in computing the Fourier transform. The value of MS may have been
changed.

\subsubsection{Argument Definitions}

\begin{description}
\item[A()]  [inout] Array used for input and output data, see Functional
Description below for specification of the storage of items in A().

\item[TCS]  [in] The character TCS$(k$:$k)$ selects the type of transform to
be done in the $k^{th}$ dimension.

$^{\prime }\text{T}^{\prime }$ or $^{\prime }\text{t}^{\prime }$ selects the Trigonometric
transform (Formula 1A or~1S).

$^{\prime }\text{C}^{\prime }$ or $^{\prime }\text{c}^{\prime }$ selects the Cosine
transform (Formula 2A or~2S).

$^{\prime }\text{S}^{\prime }$ or $^{\prime }\text{s}^{\prime }$ selects the Sine
transform (Formula 3A or~3S).

\item[MODE]  [in] The character MODE$(k$:$k)$ selects Analysis or Synthesis
in the $k^{th}$ dimension.

$^{\prime }\text{A}^{\prime }$ or $^{\prime }\text{a}^{\prime }$ selects Analysis (Formula
1A, 2A, or~3A).

$^{\prime }\text{S}^{\prime }$ or $^{\prime }\text{s}^{\prime }$ selects Synthesis
(Formula 1S, 2S, or~3S).

\item[M()]  [in] In the $k^{th}$ dimension, $k=1$, ..., ND, define $%
N_k=2^{\text{M}(k)}$. The index range for the values $y_j$ in the $k^{th}$
dimension is $[0,N_k-1]$ for the Trigonometric transform, $[0,N_k]$ for the
Cosine transform, and $[1,N_k-1]$ for the Sine transform. Require $0 \leq
\text{M}(k)\leq 31\ (\leq 30$ for the cosine or sine transform).  If
M($k)=0$, no action is taken with respect to dimension $k$.

\item[ND]  [in] Number of dimensions, 1 $\leq $ ND $\leq $ 6.

\item[MS]  [inout]  As for MS in the one dimensional case above, except,
if there is no error and  M($k) >$ 0 for some $k$, the
subroutine sets $\text{MS}_{out} = \max
(\mu _1$, $\mu _2$, ..., $\mu_{ND})$, $\text{MS}_{in}$), where $\mu _k=
\text{M}(k)$ for the Trigonometric transform,
and $=\text{M}(k)+1$ for the Cosine or Sine transform.  NT is defined
in terms of $\text{MS}_{out}$ as described in Section~B.2 above.

\item[S()]  [inout] When the sine table has been computed, S($j)=\sin \pi
j/(2\times \text{NT})$, $j=1$, 2, ..., NT $-$ 1, see MS above.
\end{description}

\subsubsection{Modifications for Double Precision}

Change STCST to DTCST, and the REAL type statements to DOUBLE PRECISION.

\subsection{Examples and Remarks}

Given%
\begin{equation*}
f(t)=\frac{2\sinh t}{\sinh \pi t}
\end{equation*}
obtain an estimate of $\varphi (\omega )=\int_0^Tf(t)\cos \omega t\,dt$ and
compare it with $\varphi (\omega )=\sin (1)/(\cosh \omega +\cos (1))$, the true
solution. Let $T$ and $\Omega $ denote the largest values of $t$ and $\omega $
to be used in the computation. As was done below Eq.\,(18) in Chapter~16.0,
we introduce the approximations%
\begin{multline*}
\varphi (\omega ) = \int_0^Tf(t)\cos \omega t\,dt\\
\approx \frac TN\!\left[ \frac 12f(t_0)+\!\sum_{j=1}^{N-1}f(t_j)\cos
\omega t_j+\frac 12f(t_N)\cos \omega t_N\right]
\end{multline*}
where $t_j=j{T}/N$. With $\omega _k=k\pi /{T}$, we get%
\begin{equation*}\hspace{-15pt}
\varphi (\omega _k)\!\approx \!\frac T2\frac 2N\!\left[ \frac
12f(t_0)\!+\!\!\sum_{j=1}^{N-1}\!f(t_j)\cos \frac{\pi jk}N\!+\!\frac
12f(t_N)(-1)^k\!\right]
\end{equation*}
which except for the factor $T/2$ has the form of Eq.\,(2A) above. Good
results are obtained by balancing the error due to a finite $T$ with the
error due to aliasing $(i.e$. use of a finite $\Omega )$. Thus we want to
select $T$ and $\Omega $ so that%
\begin{equation}
\int_T^\infty |f(t)|\,dt\approx \frac 2{\pi -1}e^{-(\pi -1)T}\text{,
and}
\end{equation}\vspace{-10pt}
\begin{equation}
\int_\Omega^\infty |\varphi (\omega )|\,d\omega \approx 2\sin (1)e^{-\Omega}
\end{equation}
are of the same order of magnitude. Since%
\begin{equation*}
\int_T^\infty |f(t)|\,dt<10^{-4}\int_0^T|f(t)|\,dt\quad \text{for }T\geq 10.
\end{equation*}
there is no point in choosing $T>10$. With $T=10$, $N=64$ gives $\Omega =(%
N \pi /{T})=6.4\pi $. The right hand sides of Equations (4) and (5) are
then $\approx 4.7\times 10^{-10}$ and $3.1\times 10^{-9}$ respectively.

The program at the end of this chapter carries out the above calculations,
but prints results only for every $10^{th}$ value of $k$ to save space.

\subsection{Functional Description}

The one-dimensional transforms computed by this subroutine are given by
equations (1S), (1A), ..., (3S), (3A). The multi-dimensional transform is
accomplished by applying the appropriate one-dimensional transforms in each
dimension. To define the relation between input and output contents of the
A() array in the multi-dimensional case we introduce a 4-argument function,
T(*,*,*,*), in which the first argument can take the values $%
^{\prime }\text{T}^{\prime }$,$^{\prime }\text{C}^{\prime }$,
or $^{\prime }\text{S}^{\prime }$
to denote Trigonometric, Cosine, or Sine, and the second argument can take
the values $^{\prime }\text{A}^{\prime }$ or $^{\prime }\text{S}^{\prime }$
to denote Analysis or Synthesis. The third and fourth arguments are integers.
There is also an implied argument, M, which together with the first
argument contributes to the definition of $N$ and $\mu $.
\begin{equation*}
\hspace{-15pt}N=2^M
\end{equation*}\vspace{-30pt}
\begin{equation*}
\hspace{-15pt}\text{T(}^{\prime }\text{T}^{\prime }{,}^{\prime }
\text{S}^{\prime },j,k)=\begin{cases}
1/2 & k=0\\
\cos (\pi jk/N)& k=2,4,...,N\!-\!2\\
\sin (\pi j(k-1)/N)& k=3,5,...,N\!-\!1\\
(1/2)(-1)^j& k=1
\end{cases}
\end{equation*}\vspace{-10pt}
\begin{equation*}
\hspace{-15pt}\text{T(}^{\prime }\text{T}^{\prime }{,}^{\prime }
\text{A}^{\prime },j,k)\!=\!\frac 2N
\begin{cases}
\cos (\pi jk/N)&\!\!j\!=\!0,2,...,N\!-\!2 \\
\sin (\pi (j\!-\!1)k/N)&\!\!j\!=\!3,5,...,N\!-\!1 \\
(-1)^k,&\!\!j\!=\!1
\end{cases}
\end{equation*}\vspace{-15pt}
\begin{equation*}
\hspace{-15pt}\text{T(}^{\prime }\text{C}^{\prime }{,}^{\prime }
\text{S}^{\prime },j,k)=
\begin{cases}
1/2& k=0 \\
\cos (\pi jk/N)& k=1,2,...,N-1 \\
(1/2)(-1)^j& k=N
\end{cases}
\end{equation*}\vspace{-15pt}
\begin{equation*}
\hspace{-15pt}\text{T(}^{\prime }\text{C}^{\prime }{,}^{\prime }%
\text{A}^{\prime },j,k)=\frac 2N\text{T(}%
^{\prime }\text{C}^{\prime },^{\prime }\text{S}^{\prime },j,k)
\end{equation*}\vspace{-15pt}
\begin{equation*}
\hspace{-15pt}\text{T(}^{\prime }\text{S}^{\prime }{,}^{\prime }%
\text{S}^{\prime },j,k)=\sin \frac{\pi jk}N
\end{equation*}\vspace{-15pt}
\begin{equation*}
\hspace{-15pt}\text{T(}^{\prime }\text{S}^{\prime }{,}^{\prime }%
\text{A}^{\prime },j,k)=\frac 2N\text{T(}^{\prime }\text{S}^{\prime},%
^{\prime }\text{S}^{\prime },j,k)
\end{equation*}\vspace{-15pt}
\begin{equation*}
\hspace{-15pt}\mu _i=
\begin{cases}
2^{\text{M}(i)}& \text{for a Trigonometric or Sine transform} \\
2^{\text{M}(i)}+\!1& \text{for a Cosine transform}
\end{cases}
\end{equation*}

The array A has its contents replaced according to the formula%
\begin{multline*}
\hspace{-5pt}A(j_1,j_2,...,j_{ND})=\sum_{k_1=1}^{\mu _1}\cdots
\sum_{k_{ND}=1}^{\mu_{ND}}A(k_1,k_2,...,k_{ND})\\\hspace{-15pt}
\times \text{T(TCS(1:1), MODE(1:1), }j_1-1,k_1-1)\times \cdots\\
\hspace{-15pt}\times \text{T(TCS(ND:ND), MODE(ND:ND), }j_{ND}-1,k_{ND}-1),
\end{multline*}
where $j_i=1,2,...,\mu _i$ and storage conventions with respect to each
dimension are defined as for the one dimensional transforms.

The computational procedure for the trigonometric transform in the
one-dimensional case is almost identical to the procedure used in SRFT1.
(See the second paragraph below Eq.\,10 in Chapter~16.0 to see why this is
so.)

The procedure for the cosine transform uses the trigonometric transform and
the identity%
\begin{equation*}
\hspace{-0pt}\cos \frac{\pi j(2k+1)}N=\frac{\sin (2\pi j(k+1)/N)-\sin
(2\pi jk/N)}{2\sin (\pi j/N)}.
\end{equation*}
This is used to transform%
\begin{equation*}
y_j=\frac 12\eta _0+\frac 12\eta _N(-1)^j+\sum_{k=1}^{N-1}\eta _k\cos \frac{%
\pi jk}N
\end{equation*}
to%
\begin{multline*}
y_j=\frac 12\eta _0+\frac 12\eta _N(-1)^j+\sum_{k=1}^{(N/2)-1}\eta _{2k}\cos
\frac{2\pi jk}N\\
+\frac 1{2\sin (\pi j/N)}\sum_{k=1}^{(N/2)-1}(\eta
_{2k-1}-\eta _{2k+1})\sin \frac{2\pi jk}N.
\end{multline*}
Let $Y_j$ be the result from the trigonometric transform with $\alpha
_k=\eta _{2k}$, $k=0$, 1, ..., $N/2$ and $\beta _k=\eta _{2k-1}-\eta _{2k+1}$%
, $k=1,2,...,(N/2)-1$. It follows that%
\begin{eqnarray*}
   y_j+y_{N-j}   & = & Y_j+Y_{N-j} \\
   y_j-y_{N-j}  & = & \frac{Y_j-Y_{N-j}}{2\sin (\pi j/N)}
\end{eqnarray*}
and thus one can compute $y_j$ from $Y_j$. The computational
procedure is to compute the $\alpha $'s and $\beta $'s
from the $\eta $'s (the $\alpha $'s require no
computation), use the trigonometric transform to get the $Y$'s, and
the $Y$'s to compute the $y$'s. The inverse transform is
exactly the same except for a factor of 2/$N$ as is clear from
Eqs.\,(2S) and (2A).

The sine transform is obtained in a very similar way to the cosine
transform. Details can be found in \cite{Krogh:1970:SCT}.

\bibliography{math77}
\bibliographystyle{math77}

\subsection{Error Procedures and Restrictions}

Require 1 $\leq $ ND $\leq $ 6, and $0 \leq \text{M}(k)\leq 31$ for the
Trigonometric transform, $0 \leq \text{M}(k)\leq 30$ for the Cosine and
Sine transforms.  Require that TCS and MODE have only the allowed values.
On violation of any of these conditions the subroutine issues an error
message using the error processing procedures of Chapter~19.2 with
severity level $=2$ to cause execution to stop.  A return will be made
with MS $=-2$ instead of stopping if the statement ``CALL\ ERMSET($-1$)''
is executed before calling this subroutine.

If the sine table does not appear to have valid data, an error message is
printed, and the sine table and then the transform are computed.

\subsection{Supporting Information}

The source language is ANSI Fortran~77.

\begin{tabular}{@{\bf}l@{\hspace{5pt}}l}
\bf Entry & \hspace{.35in} {\bf Required Files}\vspace{2pt} \\
DTCST & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
 DFFT, DTCST, ERFIN, ERMSG, IERM1, IERV1\rule[-5pt]{0pt}{8pt}}\\
STCST & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
 ERFIN, ERMSG, IERM1, IERV1, SFFT, STCST}\\
\end{tabular}

Subroutine designed and written by: Fred T. Krogh, JPL, August~1969, revised
January~1988.

\begcode

\medskip\
\lstset{language=[77]Fortran,showstringspaces=false}
\lstset{xleftmargin=.8in}

\centerline{\bf \large DRSTCST}\vspace{10pt}
\lstinputlisting{\codeloc{stcst}}

\vspace{30pt}\centerline{\bf \large ODSTCST}\vspace{10pt}
\lstset{language={}}
\lstinputlisting{\outputloc{stcst}}
\end{document}


\chapter*{Appendix C: Nonlinear Pyramidal Wavelet Transform (WT-PMT)}
\addcontentsline{toc}{chapter}{Appendix C: Pyramidal Wavelet Transform (PMWT)}

One of the advantages of the pyramidal wavelet transform over the pyramidal
median transform (PMT) is the ability to have robust noise estimation in the
different scales, while the advantage of the PMT is a better separation
of the structures in the scales. Using the PMT,
a strong structure (like a bright star, cosmic rays, bad pixels, etc.) will
not be spread over all scales as when using a wavelet transform. In fact, when
there is no signal in a given region, a wavelet transform would be better, and
if a strong signal appears, it is the PMT that we would like to use. So the
idea arises
to try to merge both transforms, and to adapt the analysis at each position
and at each scale, depending on the amplitude of the coefficient we measure.

A possible algorithm to perform this on an image $I$ is the following:
\begin{enumerate}
\item Let $c_j = I$, and $j=0$.
\item Filter the the image $c_j$ by the median: we get $m_j$
\item Set $c_j^* = c_j$ and $d_j= c_j - m_j$
\item For all pixels $k$ do \\
\ \ \ \ \ \ \ \ \ \ \ \ \
 if $\mid d_j(k) \mid > k \sigma_j$ then $c_j^*(k) = m_j(k)$
\item Smooth $c_j^*$  by a B$_3$-spline: we get $b_j$
\item Set $w_j = c_j - b_j$
\item  $c_{j+1} = dec(b_j)$ (where the decimation operation, dec, entails 1 pixel replacing
each 2 $\times$2 subimage).
Let $j=j+1$ and return to step 2 if $j < N_s$ ($N_s$ being the number of scales).
\end{enumerate}
In this algorithm, the linear filtering relative to the wavelet transform is
not applied to the strong features contained in the image. Indeed, significant
pixel values are detected at step 4, and are replaced by the median. Regions
containing no bright object are treated as if the pyramidal wavelet
transform  is used. The parameter $k$ used at step 4 must be large enough
in order to be sure that noise is not filtered by the median ($k=5$ seems
high enough). As this transform merges the wavelet transform and the PMT,
we call it the PMWT transform.
PMWT takes more time than the PMT, but this algorithm has the
advantages of the PMT without the drawbacks. The reconstruction is the
same as for the PMT.

\chapter*{Appendix D: Half Pyramidal Wavelet Transform}
\addcontentsline{toc}{chapter}{Appendix D: Half Pyramidal Wavelet Transform}

At each iteration of the pyramidal transform, there is a smoothing and
a decimation of the image. But the smoothing is not strong enough to
reduce the cut-off frequency by a factor two. The decimation then violates
Shannon's theorem. To avoid this problem, which may create artifacts,
Bijaoui \cite{wave:bijaoui97}
proposed not to decimate the image at the first iteration of the algorithm.
This means that the two first scales have the same size as the original image
(instead of just one in the standard pyramidal transform). Then the two first
iterations are identical as in the \`a trous algorithm. For the
following iterations, there is a decimation and the filtering is done
as for the second iteration (i.e.\ by taking pixels interspersed by
one pixel for the filtering).

\newpage
$ $