\chapter{Coinductive types}

\section{Limits in HoTT}

Recall that a graph $\Gamma$ in $\UU$ is a pair $\pairr{\Gamma_0,\Gamma_1}$
consisting of a type $\Gamma_0:\UU$ of vertices,
and binary relation $\Gamma_1:\Gamma_0\to\Gamma_0\to\UU$ of edges.
A diagram $D$ over $\Gamma$ in $\UU$ is a pair $\pairr{D_0,D_1}$ consisting of
$D_0:\Gamma_0\to\UU$ and $D_1:\prd{i,j:\Gamma_0}\Gamma_1(i,j)\to D_0(i)\to D_0(j)$.
A cone on $D$ with vertex $X$ is a pair $\pairr{c_0,c_1}$ consisting of
\begin{align*}
c_0 & : \prd{i:\Gamma_0} X\to D_0(i) \\
c_1 & : \prd{i,j:\Gamma_0}{e:\Gamma_1(i,j)}{x:X} D_1(e,c_0(i,x))=c_0(j,x).
\end{align*}
There is an actions of functions into $X$ on cones with vertex $X$, which
we call $\mathsf{coneMap}$.
Given any $f:Y\to X$, and any cone $c\defeq \pairr{c_0,c_1}$ with vertex $X$,
we define the cone $\mathsf{coneMap}(f,c)$ with vertex $Y$ by
\begin{align*}
\mathsf{coneMap}(f,c)_0(i,y) & \defeq c_0(i,f(y)) \\
\mathsf{coneMap}(f,c)_1(e,y) & \defeq c_1(e,f(y)).
\end{align*}
Note that $\mathsf{coneMap}$ can also be seen as a map of type
\begin{equation*}
\prd{X,Y:\UU}{c:\mathsf{cone}(X)} (Y\to X)\to\mathsf{cone}(Y).
\end{equation*}
A cone $c$ with vertex $X$ is said to be limiting if $\mathsf{coneMap}(X,Y,c)$
is an equivalence for every $Y:\UU$.

\begin{defn}
Let $D$ be a diagram over $\Gamma$. Then we define the type $\mathsf{limit}(D)$
to be the type of pairs $\pairr{x,h}$ consisting of
\begin{align*}
x & : \prd{i:\Gamma_0}D_0(i) \\
p & : \prd{i,j:\Gamma_0}{e:\Gamma_1(i,j)}D_1(e,x_i)=x_j.
\end{align*}
We define the cone $\mathsf{limitCone}(D)$ with vertex $\mathsf{limit}(D)$ by
\begin{align*}
\mathsf{limitCone}(D)_0(i,\pairr{x,h}) & \defeq x_i \\
\mathsf{limitCone}(D)_1(e,\pairr{x,h}) & \defeq p_e.
\end{align*}
\end{defn}

\begin{lem}
If the function extensionality axiom holds, the cone $\mathsf{limitCone}(D)$
with vertex $\mathsf{limit}(D)$ is a limiting cone on $D$.
\end{lem}

We are especially interested in the case where
$\Gamma\defeq\pairr{\N,\mathsf{pred}}$, consisting of the natural numbers,
and an edge from $n+1$ to $n$ for each $n:\N$.
In this case, a diagram $D$ over $\pairr{\N,\mathsf{pred}}$ is equivalently
described as a pair $\pairr{D_0,D_1}$ consisting of
\begin{align*}
D_0 & : \N\to\UU \\
D_1 & : \prd{n:\N} D_0(n+1)\to D_0(n)
\end{align*}
Similarly, the type $\mathsf{limit}(D)$ for a diagram $D$ over
$\pairr{\N,\mathsf{pred}}$ is equivalently described as the type
\begin{equation}\label{eq:sequential_limit}
\sm{x:\prd{n:\N}D_0(n)}\prd{n:\N}D_1(n,x_{n+1})=x_n.
\end{equation}
We shall use this description of sequential limits to study coinductive types.

Let $\pairr{x,h}$ and $\pairr{y,k}$ be in $\mathsf{limit}(D)$.
Then by function extensionality, the type $\pairr{x,h}=\pairr{y,k}$
is equivalent to the type of pairs $\pairr{p,q}$ consisting of
$p : \prd{i:\Gamma_0} x_i=y_i$ and for each $e:\Gamma_1(i,j)$ a path
$q_e$ witnessing that the square
\begin{equation*}
\begin{tikzcd}[column sep=huge]
D_1(e,x_i) \arrow[r,equals,"\mapfunc{D_1(e)}(p_i)"] \arrow[d,equals,swap,"h_i"] & D_1(e,y_i) \arrow[d,equals,"k_i"] \\
x_j \arrow[r,equals,swap,"p_j"] & y_j
\end{tikzcd}
\end{equation*}
commutes. In other words:

\begin{lem}\label{lem:id_limit}
For any $\pairr{x,h},\pairr{y,k}:\mathsf{limit}(D)$, the identity type
$\pairr{x,h}=\pairr{y,k}$ is equivalent to the limit of the diagram $I(D)$ over
$\Gamma$, defined by
\begin{align*}
I(D)_0(i) & \defeq x_i=y_i \\
I(D)_1(e,h) & \defeq \ct{\opp{p_i}}{\mapfunc{D_1(e)}(\alpha_i)}{q_i}.
\end{align*}
\end{lem}

\section{Ordinary coinductive types}
A coinductive type is specified by
a type $A$ and a type family $B:A\to\UU$, just as inductive types.
Such a pair $(A,B)$ determines the polynomial endofunctor given on objects by
\begin{equation*}
X \mapsto P_{A,B}(X)\defeq \sm{a:A} (B(a)\to X)
\end{equation*}
and on morphisms $h:X\to Y$ by
\begin{equation*}
\pairr{a,f}\mapsto \pairr{a,h\circ f}.
\end{equation*}
A coalgebra for the polynomial endofunctor $P_{A,B}$ is a type $X$ together
with a map $X\to P_{A,B}(X)$. A homomorphism of coalgebras, from $(X,f)$ to
$(Y,g)$ consists of a map $h:X\to Y$ such that the square
\begin{equation*}
\begin{tikzcd}[column sep=large]
X \arrow[r,"h"] \arrow[d,swap,"f"] & Y \arrow[d,"g"] \\
P_{A,B}(X) \arrow[r,swap,"P_{A,B}(h)"] & P_{A,B}(Y)
\end{tikzcd}
\end{equation*}
commutes. The coinductive type $\mathsf{M}(A,B)$ is defined to be a coalgebra
--- so it comes with a map $\mathsf{destr}_{A,B} : \mathsf{M}(A,B)\to P_{A,B}(\mathsf{M}(A,B))$ ---
with the property that for any coalgebra $(X,f)$ the type of homomorphisms
from $(X,f)$ to $\mathsf{M}(A,B)$ is contractible.
Using the type $\N$ of natural numbers and function extensionality, the coinductive types
$\mathsf{M}(A,B)$ can be shown to exist in homotopy type theory
\cite{AhrensCapriottiSpadotti}, as the limit of the diagram
\begin{equation*}
\begin{tikzcd}
\cdots \arrow[r,"u_2"] & P^2_{A,B}(\unit) \arrow[r,"u_1"] & P_{A,B}(\unit) \arrow[r,"u_0"] & \unit
\end{tikzcd}
\end{equation*}
where $u_{n+1}\defeq P_{A,B}(u_n)$.
This limit may also defined as the type
\begin{equation*}
\sm{x:\prd{n:\N} P^n_{A,B}(\unit)}\prd{n:\N} u_n(x_{n+1})=x_n.
\end{equation*}

\begin{defn}
Consider $A:\UU$ and $B:A\to\UU$. Then we define
\begin{equation*}
\mathsf{M}(A,B)\defeq \sm{x:\prd{n:\N} P^n_{A,B}(\unit)}\prd{n:\N} u_n(x_{n+1})=x_n.
\end{equation*}
\end{defn}

\begin{defn}
Let $\pairr{x,h}:\mathsf{M}(A,B)$.
We will define for each $n:\N$ an identification
\begin{equation*}
\mathsf{desc\nameless path}(\pairr{x,h})_{n+1} : \proj 1(x_{n+2})=\proj 1(x_{n+1}),
\end{equation*}
with a homotopy $\mathsf{desc\nameless htpy}(\pairr{x,h})_n$
witnessing that the square
\begin{equation*}
\begin{tikzcd}[column sep=9em]
B(\proj 1(x_{n+2})) \arrow[r,"\transf{(\mathsf{desc\nameless path}(\pairr{x,h})_{n+1})}"] \arrow[d,swap,"\proj 2(x_{n+2})"] & B(\proj 1(x_{n+1})) \arrow[d,"\proj 2(x_{n+1})"] \\
P_{A,B}^{n+1}(\unit) \arrow[r,swap,"u_n"] & P_{A,B}^n(\unit)
\end{tikzcd}
\end{equation*}
commutes.
\end{defn}

\begin{proof}[Construction]
First we decompose $x_{n+2}$ as $\pairr{a,f}$ and $x_{n+1}$ as $\pairr{a',f'}$.
We have $u_{n+1}(\pairr{a,f})\jdeq \pairr{a,u_n\circ f}$.
It follows that $\proj 1(\pairr{a,f})\jdeq \proj 1(u_{n+1}(\pairr{a,f}))$.
Since $h_n:u_{n+1}(\pairr{a,f})=\pairr{a',f'}$, we have
$\mapfunc{\proj 1}(h_n) : \proj 1(\pairr{a,f})=\proj 1(\pairr{a',f'})$.

We construct the homotopy by a generalization.
We show that for any $\pairr{a,f}:P_{A,B}^{n+2}(\unit)$,
any $\pairr{a',f'}:P_{A,B}^{n+1}(\unit)$ and any $p:u_{n+1}(a,f)=\pairr{a',f'}$
\end{proof}

\begin{defn}
This allows us to define for each $n:\N$ the identification
\begin{equation*}
\mathsf{m\nameless full\nameless desc}(\pairr{x,h})_n : \proj 1(x_{n+1})=\proj 1(x_{1})
\end{equation*}
as the concatenation $\ct{\mathsf{desc\nameless path}(\pairr{x,h})_{n}}{\cdots}{\mathsf{desc\nameless path}(\pairr{x,h})_1}$.
\end{defn}

\begin{defn}
We define the map
\begin{equation*}
\mathsf{destr}_{A,B} : \mathsf{M}(A,B)\to P_{A,B}(\mathsf{M}(A,B))
\end{equation*}
which gives $\mathsf{M}(A,B)$ the structure of a $P_{A,B}$-coalgebra.
\end{defn}

\begin{proof}[Construction]
We will construct $\mathsf{destr}_{A,B}$
as a pair $\pairr{\mathsf{destr}_0,\mathsf{destr}_1}$ consisting of maps
\begin{align*}
\mathsf{destr}_0 & : \mathsf{M}(A,B)\to A \\
\mathsf{destr}_1 & : \prd{\pairr{x,h}:\mathsf{M}(A,B)} B(\mathsf{destr}_0(x,p))\to \mathsf{M}(A,B).
\end{align*}
First, we define $\mathsf{destr}_0(x,p)\defeq \proj 1(x_1)$,
for any $\pairr{x,h}:\mathsf{M}(A,B)$.
To define $\mathsf{destr}_1$, let $\pairr{x,h}:\mathsf{M}(A,B)$.
Note that for any $n:\N$,
we have $\proj 2(x_{n+1}):B(\proj 1(x_{n+1}))\to P_{A,B}^n(\unit)$.
This can be used to obtain $\mathsf{destr}_1(\pairr{x,h},b)_0$.
More specifically, we will construct a type sequence of types
$B(\proj 1(x_{n+1}))$, in which the connecting maps are all equivalences,
and for which the maps $\proj 2(x_{n+1})$ form a natural transformation,
as indicated in the diagram.
\begin{equation*}
\begin{tikzcd}
\cdots \arrow[r,"\eqvsym"] & B(\proj 1(x_3)) \arrow[r,"\eqvsym"] \arrow[d] & B(\proj 1(x_2)) \arrow[r,"\eqvsym"] \arrow[d] & B(\proj 1(x_1)) \arrow[d]
  \\
\cdots \arrow[r,swap,"u_2"] & P_{A,B}^2 \arrow[r,swap,"u_1"] & P_{A,B}^1(\unit) \arrow[r,swap,"u_0"] & P_{A,B}^0(\unit)
\end{tikzcd}
\end{equation*}
With this type sequence consisting only of equivalences,
and with the indictated natural transformation, we obtain a cone on the bottom
type sequence with vertex $B(\proj 1(x_1))$. Since $\mathsf{M}(A,B)$ is the
limit, this defines the desired map
$\mathsf{destr}_1(x,p):B(\proj 1(x_1))\to \mathsf{M}(A,B)$.

We obtain the individual commutative squares of the above diagram by
generalization: we show that for any $\pairr{a,f}:P_{A,B}^{n+2}(\unit)$ and
any $\pairr{b,g}:P_{A,B}^{n+1}(\unit)$ such that $\alpha:u_{n+1}(a,f)=\pairr{b,g}$,
we have a commuting square
\begin{equation*}
\begin{tikzcd}
B(a) \arrow[r,densely dotted,"\eqvsym"] \arrow[d,swap,"f"] & B(b) \arrow[d,"g"] \\
P_{A,B}^{n+1}(\unit) \arrow[r,swap,"u_n"] & P_{A,B}^n(\unit)
\end{tikzcd}
\end{equation*}
Of course, since the endpoint of $\alpha$ is free, it suffices to prove the
assertion for $\alpha\jdeq \refl{u_{n+1}(a,f)}$.
Since $u_{n+1}(a,f)\jdeq \pairr{a,u_{n}\circ f}$,
we have to construct a commuting square
\begin{equation*}
\begin{tikzcd}
B(a) \arrow[r,densely dotted,"\eqvsym"] \arrow[d,swap,"f"] & B(a) \arrow[d,"u_n\circ f"] \\
P_{A,B}^{n+1}(\unit) \arrow[r,swap,"u_n"] & P_{A,B}^n(\unit)
\end{tikzcd}
\end{equation*}
Of course, the above square commutes when we take the identity map on $B(a)$.
\end{proof}

\begin{eg}
The type $\mathsf{Stream}(A)$ of streams in $A$ can either be introduced as
the final coalgebra for the polynomial endofunctor $X\mapsto A\times X$
associated to the (constant) type family $\lam{a}\unit : A\to\UU$,
or as the coinductive type with destructors
\begin{align*}
\mathsf{head} & : \mathsf{Stream}(A)\to A \\
\mathsf{tail} & : \mathsf{Stream}(A)\to\mathsf{Stream}(A).
\end{align*}
\end{eg}

\begin{lem}
The map
\begin{equation*}
\mathsf{destr}_{A,B} : \mathsf{M}(A,B)\to P_{A,B}(\mathsf{M}(A,B))
\end{equation*}
is an equivalence.
\end{lem}

\begin{proof}
We have the coalgebra
\begin{equation*}
\begin{tikzcd}[column sep=8em]
P_{A,B}(\mathsf{M}(A,B)) \arrow[r,"{P_{A,B}(\mathsf{destr}_{A,B})}"] & P_{A,B}^2(\mathsf{M}(A,B)),
\end{tikzcd}
\end{equation*}
so the type of homomorphisms from this coalgebra to $\mathsf{M}(A,B)$ is
contractible. We call the underlying map of this unique algebra homomorphism
$\mathsf{constr}_{A,B}:P_{A,B}(\mathsf{M}(A,B))\to \mathsf{M}(A,B)$.

