% file: EM_dump.tex
% Electrodynamics, in unconventional ``grande'' format; fitting a widescreen format
% Electricity and Magnetism notes "dump"
%
% github        : ernestyalumni
% linkedin      : ernestyalumni
% wordpress.com : ernestyalumni
%
% This code is open-source, governed by the Creative Common license.  Use of this code is governed by the Caltech Honor Code: ``No member of the Caltech community shall take unfair advantage of any other member of the Caltech community.''
%

\documentclass[10pt]{amsart}
\pdfoutput=1
\usepackage{mathtools,amssymb,lipsum,caption}

\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage[table]{xcolor}
\usepackage{pdfpages}
%\usepackage[version=3]{mhchem}
\usepackage{mhchem}

\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\usepackage{multicol}

\hypersetup{colorlinks=true,citecolor=[rgb]{0,0.4,0}}

\oddsidemargin=15pt
\evensidemargin=5pt
\hoffset-45pt
\voffset-55pt
\topmargin=-4pt
\headsep=5pt
\textwidth=1120pt
\textheight=595pt
\paperwidth=1200pt
\paperheight=700pt
\footskip=40pt

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
%\newtheorem*{main}{Main Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{proposition}{Proposition}

\newtheorem{definition}{Definition}
\newtheorem{remark}{Remark}

\newenvironment{claim}[1]{\par\noindent\underline{Claim:}\space#1}{}
\newenvironment{claimproof}[1]{\par\noindent\underline{Proof:}\space#1}{\hfill $\blacksquare$}

%This defines a new command \questionhead which takes one argument and
%prints out Question #. with some space.
\newcommand{\questionhead}[1]
  {\bigskip\bigskip
   \noindent{\small\bf Question #1.}
   \bigskip}

\newcommand{\problemhead}[1]
  {
   \noindent{\small\bf Problem #1.}
   }

\newcommand{\exercisehead}[1]
  { \smallskip
   \noindent{\small\bf Exercise #1.}
  }

\newcommand{\solutionhead}[1]
  {
   \noindent{\small\bf Solution #1.}
   }

\title{Electromagnetism, Electrodynamics Dump;  \large Electricity and Magnetism dump (includes notes and solutions to Purcell's Electricity and Magnetism}
\author{Ernest Yeung \href{mailto:ernestyalumni@gmail.com}{ernestyalumni@gmail.com}}
\date{7 mars 2017}
\keywords{Electromagnetism, Electrodynamics, Electricity, Magnetism}
\begin{document}

\definecolor{darkgreen}{rgb}{0,0.4,0}
\lstset{language=Python,
 frame=bottomline,
 basicstyle=\scriptsize,
 identifierstyle=\color{blue},
 keywordstyle=\bfseries,
 commentstyle=\color{darkgreen},
 stringstyle=\color{red},
 }
%\lstlistoflistings

\maketitle

From the beginning of 2016, I decided to cease all explicit crowdfunding for any of my materials on physics, math.  I failed to raise \emph{any} funds from previous crowdfunding efforts.  I decided that if I was going to live in \emph{abundance}, I must lose a scarcity attitude.  I am committed to keeping all of my material \textbf{open-sourced}.  I give all my stuff \emph{for free}.

In the beginning of 2017, I received a very generous donation from a reader from Norway who found these notes useful, through \emph{PayPal}.  If you find these notes useful, feel free to donate directly and easily through \href{https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ernestsaveschristmas%2bpaypal%40gmail%2ecom&lc=US&item_name=ernestyalumni&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted}{PayPal}, which won't go through a 3rd. party such as indiegogo, kickstarter, patreon.  Otherwise, under the \emph{open-source MIT license}, feel free to copy, edit, paste, make your own versions, share, use as you wish.

\noindent gmail        : ernestyalumni \\
linkedin     : ernestyalumni \\
twitter      : ernestyalumni \\

\setcounter{tocdepth}{1}
\tableofcontents

\begin{multicols*}{2}

\begin{abstract}
Electricity and Magnetism notes "dump" - Everything about or involving electricity and magnetism, electrodynamics.

\end{abstract}

\part{Math}

\section{Codifferential, The "Vector Potential" and Laplacian}
\emph{Keywords}: codifferential, vector potential, Laplacian

\subsection{Codifferential $\delta$}

For smooth manifold $M$, $\text{dim}M = n$,
\begin{equation}
\boxed{
\begin{aligned}
	& \delta : \Omega^k(M) \to \Omega^{k-1}(M) \\
	& \delta = (-1)^{n(k+1)+1} * d*
\end{aligned}
}
\end{equation}

For $k=1,2$ cases,
\[
\begin{aligned}
	& \delta = (-1)^{n(1+1)+1} * d* = (-1) *d* \\
	& \delta = (-1)^{n(2+1) + 1} * d * = (-1)^{3n+1} *d*
\end{aligned}
\]
For $n=d=3$,
\[
\begin{aligned}
	& \mathbf{\delta} : \Omega^2(M) \to \Omega^1(M) \\
	& \mathbf{\delta} = \mathbf{* d * }
\end{aligned}
\]

\subsection{the "Vector Potential"}

If $B=\mathbf{d} A$, $B\in \Omega^2(M)$,
\[
\begin{gathered}
B= B_{jk} dx^j \wedge dx^k = \mathbf{d}A = \frac{ \partial A_k}{ \partial x^j} dx^j \wedge dx^k  \\
 B_{jk} = \frac{ \partial A_k}{ \partial x^j}
\end{gathered}
\]
So these statements are equivalent:
\begin{equation}
\boxed{
B =\mathbf{d} A \Longleftrightarrow \mathbf{B} = \text{curl} \mathbf{A}
}
\end{equation}

Indeed, recall the \emph{deRham cohomology}:

\[
\begin{gathered}
	H^k_{\text{deRham}}(M) = Z^k(M)/ \text{im}d = \frac{Z^k(M)}{ d\Omega^{k-1}(M) }
\end{gathered}
\]
And so this form for $B=\mathbf{d}A$ presupposes that
\[
B \in [1] = [\mathbf{d}A ] \in H^2_{\text{deRham}}(M')
\]
But it should be noted on another manifold, this form may not hold; indeed, consider a submanifold or domain $M' \subseteq M$.  In this case
\[
H^2_{\text{deRham}}(M') \ni B
\]

\subsection{Laplacian}

\begin{definition}[Laplacian]
\begin{equation}
\begin{aligned}
	& \Delta : \Omega^k(M) \to \Omega^k(M) \\
	& \Delta = d\delta + \delta d
\end{aligned}
\end{equation}
\end{definition}

Both recognizing the equivalence between these 2 formulations:
\[
\mathbf{*d*}B = \mathbf{\delta}B \Longleftrightarrow \text{curl} \mathbf{B}
\]
and acknowledging that it \emph{has} to be the case that $\mathbf{*d*}B$ is the correct expression, coming from $d*F$ for the electromagnetic 2-form $F$,
\[
\mathbf{\delta} B = \mathbf{\delta} \mathbf{d}A = \Delta A - \mathbf{d \delta} A
\]
Then
\[
\begin{gathered}
	\mathbf{*d}A = \frac{ \sqrt{|\mathbf{g} |} }{ (d-2)! } \epsilon_{i_1i_2 \dots i_{d-2} jk} g^{jj'} g^{kk'} \frac{ \partial A_{k'}}{ dx^{j'} } dx^{i_1} \wedge \dots \wedge dx^{i_{d-2}} = \sqrt{ |\mathbf{g} | } \epsilon_{ijk} g^{jj'} g^{kk'} \frac{ \partial A_{k'} }{ \partial x^{j'} } dx^i  \\
\end{gathered}
\]

Consider the expression
\[
\text{curl}\mathbf{B} = \text{curl}( \text{curl} \mathbf{A})
\]
I will generalize it and point out its misgivings.

Calculating from definitions for $*$ and $d$,
\[
\begin{gathered}
	\mathbf{d} \mathbf{*} \mathbf{d} A = \frac{ \epsilon_{i_1 i_2 \dots i_{d-2} jk } }{ (d-2)! } \frac{ \partial }{ \partial x^l} \left( \sqrt{|\mathbf{g} |} g^{jj'} g^{kk'} \frac{ \partial A_{k'} }{ \partial x^{j'} } \right) dx^l \wedge dx^{i_1} \wedge \dots \wedge dx^{i_{d-2} } \\
	\mathbf{*} \mathbf{d} \mathbf{*} \mathbf{d} A = \frac{ \sqrt{ |\mathbf{g} | } }{ (d-d(-1))! } \frac{ \epsilon_{id'i_1' i_2' \dots i'_{d-2} } }{ (d-2)! } g^{l'l} g^{i_1' i_1} g^{i_2' i_2} \dots g^{i_{d-2}' i_{d-2} } \frac{ \partial }{ \partial x^l } \left( \sqrt{ |\mathbf{g} | } g^{jj'} g^{kk'} \frac{ \partial A_{k'} }{ \partial x^{j'} } \right) \epsilon_{i_1 i_2 \dots i_{d-2} jk } dx^i = \\
\xrightarrow{d=3} \sqrt{ |\mathbf{g} | } \epsilon_{il'm'} g^{l'l} g^{m'm} \frac{ \partial }{ \partial x^l} \left( \sqrt{ |\mathbf{g} | } g^{jj'} g^{kk'} \frac{ \partial A_{k'} }{ \partial x^{j'} } \right) \epsilon_{mjk} dx^i
\end{gathered}
\]
In $\mathbb{R}^3$,
\[
\mathbf{*} \mathbf{d} \mathbf{*} \mathbf{d} A \xrightarrow{ \mathbb{R}^3} \frac{ \partial }{ \partial x^j} \left( \frac{ \partial A_k }{ \partial x^j} \right) - \frac{ \partial }{ \partial x^k} \left( \frac{ \partial A_k}{ \partial x^j} \right)
\]
At this point, in the "vector calculus" formulation, the partial derivatives in the $- \frac{ \partial }{ \partial x^k} \left( \frac{ \partial A_k}{ \partial x^j} \right)$ would be exchanged in order, and then a so-called "choice of gauge" for $\nabla \cdot A \equiv \text{div}A$ would be "made," making this term equal $0$.  As we clearly see above, this should not be the case.  Rather, this choice should be made:
\begin{equation}
\mathbf{d \delta } A = 0
\end{equation}
This is because we should directly use the "manifestly covariant" definition of the Laplacian:
\begin{equation}
\begin{gathered}
	\mathbf{* d * d } A = (-1)^{d(1-1) +1} \mathbf{ \delta d} A = (-1)^{0+1} \mathbf{ \delta d } A = (-1)^{1} (\Delta - \mathbf{d\delta } ) A \\
\xrightarrow{ d=3} (-1)(\Delta - \mathbf{ d\delta } ) A
\end{gathered}
\end{equation}
Note that $k=1$, i.e. we're dealing with 1-form $A$ here, in the $(-1)^{d(k-1)+1}$ factor.

So the true expression is this (to reiterate and emphasize the point):
\begin{equation}
\mathbf{\delta}B = (-1) (\Delta - \mathbf{d\delta } ) A
\end{equation}

Are there any necessary constraints on $A$ to make it, such that $\mathbf{d\delta }A=0$?  Perhaps we can take a look at how the definition of the codifferential $\mathbf{\delta}$ necessitates that this diagram commutes:
\[
 \begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=7.8em, column sep=7.8em, minimum width=5.2em]
  {
 \Omega^1(M)  &  \Omega^{d-1}(M)  \\
	\Omega^0(M) &  \Omega^d(M)  \\
};
  \path[->]
  (m-1-1) edge node [above] {$ \mathbf{*} $ }  (m-1-2)
edge node [auto] {$\mathbf{\delta} $ } (m-2-1)
	(m-1-2) edge node [auto] {$ \mathbf{d} $ } (m-2-2)
	(m-2-1) edge node [auto] {$ \mathbf{ * } (-1) $ }(m-2-2)
  ;
\end{tikzpicture}   \qquad \quad \,
\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=7.8em, column sep=7.8em, minimum width=5.2em]
  {
 A  &  \mathbf{*}A  \\
	\delta A &  \mathbf{d}\mathbf{*} A  \\
};
  \path[|->]
  (m-1-1) edge node [above] {$ \mathbf{*} $ }  (m-1-2)
edge node [auto] {$\mathbf{\delta} $ } (m-2-1)
	(m-1-2) edge node [auto] {$ \mathbf{d} $ } (m-2-2)
	(m-2-1) edge node [auto] {$ \mathbf{ * } (-1) $ }(m-2-2)
  ;
\end{tikzpicture}
\]

\part{Maxwell's Equations; My version of Maxwell's Equations}

\section{My version of Maxwell's equations}

\subsection{Maxwell's Equations, my version, in "vector calculus" form}

If $\nabla \cdot \mathbf{B} = 0$, then
\begin{equation}
	\nabla \times \mathbf{E} = \frac{-1}{c} \left( \frac{ \partial \mathbf{B} }{\partial t} \right)
\end{equation}

If $\nabla \cdot \mathbf{E} = 4\pi \rho_{\text{total}}$, then
\begin{equation}
\begin{aligned}
	\nabla \times \mathbf{B} & = \frac{1}{c} \left( \frac{ \partial \mathbf{E}}{ \partial t} + 4\pi \frac{ \partial \mathbf{P} }{ \partial t} +  \right.  \\
	& \left.   + 4\pi \mathbf{J}_{\text{free}} + 4\pi c \nabla \times \mathbf{M}  \right)
\end{aligned}
\end{equation}

\subsection{Maxwell's Equations, my version, over spacetime manifold $M$}

For spacetime manifold $M$, of dimensions $\text{dim}M = d+1$, and for
\[
\begin{aligned}
	& E \in \Omega^1(M) \\
	& B \in \Omega^2(M)
\end{aligned}
\]
If $\mathbf{d}B=0$, then
\begin{equation}\label{Eq:MaxwellsEqnsDGEBInduction}
\boxed{ 	\mathbf{d}E + \frac{ \partial B}{ \partial t} = 0  }
\end{equation}

If $\mathbf{\delta}E = \mathbf{*} \mathbf{d} \mathbf{*} E = 4\pi \rho_{\text{total}}$,
\begin{equation}\label{Eq:MaxwellsEqnsDGEBFaraday}
	\boxed{ \mathbf{\delta} B = \mathbf{*} \mathbf{d} \mathbf{*} B = \frac{ \partial E}{ \partial t} + 4\pi \frac{ \partial P}{ \partial t} + 4\pi J_{\text{free}} + 4\pi c \mathbf{\delta} \mathbf{M} }
\end{equation}
with $\mathbf{M} \in \Omega^2(M)$, magnetization in matter (i.e. matter magnetization) is \emph{necessarily} a 2-form.

\subsubsection{Some of the algebra (scratch) work/explicit calculations, for Maxwell's Equations, my version, over spacetime manifold $M$}

\[
\mathbf{d}B \Longleftrightarrow \nabla \cdot B
\]
since component-wise,
\[
\begin{gathered}
	\mathbf{d} B = \frac{ \partial }{ \partial x^k } B_{ij} dx^k \wedge dx^i \wedge dx^j \Longleftrightarrow \nabla \cdot B
\end{gathered}
\]
\[
\mathbf{d}E = -\frac{ \partial B}{\partial t}   \Longleftrightarrow \nabla \times E \equiv \text{curl} E = \frac{-1}{c} \frac{ \partial \mathbf{B}}{ \partial t}
\]
since, component-wise,
\[
\mathbf{d} E = \frac{ \partial }{ \partial x^k} E_i dx^k \wedge dx^i = \frac{ \partial }{ \partial x^j} E_k dx^j \wedge dx^k = \frac{ -\partial }{ \partial t} B_{jk} dx^j \wedge dx^k
\]
For $\mathbf{\delta} E = \mathbf{*} \mathbf{d} \mathbf{*} E = 4\pi \rho_{\text{total}}$, consider
\[
\begin{gathered}
	\mathbf{*} E = \frac{1}{ (d-1)!} \sqrt{ \mathbf{g}} \epsilon_{i_1i_2 \dots i_{d-1} j_1} E_j g^{jj_1} e^{i_1} \wedge e^{i_2} \wedge \dots \wedge e^{i_{d-1}} = \frac{1}{2} \sqrt{ \mathbf{g}} \epsilon_{ijk} E_{k'} g^{k'k} dx^i \wedge dx^j
\end{gathered}
\]
Further,
\[
\begin{gathered}
	\mathbf{d} \mathbf{*} E = \frac{1}{ (d-1)! } \frac{ \partial }{ \partial x^k} (\sqrt{ \mathbf{g}} E_j g^{jj_1} ) \epsilon_{i_1 i_2 \dots i_{d-1} j_1 } dx^k \wedge dx^{i_1} \wedge dx^{i_2} \wedge \dots \wedge dx^{i_{d-1}} = \\
=\frac{1}{(d-1)!} \frac{ \partial }{ \partial x^k} (\sqrt{ \mathbf{g}} E^{j_1} ) \epsilon_{i_1 i_2 \dots i_{d-1} j_1} \epsilon^{ k i_1 i_2 \dots i_{d-1} } \frac{ \text{vol}^d}{ \sqrt{ |\mathbf{g} | } } = \\
=\frac{1}{(d-1)!} \frac{ \partial }{ \partial x^k} (\sqrt{ |\mathbf{g} | } E^{j_1} ) \delta^k_{ j_1} (d-1)! \frac{ \text{vol}^d}{ \sqrt{ |\mathbf{g} | } } = \frac{1}{ \sqrt{ |\mathbf{g} | }} \frac{ \partial }{ \partial x^k} (\sqrt{ |\mathbf{g} |} E^k) \text{vol}^d
\end{gathered}
\]
where this (generalized) Kronecker delta relation was used:
\[
\frac{1}{p!} \delta^{\mu_1 \dots \mu_p }_{\nu_1 \dots \nu_p } \delta^{ \nu_1 \dots \nu_p }{ \rho_1 \dots \rho_p } = \delta^{\mu_1 \dots \mu_p }_{ \rho_1 \dots \rho_p }
\]
where
\[
\delta^{\mu_1 \dots \mu_n }_{ \nu_1 \dots \nu_n } = \epsilon^{\mu_1 \dots \mu_n} \epsilon_{ \nu_1 \dots \nu_n }
\]
Note that
\[
\begin{aligned}
	*1 & = \text{vol} \\
**1  & = (-1)^{0(n-0)} 1 = 1 = *\text{vol}
\end{aligned}
\]
and so
\[
\mathbf{*} \mathbf{d} \mathbf{*} E = \mathbf{\delta} E = \frac{1}{\sqrt{ |\mathbf{g} | } } \frac{ \partial }{ \partial x^k} ( \sqrt{ | \mathbf{g} | } E^k )
\]
Indeed, we had generalized the divergence, but on a 1-form:
\begin{equation}
\begin{aligned}
	& \mathbf{\delta} : \Omega^1(M) \to C^{\infty}(M) \\
	& -\mathbf{\delta} E = -\mathbf{\delta} (E_kdx^k)  = \frac{1}{\sqrt{|\mathbf{g} |} } \frac{ \partial }{ \partial x^k} (\sqrt{ |\mathbf{g} | } E^k) \equiv \frac{1}{\sqrt{ |\mathbf{g} | } } \frac{ \partial }{ \partial x^k} ( \sqrt{ |\mathbf{g} | }  g^{kk_1} E_{k_1} )
\end{aligned}
\end{equation}

\section{Magnetostatics, macroscopic Magnetism, Magnetic permeability, magnetic susceptibility, field $\mathbf{H}$, free currents and field $\mathbf{H}$}

\emph{Keywords}: magnetic permeability, magnetic susceptibility

Suppose we have matter (i.e. the "macroscopic problem", referred to from Jackson (1998), Sec. 5.8 "Macroscopic Equations, Boundary Conditions on $B$ and $H$", \cite{Jack1998}), \emph{not} a vacuum.

Atoms in matter have electrons, $e^-$ in orbit, contributing to (rapidly) fluctuating magnetic moments $\mathbf{m}$, along with $e^-$'s intrinsic $\mathbf{m}$.

Consider an average macroscopic magnetization or magnetic moment density $\mathbf{M}(\mathbf{x})$ defined in a "vector calculus" manner by Jackson (1998) \cite{Jack1998},
\[
\mathbf{M}(\mathbf{x}) = \sum_I N_I\langle \mathbf{m}_I\rangle , \qquad \, I \equiv \text{ index of a particle }
\]

Recalling Maxwell's Equations, Eq. \ref{Eq:MaxwellsEqnsDGEBFaraday},
\[
\mathbf{\delta} B = \frac{ \partial E}{ \partial t} + 4\pi \frac{ \partial P }{ \partial t} + 4\pi J_{\text{free}} + 4\pi c \mathbf{\delta}\mathbf{M}
\]
Consider a time-independent $E$ and negligible $P$.  Then
\[
\Longrightarrow \mathbf{\delta} B =  4\pi J_{\text{free}} + 4\pi c \mathbf{\delta}\mathbf{M}
\]
Jackson (1998) \cite{Jack1998} considers this magnetization $\mathbf{M}$ as contributing to an \emph{effective current density} by vector calculus arguments of it having a vector potential form, and so he proceeds to write it as (Jackson (1998), Eqn. (5.80) \cite{Jack1998})
\[
\text{curl} \mathbf{B} = \mu_0 (\mathbf{J} + \text{curl}\mathbf{M} ) \qquad \, (SI)
\]
Then Jackson \emph{defines} the macroscopic field $\mathbf{H}$, in Jackson (1998), Eqn. (5.81) \cite{Jack1998},
\[
\mathbf{H} := \frac{1}{\mu_0} \mathbf{B} - \mathbf{M}
\]

However, Purcell's treatment is both more lucid, and more grounded in what $B$ field really is physically, less relying upon artificial artifices.

\subsection{Free currents $\mathbf{J}_{\text{free}}$ and the field $\mathbf{H}$, magnetic susceptibility}

cf. Purcell (1984) \cite{Purc1984}, Sec. 11.10 Free Currents, and the Field $\mathbf{H}$

\emph{Keywords}: $\mathbf{H}$, volume magnetic susceptibility

Bound current $\mathbf{J}_{\text{bound}}$ are current associated with molecular or atomic magnetic moments, including the intrinsic magnetic moment of particles with spin.

Free currents $\mathbf{J}_{\text{free}}$ are ordinary conduction currents.

\begin{equation}
\mathbf{J}_{\text{bound}} = c \nabla \times \mathbf{M}
\end{equation}
cf. Purcell (1984), Eq. (44) of Ch. 11 \cite{Purc1984}

At a surface, where $\mathbf{M}$ is discontinuous, we have a surface current density $\mathcal{J}$.

By superposition,
\begin{equation}
	\nabla \times \mathbf{B} = \frac{ 4\pi }{c} (\mathbf{J}_{\text{bound}} + \mathbf{J}_{\text{free} } ) = \frac{4\pi }{ c} \mathbf{J}_{\text{total} }
\end{equation}
cf. Purcell (1984), Eq. (50) of Ch. 11 \cite{Purc1984}

Thus,
\[
\begin{gathered}
\nabla \times \mathbf{B} = \frac{ 4\pi}{c}(c\nabla \times \mathbf{M} ) + \frac{4\pi}{c} \mathbf{J}_{\text{free}} = \\
	= \nabla \times (\mathbf{B} - 4\pi \mathbf{M} ) = \frac{4\pi }{c} \mathbf{J}_{\text{free} }
\end{gathered}
\]
cf. Purcell (1984), Eq. (51) of Ch. 11 \cite{Purc1984}

Purcell also defines
\begin{equation}
\mathbf{H} := \mathbf{B}-4\pi \mathbf{M}
\end{equation}
cf. Purcell (1984), Eq. (52) of Ch. 11 \cite{Purc1984}; and so
\[
\begin{gathered}
\nabla \times \mathbf{H} = \frac{4\pi}{c} \mathbf{J}_{\text{free}} \qquad \, (cgs) \qquad \qquad \, \nabla \times \mathbf{H} = \mathbf{J}_{\text{free}} \qquad \, (SI)
\end{gathered}
\]
cf. Purcell (1984), Eq. (53), (53'), respectively, of Ch. 11 \cite{Purc1984}.

In magnetic systems, it is precisely the free currents that we can control.  So $\mathbf{H}$ is useful:

\begin{equation}
\begin{gathered}
\int_C \mathbf{H} \cdot d\mathbf{l} = \frac{4\pi}{c}\int_S \mathbf{J}_{\text{free}} \cdot d\mathbf{a} = \frac{4\pi}{c} I_{\text{free}} \qquad \, (cgs) \qquad \qquad \, \int_C \mathbf{H} \cdot d\mathbf{l} = \int_S \mathbf{J}_{\text{free}} \cdot d\mathbf{a} =  I_{\text{free}} \qquad \, (SI)
\end{gathered}
\end{equation}
where in SI, $H \sim \frac{ \text{ amps } }{ \text{ meter } }$.  cf. Purcell (1984), Eq. (54), (54'), respectively, of Ch. 11 \cite{Purc1984}.

$\mathbf{B}$ is the \emph{fundamental magnetic field vector}; it is \textbf{only} $\mathbf{B}$ s.t. $\nabla \cdot \mathbf{B} =0$ or $\mathbf{d}B=0$

The basic magnetic field inside matter is $\mathbf{B}$, \emph{not} $\mathbf{H}$.  That's not a matter of mere definition, but a \emph{consequence of the absence of magnetic charges}.  cf. Purcell (1984)\cite{Purc1984}.

Now
\begin{equation}
\mathbf{M} = \chi_m \mathbf{H}
\end{equation}
cf. Purcell (1984), Eq. (56) Ch. 11 \cite{Purc1984}.

The lines of $\mathbf{H}$ inside the magnet look just like the lines of $\mathbf{E}$ inside the polarized cylinder.   \\
- $\mathbf{H}$ is the fiction of magnetic poles; if there wre magnetic poles then $\mathbf{H}$ is the macroscopic $\mathbf{B}$ filed inside the material.

For any material in which $\mathbf{M}$ is porportional to $\mathbf{H}$,
\begin{equation}
\boxed{
\begin{gathered}
	\mathbf{B} = \mathbf{H} + 4\pi \mathbf{M} = (1+4\pi \chi_m) \mathbf{H} \\
\mu = 1 + 4\pi \chi_m
\end{gathered}
}
\end{equation}

So \emph{if} there was a linear response between magnetization $\mathbf{M}$ and the measured macroscopic field $\mathbf{H}$, related through the volume magnetic susceptibility, $\chi_m$, ($\mathbf{M} = \chi_m \mathbf{H}$), then for $\mathbf{\delta} B = 4\pi J_{\text{free}} + 4\pi c \mathbf{\delta} \mathbf{M}$,
\[
\mathbf{\delta} (B-4\pi c M) = \mathbf{\delta} H = \mathbf{\delta} \frac{ B}{ \mu } = 4\pi J_{\text{free}} \Longrightarrow \mathbf{B} = \mu 4\pi J_{\text{free}}
\]
and so we have the usual expression (make the comparison)
\[
\text{curl} \mathbf{B} = \mu 4\pi \mathbf{J}_{\text{free}}
\]
Obtaining an integral form,
\[
\begin{gathered}
	\mathbf{*} \mathbf{\delta} B = \mathbf{*} \mathbf{*} \mathbf{d} \mathbf{*} B = (-1)^{2(d-2)} \mathbf{d}\mathbf{*} B = \mu 4\pi \mathbf{*} J_{\text{free}} \xrightarrow{ \int_S } \int_S \mathbf{d} \mathbf{*} B =  \int_{\partial S} \mathbf{*} B = \mu 4\pi \int_S \mathbf{*} J_{\text{free}}
\end{gathered}
\]

Jackson seems to imply to treat macroscopic field $\mathbf{H}$ as what you measure, since $\mathbf{J}_{\text{free}}$ is what one can measure and control, pointed out sagely by Purcell.  So consider this, as I write down an integral form,
\[
\begin{gathered}
\mathbf{*} \mathbf{\delta} H  = \mathbf{d} \mathbf{*} H = 4\pi \mathbf{*} J_{\text{free}} \xrightarrow{ \int_S } \int_S \mathbf{d} \mathbf{*} H = \int_{\partial S} \mathbf{*} H = 4\pi \int_S \mathbf{*} J_{\text{free}}
\end{gathered}
\]
If, over $S$, $\mathbf{J}_{\text{free}}$ is uniform, $\frac{4\pi}{c} \int_S \mathbf{*} \mathbf{J}_{\text{free}} = \frac{4\pi }{c} I_{\text{free}}$.  If we can measure the current, we can obtain the line integral of $\mathbf{H}$.  But we should really be aware that what we're \emph{really} measuring is $B-4\pi c \mathbf{M}$ - would it be possible to measure the macroscopic $\mathbf{M}$ itself?

\section{Eddy Currents}

I build upon the physical setup proposed by Jackson (1998) \cite{Jack1998} in Section 5.18 "Quasi-Static Magnetic Fields in Conductors; Eddy Currents; Magnetic Diffusion."

For a system (with characteristic) length $L$, $L$ being small, \\
compared to electromagnetic wavelength associated with dominant time scale of problem $T$,
\[
\begin{gathered}
	f := \frac{1}{T} ; \quad \, \omega = 2\pi f ; \quad \, \omega \lambda = c \Longrightarrow \lambda = \frac{c}{ \omega } = \frac{c}{ 2\pi f } = \frac{Tc}{2\pi }  \\
\frac{L}{\lambda} = \frac{LTc}{2\pi } \gg 1
\end{gathered}
\]
From Maxwell's equations, in particular, Faraday's Law, and in its integral form (over 2-dim. \emph{closed} surface $S$),
\begin{equation}
\begin{gathered}
\mathbf{d}E + \frac{ \partial }{ \partial t } B = 0 \text{ or } -\mathbf{d}E =\frac{ \partial B}{ \partial t} \xrightarrow{ \int_S } \int_S \frac{ \partial B}{ \partial t} = -\int_S \mathbf{d}E = -\int_{\partial S} E
\end{gathered}
\end{equation}
So on $S$, changing magnetic flux $\int \frac{ \partial B}{ \partial t}$ results in $E$ field, circulating around boundary of $S$, $\partial S$.

We know that in a conductor, free conducting electrons get pushed around by $E$ fields, result in a current density $J$.

$J$ is related to $E$, \emph{empirically} (by Ohm's Law)
\[
J = \sigma E
\]
where $\sigma$ is the resistivity.

Then use the force law on this induced current $J$ from the $B$ field set up:
\[
F_{\text{net}} = \frac{1}{c} \int_S J\times B dA
\]
By working through the right-hand rule, $F_{\text{net}}$ the force on those currents induced in the conductor due to the $B$ that's there, is in the direction to help oppose changing (increasing or decreasing $\frac{\partial B}{ \partial t}$).

To find $B$, suppose $B=dA$, i.e. $B\in H^2_{\text{deRham}}(M)$, i.e. $B=\text{curl}A$.

For sure,
\[
\mathbf{\delta} (B-4\pi c \mathbf{M}) = 4\pi J \Longleftrightarrow \text{curl}(B-4\pi c \mathbf{M} ) = \text{curl} H = 4\pi J
\]
Be warned now that the relation $B=\mu H$ may not be valid on all domains of interest; $\mu$ could even be a tensor! (e.g. $B_{ij} = \mu^{kl}_{ij} H_{kl}$).  However, both Jackson (1998) \cite{Jack1998} in Sec. 5.18 Quasi-Static Magnetic Fields in Conductors; Eddy Currents; Magnetic Diffusion, pp. 219, and Smythe (1968), Ch. X (his Ch. 10), pp. 368 \cite{Smyt1968}, continues on \emph{as if} this relation is linear: $B=\mu H$.

Nevertheless, as we want to find $B$ by finding its "vector potential" $A$, we obtain a diffusion equation:
\begin{equation}\label{Eq:EddyCurrentsAdiffusion}
\begin{gathered}
	- \mathbf{\delta}B = \mathbf{*d*d}A = (-1) \mathbf{\delta d} A = (-1)( \Delta - \mathbf{d\delta} ) A \xrightarrow{ \mathbf{d\delta} A = 0 } - \Delta A = \\
	= 4\pi \mu J = 4\pi \mu \sigma E = 4\pi \mu \sigma \left( -\frac{ \partial A}{ \partial t} \right) \\
\Longrightarrow \boxed{ \Delta A = 4\pi \mu \sigma \frac{ \partial A}{ \partial t } }
\end{gathered}
\end{equation}
where in the first 2 steps (equalities), $- \mathbf{\delta}B = \mathbf{*d*d}A = (-1) \mathbf{\delta d} A$ it's interesting to note that the codifferential $\mathbf{\delta}$ for the 2 form $B$ had to be written out explicitly, and then the codifferential for the 1-form $A$ is \emph{different} from the $\mathbf{\delta}$ for $B$ by a(n important) factor of $(-1)$; where $\mathbf{d\delta} A=0$ must be satisfied by the form $A$ takes; and where, since $B=\mathbf{d}A$,
\begin{equation}
\begin{gathered}
	\mathbf{d}E + \frac{ \partial B}{ \partial t} = \mathbf{d} E + \frac{ \partial }{ \partial t} \mathbf{d} A = \mathbf{d} \left( E+ \frac{ \partial A}{ \partial t} \right) = 0 \Longrightarrow E = -\frac{ \partial A}{ \partial t} + \text{grad}\Phi \xrightarrow{ \Phi = \text{ constant } } E = -\frac{ \partial A}{ \partial t}
\end{gathered}
\end{equation}
whereas a choice of gauge for $E$ was chosen so that $\Phi=\text{constant}$ (and so a particular form for $E$ was chosen, amongst those in the \emph{same} equivalence class of $H^1_{\text{deRham}}(M)$.

To ensure that the differential geometry formulation is in agreement with the practical vector calculus formulation, compare Eq. \ref{Eq:EddyCurrentsAdiffusion} with Eq. (5.160) of Jackson (1998) \cite{Jack1998} and Eq. (10) in Sec. 10.00 of Smythe (1968) \cite{Smyt1968}.

To summarize what's going on, I think one should at least understand in one's head how Maxwell's Equations apply, (and I will try to write in SI here)
\begin{equation}
\boxed{
\begin{gathered}
\int_S \frac{ \partial \mathbf{B}}{ \partial t} dA = -\oint \mathbf{E}\cdot d\mathbf{s} \Longrightarrow \mathbf{J}=\sigma \mathbf{E} \Longrightarrow \mathbf{F}_{\text{net}} = \int_S \mathbf{J} \times \mathbf{B} dA  \\
\text{ to find } \mathbf{B} = ? \qquad \, \text{ using form } \mathbf{B} = \nabla \times \mathbf{A}, \\
\nabla^2 \mathbf{A} = \mu \sigma \frac{ \partial \mathbf{A} }{ \partial t} \qquad \, (SI)
\end{gathered}
}
\end{equation}
where, a change in magnetic flux over a surface $S$ over the conductor, $\int_S \frac{ \partial \mathbf{B}}{ \partial t}dA$ induces a circulation of $E$ field around $S$, $-\oint \mathbf{E} \cdot d\mathbf{s}$, and this $E$ field is pushing around \emph{free conducting charges} according to Ohm's law, $\mathbf{J} = \sigma \mathbf{E}$, with $\sigma$ being the conductivity of the conducting material, and this current density $\mathbf{J}$ is then acted upon by the prevailing $B$ field, according to the usual force law.  To find $\mathbf{B}$, one can find $\mathbf{A}$ and \emph{try} to find $\mathbf{A}$ analytically.

Keep in mind that for $\nabla^2 \mathbf{A} = \mu \sigma \frac{ \partial \mathbf{A}}{ \partial t}$, we had used, critically, the Maxwell equation $\mathbf{\nabla} \times \mathbf{H} = \mathbf{J}$, with $\mathbf{J}$ being the \emph{induced current of free conducting charges on the conductor}.  This $\mathbf{H}$ will contribute (through linear superposition) to the $\mathbf{B}$ that could already be there due to the permanent magnet.

\end{multicols*}

\begin{thebibliography}{9}

\bibitem{Jack1998}
J.D. Jackson.  \textbf{Classical Electrodynamics} Third Edition.  Wiley.  1998.   ISBN-13: 978-0471309321

\bibitem{Purc1984}
Edward M. Purcell.  \textbf{Electricity and Magnetism} (Berkeley Physics Course, Vol. 2) Second Edition.  McGraw-Hill Science/Engineering/Math.  1984.  ISBN-13: 978-0070049086

\bibitem{Mori2001}
Shigeyuki Morita.  \textbf{Geometry of Differential Forms (Translations of Mathematical Monographs, Vol. 201)}.  American Mathematical Society (August 28, 2001).   ISBN-13: 978-0821810453

\bibitem{OCalinDChang2005}
Ovidiu Calin, Der-Chen Chang. \textbf{Geometric Mechanics on Riemannian Manifolds: Applications to Partial Differential Equations} (Applied and Numerical Harmonic Analysis).  Birkh\"{a}user. 2005. ISBN-13: 978-0817643546

\bibitem{Smyt1968}
William R. Smythe, \textbf{Static and Dynamic Electricity}.  3rd ed. (McGraw-Hill, New York, 1968).

  \end{thebibliography}

\end{document}


\clearpage
\newpage

\section{Results}
\paragraph{Statistical errors} We used coalescent simulations of neutral
polymorphisms under spatial models of admixture to compare the statistical
errors of the AQP and APLS estimates with those of the {\tt tess3}
algorithm~\citep{Caye2016}. The ground truth for the $Q$-matrix (${\bf Q}_0$)
was computed from the mathematical model for admixture proportions used to
generate the data. For the $G$-matrix, the ground truth matrix (${\bf G}_0$) was
computed from the empirical genotype frequencies in the two population samples
before an admixture event. The root mean squared errors (RMSE) for the ${\bf Q}$
and ${\bf G}$ estimates decreased as the sample size and the number of loci
increased (Figure~\ref{fig:fig1}). For all algorithms, the statistical errors were generally
small when the number of loci was greater than $10$k SNPs. Those results
provided evidence that the three algorithms produced equivalent estimates of the
matrices ${\bf Q}_0$ and ${\bf G}_0$. The results also provided a check
that the APLS and {\tt tess3} algorithms converged to the same estimates as
those obtained after the application of the AQP algorithm, which is guaranteed
to converge mathematically.

\paragraph{The benefit of including spatial information in algorithms} Using
neutral coalescent simulations of spatial admixture, we compared the statistical
estimates obtained from the spatial algorithm APLS and the non-spatial
algorithm {\tt snmf}~\citep{Frichot2014}. For various levels of ancestral
population differentiation, estimates obtained from the spatial algorithm were
more accurate than for those obtained using non-spatial approaches
(Figure~\ref{fig:fig2}). For the larger samples, much finer population structure
was detected with the spatial method than with the non-spatial algorithm
(Figure~\ref{fig:fig2}).

In simulations of outlier loci, we used the area under the precision-recall
curve (AUC) for quantifying the performances of tests based on the estimates of
ancestry matrices, {\bf Q} and {\bf G}. In addition, we computed AUCs for
$F_{\rm ST}$-based neutrality tests using truly ancestral genotypes. As they
represented the maximum reachable values, AUCs based on truly ancestral
genotypes were always higher than those obtained for tests based on
reconstructed matrices. For all values of the relative selection intensity, AUCs
were higher for spatial methods than for non-spatial methods (Figure~\ref{fig:fig3}, the
relative selection intensity is the ratio of migration rates at neutral and
adaptive loci). For high selection intensities, the performances of tests based
on estimates of ancestry matrices were close to the optimal values reached by
tests based on true ancestral frequencies. These results provided evidence that
including spatial information in ancestry estimation algorithms improves the
detection of signatures of hard selective sweeps having occurred in unknown
ancestral populations.

\paragraph{Sensitivity of estimates to spatial measurements} Next, we used the
simulated data sets to evaluate the robustness of APLS estimates to inaccurate
measurements of spatial coordinates. To this aim, Gaussian noise was added to
truly observed geographic coordinates by considering values of the
noise-to-signal ratio ranging from 0 to 3. We computed variograms in all cases,
and found that the spatial signal was removed from simulations for
noise-to-signal ratios greater than two, while the signal was still observable
with a noise-to-signal ratio lower than one. For all simulations, we compared
the relative error of APLS $Q$-matrix estimates to those obtained from an
non-spatial method ({\tt snmf}). For small levels of uncertainty in spatial
coordinates the errors of APLS estimates were lower than those of {\tt snmf}
(Figure~\ref{fig:fig2_5}). For simulations with $n = 500$ individuals and $L =
10^5$ loci, a larger noise-to-signal ratio increased statistical errors in the
$Q$-matrix estimates from the APLS algorithm. For smaller noise-to-signal ratios,
RMSEs remained generally lower for the APLS algorithm than for methods without
spatial coordinates. For simulations with $n = 50$ individuals and $L = 10^4$
loci, the APLS estimates were more accurate than the non-spatial estimates. This
unexpected result could be explained by subtle algorithmic differences in tested
programs. To a large extent, estimates from the APLS algorithm were robust to
uncertainty in spatial measurements. Standard graphical tests such as a
variogram analysis can help deciding whether our spatially explicit algorithm is
useful or not.

\paragraph{Runtime and convergence analyses} We subsampled a large SNP data set
for {\it A. thaliana} ecotypes to compare the convergence properties and
runtimes of the {\tt tess3}, AQP, and APLS algorithms. In those experiments, we
used $K = 6$ ancestral populations, and replicated 5 runs for each simulation.
For $n = 100-600$ individuals ($L = 50$k SNPs), the APLS algorithm required more
iterations (25 iterations) than the AQP algorithm (20 iterations) to converge to
its solution (Figure~\ref{fig:fig4}). This was less than for {\tt tess3} (30 iterations). For
$L = 10-200$k SNPs ($n = 150$ individuals), similar results were observed. For
$50$k SNPs, the runtimes were significantly lower for the APLS algorithm than
for the {\tt tess3} and AQP algorithms. For $L = 50$k SNPs and $n = 600$
individuals, it took on average 1.0 min for the APLS and 100 min for the AQP
algorithm to compute ancestry estimates. For {\tt tess3}, the runtime was on
average 66 min. For $L = 100$k SNPs and $n = 150$ individuals, it took on
average 0.6 min (9.0 min) for the APLS (AQP) algorithm to compute ancestry
estimates. For {\tt tess3}, the runtime was on average 1.3 min. For those
values of $n$ and $L$, the APLS algorithm implementation ran about 2 to 100
times faster than the other algorithm implementations.

\paragraph{Human data analysis} To evaluate a case of model misspecification, we
analyzed data from the 1000 Genomes project for African Americans, Africans from
Nigeria and from Kenya, and Europeans from the United Kingdom and from Italy.
Using the default values for the hyper-parameters, the Laplacian matrix was a
block diagonal matrix where each block corresponded to one of the five
populations. The spatial variogram exhibited a flat shape. For $K = 2$, the APLS
estimates for the African American population were equal to $24.2 \%$ for
European ancestors and $75.8 \%$ for African ancestors. The corresponding {\tt
  snmf} estimates were equal to $22.4 \%$ for European ancestors and $77.6 \%$
for African ancestors. For $K = 3$, the APLS estimates for the African American
population were equal to $21.4 \%$ for European ancestors, $51.8 \%$ for West
African ancestors and $26.8 \%$ for East African ancestors. The corresponding
{\tt snmf} estimates were equal to $22.2 \%$ for European ancestors, $68.4 \%$
for West African ancestors and $9.4 \%$ for East African ancestors. Overall, the
results obtained with our spatial method for African Americans were similar to
those obtained with {\tt snmf}. The main difference between APLS and {\tt snmf}
estimates were for African populations. For Africans, {\tt snmf} detected two
distinct genetic clusters whereas APLS detected a larger proportion of shared
ancestry between Eastern and Western populations.

\paragraph{Application to European ecotypes of {\it Arabidopsis thaliana}} We
used the APLS algorithm to survey spatial population genetic structure and
perform a genome scan for adaptive alleles in European ecotypes of the plant
species {\it A. thaliana}. The cross validation criterion decreased rapidly from
$K=1$ to $K=3$ clusters, indicating that there were three main ancestral groups
in Europe, corresponding to geographic regions in Western Europe, Eastern and
Central Europe and Northern Scandinavia. For $K$ greater than four, the values
of the cross validation criterion decreased in a slower way, indicating that
subtle substructure resulting from complex historical isolation-by-distance
processes could also be detected (Figure~\ref{fig:fig5}). The spatial analysis provided an
approximate range of $\sigma = 150$km for the spatial variogram (Figure~\ref{fig:fig5}).
Figure~\ref{fig:map} displays the $Q$-matrix estimate interpolated on a geographic map of
Europe for $K = 6$ ancestral groups. The estimated admixture coefficients
provided clear evidence for the clustering of the ecotypes in spatially
homogeneous genetic groups.

\paragraph{Targets of selection in {\it A. thaliana} genomes} Tests based on the
$F^Q_{\rm ST}$ statistic were applied to the 241k SNP data set to reveal new
targets of natural selection in the {\it A. thaliana} genome. {\it A. thaliana}
occurs in a broad variety of habitats, and local adaptation to the environment
is acknowledged to be important in shaping its genetic diversity through
space~\citep{Hancock2011, Fournier-Level2011}. The APLS algorithm was run on the
1,095 European lines of {\it A. thaliana} with $K=6$ ancestral populations and
$\sigma = 1.5$ for the range parameter. Using the Benjamini-Hochberg algorithm to
control the FDR at the level $1\%$, the program produced a list of 12,701
candidate SNPs, including linked loci and representing 3\% of the total number
of loci. The top 100 candidates included SNPs in the flowering-related genes
SHORT VEGETATIVE PHASE (SVP), COP1-interacting protein 4.1 (CIP4.1) and FRIGIDA
(FRI) ($p$-values $< 10^{-300}$). These genes were detected by previous scans
for selection on this dataset~\citep{Horton2012}. We performed a gene ontology
enrichment analysis using AmiGO in order to evaluate which biological functions
might be involved in local adaptation in Europe. We found a significant
over-representation of genes involved in cellular processes (fold enrichment of
1.06, $p$-value equal to 0.0215 after Bonferonni correction).


\chapter{Problem set Solutions Fourier}
\begin{abox}
	Practise Set-1
\end{abox}
\begin{enumerate}[label=\color{ocre}\textbf{\arabic*.}]
	\item   The first few terms in the Laurent series for $\frac{1}{(z-1)(z-2)}$ in the region $1 \leq|z| \leq 2$ and around $z=1$ is
	{\exyear{NET/JRF(JUNE-2012)}}
	\begin{tasks}(1)
		\task[\textbf{A.}] $\frac{1}{2}\left[1+z+z^{2}+\ldots\right]\left[1+\frac{z}{2}+\frac{z^{2}}{4}+\frac{z^{3}}{8}+\ldots .\right]$
		\task[\textbf{B.}] $\frac{1}{1-z}-z-(1-z)^{2}+(1-z)^{3}+\ldots .$
		\task[\textbf{C.}] $\frac{1}{\mathrm{z}^{2}}\left[1+\frac{1}{\mathrm{z}}+\frac{1}{\mathrm{z}^{2}}+\ldots .\right]\left[1+\frac{2}{\mathrm{z}}+\frac{4}{\mathrm{z}^{2}}+\ldots . .\right]$
		\task[\textbf{D.}]  $2(z-1)+5(z-1)^{2}+7(z-1)^{3}+\ldots$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\frac{1}{(z-1)(z-2)}&=\frac{1}{z-2}-\frac{1}{z-1}=\frac{1}{1-z}+\frac{1}{(z-1)-1}\\&=\frac{1}{1-z}-(1+(1-z))^{-1}\\
		&=\frac{1}{1-z}-\left[1+(1-z)+\frac{(-1)(-2)}{2 !}(1-z)^{2}+\frac{(-1)(-2)(-3)}{3 !}(1-z)^{3} \ldots\right]\\
		&=\frac{1}{1-z}-\left[z+(1-z)^{2}-(1-z)^{3}+\ldots . .\right]
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item Consider a sinusoidal waveform of amplitude $1 V$ and frequency $f_{0}$. Starting from an arbitrary initial time, the waveform is sampled at intervals of $\frac{1}{2 f_{0}}$. If the corresponding Fourier spectrum peaks at a frequency $\bar{f}$ and an amplitude $\bar{A}$, them
	{\exyear{NET/JRF(JUNE-2012)}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\bar{f}=2 f_{0}$ and $\bar{A}=1 V$
		\task[\textbf{B.}] $\bar{f}=2 f_{0}$ and $0 \leq \bar{A} \leq 1 V$
		\task[\textbf{C.}] $\bar{f}=0$ and $\bar{A}=1 V$
		\task[\textbf{D.}] $\bar{f}=\frac{f_{0}}{2}$ and $\bar{A}=\frac{1}{\sqrt{2}} V$
	\end{tasks}
	\begin{answer}$\left. \right. $
		\begin{figure}[H]
			\centering
			\includegraphics[height=4cm,width=8cm]{diagram-20211005(11)-crop}
		\end{figure}
		\begin{align*}
		y&=1 \sin \left(2 \pi f_{0} t\right)\\
		\text{The Fourier transform is:}\\
		F(y)&=\frac{1}{2}\left[\delta\left(f+f_{0}\right)\right]-\delta\left[f-f_{0}\right]\\
		\text{In Fourier domain }\bar{f}&=f_{0}, \bar{A}=\frac{1}{2}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item The Fourier transform of the derivative of the Dirac $\delta-$ function, namely $\delta^{\prime}(x)$, is proportional to
	{\exyear{NET/JRF(DEC-2013)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] 0
		\task[\textbf{B.}] 1
		\task[\textbf{C.}] $\sin k$
		\task[\textbf{D.}] $i k$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{Fourier transform of }\delta^{\prime}(x)\\
		H(K)=\int_{-\infty}^{\infty} \delta^{\prime}(x) e^{i k x} d x&=i k e^{(k \cdot 0)}=i k
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item The Laplace transform of $6 t^{3}+3 \sin 4 t$ is
	{\exyear{NET/JRF(JUNE-2015)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $\frac{36}{s^{4}}+\frac{12}{s^{2}+16}$
		\task[\textbf{B.}] $\frac{36}{s^{4}}+\frac{12}{s^{2}-16}$
		\task[\textbf{C.}] $\frac{18}{s^{4}}+\frac{12}{s^{2}-16}$
		\task[\textbf{D.}] $\frac{36}{s^{3}}+\frac{12}{s^{2}+16}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		L\left[6 t^{3}+3 \sin 4 t\right] &\quad \because L\left[t^{n}\right]=\frac{\sqrt{n+1}}{s^{n+1}}\\
		\because L[\sin a t]&=\frac{a}{\left(s^{2}+a^{2}\right)}\\
		L\left[6 t^{3}+3 \sin 4 t\right]&=\frac{6 \times \sqrt{4}}{s^{4}}+\frac{3 \times 4}{s^{2}+16}=\frac{36}{s^{4}}+\frac{12}{s^{2}+16}
		\end{align*}
		So the correct answer is \textbf{Option (A)}
	\end{answer}
	\item  The Fourier transform of $f(x)$ is $\tilde{f}(k)=\int_{-\infty}^{+\infty} d x e^{i k x} f(x)$.
	If $f(x)=\alpha \delta(x)+\beta \delta^{\prime}(x)+\gamma \delta^{\prime \prime}(x)$, where $\delta(x)$ is the Dirac delta-function (and prime denotes derivative), what is $\tilde{f}(k) ?$
	{\exyear{NET/JRF(DEC-2015)}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\alpha+i \beta k+i \gamma k^{2}$
		\task[\textbf{B.}] $\alpha+\beta k-\gamma k^{2}$
		\task[\textbf{C.}]  $\alpha-i \beta k-\gamma k^{2}$
		\task[\textbf{D.}] $i \alpha+\beta k-i \gamma k^{2}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\tilde{f}(k)&=\int_{-\infty}^{\infty} d x e^{i k x}\left(\alpha \delta(x)+\beta \delta^{\prime}(x)+\gamma \delta^{\prime \prime}(x)\right)\\
		\int_{-\infty}^{\infty} \alpha \delta(x) e^{i k x} d x&=\alpha\\
		\int_{-\infty}^{\infty} \beta \delta^{\prime}(x) e^{i k x} d x&=\beta\left[\left.e^{i k x} \delta(x)\right|_{-\infty} ^{\infty}-\int_{-\infty}^{\infty} i k e^{i k x} \delta(x) d x\right]=-i \beta k\\
		\int_{-\infty}^{\infty} \gamma \delta^{\prime \prime}(x) e^{i k x} d x&=-\gamma k^{2}
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item  What is the Fourier transform $\int d x e^{i l x} f(x)$ of
	$$
	f(x)=\delta(x)+\sum_{n=1}^{\infty} \frac{d^{n}}{d x^{n}} \delta(x)
	$$
	where $\delta(x)$ is the Dirac delta-function?
	{\exyear{NET/JRF(JUNE-2016)}}
	\begin{tasks}(4)
		\task[\textbf{A.}]  $\frac{1}{1-i k}$
		\task[\textbf{B.}] $\frac{1}{1+i k}$
		\task[\textbf{C.}] $\frac{1}{k+i}$
		\task[\textbf{D.}] $\frac{1}{k-i}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		f(x)&=\delta(x)+\sum_{n=1}^{\infty} \frac{d^{n}}{d x^{n}} \delta(x)\\&=\sum_{n=0}^{\infty} \frac{d^{n}}{d x^{n}} \delta(x)=\sum_{n=0}^{\infty} \delta^{(n)}(x)\\
		\because F[\delta(x)]&=1 \Rightarrow F\left[\delta^{(n)}(x)\right]\\&=(-i k)^{n} F[\delta(x)]=(-i k)^{n}\\
		\because f(x)&=\sum_{n=0}^{\infty} \delta^{(n)}(x)\\
		\Rightarrow F[f(x)]&=\sum_{n=0}^{\infty}(-i k)^{n}=1-i k+(i k)^{2}-(i k)^{3}+\ldots .\\&=\frac{1}{1-(-i k)}=\frac{1}{1+i k}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item The Laplace transform of
	$$
	f(t)=\left\{\begin{array}{cc}
	\frac{t}{T}, & 0<t<T \\
	1 & t>T
	\end{array}\right.
	$$
	is
	{\exyear{NET/JRF(DEC-2016)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $\frac{-\left(1-e^{-s T}\right)}{s^{2} T}$
		\task[\textbf{B.}] $\frac{\left(1-e^{-s T}\right)}{s^{2} T}$
		\task[\textbf{C.}] $\frac{\left(1+e^{-s T}\right)}{s^{2} T}$
		\task[\textbf{D.}] $\frac{\left(1-e^{s T}\right)}{s^{2} T}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{we can write}
		f(t)&=\left[u_{0}(t)-u_{T}(t)\right] \frac{t}{T}+u_{T}(t)\\&=\left[1-u_{T}(t)\right] \frac{t}{T}+u_{T}(t)=\frac{t}{T}-u_{T}(t) \frac{t}{T}+u_{T}(t)
		\intertext{Hence the transform of $f(t)$ is}
		L\{f(t)\}&=L\left\{\frac{t}{T}\right\}-L\left\{u_{T}(t)\left[\frac{(t-T)+T}{T}\right]\right\}+L\left\{u_{T}(t)\right\}\\
		&=\frac{1}{s^{2} T}-\frac{e^{-s T}}{T}\left(\frac{1}{s^{2}}+\frac{T}{s}\right)+\frac{e^{-s T}}{s}=\frac{1-e^{-s T}}{s^{2} T}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item The Fourier transform $\int_{-\infty}^{\infty} d x f(x) e^{i k x}$ of the function $f(x)=\frac{1}{x^{2}+2}$ is
	{\exyear{NET/JRF(DEC-2016)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $\sqrt{2} \pi e^{-\sqrt{2}|| \mid}$
		\task[\textbf{B.}] $\sqrt{2} \pi e^{-\sqrt{2 k}}$
		\task[\textbf{C.}] $\frac{\pi}{\sqrt{2}} e^{-\sqrt{2 k}}$
		\task[\textbf{D.}] $\frac{\pi}{\sqrt{2}} e^{-\sqrt{2}|k|}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{Fourier transform of }f(x)&=\frac{1}{x^{2}+a^{2}}, \\ a>0\text{ is }\int \frac{1}{x^{2}+a^{2}} e^{i k x} d x&=\frac{\pi}{a} e^{-a|k|}\\
		\text{Hence }\int \frac{1}{x^{2}+a^{2}} e^{i k x} d x&=\frac{\pi}{\sqrt{2}} e^{-\sqrt{2}|k|}
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item Consider the differential equation $\frac{d y}{d t}+a y=e^{-b t}$ with the initial condition $y(0)=0$. Then the Laplace transform $Y(s)$ of the solution $y(t)$ is
	{\exyear{NET/JRF(DEC-2017)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $\frac{1}{(s+a)(s+b)}$
		\task[\textbf{B.}] $\frac{1}{b(s+a)}$
		\task[\textbf{C.}] $\frac{1}{a(s+b)}$
		\task[\textbf{D.}] $\frac{e^{-a}-e^{-b}}{b-a}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{Given }\frac{d y}{d t}+a y&=e^{-b t}
		\intertext{Taking Laplace transform of both sides}
		\text{	We obtain}\\
		L\left\{\frac{d y}{d t}\right\}+a L\{y(t)\}&=L\left\{e^{-b t}\right\} \Rightarrow s Y(s)-y(0)+a Y(s)=\frac{1}{s+b}\\
		\text{Since, }	y(0)&=0,\text{ we obtain}\\
		(s+a) Y(s)&=\frac{1}{s+b} \Rightarrow Y(s)=\frac{1}{(s+a)(s+b)}
		\end{align*}
		So the correct answer is \textbf{Option (A)}
	\end{answer}
	\item  The Fourier transform $\int_{-\infty}^{\infty} d x f(x) e^{i k x}$ of the function $f(x)=e^{-|x|}$
	{\exyear{NET/JRF(JUNE-2018)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $-\frac{2}{1+k^{2}}$
		\task[\textbf{B.}] $-\frac{1}{2\left(1+k^{2}\right)}$
		\task[\textbf{C.}] $\frac{2}{1+k^{2}}$
		\task[\textbf{D.}] $\frac{2}{\left(2+k^{2}\right)}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\int_{-\infty}^{+\infty} d x e^{-|x|} e^{i k x}&=\int_{-\infty}^{+\infty} d x e^{-|x|} \cos k x d x\text{ odd functions in }k x\text{ vanishes}\\
		\Rightarrow 2 \int_{0}^{\infty} e^{-x} \cos k x d x&=2 \frac{e^{-x}}{1+k^{2}}[-\cos k x+k \sin k x]_{0}^{\infty}\\
		\because \int e^{a x} \cos b x d x&=\frac{e^{a x}}{a^{2}+b^{2}}[a \cos b x+b \sin b x]\\
		\Rightarrow 2 \int_{0}^{\infty} e^{-x} \cos k x d x&=2 \frac{e^{0}}{1+k^{2}}=\frac{2}{1+k^{2}}
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item The function $f(t)$ is a periodic function of period $2 \pi$. In the range $(-\pi, \pi)$, it equals $e^{-t}$. If $f(t)=\sum_{-\infty}^{\infty} c_{n} e^{\text {int }}$ denotes its Fourier series expansion, the sum $\sum_{-\infty}^{\infty}\left|c_{n}\right|^{2}$ is
	{\exyear{NET/JRF(DEC-2019)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] 1
		\task[\textbf{B.}] $\frac{1}{2 \pi}$
		\task[\textbf{C.}] $\frac{1}{2 \pi} \cosh (2 \pi)$
		\task[\textbf{D.}]  $\frac{1}{2 \pi} \sinh (2 \pi)$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		f(t)&=e^{-t} \quad-\pi<x<\pi\\
		f(t)&=\sum_{-\infty}^{\infty} c_{n} e^{\mathrm{int}}\\
		\sum_{-\infty}^{\infty}\left|c_{n}\right|^{2}&=\frac{1}{2 \pi} \int_{-\pi}^{\pi} e^{-2 t} d t=\left.\frac{1}{2 \pi} \cdot \frac{e^{-2 t}}{-2}\right|_{-\pi} ^{\pi}\\&=\frac{1}{2 \pi}\left[\frac{e^{-2 \pi}-e^{2 \pi}}{-2}\right]=\frac{1}{2 \pi} \sinh 2 \pi
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
\end{enumerate}
\colorlet{ocre1}{ocre!70!}
\colorlet{ocrel}{ocre!30!}
\setlength\arrayrulewidth{1pt}
\begin{table}[H]
	\centering
	\arrayrulecolor{ocre}
	\begin{tabular}{|p{1.5cm}|p{1.5cm}||p{1.5cm}|p{1.5cm}|}
		\hline
		\multicolumn{4}{|c|}{\textbf{Answer key}}\\\hline\hline
		\rowcolor{ocrel}Q.No.&Answer&Q.No.&Answer\\\hline
		1&\textbf{B} &2&\textbf{B}\\\hline
		3&\textbf{D} &4&\textbf{A} \\\hline
		5&\textbf{C} &6&\textbf{B} \\\hline
		7&\textbf{B}&8&\textbf{D}\\\hline
		9&\textbf{A}&10&\textbf{C}\\\hline
		11&\textbf{D} &&\textbf{}\\\hline

	\end{tabular}
\end{table}

\newpage
\begin{abox}
	Practise Set-2
\end{abox}
\begin{enumerate}[label=\color{ocre}\textbf{\arabic*.}]
	\item If $f(x)=\left\{\begin{array}{ll}0 & \text { for } x<3, \\ x-3 & \text { for } x \geq 3\end{array}\right.$ then the Laplace transform of $f(x)$ is
	{\exyear{GATE 2010}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $s^{-2} e^{3 s}$
		\task[\textbf{B.}] $s^{2} e^{3 s}$
		\task[\textbf{C.}] $s^{-2}$
		\task[\textbf{D.}] $s^{-2} e^{-3 s}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		L\{f(x)\}&=\int_{0}^{\infty} e^{-s x} f(x) d x\\&=\int_{0}^{3} e^{-s x} f(x) d x+\int_{3}^{\infty} e^{-s x} f(x) d x\\&=\int_{3}^{\infty}(x-3) e^{-s x} d x\\
		L\{f(x)\}&=\left.(x-3) \frac{e^{-s x}}{-s}\right|_{3} ^{\infty}-\int_{3}^{\infty} 1 \cdot\left(\frac{e^{-s x}}{-s}\right) d x\\&=0+\frac{1}{s} \int_{3}^{\infty} e^{-s x} d x\\&=\frac{1}{s}\left[\frac{e^{-s x}}{-s}\right]_{3}^{\infty}=s^{-2} e^{-3 s}
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item The coefficient of $e^{i k x}$ in the Fourier expansion of $u(x)=A \sin ^{2}(\alpha x)$ for $k=-2 \alpha$ is
	{\exyear{GATE 2017}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $\frac{A}{4}$
		\task[\textbf{B.}] $\frac{-A}{4}$
		\task[\textbf{C.}] $\frac{A}{2}$
		\task[\textbf{D.}] $\frac{-A}{2}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{	Since, }\sin (\alpha x)&=\frac{e^{i \alpha x}-e^{-i \alpha x}}{2 i} \Rightarrow \sin ^{2}(\alpha x)\\&=\frac{e^{i 2 \alpha x}-2+e^{-2 i \alpha x}}{(-4)}\\
		\text{Since, }2 \alpha&=-k,\text{ hence }\sin ^{2}(\alpha x)\\&=\frac{e^{-i k x}-2+e^{i k x}}{(-4)}\\
		\text{Hence, }c_{k}&=\frac{A}{2 \pi} \int_{-\pi}^{\pi} \sin ^{2}(\alpha x) d x\\&=-\frac{A}{8 \pi}\left[\int_{-\pi}^{\pi} e^{-i k x} e^{-i k x} d x-2 \int_{-\pi}^{\pi} e^{-i k x} d x+\int_{-\pi}^{\pi} e^{-i k x} e^{i k x} d x\right]\\
		&=-\frac{A}{8 \pi}\left[\int_{-\pi}^{\pi} e^{-2 i k x} d x-2 \int_{-\pi}^{\pi} e^{-i k x} d x+\int_{-\pi}^{\pi} d x\right]
		\intertext{The first two integrals are zero and the third integral has the value $2 \pi$.
			Thus,}
		c_{k}&=-\frac{A}{8 \pi}(2 \pi)=-\frac{A}{4}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item Given the fundamental constants $\hbar$ (Planck's constant), $G$ (universal gravitation constant) and $c$ (speed of light), which of the following has dimension of length?
	{\exyear{JEST 2014}}
	\begin{tasks}(2)
		\task[\textbf{A.}]$\sqrt{\frac{\hbar G}{c^{3}}}$
		\task[\textbf{B.}] $\sqrt{\frac{\hbar G}{c^{5}}}$
		\task[\textbf{C.}]$\frac{\hbar G}{c^{3}}$
		\task[\textbf{D.}] $\sqrt{\frac{\hbar c}{8 \pi G}}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\left[\frac{\left[M L^{2} T^{-1}\right]\left[M^{-1} L^{3} T^{-2}\right]}{L^{3} T^{-3}}\right]^{\frac{1}{2}}&=\left[L^{2}\right]^{\frac{1}{2}}=L\\
		\hbar=\left[M L^{2} T^{-1}\right], G=\frac{g r^{2}}{m}&=\left[M^{-1} L^{3} T^{-2}\right]
		\end{align*}
		So the correct answer is \textbf{Option (A)}
	\end{answer}
	\item The Fourier transform of the function $\frac{1}{x^{4}+3 x^{2}+2}$ up to proportionality constant is
	{\exyear{JEST 2017}}
	\begin{tasks}(2)
		\task[\textbf{A.}]$\sqrt{2} \exp \left(-k^{2}\right)-\exp \left(-2 k^{2}\right)$
		\task[\textbf{B.}]$\sqrt{2} \exp (-|k|)-\exp (-\sqrt{2}|k|)$
		\task[\textbf{C.}]$\sqrt{2} \exp (-\sqrt{|k|})-\exp (-\sqrt{2|k|})$
		\task[\textbf{D.}]  $\sqrt{2} \exp \left(-\sqrt{2} k^{2}\right)-\exp \left(-2 k^{2}\right)$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		f(x)&=\frac{1}{\left(x^{4}+3 x^{2}+2\right)}=\frac{1}{\left(x^{2}+1\right)}-\frac{1}{\left[x^{2}+(\sqrt{2})^{2}\right]}
		\intertext{Now, Fourier transform of $f(x)$ is,}
		F(p)&=A \int_{-\infty}^{\infty} f(x) e^{-1 k x} d x\\
		&=A \int_{-\infty}^{\infty}\left[\frac{1}{\left(x^{2}+1\right)}-\frac{1}{x^{2}+(\sqrt{2})^{2}}\right] e^{-i k x} d x=A\left[\int_{-\infty}^{\infty} \frac{1}{\left(x^{2}+1\right)} \times e^{-i k x} d x-\int_{-\infty}^{\infty} \frac{e^{-i k x}}{x^{2}+(\sqrt{2})^{2}} d x\right]\\
		\because &\int_{-\infty}^{\infty} \frac{1}{\left(x^{2}+a^{2}\right)} e^{-i k x} d x=\sqrt{\frac{\pi}{2}} \frac{e^{-a|k|}}{a}\\
		F(k)&=A\left[\sqrt{\frac{\pi}{2}} \frac{e^{-|k|}}{1}-\sqrt{\frac{\pi}{2}} \frac{e^{-\sqrt{2} \mid k}}{\sqrt{2}}\right]=\frac{A \sqrt{\pi}}{2}[\sqrt{2} \exp (-|k|)-\exp (-\sqrt{2}|k|)]\\
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item The function $f(x)=\cosh x$ which exists in the range $-\pi \leq x \leq \pi$ is periodically repeated between $x=(2 m-1) \pi$ and $(2 m+1) \pi$, where $m=-\infty$ to $\infty$. Using Fourier series, indicate the correct relation at $x=0$
	{\exyear{JEST 2017}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\sum_{n=-\infty}^{\infty} \frac{(-1)^{n}}{1-n^{2}}=\frac{1}{2}\left(\frac{\pi}{\cosh \pi}-1\right)$
		\task[\textbf{B.}]$\sum_{n=-\infty}^{\infty} \frac{(-1)^{n}}{1-n^{2}}=2 \frac{\pi}{\cosh \pi}$
		\task[\textbf{C.}]$\sum_{n=-\infty}^{\infty} \frac{(-1)^{-n}}{1+n^{2}}=2 \frac{\pi}{\sinh \pi}$
		\task[\textbf{D.}] $\sum_{n=1}^{\infty} \frac{(-1)^{n}}{1+n^{2}}=\frac{1}{2}\left(\frac{\pi}{\sinh \pi}-1\right)$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		f(x)&=\cosh x, \quad-\pi \leq x \leq \pi\\
		\text{Here, }a_{0}&=\frac{1}{2 \pi} \int_{-\pi}^{\pi} \cosh x d x=\frac{1}{2 \pi}[\sinh x]_{-\pi}^{\pi}=\frac{\sinh \pi}{\pi}\\
		b_{n}&=0,\text{ due to even function}\\
		\text{	and }a_{n}&=\frac{1}{2 \pi} \int_{-\pi}^{\pi}\left(e^{x}+e^{-x}\right) \cos n x d x\qquad
		\left[\because \cosh x=\frac{1}{2}\left(e^{x}+e^{-x}\right)\right]\\
		a_{n}&=\frac{1}{2 \pi}\left[\frac{e^{x}}{\left(1+n^{2}\right)}(\cos n x+n \sin n x)+\frac{e^{-x}}{1+n^{2}}(-\cos n x+n \sin n x)\right]_{-\pi}^{\pi}\\
		&=\frac{1}{2 \pi}\left[\frac{e^{\pi}(-1)^{n}}{\left(1+n^{2}\right)}-\frac{e^{-\pi}(-1)^{n}}{\left(1+n^{2}\right)}-\frac{e^{-\pi}(-1)^{n}}{\left(1+n^{2}\right)}+\frac{e^{\pi}(-1)^{n}}{\left(1+n^{2}\right)}\right]\\&=\frac{2(-1)^{n} \cdot 2 \sinh \pi}{2 \pi\left(1+n^{2}\right)}=\frac{2(-1)^{n} \sinh \pi}{\pi\left(1+n^{2}\right)}\\
		\text{	Hence, }f(x)&=a_{0}+\sum_{n=1}^{\infty}\left(a_{n} \cos n x+b_{n} \sin n x\right) \Rightarrow \cosh x=\frac{\sinh \pi}{\pi}+\sum_{n=1}^{\infty} \frac{2(-1)^{n} \sinh \pi}{\pi\left(1+n^{2}\right)} \cos n x\\
		\text{At }x&=0,\\
		\sum_{n=1}^{\infty} \frac{2(-1)^{n} \sinh \pi}{\pi\left(1+n^{2}\right)}&=\left(1-\frac{\sinh \pi}{\pi}\right) \Rightarrow \sum_{n=1}^{\infty} \frac{(-1)^{n}}{\left(1+n^{2}\right)}=\frac{1}{2}\left[\frac{\pi}{\sinh \pi}-1\right]
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item The Laplace transform of $\frac{(\sin (a t)-a t \cos (a t))}{\left(2 a^{3}\right)}$ is
	{\exyear{JEST 2018}}
	\begin{tasks}(2)
		\task[\textbf{A.}]$\frac{2 a s}{\left(s^{2}+a^{2}\right)^{2}}$
		\task[\textbf{B.}]$\frac{s^{2}-a^{2}}{\left(s^{2}+a^{2}\right)^{2}}$
		\task[\textbf{C.}]$\frac{1}{(s+a)^{2}}$
		\task[\textbf{D.}] $\frac{1}{\left(s^{2}+a^{2}\right)^{2}}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		L\left\{\frac{\sin a t-a t \cos a t}{2 a^{3}}\right\}=\frac{1}{\left(s^{2}+a^{2}\right)^{2}}
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
\end{enumerate}
\colorlet{ocre1}{ocre!70!}
\colorlet{ocrel}{ocre!30!}
\setlength\arrayrulewidth{1pt}
\begin{table}[H]
	\centering
	\arrayrulecolor{ocre}
	\begin{tabular}{|p{1.5cm}|p{1.5cm}||p{1.5cm}|p{1.5cm}|}
		\hline
		\multicolumn{4}{|c|}{\textbf{Answer key}}\\\hline\hline
		\rowcolor{ocrel}Q.No.&Answer&Q.No.&Answer\\\hline
		1&\textbf{D} &2&\textbf{B}\\\hline
		3&\textbf{A} &4&\textbf{B} \\\hline
		5&\textbf{D} &6&\textbf{D} \\\hline

	\end{tabular}
\end{table}

CSIR- Mathematical Physics/chapter/Problem set Solutions Fourier.tex


\section{Refinement Reflection}
\label{sec:formalism}
\label{sec:types-reflection}
\label{sec:refinementreflection:theory}
Next, we formalize refinement reflection
via a core calculus \corelan.
%
We define a decidable SMT language \smtlan to approximate the
higher order, potentially diverging
target language \corelan
and present a decidable and sound type system
for \corelan.

\subsection{Syntax}
\input{text/refinementreflection/syntax}
%
Figure~\ref{fig:syntax} summarizes the syntax of \corelan,
which is essentially the calculus \undeclang (from~\S~\ref{sec:language})
with explicit recursion and a special $\erefname$ binding
to denote terms that are reflected into the refinement logic.
%
The elements of \corelan are layered into
primitive constants, values, expressions, binders
and programs.

\mypara{Constants}
The primitive constants of \corelan
include all the primitive logical
operators $\op$, here, the set $\{ =, <\}$.
%
Moreover, they include the
primitive booleans $\etrue$, $\efalse$,
integers $\mathtt{-1}, \mathtt{0}$, $\mathtt{1}$, \etc,
and logical operators $\mathtt{\land}$, $\mathtt{\lor}$, $\mathtt{\lnot}$, \etc.

\mypara{Data Constructors}
%
Data constructors are special constants.
% Each data type has an equality predicate $\haseq{T}$
% that is true only if values of type $T$ can be finitely compared.
For example, the data type \tintlist, which represents
finite lists of integers, has two data constructors: $\dnull$ (nil)
and $\dcons$ (cons).

\mypara{Values \& Expressions}
%
The values of \corelan include
constants, $\lambda$-abstractions
$\efun{x}{\typ}{e}$, and fully
applied data constructors $D$
that wrap values.
%
The expressions of \corelan
include values, variables $x$,
applications $\eapp{e}{e}$, and
$\mathtt{case}$ expressions.

\mypara{Binders \& Programs}
%
A \emph{binder} $\bd$ is a series of possibly recursive
$\mathtt{let}$ definitions, followed by an expression.
%
A \emph{program} \prog is a series of $\erefname$
definitions, each of which names a function
that is reflected into the refinement
logic, followed by a binder.
%
The stratification of programs via binders
is required so that arbitrary recursive definitions
are allowed in the program but cannot be inserted into the logic
via refinements or reflection.
%
(We \emph{can} allow non-recursive $\mathtt{let}$
binders in expressions $e$, but omit them for simplicity).

\subsection{Operational Semantics}
We define $\hookrightarrow$ to be the small step, call-by-name
$\beta$-reduction semantics for \corelan.
%
We evaluate reflected terms %$\erefb{x}{\gtyp}{e}{\prog}$
as recursive $\mathtt{let}$ bindings, with extra termination-check
constraints imposed by the type system:
%
$$
\erefb{x}{\gtyp}{e}{\prog}
\hookrightarrow
\eletb{x}{\gtyp}{e}{\prog}
$$
%
We define $\evalsto{}{}$ to be the reflexive,
transitive closure of $\evals{}{}$.
%
Moreover, we define $\betaeq{}{}$ to be the reflexive,
symmetric, and transitive closure of $\evals{}{}$.

\mypara{Constants} Application of a constant requires the
argument be reduced to a value; in a single step, the
expression is reduced to the output of the primitive
constant operation, \ie ${c\ v} \hookrightarrow \ceval{c}{v}$.
%
For example, consider $=$, the primitive equality
operator on integers.
%
We have $\ceval{=}{n} \defeq =_n$
where $\ceval{=_n}{m}$ equals \etrue
iff $m$ is the same as $n$.
%

\mypara{Equality}
We assume that the equality operator
is defined \emph{for all} values,
and, for functions, is defined as
extensional equality.
%
That is, for all
$f$ and
$f'$,
$\evals{(f = f')}{\etrue}$
   $\mbox{iff}$
  $\forall v.\ \betaeq{f\ v}{f'\ v}$.
%
We assume source \emph{terms} only contain implementable equalities
over non-function types; while function extensional equality only appears
in \emph{refinements} and is approximated by the underlying logic.

\subsection{Types}

\corelan types include basic types, which are \emph{refined} with predicates,
and dependent function types.
%
\emph{Basic types} \btyp comprise integers, booleans, and a family of data-types
$T$ (representing lists, trees \etc).
%
For example, the data type \tintlist represents lists of integers.
%
We refine basic types with predicates (boolean-valued expressions \refa) to obtain
\emph{basic refinement types} $\tref{v}{\btyp}{\refa}$.
%
%
We use \tlabel to mark provably terminating
computations and use
refinements to ensure that if
${{e}\text{:}{\tref{v}{\btyp^\tlabel}{\refa'}}}$,
then $e$ terminates (as in chapter~\ref{chapter:refinedhaskell}).
%
Finally, we have dependent \emph{function types} $\tfun{x}{\typ_x}{\typ}$
where the input $x$ has the type $\typ_x$ and the output $\typ$ may
refer to the input binder $x$.
%
We write $\btyp$ to abbreviate $\tref{v}{\btyp}{\etrue}$,
and \tfunbasic{\typ_x}{\typ} to abbreviate \tfun{x}{\typ_x}{\typ} if
$x$ does not appear in $\typ$.
%
%We use $r$ to refer to refinements.

\mypara{Constants}
For each constant $c$ we define its type \constty{c}, \eg%
%
$$
\begin{array}{lcl}
\constty{3} &\doteq& \tref{v}{\tint}{v = 3}\\
\constty{+} &\doteq& \tfun{\ttx}{\tint}{\tfun{\tty}{\tint}{\tref{v}{\tint}{v = x + y}}}\\
\constty{\leq} &\doteq& \tfun{\ttx}{\tint}{\tfun{\tty}{\tint}{\tref{v}{\tbool}{v \Leftrightarrow x \leq y}}}\\
\end{array}
$$
%

\subsection{Refinement Reflection}\label{subsec:logicalannotations}
%
The key idea in our work is to
\emph{strengthen} the output type of functions
with a refinement that \emph{reflects} the
definition of the function in the logic.
%
We do this by treating each
%
$\erefname$-binder
%
(${\erefb{f}{\gtyp}{e}{\prog}}$)
%
as a $\eletname$-binder with a reflected singleton type
%
(${\eletb{f}{\exacttype{\gtyp}{e}}{e}{\prog}}$)
%
during type checking (rule $\rtreflect$ in Figure~\ref{fig:typing}).

\mypara{Reflection}
%
We write \exacttype{\typ}{e} for the \emph{reflection}
of the term $e$ into the type $\typ$,  defined by strengthening
\typ as:
%
$$
\begin{array}{lcl}
\exacttype{\tref{v}{\btyp}{r}}{e}
  & \defeq
  & \tref{v}{\btyp}{r \land v = e}\\
\exacttype{\tfun{x}{\typ_x}{\typ}}{\efun{y}{}{e}}
  & \defeq
  & \tfun{x}{\typ_x}{\exacttype{\typ}{e\subst{y}{x}}}
\end{array}
$$
%
As an example, recall from \S~\ref{sec:refinementreflection:overview}
that the @reflect fib@ strengthens the type of
@fib@ with the refinement @fibP@.
%% NV In Overview, we have fibP v n = v = fib n && fibR v n
%% NV Here we get the reflection part (fibR v n)
%% NV which we can verify
%% NV at each fix invocation we also get the v = fib n portion
%% NV via the exact rule
%% NV We can not add the v = fib n as a port condition, because
%% NV we cannot prove it.

\mypara{Consequences for Verification}
%
Reflection has two consequences for verification.
%
First, the reflected refinement is \emph{not trusted};
it is itself verified (as a valid output type)
during type checking.
%
Second, instead of being tethered to quantifier
instantiation heuristics or having to program
``triggers'' as in Dafny~\citep{dafny} or
\fstar~\citep{fstar},
%
the programmer can predictably ``unfold'' the
definition of the function during a proof simply
by ``calling'' the function, which, as discussed
in~\S~\ref{sec:evaluation}, we have found to be
a very natural way of structuring proofs.

\subsection{The SMT logic \smtlan}
\corelan is a higher order, potentially diverging language
that cannot be used for decidable verification.
%
Next, we describe \smtlan, a conservative, first order
approximation of \corelan where higher order features are
approximated with uninterpreted functions,
yielding an SMT-based
algorithmic logic that enjoys soundness and decidability.

\input{text/refinementreflection/smtsyntax}

\mypara{Syntax}
%
Figure~\ref{fig:smtsyntax} summarizes the syntax
of \smtlan, the \emph{sorted} (SMT-)
decidable logic of quantifier-free equality,
uninterpreted functions and linear
arithmetic (QF-EUFLIA) ~\citep{Nelson81,SMTLIB2}.
%
The \emph{terms} of \smtlan include
integers $n$,
booleans $b$,
variables $x$,
data constructors $\dc$ (encoded as constants),
fully applied unary \unop and binary \binop operators,
and application $x\ \overline{\pred}$ of an uninterpreted function $x$.
%
The \emph{sorts} of \smtlan include the built-in
\tint and \tbool.
%
The interpreted functions of \smtlan, \eg
the logical constants $=$ and $<$,
%% NV and the uninterpreted functions app and lam
%% NV but we have not introduced these yet
have the function sort $\sort \rightarrow \sort$.
%
Other functional values in \corelan, \eg
reflected \corelan functions and
$\lambda$-expressions, have the first-order
uninterpreted sort \tsmtfun{\sort}{\sort}.
%
The universal sort \tuniv represents all other values.

\subsection{Transforming \corelan into \smtlan}
%
\label{subsec:embedding}

%\input{defuncrules}
%
A \emph{type environment} $\env$ is a sequence of type bindings
$\tbind{x_1}{\typ_1},$ $\ldots,\tbind{x_n}{\typ_n}$.
We use the type environment to define the judgment
\tologicshort{\env}{e}{\typ}{\pred}{\sort}{\smtenv}{\axioms}
that transforms a $\corelan$ term $e$
% under an environment $\env$,
into a $\smtlan$ term $\pred$.
%
Most of the transformation rules are identity
and can be found in~\cite{vazou16techrep}.
Here we discuss the non-identity ones.

\mypara{Embedding Types}
%
We embed \corelan types into \smtlan sorts as:
%
\[
\begin{array}{rclcrcl}
\embed{\tint}                       & \defeq &  \tint & \quad &
\embed{T}                           & \defeq &  \tuniv \\
\embed{\tbool}                      & \defeq &  \tbool & \quad &
\embed{\tfun{x}{\typ_x}{\typ}} & \defeq & \tsmtfun{\embed{\typ_x}}{\embed{\typ}}
\end{array}
\]

\mypara{Embedding Constants}
%
Elements shared on both \corelan and \smtlan
translate to themselves.
%
These elements include
booleans,
integers,
variables,
binary
and unary
operators.
%
SMT solvers do not support currying,
and so in \smtlan, all function symbols
must be fully applied.
%
Thus, we assume that all applications
to primitive constants and data
constructors are fully applied, \eg by converting
source terms like @(+ 1)@ to
@(\z -> z+1)@.
%

\mypara{Embedding Functions}
%
As \smtlan is a first-order logic, we
embed $\lambda$-abstraction
using the uninterpreted function
\smtlamname{}{}.
%
$$
\inference{
    \tologicshort{\env, \tbind{x}{\typ_x}}{e}{}{\pred}{}{}{} &
        \hastype{\env}{(\efun{x}{}{e})}{(\tfun{x}{\typ_x}{\typ})}\\
}{
	\tologicshort{\env}{\efun{x}{}{e}}{(\tfun{x}{\typ_x}{\typ})}
	        {\smtlamname{\embed{\typ_x}}{\embed{\typ}}\ {x}\ {\pred}}
	        {\sort'}{\smtenv, \tbind{f}{\sort'}}{\andaxioms{\{\axioms_{f_1}, \axioms_{f_2}\}}{\axioms}}
}[\lgfun]
$$
%
The term $\efun{x}{}{e}$ of type
${\typ_x \rightarrow \typ}$ is transformed
to
${\smtlamname{\sort_x}{\sort}\ x\ \pred}$
of sort
${\tsmtfun{\sort_x}{\sort}}$, where
%
$\sort_x$ and $\sort$ are respectively
$\embed{\typ_x}$ and $\embed{\typ}$,
%
${\smtlamname{\sort_x}{\sort}}$
is a special uninterpreted function
of sort
${\sort_x \rightarrow \sort\rightarrow\tsmtfun{\sort_x}{\sort}}$,
and
$x$ of sort $\sort_x$ and $r$ of sort $\sort$ are
the embedding of the binder and body, respectively.
%
As $\smtlamname{}{}$ is an SMT-function,
it \emph{does not} create a binding for $x$.
%
Instead, $x$ is renamed to
a \emph{fresh} name pre-declared in
the SMT logic.

\mypara{Embedding Applications}
%
Dually, we embed applications via
defunctionalization~\citep{Reynolds72}
with the uninterpreted $\smtappname{}{}$ function.
%
$$
\inference{
	\tologicshort{\env}{e'}{\typ_x}{\pred'}{\embed{\typ_x}}{\smtenv}{\axioms'}
	&
	\tologicshort{\env}{e}{\tfun{x}{\typ_x}{\typ}}{\pred}{\tsmtfun{\embed{\typ_x}}{\embed{\typ}}}{\smtenv}{\axioms}
	&
	\hastype{\env}{e}{{\typ_x}\rightarrow{\typ}}
}{
	\tologicshort{\env}{e\ e'}{\typ}{\smtappname{\embed{\typ_x}}{\embed{\typ}}\ {\pred}\ {\pred'}}{\embed{\typ}}{\smtenv}{\andaxioms{\axioms}{\axioms'}}
}[\lgapp]
$$
%
The term ${e\ e'}$, where $e$ and $e'$ have
types ${\typ_x \rightarrow \typ}$ and $\typ_x$,
is transformed to
${\tbind{\smtappname{\sort_x}{\sort}\ \pred\ \pred'}{\sort}}$
where
%
$\sort$ and $\sort_x$ are $\embed{\typ}$ and $\embed{\typ_x}$,
the
${\smtappname{\sort_x}{\sort}}$
is a special uninterpreted function of sort
${\tsmtfun{\sort_x}{\sort} \rightarrow \sort_x \rightarrow \sort}$,
and
$\pred$ and $\pred'$ are the respective translations of $e$ and $e'$.

\mypara{Embedding Data Types}
%
We translate each data constructor to a
predefined \smtlan constant ${\smtvar{\dc}}$ of
sort ${\embed{\constty{\dc}}}$.
$$
	\tologicshort{\env}{\dc}{\constty{\dc}}{\smtvar{\dc}}{\embed{\constty{\dc}}}{\emptyset}{\emptyaxioms}
$$
%
For each datatype, we assume the existence of reflected functions that
\emph{check} the top-level constructor
and \emph{select} their individual fields.
%
For example, for lists, we assume the existence of measures:
%
\begin{mcode}
  isNil []     = True     isCons (x:xs) = True
  isNil (x:xs) = False    isCons []     = False

  sel1 (x:xs)  = x        sel2 (x:xs)   = xs
\end{mcode}
%
Due to the simplicity of their syntax the above checkers and selectors
can be automatically instantiated in the logic
(\ie without actual calls to the reflected functions at source level)
using the measure mechanism (\S~\ref{sec:measures}).

To generalize, let $\dc_i$ be a data constructor such that
$$
\constty{\dc_i} \defeq \typ_{i,1} \rightarrow \dots \rightarrow \typ_{i,n} \rightarrow \typ
$$
Then the \emph{check function}
${\checkdc{{\dc_i}}}$ has the sort
$\tsmtfun{\embed{\typ}}{\tbool}$,
and the \emph{select function}
${\selector{\dc}{i,j}}$ has the sort
$\tsmtfun{\embed{\typ}}{\embed{\typ_{i,j}}}$.
%

% \mypara{Checking and Projection}
%
We translate case-expressions
of \corelan into nested $\mathtt{if}$
terms in \smtlan, by using the check
functions in the guards, and the
select functions for the binders
of each case.
$$
\inference{
	\tologicshort{\env}{e}{\typ_e}{\pred}{\embed{\typ_e}}{\smtenv}{\axioms} &&
	\tologicshort{\env}{e_i\subst{\overline{y_i}}{\overline{\selector{\dc_i}{}\ x}}\subst{x}{e}}{\typ}{\pred_i}{\embed{\typ}}{\smtenv}{\axioms_i}
}{
	\tologicshort{\env}{\ecase{x}{e}{\dc_i}{\overline{y_i}}{e_i}}{\typ}
	 {\eif{\smtappname{}{}\ \checkdc{\dc_1}\ \pred}{\pred_1}{\ldots} \ \mathtt{else}\ \pred_n}{\embed{\typ}}{\smtenv}
	 {\andaxioms{\axioms}{\axioms_i}}
}[\lgcase]
$$
%
For example, the body of the list append function
%
\begin{code}
  []     ++ ys = ys
  (x:xs) ++ ys = x : (xs ++ ys)
\end{code}
%
is reflected into the \smtlan refinement:
%
$$
\ite{\mathtt{isNil}\ \mathit{xs}}
    {\mathit{ys}}
    {\mathtt{sel1}\ \mathit{xs}\
       \dcons\
       (\mathtt{sel2}\ \mathit{xs} \ \mathtt{++}\  \mathit{ys})}
$$
%
We favor selectors to the axiomatic translation of
HALO~\citep{halo} to avoid
universally quantified formulas and the resulting
instantiation unpredictability.

\subsection{Typing Rules}
\input{text/refinementreflection/typing}
%
Next, we present the
typing, well-formedness, and subtyping~\citep{Knowles10,Vazou14}
rules of \corelan.

\mypara{Typing}
A judgment \hastype{\env}{\prog}{\typ} states that
the program $\prog$ has the type $\typ$ in
the environment $\env$.
That is, when the free variables in $\prog$ are
bound to expressions described by $\env$, the
program $\prog$ will evaluate to a value
described by $\typ$.

\mypara{Rules}
%
All but two of the rules are standard~\cite{Knowles10,Vazou14}.
%
First, rule \rtreflect is used to strengthen the type of each
reflected binder with its definition, as described previously
in \S~\ref{subsec:logicalannotations}.
%
Second, rule \rtexact strengthens the expression with
a singleton type equating the value and the expression
(\ie reflecting the expression in the type).
%
This is a generalization of the ``selfification'' rules
from \cite{Ou2004,Knowles10}, and is required to
equate the reflected functions with their definitions.
%
For example, the application $(\fib\ 1)$ is typed as
${\tref{v}{\tint}{\fibdef\ v\ 1 \wedge v = \fib\ 1}}$ where
the first conjunct comes from the (reflection-strengthened)
output refinement of \fib~\S~\ref{sec:refinementreflection:overview} and
the second comes from rule~\rtexact.
%
%%Finally, rule \rtfix is used to type the intermediate
%%$\texttt{fix}$ expressions that appear, not in the
%%surface language but as intermediate terms in the
%%operational semantics.

\mypara{Well-formedness}
A judgment \iswellformed{\env}{\typ} states that
the refinement type $\typ$ is well-formed in
the environment $\env$.
%
Following chapter~\ref{chapter:refinedhaskell}, the type $\typ$ is well-formed if all
the refinements in $\typ$ are $\tbool$-typed,
provably terminating expressions in $\env$.
%
%%\mypara{Termination}
%%%
%%Under arbitrary beta-reduction semantics
%%(which includes lazy evaluation), soundness
%%of refinement type checking requires checking
%%termination, for two reasons:
%%%
%%(1)~to ensure that refinements cannot diverge, and
%%(2)~to account for the environment during subtyping~\citep{Vazou14}.
%%%
%%We use \tlabel to mark provably terminating
%%computations, and extend the rules to use
%%refinements to ensure that if
%%${\ahastype{\env}{e}{\tref{v}{\btyp^\tlabel}{r}}}$,
%%then $e$ terminates~\citep{Vazou14}.
%%%

\mypara{Subtyping}
A judgment \issubtype{\env}{\typ_1}{\typ_2} states
that the type $\typ_1$ is a subtype of %the type
$\typ_2$ in the environment $\env$.
%
Informally, $\typ_1$ is a subtype of $\typ_2$ if
the refinement of $\typ_1$ \emph{implies}
the refinement of $\typ_2$
under the assumptions described by $\env$.
%
Subtyping of basic types reduces to implication checking.

\mypara{Verification Conditions}
The implication or \emph{verification condition} (VC)
${\vcond{\env}{\pred}}$
is \emph{valid} only if the set of values
described by $\env$, is subsumed by
the set of values described by $\pred$.
%
$\env$ is embedded into logic by conjoining
(the embeddings of) the refinements of
provably terminating binders (Chapter~\ref{chapter:refinedhaskell}):
%
\begin{align*}
\embed{\env} \defeq & \bigwedge_{x \in \env} \embed{\env, x} \\
\intertext{where we embed each binder as}
\embed{\env, x} \defeq & \begin{cases}
                           \pred  & \text{if } \env(x)=\tref{v}{\btyp^{\tlabel}}{e},\
                                    \tologicshort{\env}{e\subst{v}{x}}{\btyp}{\pred}{\embed{\btyp}}{\smtenv}{\axioms} \\
                           \etrue & \text{otherwise}.
                         \end{cases}
\end{align*}

It is important to note that since \smtlan
is carefully restricted to SMT-decidable theories,
VC checking, and thus type checking of \corelan, is decidable.

\subsection{Soundness}

Following \undeclang from chapter~\ref{chapter:refinedhaskell}, in~\citep{vazou16techrep}, we show that
if validity checking respects the axioms of $\beta$-equivalence,
then \corelan is sound.

We define the $\beta$-equivalence axioms on the uninterpreted function
that represent $\lambda$-abstraction (\smtlamname{}{}) and
and application (\smtappname{}{}).
$$
\begin{array}{rcl}
\forall x\ y\ e. \smtlamname{}{}\ x\ e
  & = & \smtlamname{}{}\ y\ (e\subst{x}{y}) \\
\forall x\ e_x\ e. (\smtappname{}{}\ (\smtlamname{}{}\ x\ e)\ e_x)
  & = &  e\subst{x}{e_x}
\end{array}
$$
%
 We prove that when validity checking assumes the $\beta$-equivalence
 axioms, \corelan is sound.

\begin{theorem}{[Soundness of \corelan]}\label{thm:safety}
Assuming the $\beta$-equivalence axioms,
if \hastype{\emptyset}{\prog}{\typ}
       and $\evalsto{\prog}{w}$ then $\hastype{\emptyset}{w}{\typ}$.
\end{theorem}

Theorem~\ref{thm:safety} lets us interpret well typed terminating programs as proofs of
propositions.
%
For example, in \S~\ref{sec:refinementreflection:overview} we verified that
%
$\fibincrname\text{ :: }{\tfun{n}{\tnat}{\ttref{\fib{n} \leq \fib{(n+1)}}}}$.
%
Via soundness of \corelan, we get runtime monotonicity of @fib@.
$$
\forall n. \evalsto{0 \leq n}{\etrue} \Rightarrow \evalsto{\fib{n} \leq \fib{(n+1)}}{\etrue}
$$
% \section{Algorithmic Verification}\label{sec:algorithmic}

\mypara{Approximation of $\beta$-equivalence}
%
Though sound and precise, directly extending the logic with $\beta$-equivalence axioms
would render SMT validity checking undecidable.
%
Next, we discuss an incomplete,
yet decidable, technique that allows the
user to manually instantiate the $\beta$-equivalence axioms
when required for precise typing.


\documentclass{article}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[T5]{fontenc}
\usepackage[utf8]{inputenc}

% You can use a package 📦 called booktabs \usepackage{booktabs} for a visually better table.
\usepackage{booktabs}

\graphicspath{ {images/} }

% from begin-latex-in-minutes
\usepackage{listings}
\usepackage{color}

\lstdefinestyle{mystyle}{
keywordstyle=\color{magenta},
backgroundcolor=\color{yellow},
commentstyle=\color{green},
basicstyle=\footnotesize,
}
\lstset{style=mystyle}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.25\textwidth]{mesh}
    \caption{a nice plot}
    \label{fig:mesh1}
\end{figure}

As you can see in the figure \ref{fig:mesh1}, the
function grows near 0. Also, in the page \pageref{fig:mesh1}
is the same example.

\begin{itemize}
  \item The individual entries are indicated with a black dot, a so-called bullet.
  \item The text in the entries may be of any length.
\end{itemize}

\begin{enumerate}
  \item This is the first entry in our list
  \item The list numbers increase with each entry we add
\end{enumerate}

In physics, the mass-energy equivalence is stated
by the equation $E=mc^2$, discovered in 1905 by Albert Einstein.

The mass-energy equivalence is described by the famous equation
\[ E=mc^2 \]
discovered in 1905 by Albert Einstein.
In natural units ($c = 1$), the formula expresses the identity
\begin{equation}
E=m
\end{equation}

Subscripts in math mode are written as $a_b$ and superscripts are written as $a^b$. These can be combined an nested to write expressions such as

\[ T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} = T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q}) \]

We write integrals using $\int$ and fractions using $\frac{a}{b}$. Limits are placed on integrals using superscripts and subscripts:

\[ \int_0^1 \frac{dx}{e^x} =  \frac{e-1}{e} \]

Lower case Greek letters are written as $\omega$ $\delta$ etc. while upper case Greek letters are written as $\Omega$ $\Delta$.

Mathematical operators are prefixed with a backslash as $\sin(\beta)$, $\cos(\alpha)$, $\log(x)$ etc.

\paragraph{dsfsfsdfds}
This is a paragraph. Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself

\section{zczxzzcxzx}
We begin a section with section and a paragraph with paragraph. You can also add subsection with subsection and subparagraph with subparagraph

\subsection{zczxcxzcc}
We begin a section with section and a paragraph with paragraph. You can also add subsection with subsection and subparagraph with subparagraph
xcvcxvcxv

Hi let me introduce myself\footnote{\label{myfootnote}Hello footnote}.
... (later on)

I'm referring to myself \ref{myfootnote}.

\begin{table}[h!]
  \centering
  \caption{Caption for the table.}
  \label{tab:table1}

  \begin{tabular}{|l|c|||r|}
    \hline
    1 sadfsd sdfsf sfds & 2 sdfds dsfd sdf sdf & asdasd asd asdaad adaa 3\\
    \hline
    a & b xcv dfd dsf sdfsd & ada adsdc\\
    \hline
  \end{tabular}

\end{table}

\paragraph{dsfsfsdfds}
This is a paragraph. Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself

\paragraph{dsfsfsdfds}
This is a paragraph. Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself

\begin{figure}[h]
  % \includegraphics[width=\linewidth]{mesh.png}
  \includegraphics[width=0.25\linewidth]{mesh.png}
  \caption{What is it about?}
  \label{fig:whateverlabel}
\end{figure}

\begin{verbatim}
  #include <iostream>

  int main()
  {
    std::cout << "hello world!\n";
    return 0;
  }
\end{verbatim}

\begin{lstlisting}[language=Python]

  print "Hello World!"

\end{lstlisting}

Lorem ipsum dolor sit amet \lstinline{print "Hello World"} , consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\input{part2}

\end{document}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{amsmath,amssymb,amsthm}

\theoremstyle{plain}
\newtheorem{result}{Result}[section]

\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\newcommand{\GF}{\operatorname{GF}}

\title{DammSum: efficient mnemonic seeds from quasigroup checksums}
\author{Cypher Stack \\ for Slaz Labs}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This technical note describes DammSum, a method for producing digital asset mnemonic seed checksums that are robust against all single substitutions and transpositions.
The method uses an optimization of the Damm algorithm to produce and validate checksums efficiently, in particular without requiring elementwise construction of a required quasigroup and its associated Cayley table.
\end{abstract}

This document describes technical information relevant to mnemonic seed generation in digital assets.
It has not been independently reviewed, and may contain errors.
The author asserts no warranty and disclaims liability for its use.
The author further expresses no endorsement of Slaz Labs or its associated entities.

\section{Introduction}

Many digital asset projects and protocols support the use of mnemonic seeds to generate keys in common client applications.
At its core, a mnemonic seed is simply a mapping between a given list of words and a corresponding bit string; depending on the method used, this bit string is used to produce keys, either directly or using a pseudorandom function like a hash function or key derivation function.

Mnemonic seeds are useful precisely because they are designed for use by humans, as they can be easily written down, spoken by voice, typed into wallet software, or otherwise securely stored using physical media.
However, this poses challenges:
\begin{itemize}
	\item What happens if the user communicates the seed over a noisy channel, and one or more words are substituted with others?
	\item What happens if the user reads the seed incorrectly, and one or more words are transposed?
	\item What happens if the user stores the seed incorrectly, and it is truncated when later read?
\end{itemize}

One mitigation to these and related challenges is to introduce a checksum to the seed phrase.
When generating a seed, client software first uses suitable randomness to produce the bitstring intended for use in key generation.
It then maps the bitstring to the mnemonic seed using a given word list.
Finally, it produces the checksum, which (depending on the method used) is typically prepended or appended to the seed.
When later communicating or using the seed, client software ensures that the checksum is valid for the given seed.

When considering designs for checksums, we consider two important concepts from coding theory relating to errors: detection and correction.
A design that detects errors is intended to alert the user that some particular type of transmission error occurred, and that the seed is invalid.
A design that corrects errors can do more, identifying the (ideally unique) valid seed to which the errors were applied.
Different constructions provide varying degrees of error detection and correction.

In this technical note, we describe a checksum design called DammSum that has the following properties:
\begin{itemize}
	\item The checksum design is compatible with the common Electrum word set used in many digital asset projects.
	\item The checksum is a single word, regardless of the length of the seed.
	\item All erasure errors are detected.
	\item All single substitution errors are detected.
	\item All single adjacent transpositions, including transposition of the checksum itself, are detected.
	\item Computation and verification of a checksum is efficient, with no lookup tables or complex computations required.
\end{itemize}

While error detection is useful, this design does not permit unique correction of substitution, transposition, or erasure errors.

\section{Mathematical background}

In a dissertation \cite{damm_thesis} and related papers \cite{damm2000,damm2007}, Damm notes the applicability of group structures to check digits, in particular observing that while the use of a group operation on antisymmetric permutation compositions can always detect single substitutions, it is limited in detection of adjacent transpositions based on the order of the group.
It is shown that replacement of the general group structure with at least a weakly totally antisymmetric quasigroup removes this limitation, such that a checksum construction based on this structure reliably and provably detects single substitutions and adjacent transpositions.

This observation then reduces the problem of checksum design to construction of weakly totally antisymmetric quasigroups of the required order, as well as optimizations for evaluation of the quasigroup operation on each digit of the seed.

For completeness, we define quasigroups, the weakly totally antisymmetric and totally antisymmetric properties, and the Damm algorithm, but refer the reader to \cite{damm_thesis,damm2000,damm2007} for a more complete treatment.

\subsection{Quasigroups and asymmetry}

\begin{definition}
	A \textit{quasigroup} $(G,\star)$ is a set $G \neq \emptyset$ closed under a binary operation $\star$ such that for all $a,b \in G$ there exist unique $x,y \in G$ such that $a \star x = b$ and $y \star a = b$.
\end{definition}

For the Damm algorithm, we will consider finite quasigroups, where the definition implies the usual cancellation laws.

\begin{definition}
	A quasigroup $(G,\star)$ is \textit{weakly totally antisymmetric} if for all $c,x,y \in G$, if $(c \star x) \star y = (c \star y) \star x$, then $x = y$.
\end{definition}

\begin{definition}
	A quasigroup $(G,\star)$ is \textit{totally antisymmetric} if it is weakly totally antisymmetric and $x \star y = y \star x$ implies $x = y$ for all $x,y \in G$.
\end{definition}

The paper \cite{damm2007} proves that there exist totally antisymmetric quasigroups of order $n$ for all $n \not\in \{2,6\}$, and that there exists a weakly totally antisymmetric quasigroup of order $n$ if and only if there exists a totally antisymmetric quasigroup of order $n$.

For the specific DammSum construction we describe later, the following additional results from \cite{damm2007} will be useful.

\begin{result}
	\label{result:gf_is_ta}
	Let $k > 1$ be an integer, and let $G = \GF(2^k)$ be the Galois field with $2^k$ elements.
	Let $a \in G$ such that $a \not\in \{0,1\}$, and define the binary operation $\star$ such that $x \star y = ax + y$ for all $x,y \in G$.
	Then $(G,\star)$ is a totally antisymmetric quasigroup.
\end{result}

\begin{result}
	\label{result:permute_wta}
	Let $(G,\star)$ be a totally antisymmetric quasigroup, and let $\beta: G \to G$ be a permutation of the elements of $G$.
	Define a binary operation $\star'$ on $G$ such that for all $x,y \in G$, we have $x \star' y = x \star \beta(y)$.
	Then $(G,\star')$ is a weakly totally antisymmetric quasigroup.
\end{result}

We now prove that a particular construction over a Galois field is a weakly totally antisymmetric quasigroup.

\begin{result}
	\label{result:wta}
	Let $k > 1$ be an integer, and let $G = \GF(2^k)$ be the Galois field with $2^k$ elements.
	Define a binary operation $\star'$ on $G$ such that for $x,y \in G$ we have $x \star' y = 2 \cdot (x + y)$.
	Then $(G,\star')$ is a weakly totally antisymmetric quasigroup.
\end{result}

\begin{proof}
	Define a binary operation $\star$ on $G = \GF(2^k)$ such that $x \star y = 2 \cdot x + y$ for all $x,y \in G$; then by Result \ref{result:gf_is_ta}, $(G,\star)$ is a totally antisymmetric quasigroup.

	Let $\beta: G \to G$ be a permutation on $G$ defined such that $\beta(x) = 2 \cdot x$ for all $x \in G$.
	Then for all $x,y \in G$ we have
	\begin{alignat*}{1}
		x \star' y &= 2 \cdot (x + y) \\
		&= 2 \cdot x + 2 \cdot y \\
		&= 2 \cdot x + \beta(y) \\
		&= x \star \beta(y)
	\end{alignat*}
	Result \ref{result:permute_wta} implies that $(G,\star')$ is weakly totally antisymmetric.
\end{proof}
Note that by construction, $x \star' x = 0$ for all $x \in G$.

\subsection{Damm algorithm}

We now define the Damm algorithm, which produces a checksum that provably detects single substitutions and adjacent transpositions.
The algorithm requires a finite weakly totally antisymmetric quasigroup $(G,\star)$ of order $n$, where for notational convenience we denote $G = \{0,1,\ldots,n-1\}$.
For optimization purposes, it further requires that $x \star x = 0$ for all $x \in G$ (the element $0$ is arbitrary and denoted as such for convenience); this is equivalent to asserting that the diagonal of the Cayley table for $G$ contain only this element.

Let $w = d_m | d_{m-1} | \cdots | d_1$ be an $m$-digit word formed by concatenating the digits $\{d_i\}_{i=1}^m$, where $d_i \in G$ for all $i \in [1,m]$ and $m > 0$.
Define the checksum of $w$ to be the digit $d_0$ such that the equation
$$(\cdots((d_m \star d_{m-1}) \star d_{m-2}) \star \cdots \star d_1) \star d_0 = 0$$
holds.
Observe that because we require $x \star x = 0$ for all $x \in G$, we may simplify the above equation by defining
$$d_0 = (\cdots((d_m \star d_{m-1}) \star d_{m-2}) \star \cdots \star d_1)$$
and using the former equation as verification of the checksum $d_0$.

Because $(G,\star)$ is a weakly totally antisymmetric quasigroup, any single substitution or transposition is detected.

\section{DammSum}

We now describe the construction of DammSum, a method for efficiently producing Damm-based checksums for digital asset mnemonic seed phrases.

Let $k = 11$, so $2^k = 2^{11} = 2048$.
Let $m = 12$.
Let $G = \GF(2^k)$, and define the binary operation $\star'$ on $G$ such that $x \star' y = 2 \cdot (x + y)$ for all $x,y \in G$.

Generation of a DammSum seed proceeds as follows:
\begin{enumerate}
	\item For $i \in [1,m]$, sample a digit $d_i \in G$ uniformly at random, and let $w = d_m | d_{m-1} | \cdots | d_1$.
	\item Compute $d_0 = (\cdots((d_m \star' d_{m-1}) \star' d_{m-2}) \star' \cdots \star' d_1)$.
	\item For each $i \in [0,m]$, let $D_i$ be the English word from the Electrum word list corresponding to $d_i$.
	\item Output the seed $D_m | D_{m-1} | \cdots | D_1 | D_0$.
\end{enumerate}

To verify a DammSum seed has the correct checksum:
\begin{enumerate}
	\item For each $i \in [0,m]$, let $d_i$ be the element of $\GF(2^k)$ corresponding to $D_i$.
	\item If the equation
	$$(\cdots((d_m \star' d_{m-1}) \star' d_{m-2}) \star' \cdots \star' d_1) \star' d_0 = 0$$
	holds, then verification succeeds; otherwise, it fails.
\end{enumerate}

The above construction meets the requirements of the Damm algorithm by Result \ref{result:wta}.
Further, a seed generated in this manner has $\log_2\left((2^{11})^{12}\right) = 132$ bits of entropy.

\section{Implementation}

We can implement DammSum efficiently, and note here how to do so.

Consider a representation of $\GF(2^k)$ as the set of binary-valued polynomials of degree at most $k-1$, reduced by an arbitrary monic irreducible binary-valued polynomial $f$ of degree exactly $k$.
While all choices of $f$ are valid, for efficiency we seek a polynomial of low weight.
For our purpose, we use the table in \cite{hp}, which lists $f(x) = x^{11} + x^2 + 1$.

In order to compute the checksum for a seed, we must compute quantities of the form $2 \cdot (x + y)$ in $\GF(2^k)$.
The sum $x + y$ is simply the bitwise \texttt{XOR} of the binary representations of $x$ and $y$, which is trivial to compute.

In order to compute the multiplication of the sum $x + y$ by $2$, it suffices to perform a bitwise left shift of $x + y$ and, if the result has the $k$ bit set, \texttt{XOR} this result with the binary representation of $f(2) = 2053$.

We then iterate this process over each digit in the seed to produce the checksum.

\section{Observations}

We note that while computation and verification of DammSum checksums is extremely efficient and can detect single substitution and transposition errors, it cannot uniquely correct them in all cases.

In order to provide robust and flexible error correction, a design based on constructions like Bose-Chaudhuri-Hocquenghem codes \cite{hocquenghem,bose} is recommended; however, such constructions are generally more complex and marginally less efficient.

\bibliographystyle{plain}
\bibliography{main}

\end{document}