Now we have the commuting squares
\begin{equation*}
\begin{tikzcd}
\mathsf{M}(A,B) \arrow[r,"\mathsf{destr}_{A,B}"] \arrow[d,"\mathsf{destr}_{A,B}",swap] & P_{A,B}(\mathsf{M}(A,B)) \arrow[d,swap,"P_{A,B}(\mathsf{destr}_{A,B})"] \arrow[r,"\mathsf{constr}_{A,B}"] & \mathsf{M}(A,B) \arrow[d,"\mathsf{destr}_{A,B}"] \\
P_{A,B}(\mathsf{M}(A,B)) \arrow[r] & P_{A,B}(P_{A,B}(\mathsf{M}(A,B))) \arrow[r] & P_{A,B}(\mathsf{M}(A,B))
\end{tikzcd}
\end{equation*}
By contractibility of the type of homomorphisms from $\mathsf{M}(A,B)$ to itself,
it must be the case that $\mathsf{constr}_{A,B}\circ \mathsf{destr}_{A,B}=\idfunc$.
The fact that $\mathsf{destr}_{A,B}\circ \mathsf{constr}_{A,B}=\idfunc$ is now just a computation:
\begin{align*}
\mathsf{destr}_{A,B}\circ\mathsf{constr}_{A,B} & = P_{A,B}(\mathsf{constr}_{A,B})\circ P(\mathsf{destr}_{A,B}) \\
& = P_{A,B}(\mathsf{constr}_{A,B}\circ \mathsf{destr}_{A,B}) \\
& = P_{A,B}(\idfunc) \\
& = \idfunc.\qedhere
\end{align*}
\end{proof}

The construction of Ahrens, Capriotti and Spadotti of the coinductive type
$\mathsf{M}(A,B)$ also gives further characterizations of the identity type
on $\mathsf{M}(A,B)$.

\begin{lem}\label{lem:mtype_id}
Let $\pairr{x,h}$ and $\pairr{y,k}$ be terms of $\mathsf{M}(A,B)$.
The following types are equivalent:
\begin{enumerate}
\item the type $\pairr{x,h}=\pairr{y,k}$,
\item the type of pairs $\pairr{\alpha,\beta}$ consisting of
\begin{align*}
\alpha & : \mathsf{destr}_0(x,h)=\mathsf{destr}_0(y,k)\\
\beta & : \prd{z:B(\mathsf{destr}_0(x,h))}\mathsf{destr}_1(\pairr{x,h},z)=\mathsf{destr}_1(\pairr{y,k},\trans{\alpha}{z}),
\end{align*}
\item the limit of the type sequence
\begin{equation*}
\begin{tikzcd}
\cdots \arrow[r,"v_2"] & x_2=y_2 \arrow[r,"v_1"] & x_1=y_1 \arrow[r,"v_0"] & x_0=y_0.
\end{tikzcd}
\end{equation*}
where $v_n(p)\defeq \ct{\opp{h_n}}{\mapfunc{u_n}(p)}{k_n}$.
\end{enumerate}
\end{lem}

\begin{rmk}
In \autoref{conj:bisim_id} we add one more equivalent description of this type.
\end{rmk}

\begin{proof}
The type $\pairr{x,h}=\pairr{y,k}$ is equivalent to the indicated type of pairs
$\pairr{\alpha,\beta}$, because $\mathsf{destr}_{A,B}$ is an equivalence.
The third equivalent description of $\pairr{x,h}=\pairr{y,k}$ follows from
\autoref{lem:id_limit}.
\end{proof}

\begin{comment}
\begin{defn}
Consider $B:A\to\UU$, defining the coinductive type $\mathsf{M}(A,B)$, and let
$C:\mathsf{M}(A,B)\to\UU$ be a family.

We define a map $\mathsf{lazyDef}_{A,B,C}$, that assigns to each
\begin{equation*}
IH : \prd{a:A}{f:B(a)\to \mathsf{M}(A,B)} (\prd{b:B(a)} C(f(b)))\to C(\mathsf{cons}_{A,B}(a,f))
\end{equation*}
a section $s : \prd{x:\mathsf{M}(A,B)}C(x)$ satisfying
\begin{equation*}
s(\mathsf{cons}_{A,B}(a,f)) = IH(a,f,\lam{b}s(f(b))).
\end{equation*}
\end{defn}

\begin{proof}[Construction]
It suffices to construct a term of type
\begin{equation*}
\prd{a:A}{f:B(a)\to \mathsf{M}(A,B)}C(\mathsf{cons}_{A,B}(a,f)).
\end{equation*}
Let $a:A$, $f:B(a)\to \mathsf{M}(A,B)$. Then we have
\begin{equation*}
IH(a,f) : (\prd{b:B(a)} C(f(b)))\to C(\mathsf{cons}_{A,B}(a,f)),
\end{equation*}
so it suffices to construct a term of type $\prd{b:B(a)} C(f(b))$. Let $b:B(a)$.
Then we have $f(b):\mathsf{M}(A,B)$.

Then we have a map $g:B(a)\to\sm{x:\mathsf{M}(A,B)}C(x)$, given by
\begin{equation*}
g(b)\defeq \pairr{f(b),CH(b)}.
\end{equation*}
and hence we have
a term of type $P_{A,B}(\sm{x:\mathsf{M}(A,B)}C(x))$. In particular, it follows
that $\sm{x:\mathsf{M}(A,B)}C(x)$ has the structure of a $P_{A,B}$-coalgebra.

Since $\mathsf{M}(A,B)$ is the terminal coalgebra, there is a unique
\end{proof}

\begin{defn}
Let $C:\mathsf{M}(A,B)\to\UU$ be a type family for which we have a term
\begin{equation*}
CH : \prd{a:A}{f:B(a)\to \mathsf{M}(A,B)}{y:C(\mathsf{cons}_{A,B}(a,f))}\prd{b:B(a)} C(f(b)).
\end{equation*}
Then we get the map
\begin{equation*}
c : (\sm{x:\mathsf{M}(A,B)}C(x))\to P_{A,B}(\sm{x:\mathsf{M}(A,B)}C(x)),
\end{equation*}
defined by
\begin{equation*}
c(\mathsf{cons}_{A,B}(a,f),y) \defeq \pairr{a, \lam{b}\pairr{f(b),CH(a,f,y,b)}},
\end{equation*}
for which the square
\begin{equation*}
\begin{tikzcd}[column sep=huge]
\sm{x:\mathsf{M}(A,B)}C(x) \arrow[r,"\proj 1"] \arrow[d,swap,"c"] & \mathsf{M}(A,B) \arrow[d,"\mathsf{destr}_{A,B}"] \\
P_{A,B}(\sm{x:\mathsf{M}(A,B)}C(x)) \arrow[r,swap,"P_{A,B}(\proj 1)"] & P_{A,B}(\mathsf{M}(A,B))
\end{tikzcd}
\end{equation*}
commutes. Then coalgebra homomorphisms
\begin{equation*}
\begin{tikzcd}[column sep=large]
\mathsf{M}(A,B) \arrow[d,swap,"\mathsf{destr}_{A,B}"] \arrow[r,"h"] & \sm{x:\mathsf{M}(A,B)}C(x) \arrow[d,"c"] \\
P_{A,B}(\mathsf{M}(A,B)) \arrow[r,swap,"P_{A,B}(h)"] & P_{A,B}(\sm{x:\mathsf{M}(A,B)}C(x))
\end{tikzcd}
\end{equation*}
define terms of type $\prd{x:\mathsf{M}(A,B)}C(x)$.
\end{defn}

\begin{proof}[Construction]
Let $h$ be an coalgebra homomorphism of the indicated type. Since $\mathsf{M}(A,B)$
is the terminal coalgebra, it follows that $\proj 1\circ h=\idfunc$. Since
 we have an equivalence
\begin{equation*}
\eqv{\Big(\prd{x:\mathsf{M}(A,B)}C(x)\Big)}{\Big(\sm{g:\mathsf{M}(A,B)\to\sm{x:\mathsf{M}(A,B)}C(x)}\proj 1\circ g=\idfunc\Big)}
\end{equation*}
we get a section of $C$.
\end{proof}
\end{comment}

\section{Indexed coinductive types}
An indexed coinductive type is specified by an indexed container.

\begin{defn}
An indexed container is a quadruple $\pairr{I,A,B,j}$ consisting of
\begin{align*}
I & : \UU \\
A & : I\to \UU\\
B & : \prd*{i:I} A(i)\to \UU \\
j & : \prd*{i:I}*{a:A(i)} B(i)\to I.
\end{align*}
\end{defn}

\begin{defn}
Let $C\defeq\pairr{I,A,B,j}$ be an indexed container. We define the polynomial
endofunctor $P_C$ on type families over $I$ by
\begin{equation*}
P_C(X)(i) \defeq \sm{a:A(i)}\prd{b:B(i,a)} X(j(b))
\end{equation*}
The functoriality of $P_C$ is given by post-composition.
\end{defn}

Using this polynomial functor, we can again define the type family $\mathsf{M}(C) : I \to \UU$ to
be the final coalgebra of $P_C$. The final coalgebra comes with a map
\begin{equation*}
\mathsf{destr}_C : \prd{i:I} \mathsf{M}(C)(i) \to P_C(\mathsf{M}(C))(i)
\end{equation*}
Existence of this final coalgebra is shown in \cite{AhrensCapriottiSpadotti}.
They define $\mathsf{M}(C)(i)$ to be the limit of the
sequence
\begin{equation*}
\begin{tikzcd}
\cdots \arrow[r,"u_2(i)"] & P^2_C(\lam{\nameless}\unit)(i) \arrow[r,"u_1(i)"] & P_C(\lam{\nameless}\unit)(i) \arrow[r,"u_0(i)"] & \unit
\end{tikzcd}
\end{equation*}
where $\lam{\nameless}\unit:I\to\UU$ is the constant type family at the unit type.
More specifically,
\begin{equation*}
\mathsf{M}(C)(i)\defeq \sm{x:\prd{n:\N}P_C^n(\lam{\nameless}\unit)(i)}\prd{n:\N} u_n(i,x_{n+1})= x_n.
\end{equation*}

\begin{lem}
Let $C\defeq\pairr{I,A,B,j}$ be an indexed container. Then $\mathsf{destr}_C(i)$ is an
equivalence for each $i:I$.
\end{lem}

\begin{proof}
Since we have a coalgebra $(P_{C}(\mathsf{M}(C)), P_{C}(\mathsf{destr}_C))$,
so the type of homomorphisms from this coalgebra to $\mathsf{M}(A,B)$ is
contractible. Again, we call the underlying map of this unique algebra homomorphism
\begin{equation*}
\mathsf{constr}_{C}:\prd{i:I} P_{C}(\mathsf{M}(C))(i)\to \mathsf{M}(C)(i).
\end{equation*}

Now we have the commuting squares
\begin{equation*}
\begin{tikzcd}
\mathsf{M}(C)(i) \arrow[r,"\mathsf{destr}_C(i)"] \arrow[d,"\mathsf{destr}_C(i)",swap] & P_{C}(\mathsf{M}(A,B))(i) \arrow[d,swap,"P_{C}(\mathsf{destr}_C)(i)"] \arrow[r,"\mathsf{constr}_C(i)"] & \mathsf{M}(C)(i) \arrow[d,"\mathsf{destr}_C(i)"] \\
P_{C}(\mathsf{M}(C))(i) \arrow[r] & P_{C}(P_{C}(\mathsf{M}(C)))(i) \arrow[r] & P_{C}(\mathsf{M}(C))(i)
\end{tikzcd}
\end{equation*}
for each $i:I$. In particular, we have a coalgebra homomorphism from
$\mathsf{M}(C)$ to itself with underlying map $\mathsf{constr}_C\circ \mathsf{destr}_C$.
By contractibility of the type of homomorphisms from $\mathsf{M}(C)$ to itself,
it follows that $\mathsf{constr}_C\circ \mathsf{destr}_C=\idfunc$.

The fact that $\mathsf{destr}_C\circ \mathsf{constr}_C=\idfunc$ is now just a computation:
\begin{align*}
\mathsf{destr}_C\circ\mathsf{constr}_C & = P_{C}(\mathsf{constr}_C)\circ P(\mathsf{destr}_C) \\
& = P_{C}(\mathsf{constr}_C\circ \mathsf{destr}_C) \\
& = P_{C}(\idfunc) \\
& = \idfunc.\qedhere
\end{align*}
\end{proof}

\begin{cor}
Let $C\defeq\pairr{I,A,B,j}$ be an indexed container and consider
$\pairr{a_i,f_i},\pairr{b_i,g_i}:P_C(\mathsf{M}(C))(i)$. Then we have
an equivalence of type
\begin{align*}
& \Big(\mathsf{constr}_C(i)(a_i,f_i)=\mathsf{constr}_C(i)(b_i,g_i) \\
& \qquad\eqvsym \Big(\sm{p:a_i=b_i}\prd{x:B(i,a_i)} \trans{p}{f_i(x)}=g_i(\trans{p}{x})\Big).
\end{align*}
\end{cor}

\begin{defn}
Let $B:A\to\UU$ be a type family. We define the \define{bisimilation relation}
$\mathsf{Bisim}_{A,B}:\mathsf{M}(A,B)\to \mathsf{M}(A,B)\to\UU$ as an
indexed coinductive type, with container
\begin{align*}
I & \defeq \mathsf{M}(A,B)\times \mathsf{M}(A,B) \\
A'(i,j) & \defeq \mathsf{destr}_0(i)=\mathsf{destr}_0(j) \\
B'(i,j,p) & \defeq B(\mathsf{destr}_0(i)) \\
j(i,j,p,z) & \defeq \pairr{\mathsf{destr}_1(i,z),\mathsf{destr}_1(j,\trans{p}{z})}.
\end{align*}
\end{defn}

\begin{rmk}
Alternatively, the indexed coinductive type $\mathsf{Bisim}_{A,B}$ can be
introduced by its destructors
\begin{align*}
\mathsf{bdestr}_0(p) & : \mathsf{destr}_0(m)=\mathsf{destr}_0(n) \\
\mathsf{bdestr}_1(p) & : \prd{z:B(\mathsf{destr}_0(i))} \mathsf{Bisim}_{A,B}(\mathsf{destr}_1(i,z),\mathsf{destr}_1(j,\trans{\mathsf{bdestr}_0(p)}{z}))
\end{align*}
for every $i,j:\mathsf{M}(A,B)$ and $p:\mathsf{Bisim}_{A,B}(i,j)$.
\end{rmk}

\begin{conj}
Let $\pairr{x,h}$ and $\pairr{y,k}$ be terms of $\mathsf{M}(A,B)$. Then
$x_{n+1}=y_{n+1}$ is equivalent to the type of pairs $\pairr{\alpha,\beta}$
consisting of
\begin{align*}
\alpha & : \proj 1 (x_1)= \proj 1(y_1) \\
\beta & : \prd{z:B(\mathsf{destr}_0(x,h))}
P_C^n(\lam{\nameless}\unit)(\mathsf{destr}_1(\pairr{x,h},z),\mathsf{destr}_1(\pairr{y,k},\trans{\alpha}{z}))
\end{align*}
for any $n:\N$.
\end{conj}

\begin{conj}\label{conj:bisim_id}
For any type family $B:A\to\UU$, and any $i,j:\mathsf{M}(A,B)$,
there is an equivalence of type
\begin{equation*}
\eqv{(i=j)}{\mathsf{Bisim}_{A,B}(i,j)}.
\end{equation*}
\end{conj}

\begin{proof}[Proof attempt]
In \autoref{lem:mtype_id}, we characterized the identity type $\pairr{x,h}=
\pairr{y,k}$ as a sequential limit, so it suffices
to construct a natural equivalence
\begin{equation*}
\begin{tikzcd}
\cdots \arrow[r,"v_2"] & x_2=y_2 \arrow[r,"v_1"] \arrow[d,"\eqvsym"] & x_1=y_1 \arrow[d,"\eqvsym"] \arrow[r,"v_0"] & x_0=y_0 \arrow[d,"\eqvsym"] \\
\cdots \arrow[r,swap,"{u_2(i,j)}"] & P^2_C(\lam{\nameless}\unit)(i,j) \arrow[r,swap,"{u_1(i,j)}"] & P_C(\lam{\nameless}\unit)(i,j) \arrow[r,swap,"{u_0(i,j)}"] & \unit
\end{tikzcd}
\end{equation*}
of type sequences, where $i\jdeq\pairr{x,h}$ and $j\jdeq\pairr{y,k}$, and where
$C\jdeq\pairr{I,A',B',j}$ is the defining container
of the bisimilation relation on $\mathsf{M}(A,B)$.

We show that for any $n:\N$, for any $\pairr{x,h},\pairr{y,k}:\mathsf{M}(A,B)$
there is an equivalence of type $(x_n=y_n)\to $ [...]

The type $x_0=y_0$ is an equality type in a contractible type,
so it is uniquely equivalent to the unit type. Since it is contractible, we may
just ignore this part.

Next, note that the type
\begin{equation*}
P_C(\lam{\nameless}\unit)(i,j)\jdeq\sm{p:A'(\pairr{x,h},\pairr{y,k}}\prd{b:B'(i,j,p)}\unit
\end{equation*}
is equivalent to the type $A'(\pairr{x,h},\pairr{y,k})\jdeq (\proj 1(x_1)=\proj 1(y_1))$.
Note that $x_1$ and $y_1$ are in $P_{A,B}(\unit)\jdeq\sm{a:A}\unit^{B(a)}$, so
we see that the type $x_1=y_1$ is equivalent to the type $P_C(\lam{\nameless}\unit)(i,j)$.

For the remainder of the proof, it suffices to show that for each equivalence
\begin{equation*}
e_{n+1}:\eqv{(x_{n+1}=y_{n+1})}{P^{n+1}_C(\lam{\nameless}\unit)(i,j)}
\end{equation*}
we can construct a commuting square
\begin{equation*}
\begin{tikzcd}
x_{n+2}=y_{n+2} \arrow[r,"v_{n+1}"] \arrow[d,densely dotted,swap,"e_{n+2}"]
& x_{n+1}=y_{n+1} \arrow[d,"e_{n+1}"] \\
P^{n+2}_C(\lam{\nameless}\unit)(i,j) \arrow[r,swap,"u_{n+1}"] & P^{n+1}_C(\lam{\nameless}\unit)(i,j)
\end{tikzcd}
\end{equation*}
in which $e_{n+2}$ is an equivalence.
This follows, once we show that for any $\pairr{a',f'}$ and
$\pairr{b',g'}$ in $P^{n+1}_{A,B}(\unit)$ such that $p:u_{n+1}(x_{n+2})=\pairr{a',f'}$
and $q:u_{n+1}(y_{n+2})=\pairr{b',g'}$, any equivalence
\begin{equation*}
e:\eqv{(\pairr{a',f'}=\pairr{b',g'})}{P^{n+1}_C(\lam{\nameless}\unit)(i,j)},
\end{equation*}
we can construct a commuting square
\begin{equation*}
\begin{tikzcd}[column sep=8em]
x_{n+2}=y_{n+2} \arrow[r,"\lam{\alpha}\ct{\opp{p}}{\mapfunc{u_{n+1}}(\alpha)}{q}"] \arrow[d,densely dotted,swap,"\eqvsym"]
& \pairr{a',f'}=\pairr{b',g'} \arrow[d,"e"] \\
P^{n+2}_C(\lam{\nameless}\unit)(i,j) \arrow[r,swap,"u_{n+1}"] & P^{n+1}_C(\lam{\nameless}\unit)(i,j)
\end{tikzcd}
\end{equation*}
Since the endpoints of $p$ and $q$ are free, it suffices to construct a commuting
square
\begin{equation*}
\begin{tikzcd}[column sep=large]
\pairr{a,f}=\pairr{b,g} \arrow[r,"\mapfunc{u_{n+1}}"] \arrow[d,densely dotted,swap,"\eqvsym"]
& \pairr{a,u_n\circ f}=\pairr{b,u_n\circ g} \arrow[d,"e"] \\
P^{n+2}_C(\lam{\nameless}\unit)(i,j) \arrow[r,swap,"u_{n+1}"] & P^{n+1}_C(\lam{\nameless}\unit)(i,j)
\end{tikzcd}
\end{equation*}
where $x_{n+2}=\pairr{a,f}$ and $y_{n+2}=\pairr{b,g}$.
Note that $P^{n+2}_C(\lam{\nameless}\unit)(i,j)$ is defined
as the type
\begin{equation*}
\sm{\alpha:\proj 1(x_1)=\proj 1(y_1)}\prd{z:B(\proj 1(x_1))}P^{n+1}_C(\lam{\nameless}\unit)(\mathsf{destr}_1(i,z),\mathsf{destr}_1(j,\trans{\alpha}{z}))
\end{equation*}

Since we have $x_{n+2},y_{n+2}:\sm{a:A} (B(a)\to P^{n+1}_{A,B}(\unit))$,
so we can decompose them as $x_{n+2}\defeq\pairr{a,f}$
and $y_{n+2}\defeq\pairr{b,g}$.

The equality type $x_{n+2}=y_{n+2}$ is then
equivalent to the type $\sm{p:a=b}\prd{c:B(a)}f(c)=g(\trans{p}{c})$.
We need to construct a commuting square of the form
\begin{equation*}
\begin{tikzcd}
\pairr{a,f}=\pairr{b,g} \arrow[r] \arrow[d,densely dotted] & x_{n+1}=y_{n+1} \arrow[d] \\
P^{n+2}_C(\lam{\nameless}\unit)(i,j) \arrow[r] & P^{n+1}_C(\lam{\nameless}\unit)(i,j)
\end{tikzcd}
\end{equation*}
Note that
\begin{equation*}
P^{n+2}_C(\lam{\nameless}\unit)(i,j)\jdeq
\sm{\alpha:\proj 1(x_1)=\proj 1(y_1)}\prd{z:B(\proj 1(x_1))}P^{n+1}_C(\lam{\nameless}\unit)(\mathsf{destr}_1(i,z),\mathsf{destr}_1(j,\trans{\alpha}{z}))
\end{equation*}

Our goal is to show that this type is equivalent to the type of pairs
$\pairr{\alpha,\beta}$ consisting of
\begin{align*}
\alpha & :\mathsf{destr}_0(x,h)=\mathsf{destr}_0(y,k) \\
\beta & : \prd{z:B(\mathsf{destr}_0(x,h))}
P_C^n(\lam{\nameless}\unit)(\mathsf{destr}_1(\pairr{x,h},z),\mathsf{destr}_1(\pairr{y,k},\trans{\alpha}{z}))
\end{align*}
\end{proof}
\begin{comment}
\begin{defn}
Let $C\defeq \pairr{I,A,B,k}$ be an indexed container, defining the indexed
coinductive type $\mathsf{M}(C)$, and let $D:\prd{i:I}\mathsf{M}(C)(i)\to\UU$ be a family.

Then a section
\begin{equation*}
f : \prd{i:I}{x:\mathsf{M}(C)(i)}D(i,x)
\end{equation*}
can be defined by specifying
\begin{equation*}
\prd{i:I}{CH:\prd{a:A(i)}{c:B(i,a)\to \mathsf{M}(C)(i)} X(k(i,a,c),\mathsf{cons}_C(a,c))}\prd{a:A(i)}{c:B(i,a)\to \mathsf{M}(C)(i)}\cdots
\end{equation*}
\end{defn}
\end{comment}


\documentclass{standalone}
\begin{document}
	\chapter{Pascal's Triangle}
	\bigskip
	\emph{Consider the following expansions:}
	\begin{gather*}
		(1+x)^0 = 1\\
		(1+x)^1 = 1+x\\
		(1+x)^2 = 1+2x+x^2\\
		(1+x)^3 = 1+3x+3x^2+x^3\\
		(1+x)^4 = 1+4x+6x^2+4x^3+x^4\\
		(1+x)^5 = 1+5x+10x^2+10x^3+5x^4+x^5\\
		(1+x)^6 = 1+6x+15x^2+20x^3+15x^4+6x^5+x^6\\
		\ldots\\
		\begin{tabular}{>{$n=}l<{$\hspace{12pt}}*{13}{c}}
			&   &   &   &   &    &    & 1  &    &    &   &   &   &   \\
			&   &   &   &   &    & 1  &    & 1  &    &   &   &   &   \\
			&   &   &   &   & 1  &    & 2  &    & 1  &   &   &   &   \\
			&   &   &   & 1 &    & 3  &    & 3  &    & 1 &   &   &   \\
			&   &   & 1 &   & 4  &    & 6  &    & 4  &   & 1 &   &   \\
			&   & 1 &   & 5 &    & 10 &    & 10 &    & 5 &   & 1 &   \\
			6 & 1 &   & 6 &   & 15 &    & 20 &    & 15 &   & 6 &   & 1
		\end{tabular}
	\end{gather*}\\
	The above array of numbers is called Pascal's Triangle. It can be used to expand any binomial. The following examples illustrate its use.\\
	\newpage
	\begin{example}
		Expand the following using Pascal's Triangle
	\end{example}
	\begin{alignat*}{2}
		(1+2x)^5                      & \equiv 1(2x)^0 + 5(2x)^1 + 10(2x)^2 + 10(2x)^3 + 5(2x)^4 + 2x^5\tag*{a)}                                                                          \\
		& \equiv 1 + 10x + 40x^2 + 80x^3 + 80x^4 + 32x^5                                                                                \\
		\\
		\left(1-\frac{3x}{2}\right)^6 & \equiv 1\left(\frac{-3x}{2}\right)^0 + 6\left(\frac{-3x}{2}\right)^1 + 15\left(\frac{-3x}{2}\right)^2 + 20\left(\frac{-3x}{2}\right)^3 +\tag*{b)} \\
		& \quad 15\left(\frac{-3x}{2}\right)^4 + 6\left(\frac{-3x}{2}\right)^5 + 1\left(\frac{-3x}{2}\right)^6                                              \\
		& \equiv 1 - 9x + \frac{135x^2}{4} - \frac{135x^3}{2} + \frac{1215x^4}{16} - \frac{243x^5}{16} + \frac{728x^6}{64}                                  \\
		&   \\(p+q)^4 &\equiv (p(1+\frac{q}{p}))^4\tag*{c)}\\
		& \equiv p^4\left(1+\frac{q}{p}\right)^4                                                                                \\
		& \equiv p^4\left(1 + \frac{4q}{p} + \frac{6q^2}{p^2} + \frac{4q^3}{p^3} + \frac{q^4}{p^4}\right)                                                   \\
		& \equiv p^4 + 4p^3q + 6p^2q^2 + 4pq^3 + q^4
	\end{alignat*}
	In the above examples we observe that:

	\begin{itemize}
		\item{The expansion contains the coefficients for Pascal's Triangle.}
		\item{The expansion is formed by descending exponents of the first term of the binomial \& ascending exponents of the second.}
		\item{The sum of the exponents in each term is equal to the 	exponent by which the binomial was raised.}
	\end{itemize}
	These observations can be applied to expand any binomials raised with positive integer exponents.
\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% fphw Assignment
% LaTeX Template
% Version 1.0 (27/04/2019)
%
% This template originates from:
% https://www.LaTeXTemplates.com
%
% Authors:
% Class by Felipe Portales-Oliva (f.portales.oliva@gmail.com) with template
% content and modifications by Vel (vel@LaTeXTemplates.com)
%
% Template (this file) License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%    PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[
    12pt, % Default font size, values between 10pt-12pt are allowed
    %letterpaper, % Uncomment for US letter paper size
    %spanish, % Uncomment for Spanish
]{fphw}

% Template-specific packages
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage{fontspec,unicode-math} % Required for using utf8 characters in math mode
\usepackage{parskip}  % To add extra space between paragraphs
% \usepackage{mathpazo} % Use the Palatino font
\usepackage{graphicx} % Required for including images
\usepackage{booktabs} % Better horizontal rules in tables
\usepackage{hyperref} % For links (both internal and external)
% \usepackage{listings} % Required for insertion of code
\usepackage{enumerate}% To modify the enumerate environment
\usepackage{cleveref} % Better \ref command -> \cref
\usepackage{import}   % This 4 packages and the command allow importing pdf
\usepackage{xifthen}  % figures generated with inkscape
\usepackage{pdfpages} % Source: https://castel.dev/post/lecture-notes-2/
\usepackage{mathtools}
\usepackage{wrapfig}
\usepackage{cancel}
\usepackage{transparent}
\newcommand{\incfig}[1]{%
    \def\svgwidth{0.95\columnwidth}
    \small
        \import{./images/}{#1.pdf_tex}
}

\setlength{\parindent}{15pt}
\setlength{\headheight}{22.66pt}

%----------------------------------------------------------------------------------------
%    ASSIGNMENT INFORMATION
%----------------------------------------------------------------------------------------

\title{Task 1 \\ Parallel Vector Fields} % Assignment title

\author{Emilio Domínguez Sánchez} % Student name

\date{February 21st, 2021} % Due date

\institute{University of Murcia \\ Faculty of Mathematics} % Institute or school name

\class{Geometría Global de Superficies} % Course or class name

\professor{Dr. Luis J. Alías Linares} % Professor or teacher in charge of the assignment

%----------------------------------------------------------------------------------------
%    Definitions
%----------------------------------------------------------------------------------------

\usepackage{physics}
\newcommand{\R}{\mathbb{R}}
\newcommand{\inner}[2]{\left\langle #1, \; #2 \right\rangle}
\newcommand{\vfield}{\mathfrak{X}}

\DeclareDocumentCommand\covariantderivative{ s o m g d() }
{ % Covariant derivative
	% s: star for \flatfrac flat covariant derivative
	% o: optional n for nth covariant derivative
	% m: mandatory (x in Df/dx)
	% g: optional (f in Df/dx)
	% d: long-form D/dx(...)
	\IfBooleanTF{#1}
	{\let\fractype\flatfrac}
	{\let\fractype\frac}
	\IfNoValueTF{#4}
	{
		\IfNoValueTF{#5}
		{\fractype{D \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}}}
		{\fractype{D \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#5\argclose)}
	}
	{\fractype{D \IfNoValueTF{#2}{}{^{#2}} #3}{\diffd #4\IfNoValueTF{#2}{}{^{#2}}}}
}
\DeclareDocumentCommand\cdv{}{\covariantderivative} % Shorthand for \covariantderivative

\begin{document}

\maketitle % Output the assignment title, created automatically using the information in the custom commands above

%----------------------------------------------------------------------------------------
%    ASSIGNMENT CONTENT
%----------------------------------------------------------------------------------------

\section*{Problem}

\begin{problem}
    Let $α : I \to S \subset \R^3$ be a parametrized curve on
    a regular surface oriented by a Gauss application $N$
    and let $V \in \vfield(α)$ be a differentiable tangent vector field along $α$.
    As it is usual,
    let $N(t) = N(α(t))$ denote the Gauss application with respect to the interval $I$
    and let $JV \in \vfield(α)$ denote the rotation of angle $\frac{π}{2}$ of $V$.
    That is,
    %
    \begin{equation*}
        JV(t) = N(t) \cross V(t) \in T_{α(t)}S, \qq{for all $t \in I$.}
    \end{equation*}

    \begin{enumerate}
        \item Prove that
        %
        \begin{equation*}
            \cdv{(JV)}{t} = J\qty(\cdv{V}{t}).
        \end{equation*}
        %
        In other words, that the covariant derivative commutes with $J$,
        the rotation of angle $\frac{π}{2}$.
        %
        \begin{equation*}
            \cdv{t} \circ J = J \circ \cdv{t}.
        \end{equation*}

        \item Conclude that $V \in \vfield(α)$ is parallel along $α$
        if and only if so is $JV$.

        \item Suppose that $V \neq 0$ is parallel along $α$.
        Prove that any other field $W \in \vfield(α)$ is parallel along $α$
        if and only if there exist constants $a,b \in \R$ such that
        %
        \begin{equation*}
            W(t) = aV(t) + bJV(t).
        \end{equation*}
    \end{enumerate}
\end{problem}

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

\subsection*{Answer}

    Write $JV = N \cross V$. Then the derivative can be computed as
%
\begin{equation*}
    \dv{(N \cross V)}{t} = \dv{N}{t} \cross V + N \cross \dv{V}{t}.
\end{equation*}

Let us examine the first cross product.
$N$ is unitary, which means that $\dv{N}{t}$ is tangent to $S$.
Because $V$ is also tangent to $S$,
$\dv{N}{t} \cross V$ is normal to $S$.
Now let us look at the second cross product,
which is normal to $N$ and therefore tangential to $S$.
%
\begin{gather*}
    % \dv{V}{t} = \cdv{V}{t} + \qty(\dv{V}{t})^{\perp}. \\
    N \cross \dv{V}{t} =
    N \cross \qty(\cdv{V}{t} + \qty(\dv{V}{t})^{\perp}) =
    N \cross \cdv{V}{t}.
\end{gather*}
%
Writing everything together we get
%
\begin{equation*}
    \cdv{(JV)}{t} =
    \cdv{(N \cross V)}{t} =
    \qty(\dv{(N \cross V)}{t})^{\top} =
    N \cross \dv{V}{t} =
    N \cross \cdv{V}{t} =
    J\qty(\cdv{V}{t}).
\end{equation*}

    As a small corollary, we can conclude that $V$ is parallel if and only if so is $JV$,
due to the fact that $J$ is an isomorphism ($Jv = 0 \iff v = 0$).
%
\begin{equation*}
    \cdv{(JV)}{t} = J\qty(\cdv{V}{t}) = 0 \iff \cdv{V}{t} = 0.
\end{equation*}

    If we now take a parallel vector field $V \in \vfield(α)$
such that $V \neq 0$,\footnote{
    Because the norm of a parallel vector field is constant,
    it is the same to ask that $V \neq 0$ or that $V(t) \neq 0$ for all $t \in I$.
}
$V(t)$ and $JV(t)$ form an (orthogonal) basis of $T_{α(t)}S$.
Thus, any other differentiable vector field $W \in \vfield(α)$ can be written as
%
\begin{equation*}
    W = aV + bJV
\end{equation*}
%
for some \emph{unique} functions $a,b : I \to \R$.
More precisely, we know that
$a(t) = \frac{\inner{W(t)}{V(t)}}{\norm{V(t)}^2}$ and
$b(t) = \frac{\inner{W(t)}{JV(t)}}{\norm{JV(t)}^2}$,
which means that $a$ and $b$ are differentiable.
This allows us to write the covariant derivative of $W$ as
%
\begin{equation*}
    \cdv{W}{t} =
    \dv{a}{t}V + a\cdv{V}{t} + \dv{b}{t}JV + b\cdv{(JV)}{t} =
    \dv{a}{t}V + \dv{b}{t}JV.
\end{equation*}
%
$W$ is parallel if and only if its covariant derivative is everywhere $0$.
However, because $V(t)$ and $JV(t)$ form a basis,
$\cdv{W}{t}\qty(t) = \dv{a}{t}\qty(t)V(t) + \dv{b}{t}\qty(t)JV(t) = 0$
if and only if $\dv{a}{t}(t) = \dv{b}{t}(t) = 0$.
That is, $W$ is parallel if and only if $\dv{a}{t} = \dv{b}{t} = 0$
if and only if $a$ and $b$ are constants.

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

\end{document}


\subsection{Domain Example} \label{sec:dd_example}
This section describes how to compute the values for the \var{run\_dd}
and \var{param\_dd} arrays.

First, we shall generate the values for the parameter data domain.  These
are the values for the \var{param\_dd} array.  LIS' parameter data is defined
on a Latitude/Longitude grid, from $-180$ to $180$ degrees longitude and
from $-60$ to $90$ degrees latitude.

For this example, consider running at 1/4 deg resolution.  The coordinates
of the south-west and the north-east points are specified at the grid-cells'
centers.
Here the south-west grid-cell is given by the box
$(-180,-60), (-179.750,-59.750)$.
The center of this box is $(-179.875,-59.875)$.
\footnote{Note, these coordinates are ordered (longitude, latitude).}
\begin{verbatim}
param_dd(1)   = -59.875
param_dd(2)   = -179.875
\end{verbatim}

The north-east grid-cell is given by the box $(179.750,89.750), (180,90)$.
Its center is $(179.875,89.875)$.
\begin{verbatim}
param_dd(3)   = 89.875
param_dd(4)   = 179.875
\end{verbatim}

Setting the resolution (0.25 deg) gives
\begin{verbatim}
param_dd(5)   = 0.25
param_dd(6)   = 0.25
\end{verbatim}

And this completely defines the parameter data domain.

Next, we shall generate the values for the running domain.  These
are the values for the \var{run\_dd} array.

Since the parameter data is on a Latitude/Longitude grid, we set
\begin{verbatim}
run_dd(1)   = 0
\end{verbatim}

If you wish to run over the whole domain defined by the parameter data
domain then you simply set the values of dd(2) -- dd(7) equal to
the values given by dd(8) -- dd(13).  This gives
\begin{verbatim}
run_dd(2)    = -59.875
run_dd(3)    = -179.875
run_dd(4)    = 89.875
run_dd(5)    = 179.875
run_dd(6)    = 0.25
run_dd(7)   = 0.25
\end{verbatim}

Now say you wish to run only over the region given by
$(-97.6,27.9), (-92.9,31.9)$.  Since the running domain is a sub-set of the
parameter domain, it is also a Latitude/Longitude domain at 1/4 deg.
resolution.  Thus,
\begin{verbatim}
run_dd(6)    = 0.25
run_dd(7)   = 0.25
\end{verbatim}

Now, since the running domain must fit onto the parameter domain, the desired
running region must be expanded from $(-97.6,27.9), (-92.9,31.9)$
to $(-97.75,27.75), (-92.75,32.0)$.  The south-west grid-cell for the running
domain is the box $(-97.75,27.75), (-97.5,28.0)$.
Its center is $(-97.625,27.875)$; giving
\begin{verbatim}
run_dd(2)    = 27.875
run_dd(3)    = -97.625
\end{verbatim}

The north-east grid-cell for the running domain is the box
$(-93,31.75), (-92.75,32.0)$.  Its center is $(-92.875,31.875)$; giving
\begin{verbatim}
run_dd(4)    = 31.875
run_dd(5)    = -92.875
\end{verbatim}

This completely defines the running domain.

Note, the LIS project has defined 5 km resolution to be 0.05 deg. and
1 km resolution to be 0.01 deg.  If you wish to run at 5 km or 1 km
resolution, redo the above example to compute the appropriate grid-cell
values.

See Figure~\ref{fig:snap_to_grid} for an illustration of adjusting the running
grid.  See Figures~\ref{fig:south-west} and \ref{fig:north-east} for an
illustration of the south-west and north-east grid-cells.

\begin{figure}
\figureimage[.75]{c}{figs/snap_to_grid.png}
\caption{Illustration showing how to fit the desired running grid onto the actual grid} \label{fig:snap_to_grid}
\end{figure}

\begin{figure}
\figureimage[.75]{c}{figs/sw.png}
\caption{Illustration showing the south-west grid-cell corresponding to
the example in Section~\ref{sec:dd_example}} \label{fig:south-west}
\end{figure}

\begin{figure}
\figureimage[.75]{c}{figs/ne.png}
\caption{Illustration showing the north-east grid-cell corresponding to
the example in Section~\ref{sec:dd_example}} \label{fig:north-east}
\end{figure}


\chapter{Variational-Net Solutions}
\begin{abox}
	Practise set-01
\end{abox}
\begin{enumerate}
	\item A double pendulum consists of two point masses $m$ attached by strings of length $l$ as shown in the figure: The kinetic energy of the pendulum is
	{\exyear{NET/JRF(DEC-2011)}}
\begin{figure}[H]
\centering
\includegraphics[height=4cm,width=4.5cm]{diagram-20210926(1)-crop}
\end{figure}
\begin{tasks}(1)
\task[\textbf{A.}] $\frac{1}{2} m l^{2}\left[\dot{\theta}_{1}^{2}+\dot{\theta}_{2}^{2}\right]$
\task[\textbf{B.}] $\frac{1}{2} m l^{2}\left[2 \dot{\theta}_{1}^{2}+\dot{\theta}_{2}^{2}+2 \dot{\theta}_{1} \dot{\theta}_{2} \cos \left(\theta_{1}-\theta_{2}\right)\right]$
\task[\textbf{C.}] $\frac{1}{2} m l^{2}\left[\dot{\theta}_{1}^{2}+2 \dot{\theta}_{2}^{2}+2 \dot{\theta}_{1} \dot{\theta}_{2} \cos \left(\theta_{1}-\theta_{2}\right)\right]$
\task[\textbf{D.}] $\frac{1}{2} m l^{2}\left[2 \dot{\theta}_{1}^{2}+\dot{\theta}_{2}^{2}+2 \dot{\theta}_{1} \dot{\theta}_{2} \cos \left(\theta_{1}+\theta_{2}\right)\right]$
\end{tasks}
\begin{answer}
\begin{align*}
\text{	Let co-ordinate }&\left(x_{1}, y_{1}\right)\text{ and }\left(x_{2}, y_{2}\right) .\\ K . E .&=\frac{1}{2} m\left(\dot{x}_{1}^{2}+\dot{y}_{1}^{2}\right)+\frac{1}{2} m\left(\dot{x}_{2}^{2}+\dot{y}_{2}^{2}\right)\\
x_{1}&=l \sin \theta_{1}, y_{1}=l \cos \theta_{1} \Rightarrow \dot{x}_{1}\\&=l \cos \theta_{1} \dot{\theta}_{1}, \dot{y}_{1}=-l \sin \theta_{1} \dot{\theta}_{1}\\
x_{2}&=l \sin \theta_{1}+l \sin \theta_{2}, y_{2}=l \cos \theta_{1}+l \cos \theta_{2}\\
\Rightarrow \dot{x}_{2}&=l \cos \theta_{1} \dot{\theta}_{1}+l \cos \theta_{2} \dot{\theta}_{2}, \dot{y}_{2}\\&=l\left(-\sin \theta_{1} \dot{\theta}_{1}\right)+l\left(-\sin \theta_{2}\right) \dot{\theta}_{2}
\intertext{Put the value of $\dot{x}_{1}, \dot{y}_{1}, \dot{x}_{2}, \dot{y}_{2}$ in K.E equation, one will get}
T&=\frac{1}{2} m l^{2}\left[2 \dot{\theta}_{1}^{2}+\dot{\theta}_{2}^{2}+2 \dot{\theta}_{1} \dot{\theta}_{2} \cos \left(\theta_{1}-\theta_{2}\right)\right]
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item A particle of mass $m$ moves inside a bowl. If the surface of the bowl is given by the equation $z=\frac{1}{2} a\left(x^{2}+y^{2}\right)$, where $a$ is a constant, the Lagrangian of the particle is
{\exyear{NET/JRF(DEC-2011)}}
\begin{tasks}(2)
\task[\textbf{A.}] $\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\phi}^{2}-g a r^{2}\right)$
\task[\textbf{B.}] $\frac{1}{2} m\left[\left(1+a^{2} r^{2}\right) \dot{r}^{2}+r^{2} \dot{\phi}^{2}\right]$
\task[\textbf{C.}]  $\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\theta}^{2}+r^{2} \sin ^{2} \theta \dot{\phi}^{2}-g a r^{2}\right)$
\task[\textbf{D.}]  $\frac{1}{2} m\left[\left(1+a^{2} r^{2}\right) \dot{r}^{2}+r^{2} \dot{\phi}^{2}-g a r^{2}\right]$
\end{tasks}
\begin{answer}
\begin{align*}
L&=\frac{1}{2} m\left(\dot{x}^{2}+\dot{y}^{2}+\dot{z}^{2}\right)-m g z,\\\text{ where } z&=\frac{1}{2} a\left(x^{2}+y^{2}\right)\\
\text{It has cylindrical symmetry. Thus }x&=r \cos \phi, y=r \sin \phi, z=\frac{1}{2} a\left(r^{2}\right)\\
\dot{x}&=\dot{r} \cos \phi-r \sin \phi \dot{\phi}, \dot{y}\\&=\dot{r} \sin \phi+r \cos \phi \dot{\phi}\text{ and }\dot{z}=a(r \dot{r})\\
\text{	So, }L&=\frac{1}{2} m\left[\left(1+a^{2} r^{2}\right) \dot{r}^{2}+r^{2} \dot{\phi}^{2}-g a r^{2}\right]
\end{align*}
So the correct answer is \textbf{Option (D)}
\end{answer}
\item The Lagrangian of a particle of mass $m$ moving in one dimension is given by
$$
L=\frac{1}{2} m \dot{x}^{2}-b x
$$
where $b$ is a positive constant. The coordinate of the particle $x(t)$ at time $t$ is given by: (in following $c_{1}$ and $c_{2}$ are constants)
{\exyear{NET/JRF(JUNE-2013)}}
\begin{tasks}(2)
\task[\textbf{A.}] $-\frac{b}{2 m} t^{2}+c_{1} t+c_{2}$
\task[\textbf{B.}] $c_{1} t+c_{2}$
\task[\textbf{C.}] $c_{1} \cos \left(\frac{b t}{m}\right)+c_{2} \sin \left(\frac{b t}{m}\right)$
\task[\textbf{D.}] $c_{1} \cosh \left(\frac{b t}{m}\right)+c_{2} \sinh \left(\frac{b t}{m}\right)$
\end{tasks}
\begin{answer}
\begin{align*}
\text{Equation of motion }\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\frac{\partial L}{\partial x}&=0 \Rightarrow \frac{d}{d t}(m \dot{x})+b\\&=0 \Rightarrow m \ddot{x}+b=0 \Rightarrow m \ddot{x}=-b\\
\frac{d^{2} x}{d t^{2}}&=-\frac{b}{m} \Rightarrow \frac{d x}{d t}=-\frac{b}{m} t+c_{1} \Rightarrow x\\&=-\frac{b}{m} \frac{t^{2}}{2}+c_{1} t+c_{2}
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item A particle moves in a potential $V=x^{2}+y^{2}+\frac{z^{2}}{2} .$ Which component(s) of the angular momentum is/are constant(s) of motion?
{\exyear{NET/JRF(DEC-2013)}}
\begin{tasks}(4)
\task[\textbf{A.}] None
\task[\textbf{B.}] $L_{x}, L_{y}$ and $L_{z}$
\task[\textbf{C.}]  only $L_{x}$ and $L_{y}$
\task[\textbf{D.}] only $L_{z}$
\end{tasks}
\begin{answer}
\begin{align*}
\text{A particle moves in a potential }V&=x^{2}+y^{2}+\frac{z^{2}}{2}\\
V(r, \theta, \phi)&=r^{2} \sin ^{2} \theta \cos ^{2} \phi+r^{2} \sin ^{2} \theta \sin ^{2} \phi+\frac{r^{2}}{2} \cos ^{2} \theta\\
V(r, \theta, \phi)&=r^{2} \sin ^{2} \theta+\frac{r^{2}}{2} \cos ^{2} \theta\\
\text{	Now $\phi$ is cyclic-co-ordinate }&\left(p_{\phi}\right)\text{ i.e $L_{z}$ is constant of motion.}
\end{align*}
So the correct answer is \textbf{Option (D)}
\end{answer}
\item A pendulum consists of a ring of mass $M$ and radius $R$ suspended by a massless rigid rod of length $l$ attached to its rim. When the pendulum oscillates in the plane of the ring, the time period of oscillation is
{\exyear{NET/JRF(DEC-2013)}}
\begin{tasks}(2)
\task[\textbf{A.}] $2 \pi \sqrt{\frac{l+R}{g}}$
\task[\textbf{B.}] $\frac{2 \pi}{\sqrt{g}}\left(l^{2}+R^{2}\right)^{1 / 4}$
\task[\textbf{C.}] $2 \pi \sqrt{\frac{2 R^{2}+2 R l+l^{2}}{g(R+l)}}$
\task[\textbf{D.}] $\frac{2 \pi}{\sqrt{g}}\left(2 R^{2}+2 R l+l^{2}\right)^{1 / 4}$
\end{tasks}
\begin{answer}
\begin{align*}
\intertext{The moment of inertia about pivotal point is given by}
I&=I_{c, m}+M d^{2}=M R^{2}+M(l+R)^{2}\\
\intertext{If ring is displaced by angle $\theta$ then potential energy is $-M g(l+R) \cos \theta$.}
\intertext{ The Lagrangian is given by}
L&=\frac{1}{2} I \dot{\theta}^{2}-V(\theta)\\&=\frac{1}{2}\left(M R^{2}+M(l+R)^{2}\right) \dot{\theta}^{2}+M g(l+R) \cos \theta\\
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{\theta}}\right)-\left(\frac{\partial L}{\partial \theta}\right)&=0 \Rightarrow\left(M R^{2}+M(l+R)^{2}\right) \ddot{\theta}+M g(l+R) \sin \theta=0\\
\text{For small oscillation }\sin \theta&=\theta \Rightarrow\left(M R^{2}+M(l+R)^{2}\right) \ddot{\theta}+M g(l+R) \theta=0\\
\text{Time period is given by }&2 \pi \sqrt{\frac{2 R^{2}+2 R l+l^{2}}{g(R+l)}}.
\end{align*}
So the correct answer is \textbf{Option (C)}
\end{answer}
\item Consider a particle of mass $m$ attached to two identical springs each of length $l$ and spring constant $k$ (see the figure). The equilibrium configuration is the one where the springs are unstretched. There are no other external forces on the system. If the particle is given a small displacement along the $x$-axis, which of the following describes the equation of motion for small oscillations?
{\exyear{NET/JRF(DEC-2013)}}
\begin{figure}[H]
\centering
\includegraphics[height=4.5cm,width=5cm]{diagram-20210926(18)-crop}
\end{figure}
\begin{tasks}(4)
\task[\textbf{A.}] $m \ddot{x}+\frac{k x^{3}}{l^{2}}=0$
\task[\textbf{B.}]  $m \ddot{x}+k x=0$
\task[\textbf{C.}] $m \ddot{x}+2 k x=0$
\task[\textbf{D.}] $m \ddot{x}+\frac{k x^{2}}{l}=0$
\end{tasks}
\begin{answer}$\left. \right. $
\begin{figure}[H]
	\centering
	\includegraphics[height=4.5cm,width=5cm]{diagram-20210926(19)-crop}
\end{figure}
\begin{align*}
\intertext{The lagrangian of system is given by}
L&=\frac{1}{2} m \dot{x}^{2}-V(x)
\intertext{The potential energy is given by}
V(x)&=\frac{k}{2}\left[\left(x^{2}+l^{2}\right)^{\frac{1}{2}}-l\right]^{2}+\frac{k}{2}\left[\left(x^{2}+l^{2}\right)^{\frac{1}{2}}-l\right]^{2}\\
V(x)&=k\left[\left(x^{2}+l^{2}\right)^{\frac{1}{2}}-l\right]^{2}
\intertext{For small oscillation one can approximate potential by Taylor expansion}
V(x)&=k l^{2}\left[\left(1+\frac{x^{2}}{l^{2}}\right)^{\frac{1}{2}}-1\right]^{2} \Rightarrow V(x)\\&=k l^{2}\left[\left(1+\frac{1}{2} \frac{x^{2}}{l^{2}}-\frac{1}{8} \frac{x^{4}}{l^{4}}\right)-1\right]^{2}\\
V(x)&=\frac{k l^{2}}{4}\left(\frac{x^{2}}{l^{2}}\right)^{2} \Rightarrow V(x)=k\left(\frac{x^{4}}{4 l^{2}}\right)\\
\text{So Lagrangian of system is given by }L&=\frac{1}{2} m \dot{x}^{2}-k\left(\frac{x^{4}}{4 l^{2}}\right)\\
\text{The Lagranges equation of motion }&\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\left(\frac{\partial L}{\partial x}\right)=0 \Rightarrow m \ddot{x}+\frac{k x^{3}}{l^{2}}=0
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item The equation of motion of a system described by the time-dependent Lagrangian
$$
L=e^{\gamma t}\left[\frac{1}{2} m \dot{x}^{2}-V(x)\right] \text { is }
$$
{\exyear{NET/JRF(DEC-2014)}}
\begin{tasks}(2)
\task[\textbf{A.}] $m \ddot{x}+\gamma m \dot{x}+\frac{d V}{d x}=0$
\task[\textbf{B.}] $m \ddot{x}+\gamma m \dot{x}-\frac{d V}{d x}=0$
\task[\textbf{C.}]  $m \ddot{x}-\gamma m \dot{x}+\frac{d V}{d x}=0$
\task[\textbf{D.}] $m \ddot{x}+\frac{d V}{d x}=0$
\end{tasks}
\begin{answer}
\begin{align*}
\because L&=e^{\gamma t}\left[\frac{1}{2} m \dot{x}^{2}-V(x)\right] \Rightarrow \frac{\partial L}{\partial \dot{x}}\\&=e^{\gamma t} m \dot{x}\text{ and }\frac{\partial L}{\partial x}=-\frac{\partial V}{\partial x} e^{\gamma t}\\
\because \frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\frac{\partial L}{\partial x}&=0 \Rightarrow \frac{d}{d t}\left(e^{\gamma t} m \dot{x}\right)+\frac{\partial V}{\partial x} e^{\gamma t}\\&=m \ddot{x} e^{r t}+m \dot{x} \gamma e^{\gamma t}+\frac{\partial V}{\partial x} e^{r t}=0\\
\left(m \ddot{x}+m \gamma \dot{x}+\frac{\partial V}{\partial x}\right) e^{\gamma t}&=0 \Rightarrow m \ddot{x}+\gamma m \dot{x}+\frac{\partial V}{\partial x}=0
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item A particle of unit mass moves in the $x y$-plane in such a way that $\dot{x}(t)=y(t)$ and $\dot{y}(t)=-x(t) .$ We can conclude that it is in a conservative force-field which can be derived from the potential
{\exyear{NET/JRF(JUNE-2015)}}
\begin{tasks}(4)
\task[\textbf{A.}] $\frac{1}{2}\left(x^{2}+y^{2}\right)$
\task[\textbf{B.}] $\frac{1}{2}\left(x^{2}-y^{2}\right)$
\task[\textbf{C.}] $x+y$
\task[\textbf{D.}] $x-y$
\end{tasks}
\begin{answer}
\begin{align*}
\because \dot{x}&=y\text{ and }\dot{y}=-x\\
\Rightarrow \quad \ddot{x}&=\dot{y}=-x \quad\text{ and }\ddot{y}=-\dot{x}=-y\\
\Rightarrow \quad \ddot{x}+x&=0 \quad\text{ and }\ddot{y}+y=0\\
\text{that is possible for }L&=\frac{1}{2} m \dot{x}^{2}+\frac{1}{2} m \dot{y}^{2}-\frac{1}{2}\left(x^{2}+y^{2}\right) \\\Rightarrow V&=\frac{1}{2}\left(x^{2}+y^{2}\right)
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item The Lagrangian of a particle moving in a plane s given in Cartesian coordinates as
$$
L=\dot{x} \dot{y}-x^{2}-y^{2}
$$
In polar coordinates the expression for the canonical momentum $p_{r}$ (conjugate to the radial coordinate $r$ ) is
{\exyear{NET/JRF(DEC-2015)}}
\begin{tasks}(2)
\task[\textbf{A.}] $\dot{r} \sin \theta+r \dot{\theta} \cos \theta$
\task[\textbf{B.}]  $\dot{r} \cos \theta+r \dot{\theta} \sin \theta$
\task[\textbf{C.}] $2 \dot{r} \cos \theta-r \dot{\theta} \sin 2 \theta$
\task[\textbf{D.}] $\dot{r} \sin 2 \theta+r \dot{\theta} \cos 2 \theta$
\end{tasks}
\begin{answer}
\begin{align*}
L&=\dot{x} \dot{y}-x^{2}-y^{2}=\dot{x} \dot{y}-\left(x^{2}+y^{2}\right)\\
x&=r \cos \theta, y=r \sin \theta \Rightarrow \dot{x}=\dot{r} \cos \theta-r \sin \theta \dot{\theta}, \\ \dot{y}&=\dot{r} \sin \theta+r \cos \theta \dot{\theta}\\
L&=\dot{r}^{2} \sin \theta \cos \theta-r^{2} \sin \theta \cos \theta \dot{\theta}^{2}+\dot{r} r \cos ^{2} \theta \dot{\theta}-\dot{r} r \sin ^{2} \theta \dot{\theta}\\
P_{r}&=\frac{\partial L}{\partial \dot{r}} \Rightarrow 2 \dot{r} \sin \theta \cos \theta+r \dot{\theta}\left(\cos ^{2} \theta-\sin ^{2} \theta\right)\\
\Rightarrow P_{r}&=\dot{r} \sin 2 \theta+r \dot{\theta} \cos 2 \theta
\end{align*}
So the correct answer is \textbf{Option (D)}
\end{answer}
\item The dynamics of a particle governed by the Lagrangian
$$
L=\frac{1}{2} m \dot{x}^{2}-\frac{1}{2} k x^{2}-k x \dot{x} t \text { describes }
$$
{\exyear{NET/JRF(DEC-2016)}}
\begin{tasks}(1)
\task[\textbf{A.}] An undamped simple harmonic oscillator
\task[\textbf{B.}] A damped harmonic oscillator with a time varying damping factor
\task[\textbf{C.}]  An undamped harmonic oscillator with a time dependent frequency
\task[\textbf{D.}] A free particle
\end{tasks}
\begin{answer}
\begin{align*}
L&=\frac{1}{2} m \dot{x}^{2}-\frac{1}{2} k x^{2}-k x \dot{x} t\\
\frac{\partial L}{\partial \dot{x}}&=m \dot{x}-k x t, \frac{\partial L}{\partial x}=-k x-k \dot{x} t\\
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\frac{\partial L}{\partial x}&=0 \Rightarrow m \ddot{x}-k \dot{x} t-k x+k x+k \dot{x} t\\&=0 \Rightarrow m \ddot{x}=0
\intertext{So motion is equivalent to free particle}
\end{align*}
So the correct answer is \textbf{Option (D)}
\end{answer}
\item The parabolic coordinates $(\xi, \eta)$ are related to the Cartesian coordinates $(x, y)$ by $x=\xi \eta$ and $y=\frac{1}{2}\left(\xi^{2}-\eta^{2}\right)$. The Lagrangian of a two-dimensional simple harmonic oscillator of mass $m$ and angular frequency $\omega$ is
{\exyear{NET/JRF(DEC-2016)}}
\begin{tasks}(2)
\task[\textbf{A.}] $\frac{1}{2} m\left[\dot{\xi}^{2}+\dot{\eta}^{2}-\omega^{2}\left(\xi^{2}+\eta^{2}\right)\right]$
\task[\textbf{B.}] $\frac{1}{2} m\left(\xi^{2}+\eta^{2}\right)\left[\left(\dot{\xi}^{2}+\dot{\eta}^{2}\right)-\frac{1}{4} \omega^{2}\left(\xi^{2}+\eta^{2}\right)\right]$
\task[\textbf{C.}] $\frac{1}{2} m\left(\xi^{2}+\eta^{2}\right)\left[\dot{\xi}^{2}+\dot{\eta}^{2}-\frac{1}{2} \omega^{2} \xi \eta\right]$
\task[\textbf{D.}] $\frac{1}{2} m\left(\xi^{2}+\eta^{2}\right)\left[\dot{\xi}^{2}+\dot{\eta}^{2}-\frac{1}{4} \omega^{2}\right]$
\end{tasks}
\begin{answer}
\begin{align*}
\intertext{For two dimensional Harmonic oscillation}
L&=\frac{1}{2} m\left(\dot{x}^{2}+\dot{y}^{2}\right)-\frac{1}{2} m \omega^{2}\left(x^{2}+y^{2}\right)\\
x&=\xi \eta, \quad y=\frac{1}{2}\left(\xi^{2}-\eta^{2}\right)\\
\dot{x}&=\dot{\xi} \eta+\xi \dot{\eta}, \quad \dot{y}=\xi \dot{\xi}-\eta \dot{\eta}\\
L&=\frac{1}{2} m\left[(\dot{\xi} \eta+\xi \dot{\eta})^{2}+(\xi \dot{\xi}-\eta \dot{\eta})^{2}\right]-\frac{1}{2} m \omega^{2}\left[\xi^{2} \eta^{2}+\frac{1}{4}\left(\xi^{2}-\eta^{2}\right)^{2}\right]\\
L&=\frac{1}{2} m\left(\dot{\xi}^{2} \eta^{2}+\xi^{2} \dot{\eta}^{2}+\xi^{2} \dot{\xi}^{2}+\eta^{2} \dot{\eta}^{2}\right)-\frac{1}{8} m \omega^{2}\left(\xi^{4}+\eta^{4}+2 \xi^{2} \eta^{2}\right)\\
&=\frac{1}{2} m\left(\xi^{2}+\eta^{2}\right)\left(\dot{\eta}^{2}+\dot{\xi}^{2}\right)-\frac{1}{8} m \omega^{2}\left(\xi^{2}+\eta^{2}\right)^{2}\\
&=\frac{1}{2} m\left(\xi^{2}+\eta^{2}\right)\left[\dot{\eta}^{2}+\dot{\xi}^{2}-\frac{1}{4} \omega^{2}\left(\xi^{2}+\eta^{2}\right)\right]
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item The spring constant $k$ of a spring of mass $m_{s}$ is determined experimentally by loading the spring with mass $M$ and recording the time period $T$, for a single oscillation. If the experiment is carried out for different masses, then the graph that correctly represents the result is
{\exyear{NET/JRF(DEC-2017)}}
\begin{tasks}(2)
\task[\textbf{A.}] \begin{figure}[H]
	\centering
	\includegraphics[height=3cm,width=4.5cm]{diagram-20210926(38)-crop}
\end{figure}
\task[\textbf{B.}] \begin{figure}[H]
	\centering
	\includegraphics[height=3cm,width=4.5cm]{diagram-20210926(39)-crop}
\end{figure}
\task[\textbf{C.}] \begin{figure}[H]
	\centering
	\includegraphics[height=3cm,width=4.5cm]{diagram-20210926(40)-crop}
\end{figure}
\task[\textbf{D.}] \begin{figure}[H]
	\centering
	\includegraphics[height=3cm,width=4.5cm]{diagram-20210926(41)-crop}
\end{figure}
\end{tasks}
\begin{answer}
\begin{align*}
\intertext{The Langragian of system.}
L&=\frac{1}{2} \cdot \frac{m_{s}}{3} \dot{x}^{2}+\frac{1}{2} M \dot{x}^{2}-\frac{1}{2} k x^{2}, \frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\frac{\partial L}{\partial x}=0\\
\frac{d}{d t} \frac{\partial L}{\partial x}&=0 \Rightarrow\left(\frac{m_{s}}{3}+M\right) \ddot{x}=-k x\\
T&=2 \pi \sqrt{\frac{M+\frac{m_{s}}{3}}{k}} \Rightarrow T^{2}=4 \pi \frac{\left(M+\frac{m_{s}}{3}\right)}{k}
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item The motion of a particle in one dimension is described by the Langrangian $L=\frac{1}{2}\left(\left(\frac{d x}{d t}\right)^{2}-x^{2}\right)$ in suitable units. The value of the action along the classical path from $x=0$ at $t=0$ to $x=x_{0}$ at $t=t_{0}$, is
{\exyear{NET/JRF(DEC-2018)}}
\begin{tasks}(4)
\task[\textbf{A.}] $\frac{x_{0}^{2}}{2 \sin ^{2} t_{0}}$
\task[\textbf{B.}] $\frac{1}{2} x_{0}^{2} \tan t_{0}$
\task[\textbf{C.}] $\frac{1}{2} x_{0}^{2} \cot t_{0}$
\task[\textbf{D.}] $\frac{x_{0}^{2}}{2 \cos ^{2} t_{0}}$
\end{tasks}
\begin{answer}
\begin{align*}
L&=\frac{1}{2} \dot{x}^{2}-\frac{1}{2} x^{2}\\
\intertext{From Lagrangian equation of motion, $\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\frac{\partial L}{\partial x}=0$}
\ddot{x}+x&=0\\
\text{The solution is}&=A \sin t+B \cos t\\
t&=0, \quad x=0, \quad B=0\\
x&=A \sin t\\
t&=t_{0}, \quad x=x_{0}, A=\frac{x_{0}}{\sin t_{0}}\\
x&=\frac{x_{0}}{\sin t_{0}} \sin t, \quad \dot{x}=\frac{x_{0}}{\sin t_{0}} \cos t\\
A&=\int_{0}^{t_{0}} L d t=\int_{0}^{t_{0}} \frac{1}{2} \dot{x}^{2} d t-\int_{0}^{t_{0}} \frac{1}{2} x^{2} d t\\&=\frac{1}{2} \frac{x_{0}^{2}}{\sin ^{2} t_{0}} \int_{0}^{t_{0}} \cos ^{2} t d t-\frac{1}{2} \frac{x_{0}^{2}}{\sin ^{2} t_{0}} \int_{0}^{t_{0}} \sin ^{2} t d t\\
&=\frac{1}{2} \frac{x_{0}^{2}}{\sin ^{2} t_{0}}\left[\int_{0}^{t_{0}} \cos ^{2} t d t-\int_{0}^{t} \sin ^{2} t d t\right]\\&=\frac{1}{2} \frac{x_{0}^{2}}{\sin ^{2} t_{0}} \int_{t}^{t_{0}} \cos 2 t d t=\left.\frac{1}{2} \frac{x_{0}^{2}}{\sin ^{2} t_{0}} \frac{\sin 2 t_{0}}{2}\right|_{0} ^{t_{0}}=\frac{x_{0}^{2}}{2} \cot t_{0}
\end{align*}
So the correct answer is \textbf{Option (C)}
\end{answer}
\item Two particles of masses $m_{1}$ and $m_{2}$ are connected by a massless thread of length $l$ as shown in figure below.\\
The particle of mass in on the plane undergoes a circular motion with radius $r_{0}$ and angular momentum $L$. When a small radial displacement $\in$ (whew $\in \ll<r_{0}$ ) is applied, its radial coordinate is found to oscillate about $r_{0}$. The frequency of the oscillations is
{\exyear{NET/JRF(JUNE-2019)}}
\begin{tasks}(2)
\task[\textbf{A.}] $\sqrt{\frac{7 m_{2} g}{\left(m_{1}+\frac{m_{2}}{2}\right) r_{0}}}$
\task[\textbf{B.}] $\sqrt{\frac{7 m_{2} g}{\left(m_{1}+m_{2}\right) r_{0}}}$
\task[\textbf{C.}] $\sqrt{\frac{3 m_{2} g}{\left(m_{1}+\frac{m_{2}}{2}\right) r_{0}}}$
\task[\textbf{D.}] $\sqrt{\frac{3 m_{2} g}{\left(m_{1}+m_{2}\right) r_{0}}}$
\end{tasks}
\begin{answer}
\begin{align*}
L&=\frac{1}{2}\left(m_{1}+m_{2}\right) \ddot{r}+\frac{1}{2} m_{1} r^{2} \dot{\theta}^{2}-m_{2} g(l-r)\\
\text{Lagrangian equation of motion; }&\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{r}}\right)-\frac{\partial L}{\partial r}=0\\
\left(m_{1}+m_{2}\right) \ddot{r}-m_{1} r \dot{\theta}^{2}+m_{2} g&=0
\intertext{Hence angular momentum is conserved}
m_{1} r^{2} \dot{\theta}&=m_{1} r_{0}^{2} \dot{\theta}_{0} \Rightarrow \dot{\theta}=\frac{r_{0}^{2} \dot{\theta}_{0}}{r^{2}}\\
\text{For circular motion }&m r_{0} \dot{\theta}_{0}^{2}=m_{2} g\\
\text{	so }r \dot{\theta}^{2}&=\frac{m_{2}}{m_{1}}\left(\frac{r_{0}}{r}\right)^{3} g\\
\left(m_{1}+m_{2}\right) \ddot{r}-m_{2}\left(\frac{r_{0}}{r}\right)^{3} g+m_{2} g&=0\\
\text{Put }r&=r_{0}+\in \ddot{r}=\ddot{\epsilon}\\
\intertext{$\left(m_{1}+m_{2}\right) \ddot{\in}-m_{2}\left(\frac{r_{0}}{r_{0}+\epsilon}\right)^{3} g+m_{2} g\Rightarrow\left(m_{1}+m_{2}\right) \ddot{\in}-m_{2} r_{0}^{3}\left(r_{0}+\epsilon\right)^{-3} g+m_{2} g$}\\
\left(m_{1}+m_{2}\right) \ddot{\star}-m_{2} r_{0}^{3} g r_{0}^{-3}\left(1+\frac{\epsilon}{r_{0}}\right)^{-3}+m_{2} g&=0\\
\left(m_{1}+m_{2}\right) \ddot+\frac{m_{2} 3 \epsilon}{r_{0}}&=0 \Rightarrow \omega=\sqrt{\frac{3 m_{2} g}{\left(m_{1}+m_{2}\right) r_{0}}}
\end{align*}
So the correct answer is \textbf{Option (D)}
\end{answer}
\item Which of the following terms, when added to the Lagrangian $L(x, y, \dot{x}, \dot{y})$ of a system with two degrees of freedom will not change the equations of motion?\\
(check question )
{\exyear{NET/JRF(DEC-2019)}}
\begin{tasks}(4)
\task[\textbf{A.}] $x \ddot{x}-y \ddot{y}$
\task[\textbf{B.}] $x \ddot{y}-y \ddot{x}$
\task[\textbf{C.}] $x \dot{y}-y \dot{x}$
\task[\textbf{D.}] $y \dot{x}^{2}+x \dot{y}^{2}$
\end{tasks}
\begin{answer}
\begin{align*}
L(x, y, \dot{x}, \dot{y})\\
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\frac{\partial L}{\partial x}&=0, \frac{d}{d t}\left(\frac{\partial L}{\partial \dot{y}}\right)-\frac{\partial L}{\partial y}=0\\
L^{\prime}&=L(x, y, \dot{x}, \dot{y})+x \ddot{y}-y \ddot{x}\\
\frac{d^{\prime}}{d t^{\prime}}\left(\frac{\partial L^{\prime}}{\partial \dot{x}}\right)-\frac{\partial L^{\prime}}{\partial x}&=\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\frac{\partial L}{\partial x}+\ddot{y}\\&=0=0+\ddot{y}=0 \Rightarrow \dot{y}=c_{1}\\
\frac{d}{d t}\left(\frac{\partial L}{\partial y}\right)-\frac{\partial L^{\prime}}{\partial y}&=\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{y}}\right)-\frac{\partial L}{\partial y}+\ddot{x}\\&=0=0-\ddot{x}=0 \Rightarrow \dot{x}=c_{2}
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item A point mass $m$, is constrained to move on the inner surface of a paraboloid of revolution $x^{2}+y^{2}=a z$ (where $a>0$ is a constant). When it spirals down the surface, under the influence of gravity (along $-z$ direction), the angular speed about the $z$-axis is proportional to
{\exyear{NET/JRF(JUNE-2020)}}
\begin{tasks}(2)
\task[\textbf{A.}] 1 (independent of $z$ )
\task[\textbf{B.}] $z$
\task[\textbf{C.}]  $z^{-1}$
\task[\textbf{D.}] $z^{-2}$
\end{tasks}
\begin{answer}
\begin{align*}
\intertext{Using Lagrangian in cylindrical coordinate}
L&=\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\theta}^{2}+\dot{z}^{2}\right)-m g z \\\text{ with constraint }x^{2}+y^{2}&=a z \Rightarrow r^{2}=a z \Rightarrow \dot{z}=\frac{2 r \dot{r}}{a}\\
L&=\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\theta}^{2}+\left(\frac{2 r \dot{r}}{a}\right)^{2}\right)-\frac{m g r^{2}}{a}\\
\theta \text{is cyclic coordinate so }\frac{\partial L}{\partial \theta}&=0 \Rightarrow \frac{\partial L}{\partial \dot{\theta}}=J \Rightarrow m r^{2} \dot{\theta}=J \Rightarrow \dot{\theta} \propto \frac{1}{r^{2}} \propto \frac{1}{z}
\end{align*}
So the correct answer is \textbf{Option (C)}
\end{answer}
\end{enumerate}
\newpage
\begin{abox}
	Practise set-02
\end{abox}
\begin{enumerate}
	\item A particle of mass $m$ slides under the gravity without friction along the parabolic path $y=a x^{2}$, as shown in the figure. Here $a$ is a constant.\\
	\begin{figure}[H]
		\centering
		\includegraphics[height=4.5cm,width=5cm]{diagram-20210915(2)-crop}
	\end{figure}
	The Lagrangian for this particle is given by
{	\exyear{GATE 2012}}
\begin{tasks}(2)
\task[\textbf{A.}] $L=\frac{1}{2} m \dot{x}^{2}-m g a x^{2}$
\task[\textbf{B.}] $L=\frac{1}{2} m\left(1+4 a^{2} x^{2}\right) \dot{x}^{2}-m g a x^{2}$
\task[\textbf{C.}] $L=\frac{1}{2} m \dot{x}^{2}+m g a x^{2}$
\task[\textbf{D.}] $L=\frac{1}{2} m\left(1+4 a^{2} x^{2}\right) \dot{x}^{2}+m g a x^{2}$
\end{tasks}
\begin{answer}
\begin{align*}
\text{	Equation of constrain is given by }y&=a x^{2}, K.E., T=\frac{1}{2}m\left(\dot{x}^{2}+\dot{y}^{2}\right)\\
\dot{y}&=2 a x \dot{x} \Rightarrow T=\frac{1}{2} m\left(\dot{x}^{2}+4 a^{2} x^{2} \dot{x}^{2}\right)\\&=\frac{1}{2} m \dot{x}^{2}\left(1+4 a x^{2}\right) \\
V&=m g y=m g a x^{2}\\
\because L&=T-V \Rightarrow L\\&=\frac{1}{2} m\left(1+4 a^{2} x^{2}\right) \dot{x}^{2}-m g a x^{2}
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item  The Lagrange's equation of motion of the particle for above question is given by
{\exyear{GATE 2012}}
\begin{tasks}(2)
\task[\textbf{A.}] $\ddot{x}=2 g a x$
\task[\textbf{B.}] $m\left(1+4 a^{2} x^{2}\right) \ddot{x}=-2 m g a x-4 m a^{2} x \dot{x}^{2}$
\task[\textbf{C.}] $m\left(1+4 a^{2} x^{2}\right) \ddot{x}=2 m g a x+4 m a^{2} x \dot{x}^{2}$
\task[\textbf{D.}] $\ddot{x}=-2 g a x$
\end{tasks}
\begin{answer}
\begin{align*}
\frac{d}{d t}\left(\frac{d L}{d \dot{x}}\right)&=\frac{d L}{d x} \Rightarrow m \ddot{x}\left(1+4 a^{2} x^{2}\right)\\&=-4 m a^{2} x \dot{x}^{2}-2 m g a x
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item The Lagrangian of a system with one degree of freedom $q$ is given by $L=\alpha \dot{q}^{2}+\beta q^{2}$, where $\alpha$ and $\beta$ are non-zero constants. If $p_{q}$ denotes the canonical momentum conjugate to $q$ then which one of the following statements is CORRECT?
{\exyear{GATE 2013}}
\begin{tasks}(1)
\task[\textbf{A.}] $p_{q}=2 \beta q$ and it is a conserved quantity.
\task[\textbf{B.}]  $p_{q}=2 \beta q$ and it is not a conserved quantity.
\task[\textbf{C.}] $p_{q}=2 \alpha \dot{q}$ and it is a conserved quantity.
\task[\textbf{D.}]  $p_{q}=2 \alpha \dot{q}$ and it is not a conserved quantity.
\end{tasks}
\begin{answer}
\begin{align*}
\text{	As, }\frac{\partial L}{\partial \dot{q}}=p_{q}\text{ but }\quad \frac{\partial L}{\partial q} \neq 0.\text{ Thus, it is not a conserved quantity.}
\end{align*}
So the correct answer is \textbf{Option (D)}
\end{answer}
\item A bead of mass $m$ can slide without friction along a massless rod kept at $45^{\circ}$ with the vertical as shown in the figure. The rod is rotating about the vertical axis with a constant angular speed $\omega$. At any instant $r$ is the distance of the bead from the origin. The momentum conjugate to $r$ is
{\exyear{GATE 2014}}
\begin{figure}[H]
\centering
\includegraphics[height=5cm,width=7cm]{diagram-20210915(4)-crop}
\end{figure}
\begin{tasks}(4)
\task[\textbf{A.}] $m \dot{r}$
\task[\textbf{B.}] $\frac{1}{\sqrt{2}} m \dot{r}$
\task[\textbf{C.}] $\frac{1}{2} m \dot{r}$
\task[\textbf{D.}] $\sqrt{2} m \dot{r}$
\end{tasks}
\begin{answer}
\begin{align*}
L&=\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\theta}^{2}+r^{2} \sin ^{2} \theta \dot{\phi}^{2}\right)-m g r \cos \theta\\
\text{Equation of constrain is }\theta&=\frac{\pi}{4}\text{ and it is given } \dot{\phi}=\omega\\
L&=\frac{1}{2} m\left(\dot{r}^{2}+\frac{1}{2} r^{2} \omega^{2}\right)-\frac{1}{\sqrt{2}} m g r\\
\text{	Thus the momentum conjugate to $r$ is }p_{r}&=\frac{\partial L}{\partial \dot{r}} \Rightarrow p_{r}=m \dot{r}
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item The Lagrangian of a system is given by
$L=\frac{1}{2} m l^{2}\left[\dot{\theta}^{2}+\sin ^{2} \theta \dot{\varphi}^{2}\right]-m g l \cos \theta$, where $m, l$ and $g$ are constants.
Which of the following is conserved?
{\exyear{GATE 2016}}
\begin{tasks}(4)
\task[\textbf{A.}] $\dot{\varphi} \sin ^{2} \theta$
\task[\textbf{B.}] $\dot{\varphi} \sin \theta$
\task[\textbf{C.}] $\frac{\dot{\varphi}}{\sin \theta}$
\task[\textbf{D.}] $\frac{\dot{\varphi}}{\sin ^{2} \theta}$
\end{tasks}
\begin{answer}
\begin{align*}
\intertext{Solution: As $\varphi$ is cyclic coordinate, so $\frac{\partial L}{\partial \dot{\varphi}}=p_{\varphi}=m l^{2} \sin ^{2} \dot{\varphi}$, is a constant since $m, l$ and $g$ are constants. Thus $\dot{\varphi} \sin ^{2} \theta$ is conserved.}
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item If the Lagrangian $L_{0}=\frac{1}{2} m\left(\frac{d q}{d t}\right)^{2}-\frac{1}{2} m \omega^{2} q^{2}$ is modified to $L=L_{0}+\alpha q\left(\frac{d q}{d t}\right)$, which one of the following is TRUE?
{\exyear{GATE 2017}}
\begin{tasks}(1)
\task[\textbf{A.}] Both the canonical momentum and equation of motion do not change
\task[\textbf{B.}] Canonical momentum changes, equation of motion does not change
\task[\textbf{C.}] Canonical momentum does not change, equation of motion changes
\task[\textbf{D.}] Both the canonical momentum and equation of motion change
\end{tasks}
\begin{answer}
\begin{align*}
\text{	For Lagrangian }L_{0}&=\frac{1}{2} m\left(\frac{d q}{d t}\right)^{2}-\frac{1}{2} m \omega^{2} q^{2}\\
\text{canonical momentum is }p&=m \dot{q}
\intertext{ and equation of motion is given by }\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{q}}\right)-\left(\frac{\partial L}{\partial q}\right)&=0 \Rightarrow m \ddot{q}+m \omega^{2} q=0\\
\text{For Lagrangian }L&=L_{0}+\alpha q\left(\frac{d q}{d t}\right) \Rightarrow L\\&=\frac{1}{2} m\left(\frac{d q}{d t}\right)^{2}-\frac{1}{2} m \omega^{2} q^{2}+\alpha q \dot{q}\\
\text{Canonical momentum is }p&=m \dot{q}+\alpha q\\
\text{Equation of motion is,}\\
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{q}}\right)-\left(\frac{\partial L}{\partial q}\right)&=0 \Rightarrow m \ddot{q}+m \omega^{2} q=0
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item  A double pendulum consists of two equal masses $m$ suspended by two strings of length $l$. What is the Lagrangian of this system for oscillations in a plane? Assume the angles $\theta_{1}, \theta_{2}$ made by the two strings are small (you can use $\cos \theta=1-\theta^{2} / 2$ ).\\
Note: $\omega_{0}=\sqrt{g / l}$.
{\exyear{JEST 2014}}
\begin{tasks}(1)
\task[\textbf{A.}] $L \approx m l^{2}\left(\dot{\theta}_{1}^{2}+\frac{1}{2} \dot{\theta}_{2}^{2}-\omega_{0}^{2} \theta_{1}^{2}-\frac{1}{2} \omega_{0}^{2} \theta_{2}^{2}\right)$
\task[\textbf{B.}]  $L \approx m l^{2}\left(\dot{\theta}_{1}^{2}+\frac{1}{2} \dot{\theta}_{2}^{2}+\dot{\theta}_{1} \dot{\theta}_{2}-\omega_{0}^{2} \theta_{1}^{2}-\frac{1}{2} \omega_{0}^{2} \theta_{2}^{2}\right)$
\task[\textbf{C.}] $L \approx m l^{2}\left(\dot{\theta}_{1}^{2}+\frac{1}{2} \dot{\theta}_{2}^{2}-\dot{\theta}_{1} \dot{\theta}_{2}-\omega_{0}^{2} \theta_{1}^{2}-\frac{1}{2} \omega_{0}^{2} \theta_{2}^{2}\right)$
\task[\textbf{D.}]  $L \approx m l^{2}\left(\frac{1}{2} \dot{\theta}_{1}^{2}+\frac{1}{2} \dot{\theta}_{2}^{2}+\dot{\theta}_{1} \dot{\theta}_{2}-\omega_{0}^{2} \theta_{1}^{2}-\omega_{0}^{2} \theta_{2}^{2}\right)$
\end{tasks}
\begin{answer}$\left. \right. $\\
\begin{minipage}{0.45\textwidth}
	\begin{align*}
	x_{1}&=l \sin \theta_{1},\\ y_{1}&=l \cos \theta_{1}\\
	x_{2}&=x_{1}+l \sin \theta_{2}\\y_{2}&=y_{1}+l \cos \theta_{2}\\
	\dot{x}_{2}&=l \cos \theta_{1} \dot{\theta}_{1}+l \cos \theta_{2} \dot{\theta}_{2},\\ \dot{y}_{2}&=-l \sin \theta_{1} \dot{\theta}_{1}-l \sin \theta_{2} \dot{\theta}_{2}\\
	\dot{x}_{2}^{2}+\dot{y}_{2}^{2}&=l^{2} \cos ^{2} \theta_{1} \dot{\theta}_{1}^{2}+l^{2} \cos ^{2} \theta_{2} \dot{\theta}_{2}^{2}\\&+2 l^{2} \cos \theta_{1} \dot{\theta}_{1} \cos \theta_{2} \dot{\theta}_{2}+l^{2} \sin \theta_{1}^{2} \dot{\theta}_{1}^{2}
	\\&+l^{2} \sin \theta_{2}^{2} \dot{\theta}_{2}^{2}+2 l^{2} \sin \theta_{1} \sin \theta_{2} \dot{\theta}_{1} \dot{\theta}_{2}\\
	\Rightarrow \dot{x}_{2}^{2}+\dot{y}_{2}^{2}&=l^{2} \dot{\theta}_{1}^{2}+l^{2} \dot{\theta}_{2}^{2}+2 l^{2} \cos \left(\theta_{1}-\theta_{2}\right) \dot{\theta}_{1} \dot{\theta}_{2}\\\text{ also }\dot{x}_{1}^{2}+\dot{y}_{1}^{2}&=l^{2} \dot{\theta}_{1}^{2}\\
	\end{align*}
\end{minipage}
\begin{minipage}{0.35\textwidth}
	\begin{figure}[H]
		\centering
		\includegraphics[height=4cm,width=4cm]{diagram-20210807(4)-crop}
	\end{figure}
\end{minipage}
\begin{align*}
L=T-V&=\frac{1}{2} m\left(\dot{x}_{1}^{2}+\dot{y}_{1}^{2}+\dot{x}_{2}^{2}+\dot{y}_{2}^{2}\right)-m g y_{1}-m g y_{2}\\
\Rightarrow L&=\frac{1}{2} m\left(l^{2} \dot{\theta}_{1}^{2}+l^{2} \dot{\theta}_{1}^{2}+l^{2} \dot{\theta}_{2}^{2}+2 l^{2} \cos \left(\theta_{1}-\theta_{2}\right) \dot{\theta}_{1} \dot{\theta}_{2}\right)\\&+2 m g l \cos \theta_{1}+m g l \cos \theta_{2}\\
\Rightarrow L&=m l^{2}\left[\dot{\theta}_{1}^{2}+\frac{1}{2} \dot{\theta}_{2}^{2}+\dot{\theta}_{1} \dot{\theta}_{2}+\frac{2 g}{2 l}\left(1-\frac{\theta_{1}^{2}}{2}\right)+\frac{1}{2} \frac{g}{l}\left(1-\frac{\theta_{2}^{2}}{2}\right)\right]\\&\left[\because \cos \left(\theta_{1}-\theta_{2}\right) \approx 1\right]\\
\Rightarrow L&=m l^{2}\left[\dot{\theta}_{1}^{2}+\frac{1}{2} \dot{\theta}_{2}^{2}+\dot{\theta}_{1} \dot{\theta}_{2}+\frac{g}{l}-\frac{g}{l} \frac{\theta_{1}^{2}}{2}+\frac{g}{2 l}-\frac{g}{2 l} \frac{\theta_{2}^{2}}{2}\right]
\intertext{comparing given options, option (B) is correct i.e.}
L&=m l^{2}\left(\dot{\theta}_{1}^{2}+\frac{1}{2} \dot{\theta}_{2}^{2}+\dot{\theta}_{1} \dot{\theta}_{2}-\frac{\omega_{0}^{2} \dot{\theta}_{1}^{2}}{2}-\frac{1}{4} \omega_{0} \dot{\theta}_{2}^{2}\right)
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item A bike stuntman rides inside a well of frictionless surface given by $z=a\left(x^{2}+y^{2}\right)$, under the action of gravity acting in the negative $z$ direction. $\vec{g}=-g \hat{z} .$ What speed should be maintain to be able to ride at a constant height $z_{0}$ without falling down?
{\exyear{JEST 2015}}
\begin{tasks}(1)
\task[\textbf{A.}] $\sqrt{g z_{0}}$
\task[\textbf{B.}] $\sqrt{3 g z_{0}}$
\task[\textbf{C.}] $\sqrt{2 g z_{0}}$
\task[\textbf{D.}] The biker will not be able to maintain a constant height, irrespective of speed.
\end{tasks}
\begin{answer}
\begin{align*}
z&=a\left(x^{2}+y^{2}\right)
\intertext{Using equation of constrain, we must solve the given system in cylindrical co-ordinate.}
z&=a r^{2}, \dot{z}=2 a r \dot{r} \Rightarrow L\\&=\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\theta}+\dot{z}^{2}\right)-m g z\\
\Rightarrow L&=\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\theta}+4 a^{2} r^{2} \dot{r}^{2}\right)-m g a r^{2}\\&=\frac{1}{2} m\left[\dot{r}^{2}\left(1+4 a^{2} r^{2}\right)+r^{2} \dot{\theta}^{2}\right]-m g a r^{2}\\
\text{	Equation of motion}\\
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{r}}\right)-\frac{\partial L}{\partial r}&=0\\
\Rightarrow m \ddot{r}\left(1+4 a^{2} r^{2}\right)+m \dot{r}^{2} 4 a^{2} r-m r \dot{\theta}^{2}+2 m g a r&=0\\
\text{At }z=z_{0}, \dot{r}=0, \quad r=r_{0},\text{ so,} m r_{0} \dot{\theta}^{2}&=2 m g a r_{0}\\
\dot{\theta}^{2}&=2 g a \Rightarrow \dot{\theta}=\sqrt{2 g a}, \frac{v}{r_{0}}\\&=\sqrt{2 g a}, v=\sqrt{2 g a} \cdot r_{0}\\
v&=\sqrt{2 g a} \cdot\left(\frac{z_{0}}{a}\right)^{1 / 2}\\&=\sqrt{2 g z_{0}}\\
\left(\because z_{0}=a r_{0}^{2}\right)
\end{align*}
So the correct answer is \textbf{Option (C)}
\begin{figure}[H]
	\centering
	\includegraphics[height=2.5cm,width=4cm]{diagram-20210809(8)-crop}
\end{figure}
\end{answer}
\item The Lagrangian of a particle is given by $L=\dot{q}^{2}-q \dot{q}$. Which of the following statements is true?
{\exyear{JEST 2015}}
\begin{tasks}(1)
\task[\textbf{A.}]  This is a free particle
\task[\textbf{B.}] The particle is experiencing velocity dependent damping
\task[\textbf{C.}] The particle is executing simple harmonic motion
\task[\textbf{D.}] The particle is under constant acceleration.
\end{tasks}
\begin{answer}
\begin{align*}
\because L&=\dot{q}^{2}-q \dot{q} \Rightarrow \frac{\partial L}{\partial \dot{q}}\\&=2 \dot{q}-q \Rightarrow \frac{d}{d t}\left(\frac{\partial L}{\partial \dot{q}}\right)\\&=2 \ddot{q}-\dot{q}\\
\because \frac{d}{d t}\left(\frac{\partial L}{\partial \dot{q}}\right)-\frac{\partial L}{\partial q}&=0
\Rightarrow 2 \ddot{q}-\dot{q}+\dot{q}\\&=0 \Rightarrow 2 \ddot{q}=0 \Rightarrow \frac{d^{2} q}{d t^{2}}\\&=0 \Rightarrow \frac{d q}{d t}=C \Rightarrow q=C t+\alpha
\end{align*}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item A hoop of radius a rotates with constant angular velocity $\omega$ about the
vertical axis as shown in the figure. A bead of mass $m$ can slide on the
hoop without friction. If $g<\omega^{2} a$ at what angle $\theta$ apart from 0 and $\pi$ is the bead stationary (i.e., $\frac{d \theta}{d t}=\frac{d^{2} \theta}{d t^{2}}=0$ )?
{\exyear{JEST 2016}}
\begin{figure}[H]
\centering
\includegraphics[height=4.2cm,width=3.5cm]{diagram-20210809(11)-crop}
\caption{}
\label{}
\end{figure}
\begin{tasks}(4)
\task[\textbf{A.}] $\tan \theta=\frac{\pi g}{\omega^{2} a}$
\task[\textbf{B.}] $\sin \theta=\frac{g}{\omega^{2} a}$
\task[\textbf{C.}] $\cos \theta=\frac{g}{\omega^{2} a}$
\task[\textbf{D.}] $\tan \theta=\frac{g}{\pi \omega^{2} a}$
\end{tasks}
\begin{answer}
\begin{align*}
\text{The Lagrangian of the system is}\\
L&=\frac{1}{2} m a^{2}\left(\dot{\theta}^{2}+\sin ^{2} \theta \dot{\phi}^{2}\right)+m g a \cos \theta\\
\text{The equation of motion is,}\\
&\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{\theta}}\right)-\left(\frac{\partial L}{\partial \theta}\right)\\&=0 \Rightarrow m a^{2} \ddot{\theta}-m a^{2}\left(\sin \theta \cos \theta \dot{\phi}^{2}\right)+m g a \sin \theta=0\\
\text{When bead is stationary, then}\\
\frac{d \theta}{d t}&=\frac{d^{2} \theta}{d t^{2}}\\&=0 \Rightarrow-m a^{2}\left(\sin \theta \cos \theta \dot{\phi}^{2}\right)+m g a \sin \theta=0\\
\Rightarrow \dot{\phi}&=\omega\text{ and }g<\omega^{2} a,\text{ then }\cos \theta=\frac{g}{\omega^{2} a}
\end{align*}
So the correct answer is \textbf{Option (C)}
\end{answer}
\item A bead of mass $M$ slides along a parabolic wire described by $z=2\left(x^{2}+y^{2}\right)$. The wire rotates with angular velocity $\Omega$ about the $z$ - axis. At what value of $\Omega$ does the bead maintain a constant nonzero height under the action of gravity along $-\hat{z}$ ?
{\exyear{JEST 2017}}
\begin{tasks}(4)
\task[\textbf{A.}] $\sqrt{3 g}$
\task[\textbf{B.}] $\sqrt{g}$
\task[\textbf{C.}] $\sqrt{2 g}$
\task[\textbf{D.}] $\sqrt{4 g}$
\end{tasks}
\begin{answer}
\begin{align*}
L&=\frac{1}{2} m\left(\dot{r}^{2}+r^{2} \dot{\theta}^{2}+16 r^{2} \dot{r}^{2}\right)-2 m g r^{2} \Rightarrow L\\&=\frac{1}{2} m\left(\dot{r}^{2}\left(1+16 r^{2}\right)+r^{2} \dot{\theta}^{2}\right)-2 m g r^{2}
\intertext{The equation of motion is given by}
&\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{r}}\right)-\frac{\partial L}{\partial r}\\&=0 \Rightarrow m \ddot{r}\left(1+16 r^{2}\right)+16 m \dot{r}^{2} r-m r \dot{\theta}^{2}+4 m g r=0\\
\text{	At equilibrium, }r&=r_{0}, \dot{r}=0, \ddot{r}=0\\
\text{So, }-m r_{0} \dot{\theta}^{2}+4 m g r_{0}&=0 \Rightarrow \dot{\theta}=\Omega=\sqrt{4 g}
\end{align*}
So the correct answer is \textbf{Option (D)}
\end{answer}
\item A possible Lagrangian for a free particle is
{\exyear{JEST 2017}}
\begin{tasks}(4)
\task[\textbf{A.}] $L=\dot{q}^{2}-q^{2}$
\task[\textbf{B.}] $L=\dot{q}^{2}-q \dot{q}$
\task[\textbf{C.}] $L=\dot{q}^{2}-q$
\task[\textbf{D.}] $L=\dot{q}^{2}-\frac{1}{q}$
\end{tasks}
\begin{answer}
\begin{align*}
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{q}}\right)-\left(\frac{\partial L}{\partial q}\right)&=0 \Rightarrow 2 \ddot{q}-\dot{q}+\dot{q}\\&=0 \Rightarrow \ddot{q}=0
\end{align*}
So the correct answer is \textbf{Option (B)}
\end{answer}
\item  A rod of mass $m$ and length $l$ is suspended from two massless vertical springs with a spring constants $k_{1}$ and $k_{2} .$ What is the Lagrangian for the system, if $x_{1}$ and $x_{2}$ be the displacements from equilibrium position of the two ends of the rod?
{\exyear{JEST 2017}}
\begin{tasks}(2)
\task[\textbf{A.}] $\frac{m}{8}\left(\dot{x}_{1}^{2}+2 \dot{x}_{1} \dot{x}_{2}+\dot{x}_{2}^{2}\right)-\frac{1}{2} k_{1} x_{1}^{2}-\frac{1}{2} k_{2} x_{2}^{2}$
\task[\textbf{B.}] $\frac{m}{2}\left(\dot{x}_{1}^{2}+\dot{x}_{1} \dot{x}_{2}+\dot{x}_{2}^{2}\right)-\frac{1}{4}\left(k_{1}+k_{2}\right)\left(x_{1}^{2}+x_{2}^{2}\right)$
\task[\textbf{C.}] $\frac{m}{6}\left(\dot{x}_{1}^{2}+x_{1} \dot{x}_{2}+\dot{x}_{2}^{2}\right)-\frac{1}{2} k_{1} x_{1}^{2}-\frac{1}{2} k_{2} x_{2}^{2}$
\task[\textbf{D.}] $\frac{m}{2}\left(\dot{x}_{1}^{2}-2 \dot{x}_{1} \dot{x}_{2}+\dot{x}_{2}^{2}\right)-\frac{1}{4}\left(k_{1}-k_{2}\right)\left(x_{1}^{2}+x_{2}^{2}\right)$
\end{tasks}
\begin{answer}
\begin{align*}
T&=\frac{1}{2} M V_{c, m}^{2}+\frac{1}{2} I_{c . m} \omega^{2}\\&=\frac{1}{2} m\left(\frac{\dot{x}_{1}+\dot{x}_{2}}{2}\right)^{2}+\frac{1}{2} \frac{m l^{2}}{12} \dot{\theta}^{2}\\
\text{	Potential energy is, }V&=\frac{1}{2} k x_{1}^{2}+\frac{1}{2} k x_{2}^{2}\\
\sin \theta&=\frac{x_{2}-x_{1}}{l}\text{ for small oscillation} \theta\\&=\frac{x_{2}-x_{1}}{l}=\dot{\theta}\\&=\frac{\dot{x}_{2}-\dot{x}_{1}}{l}\\
L&=\frac{1}{2} m\left(\frac{\dot{x}_{1}+\dot{x}_{2}}{2}\right)^{2}+\frac{1}{2} \frac{m l^{2}}{12}\left(\frac{\dot{x}_{1}-\dot{x}_{2}}{l}\right)^{2}-\frac{1}{2} k x_{1}^{2}-\frac{1}{2} k x_{2}^{2}\\
&=\frac{m}{6}\left(\dot{x}_{1}^{2}+x_{1} \dot{x}_{2}+\dot{x}_{2}^{2}\right)-\frac{1}{2} k_{1} x_{1}^{2}-\frac{1}{2} k_{2} x_{2}^{2}
\end{align*}
So the correct answer is \textbf{Option (C)}
\end{answer}
\item Consider the Lagrangian
$$L=1-\sqrt{1-\dot{q}^{2}}-\frac{q^{2}}{2}$$
of a particle executing oscillations whose amplitude is $A$. If $p$ denotes the momentum of the particle, then $4 p^{2}$ is
{\exyear{JEST 2015}}
\begin{tasks}(2)
\task[\textbf{A.}] (a) $\left(A^{2}-q^{2}\right)\left(4+A^{2}-q^{2}\right)$
\task[\textbf{B.}] $\left(A^{2}+q^{2}\right)\left(4+A^{2}-q^{2}\right)$
\task[\textbf{C.}] $\left(A^{2}-q^{2}\right)\left(4+A^{2}+q^{2}\right)$
\task[\textbf{D.}] $\left(A^{2}+q^{2}\right)\left(4+A^{2}+q^{2}\right)$
\end{tasks}
\begin{answer}
So the correct answer is \textbf{Option (A)}
\end{answer}
\item Consider the motion of a particle in two dimensions given by the Lagrangian $$L=\frac{m}{2}\left(\dot{x}^{2}+\dot{y}^{2}\right)-\frac{\lambda}{4}(x+y)^{2}$$
where $\lambda>0$. The initial conditions are given as $y(0)=0, x(0)=42$ meters, $\dot{x}(0)=\dot{y}(0)=0$. What is the value of $x(t)-y(t)$ at $t=25$ seconds in meters?
{\exyear{JEST 2019}}
\begin{answer}
\begin{align}
L&=\frac{m}{2}\left(\dot{x}^{2}+\dot{y}^{2}\right)-\frac{\lambda}{4}(x+y)^{2}\notag
\intertext{The equation of motion is}
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{x}}\right)-\left(\frac{\partial L}{\partial x}\right)&=0 \Rightarrow m \ddot{x}+\frac{\lambda}{2} x+\frac{\lambda}{2} y=0\label{72-1}\\
\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{y}}\right)-\left(\frac{\partial L}{\partial y}\right)&=0 \Rightarrow m \ddot{y}+\frac{\lambda}{2} y+\frac{\lambda}{2} x=0\label{72-2}
\intertext{Subtracting equation (\ref{72-1}) from (\ref{72-2}) gives $m(\ddot{x}-\ddot{y})=0 \Rightarrow \ddot{x}-\ddot{y}=0$}\notag
\intertext{Integrating both sides with $t$ gives}\notag
\dot{x}-\dot{y}&=c_{1}\notag\\
\text{	From the equation }\dot{x}(0)&=\dot{y}(0)=0,\text{ there }c_{1}=0\notag\\
\text{Hence, }\dot{x}-\dot{y}&=0\label{jest10}\\
\intertext{Integrating both sides of this equation with $t$ gives}
x-y&=c_{2}\notag\\
\text{Putting }x(0)&=42, y(0)=0\text{ gives}\notag\\
42-0&=c_{2} \Rightarrow 42\notag\\
\text{Therefore, }x-y=42\notag\\
\intertext{The value of $x-y$ is independent of $t$.}\notag
\text{Therefore, at }t&=25 s\notag\\
x(t)-y(t)&=42\notag
\end{align}
\end{answer}

\end{enumerate}

Classical Mechanics  -CSIR/chapter/Variational Principles -Solutionstex.tex


\documentclass[11pt,a4paper]{article}
\usepackage{fullpage}
\usepackage{graphicx}

\begin{document}

\section*{Theory}
Let us consider the following simplified EMI model
\begin{eqnarray}
\nabla\cdot(\sigma_i) u_i &=& 0, \mbox{ in } \Omega_i \\
\nabla\cdot(\sigma_e) u_e &=& 0, \mbox{ in } \Omega_e \\
\sigma \nabla u_i \cdot n  -v &=& f \mbox{ on } \Gamma
\end{eqnarray}
where
$\Omega_i$ is the intra-cellular domain,  $\Omega_e$
is the extra-cellular domain,  and $\Gamma$ is
the cell membrane. The unknowns $u_i$ and $u_e$ are
intra- and extracellular potientials whereas
$v$ is the transmembrane potential.
We have interface conditions
\begin{eqnarray}
u_i - u_e &=& v  \\
\sigma_i \nabla u_i \cdot n_i &=& -\sigma_e \nabla u_e \cdot n_e
\end{eqnarray}
When EMI is considered in cardiac modelling the \emph{interior} domain is
a union of a number of heart cells and $\Gamma$ represents not only the
interfaces between cells and the exterior but the cell-cell interfaces as well,
see Figure \ref{fig:iface_types}. The source terms $f$ on the two interface types
are typically different. Here we shall assume only on interface type.

\begin{figure}
      \begin{center}
     \includegraphics[scale=0.5]{./multi_branches23.mps}
   \end{center}
   \caption{Interface types in the EMI problem. (blue) cell-cell interfaces,
     (red) cell-exterior inerfaces.}
   \label{fig:iface_types}
\end{figure}

The mixed formulation is obtained
by introducing the fluxes $s_i = \sigma_i \nabla u_i$
and $s_e = \sigma_e \nabla u_e$. Noting that the flux has continuour normal
component, we may write the above equations
in weak form as: Find
$s \in H(\mbox{div}, \Omega)$
$u \in L^2(\Omega)$
$v \in H^{1/2}(\Gamma)$  such that
\begin{eqnarray}
(\sigma^{-1} s, k)_{\Omega} + (u, \nabla \cdot k)_{\Omega} - (v,   n \cdot k)_\Gamma &=& 0 \\
(\nabla \cdot s, l)_{\Omega} &=& 0 \\
(s\cdot n, m)_{\Gamma} - (v, m)_{\Gamma} &=& 0 \\
\end{eqnarray}
for
$k \in H(\mbox{div}, \Omega)$
$l \in L^2(\Omega)$
$m \in H^{1/2}(\Gamma)$
We remark here that the variations
between $\sigma_i$ and $\sigma_e$ are
small, typically order of 10.

Formally, we may write the system as
\[
\left(
\begin{array}{ccc}
\sigma^{-1} & (\nabla\cdot)' & T_n' \\
\nabla \cdot & 0 & 0 \\
T_n & 0 & -I
\end{array}
\right)
\left(
\begin{array}{c}
s \\ u \\ v
\end{array}
\right)
=
\left(
\begin{array}{c}
f \\ g \\ h
\end{array}
\right)
\]
and to discretize the problem we would use
Raviart-Thomas elements combined with corresponding discontinuous
Galerkin for $s$ and $u$. Further, $v$ is only defined on $\Gamma$
and is similarly discretized by discontinuous Galerkin elements
of the same order as $u$.

In the FEniCS implementation we note that finite elements
on sub-manifolds is still not fully supported, at least not
in parallel. Therefore the space for $v$ shall be setup on \emph{all}
the facets in $\Omega$ and not just on $\Gamma$. As such, we modify the
above system to obtain
\[
\left(
\begin{array}{ccc}
\sigma^{-1} & (\nabla\cdot)' & T_n' \\
\nabla \cdot & 0 & 0 \\
T_n & 0 & -I_f
\end{array}
\right)
\left(
\begin{array}{c}
s \\ u \\ v
\end{array}
\right)
=
\left(
\begin{array}{c}
f \\ g \\ h
\end{array}
\right)
\]
Here, let $E$ be the set of faces in $\Omega$ (both
in the interior and at the boundary), then
\[
I_m (v,m) = \sum_{e \in E}\int_e v m \, \mbox{dS}
\]
We remark that $I_m$ is a diagonal matrix.

The question is then: Does BDDC work on this saddle point problem which
is somewhat similar to a standard mixed Darcy problem and is it scalable?

\section*{Practice}

Gmsh version with CAD support (version 3.0.7 and higher) is used to create
the geometry. Since using Gmsh for generation and subsequent meshing of the
geometry with order 1000 cylinders is not feasible the mesh is created in two
steps as follows. First we generate a mesh (referred to later as \emph{tile})
for one cylinder such that the facets in $x$ and $y$ directions are meshed periodically
\[
\texttt{gmsh -3 -clscale 0.25 tile\textunderscore 1\textunderscore narrow.geo}
\]
With the command below one gets a mesh with element size approximately 3$\mu m$.
\begin{center}
\includegraphics[width=\textwidth]{tile_1.png}
\end{center}

\begin{center}
\includegraphics[width=\textwidth]{single_cell.png}
\end{center}

To proceed the mesh is stored in HDF5 format as
\[
\texttt{python msh\textunderscore convert.py tile\textunderscore 1\textunderscore narrow.h5}
\]
Next with glue together the \emph{tiles} together in the periodic directions to
get the full mesh:
\[
\texttt{python tiling.py tile\textunderscore 1\textunderscore narrow.msh -n 128 -m 128},
\]
where $n, m$ specify the number of tiles in $x$ and $y$ directions. The algorithm generated the
mesh in approx 500 seconds (most of which was spent generating markers for the cell interiors
and interfaces) using about 30GB RAM. The mesh takes about 17GB of disk space.
A piece\footnote{I cannot render data from all 32 CPUs at once} of this mesh is shown below
using some of the cell surfaces (coloring by CPU

\subsubsection*{BUG} Due to the bug in the tile geometry discovered after the
above experiment was performed and which meant that only the mesh for the cells
was computed, the result do \emph{not} represent truly the computational effort
needed to get the full mesh. With the current settings of the geometry and mesh size
parameters the tetrahedra of the cell constitute roughly 1/4 of all the elements
in the tile. About factor 4 should then be used to get a more realistic picture
of the computational costs.

Let us note that we currently have rather large bounding box, and, more importantly,
the mesh has approximately uniformely sized elements. Smaller bounding box and
coarser mesh outiside of the cell boundary are some of the ways how to bring
the cost down.

\begin{center}
\includegraphics[width=\textwidth]{piece.png}
\end{center}

We remark that we observed factor 4 increase in the execution time/RAM/storage upon doubling
the $n$ and $m$ counts.

The computational domain generated above is such that the cells have interfaces which are on
the boundary of the domain. We currently asume that all the boundary surfaces (including the cells'
ones) have zero potential. The script for assembling the EMI system with the generated gemetry is
in \texttt{emi\textunderscore system.py}.

% Of the parameters in the script \texttt{cell\textunderscore grid.geo}
% the interesting ones are \emph{nx}, \emph{ny} which control the number of cells
% and thus the length of the interface, see
% \[
% \texttt{gmsh -setnumber nx 2 -setnumber ny 2 cell\textunderscore grid.geo}
% \]
% For mesh generation run
% \[
% \texttt{gmsh -3 -setnumber nx 2 -setnumber ny 2 -clscale 0.5 cell\textunderscore grid.geo}
% \]
% where the number $0.5$ passed to \emph{clscale} instructs to half the characteristic
% mesh sizes set in the script (\emph{size}\textunderscore\emph{box},
% \emph{size}\textunderscore\emph{cell}). The number thus controls resolution
% of the mesh. Two dimensional geometries are generated similarly using
% \[
% \texttt{gmsh -setnumber nx 2 -setnumber ny 2 cell\textunderscore grid\textunderscore 2d.geo}
% \]
% for inspecting and
% \[
% \texttt{gmsh -2 -setnumber nx 2 -setnumber ny 2 -clscale 1.0 cell\textunderscore grid\textunderscore 2d.geo}
% \]
% for generation of the mesh.

% When Gmsh is done, I convert the \emph{msh} file to HDF5 file format
% using the

\end{document}