\chapter{Application of cohomology}
In this final chapter on topology, I'll state (mostly without proof)
some nice properties of cohomology groups, and in particular
introduce the so-called cup product.
For an actual treatise on the cup product,
see \cite{ref:hatcher} or \cite{ref:maxim752}.

\section{Poincar\'e duality}
First cool result:
you may have noticed symmetry in the (co)homology groups of
``nice'' spaces like the torus or $S^n$.
In fact this is predicted by:
\begin{theorem}
	[Poincar\'e duality]
	If $M$ is a smooth oriented compact $n$-manifold,
	then we have a natural isomorphism
	\[ H^k(M; \ZZ) \cong H_{n-k}(M) \]
	for every $k$.
	In particular, $H^k(M) = 0$ for $k > n$.
\end{theorem}
So for smooth oriented compact manifolds,
cohomology and homology groups are not so different.

From this follows the symmetry that we mentioned
when we first defined the Betti numbers:
\begin{corollary}
	[Symmetry of Betti numbers]
	Let $M$ be a smooth oriented compact $n$-manifold,
	and let $b_k$ denote its Betti number.
	Then \[ b_k = b_{n-k}. \]
\end{corollary}
\begin{proof}
	\Cref{prob:betti}.
\end{proof}

\section{de Rham cohomology}
We now reveal the connection between
differential forms and singular cohomology.

Let $M$ be a smooth manifold.
We are interested in the homology and cohomology groups of $M$.
We specialize to the case $G = \RR$, the additive group of real numbers.
\begin{ques}
	Check that $\Ext(H, \RR) = 0$ for any finitely generated abelian group $H$.
\end{ques}
Thus, with real coefficients the universal coefficient theorem says that
\[ H^k(M; \RR) \cong \Hom(H_k(M), \RR) = \left( H_k(M) \right)^\vee \]
where we view $H_k(X)$ as a real vector space.
So, we'd like to get a handle on either $H_k(M$) or $H^k(M; \RR)$.

Consider the cochain complex
\[
	0 \to \Omega^0(M)
	\taking d \Omega^1(M)
	\taking d \Omega^2(M)
	\taking d \Omega^3(M)
	\taking d \dots
\]
and let $\HdR^k(M)$ denote its cohomology groups.
Thus the de Rham cohomology is the closed forms modulo the exact forms.
\[
	\text{Cochain} : \text{Cocycle} : \text{Coboundary}
	= \text{$k$-form} : \text{Closed form} : \text{Exact form}.
\]

The whole punch line is:
\begin{theorem}
	[de Rham's theorem]
	For any smooth manifold $M$, we have a natural isomorphism
	\[ H^k(M; \RR) \cong \HdR^k(M). \]
\end{theorem}
So the theorem is that the real cohomology groups of manifolds $M$
are actually just given by the behavior of differential forms.
Thus,
\begin{moral}
	One can metaphorically think of elements of cohomology groups
	as $G$-valued differential forms on the space.
\end{moral}

Why does this happen?
In fact, we observed already behavior of differential
forms which reflects holes in the space.
For example, let $M = S^1$ be a circle
and consider the \textbf{angle form} $\alpha$
(see \Cref{ex:angle_form}).
The from $\alpha$ is closed, but not exact,
because it is possible to run a full circle around $S^1$.
So the failure of $\alpha$ to be exact is signaling
that $H_1(S^1) \cong \ZZ$.

\section{Graded rings}
\prototype{Polynomial rings are commutative graded rings,
while $\Lambda^\bullet(V)$ is anticommutative.}
In the de Rham cohomology, the differential forms can interact in another way:
given a $k$-form $\alpha$ and an $\ell$-form $\beta$, we can consider
a $(k+\ell)$-form
\[ \alpha \wedge \beta. \]
So we can equip the set of forms with a ``product'', satisfying
$\beta \wedge \alpha = (-1)^{k\ell} \alpha \wedge \beta$
This is a special case of a more general structure:

\begin{definition}
	A \vocab{graded pseudo-ring} $R$ is an abelian group
	\[ R = \bigoplus_{d \ge 0} R^d \]
	where $R^0$, $R^1$, \dots, are abelian groups,
	with an additional associative binary operation $\times : R \to R$.
	We require that if $r \in R^d$ and $s \in R^e$, we have $rs \in R^{d+e}$.
	Elements of an $R^d$ are called \vocab{homogeneous elements};
	if $r \in R^d$ and $r \neq 0$, we write $|r| = d$.
\end{definition}
Note that we do \emph{not} assume commutativity.
In fact, these ``rings'' may not even have an identity $1$.
We use other words if there are additional properties:
\begin{definition}
	A \vocab{graded ring} is a graded pseudo-ring with $1$.
	If it is commutative we say it is a \vocab{commutative graded ring}.
\end{definition}
\begin{definition}
	A graded (pseudo-)ring $R$ is \vocab{anticommutative} if
	for any homogeneous $r$ and $s$ we have
	\[ rs = (-1)^{|r| |s|} sr. \]
\end{definition}

To summarize:
\begin{center}
	\small
	\begin{tabular}[h]{|c|cc|}
		\hline
		\textbf{Flavors of graded rings} &
		Need not have $1$ & Must have a $1$ \\ \hline
		No Assumption & graded pseudo-ring & graded ring \\
		Anticommutative & anticommutative pseudo-ring & anticommutative ring \\
		Commutative &  & commutative graded ring \\ \hline
	\end{tabular}
\end{center}

\begin{example}[Examples of graded rings]
	\listhack
	\begin{enumerate}[(a)]
		\ii The ring $R = \ZZ[x]$ is a \textbf{commutative graded ring},
		with the $d$th component being the multiples of $x^d$.
		\ii The ring $R = \ZZ[x,y,z]$ is a \textbf{commutative graded ring},
		with the $d$th component being the abelian group
		of homogeneous degree $d$ polynomials (and $0$).
		\ii Let $V$ be a vector space, and consider
		the abelian group
		\[ \Lambda^\bullet(V) = \bigoplus_{d \ge 0} \Lambda^d(V). \]
		For example, $e_1 + (e_2 \wedge e_3) \in \Lambda^\bullet(V)$, say.
		We endow $\Lambda^\bullet(V)$ with the product $\wedge$,
		which makes it into an \textbf{anticommutative ring}.
		\ii Consider the set of differential forms of a manifold $M$,
		say \[ \Omega^\bullet(M) = \bigoplus_{d \ge 0} \Omega^d(M) \]
		endowed with the product $\wedge$.
		This is an \textbf{anticommutative ring}.
	\end{enumerate}
	All four examples have a multiplicative identity.
\end{example}

Let's return to the situation of $\Omega^\bullet(M)$.
Consider again the de Rham cohomology groups $\HdR^k(M)$,
whose elements are closed forms modulo exact forms.
We claim that:
\begin{lemma}
	[Wedge product respects de Rham cohomology]
	The wedge product induces a map
	\[ \wedge : \HdR^k(M) \times \HdR^\ell(M) \to \HdR^{k+\ell}(M). \]
\end{lemma}
\begin{proof}
	First, we recall that the operator $d$ satisfies
	\[
		d(\alpha \wedge \beta)
		= (d\alpha) \wedge \beta + \alpha \wedge (d\beta).
	\]
	Now suppose $\alpha$ and $\beta$ are closed forms.
	Then from the above, $\alpha \wedge \beta$ is clearly closed.
	Also if $\alpha$ is closed and $\beta = d\omega$ is exact,
	then $\alpha \wedge \beta$ is exact, from the identity
	\[ d(\alpha \wedge \omega)
		= d\alpha \wedge\omega + \alpha \wedge d\omega = \alpha \wedge \beta. \]
	Similarly if $\alpha$ is exact and $\beta$ is closed
	then $\alpha \wedge \beta$ is exact.
	Thus it makes sense to take the product modulo exact forms,
	giving the theorem above.
\end{proof}

Therefore, we can obtain a \emph{anticommutative ring}
\[ \HdR^\bullet(M) = \bigoplus_{k \ge 0} \HdR^k(M) \]
with $\wedge$ as a product, and $1 \in \Lambda^0(\RR) = \RR$ as the identity

\section{Cup products}
Inspired by this, we want to see if we can construct a similar product
on $\bigoplus_{k \ge 0} H^k(X; R)$ for any topological space $X$ and ring $R$
(where $R$ is commutative with $1$ as always).
The way to do this is via the \emph{cup product}.

Then this gives us a way to multiply two cochains, as follows.
\begin{definition}
	Suppose $\phi \in C^k(X;R)$ and $\psi \in C^\ell(X;R)$.
	Then we can define their \vocab{cup product}
	$\phi\smile\psi \in C^{k+\ell}(X;R)$ to be
	\[
		(\phi\smile\psi)([v_0, \dots, v_{k+\ell}])
		=
		\phi\left( [v_0, \dots, v_k] \right)
		\cdot
		\psi\left( [v_k, \dots, v_{k+\ell}] \right)
	\]
	where the multiplication is in $R$.
\end{definition}

\begin{ques}
	Assuming $R$ has a $1$, which $0$-cochain is the identity for $\smile$?
\end{ques}

First, we prove an analogous result as before:
\begin{lemma}[$\delta$ with cup products]
	We have
	$\delta(\phi\smile\psi) = \delta\phi\smile\psi
	+ (-1)^k\phi\smile\delta\psi$.
\end{lemma}
\begin{proof}
	Direct $\sum$ computations.
\end{proof}
Thus, by the same routine we used for de Rham cohomology, we get
an induced map
\[ \smile : H^k(X;R) \times H^\ell(X;R) \to H^{k+\ell}(X;R).  \]
We then define the \vocab{singular cohomology ring}
whose elements are finite sums in
\[ H^\bullet(X;R) = \bigoplus_{k \ge 0} H^k(X;R) \]
and with multiplication given by $\smile$.
Thus it is a graded ring (with $1_R \in R$ the identity)
and is in fact anticommutative:
\begin{proposition}[Cohomology is anticommutative]
	$H^\bullet(X; R)$ is an anticommutative ring,
	meaning $\phi \smile \psi = (-1)^{k\ell} \psi \smile \phi$.
\end{proposition}
For a proof, see \cite[Theorem 3.11, pages 210-212]{ref:hatcher}.
Moreover, we have the de Rham isomorphism
\begin{theorem}
	[de Rham extends to ring isomorphism]
	For any smooth manifold $M$, the isomorphism
	of de Rham cohomology groups to singular cohomology
	groups in facts gives an isomorphism
	\[ H^\bullet(M; \RR) \cong \HdR^\bullet(M) \]
	of anticommutative rings.
\end{theorem}

Therefore, if ``differential forms'' are the way to visualize
the elements of a cohomology group, the wedge product is the
correct way to visualize the cup product.

We now present (mostly without proof)
the cohomology rings of some common spaces.

\begin{example}
	[Cohomology of torus]
	The cohomology ring $H^\bullet(S^1 \times S^1; \ZZ)$
	of the torus is generated by elements $|\alpha| = |\beta| = 1$
	which satisfy the relations
	$\alpha \smile \alpha = \beta \smile \beta = 0$,
	and $\alpha \smile \beta = -\beta \smile \alpha$.
	(It also includes an identity $1$.)
	Thus as a $\ZZ$-module it is
	\[ H^\bullet(S^1 \times S^1; \ZZ)
		\cong \ZZ \oplus \left[ \alpha \ZZ \oplus \beta \ZZ \right]
		\oplus (\alpha \smile \beta) \ZZ. \]
	This gives the expected dimensions $1+2+1=4$.
	It is anti-commutative.
\end{example}

\begin{example}[Cohomology ring of $S^n$]
	Consider $S^n$ for $n \ge 1$.
	The nontrivial cohomology groups are given by
	$H^0(S^n; \ZZ) \cong H^n(S^n; \ZZ) \cong \ZZ$.
	So as an abelian group
	\[ H^\bullet(S^n; \ZZ) \cong \ZZ \oplus \alpha \ZZ \]
	where $\alpha$ is the generator of $H^n(S^n, \ZZ)$.

	Now, observe that $|\alpha\smile\alpha| = 2n$, but
	since $H^{2n}(S^n; \ZZ) = 0$ we must have $\alpha\smile\alpha=0$.
	So even more succinctly,
	\[ H^\bullet(S^n; \ZZ) \cong \ZZ[\alpha]/(\alpha^2). \]
	Confusingly enough, this graded ring is both
	commutative \emph{and} anti-commutative.
	The reason is that $\alpha \smile \alpha = 0 = -(\alpha \smile \alpha)$.
\end{example}

\begin{example}[Cohmology ring of real and complex projective space]
	It turns out that
	\begin{align*}
		H^\bullet(\RP^n; \Zc2) &\cong \Zc2[\alpha]/(\alpha^{n+1}) \\
		H^\bullet(\CP^n; \ZZ) &\cong \ZZ[\beta]/(\beta^{n+1})
	\end{align*}
	where $|\alpha| = 1$ is a generator of $H^1(\RP^n; \Zc2)$
	and $|\beta| = 2$ is a generator of $H^2(\CP^n; \ZZ)$.

	Confusingly enough, both graded rings are commutative \emph{and} anti-commutative.
	In the first case it is because we work in $\Zc 2$, for which $1 = -1$,
	so anticommutative is actually equivalent to commutative.
	In the second case, all nonzero homogeneous elements have degree $2$.
\end{example}

\section{Relative cohomology pseudo-rings}
For $A \subseteq X$, one can also define a relative cup product
\[ H^k(X,A;R) \times H^\ell(X,A;R) \to H^{k+\ell}(X,A;R). \]
After all, if either cochain vanishes on chains in $A$,
then so does their cup product.
This lets us define \vocab{relative cohomology pseudo-ring}
and \vocab{reduced cohomology pseudo-ring} (by $A = \{\ast\}$), say
\begin{align*}
H^\bullet(X,A;R) &= \bigoplus_{k \ge 0} H^k(X,A; R) \\
\wt H^\bullet(X;R) &= \bigoplus_{k \ge 0} \wt H^k(X;R).
\end{align*}
These are both \textbf{anticommutative pseudo-rings}.
Indeed, often we have $\wt H^0(X;R) = 0$ and thus there is no identity at all.

Once again we have functoriality:
\begin{theorem}
	[Cohomology (pseudo-)rings are functorial]
	Fix a ring $R$ (commutative with $1$).
	Then we have functors
	\begin{align*}
		H^\bullet(-; R) &: \catname{hTop}\op \to \catname{GradedRings} \\
		H^\bullet(-,-; R) &: \catname{hPairTop}\op \to \catname{GradedPseudoRings}.
	\end{align*}
\end{theorem}

Unfortunately, unlike with (co)homology groups,
it is a nontrivial task to determine the cup product
for even nice spaces like CW complexes.
So we will not do much in the way of computation.
However, there is a little progress we can make.

\section{Wedge sums}
Our goal is to now compute $\wt H^\bullet(X \vee Y)$.
To do this, we need to define the product of two graded pseudo-rings:
\begin{definition}
	Let $R$ and $S$ be two graded pseudo-rings.
	The \vocab{product pseudo-ring} $R \times S$ is the graded pseudo-ring
	defined by taking the underlying abelian group as
	\[ R \oplus S = \bigoplus_{d \ge 0} (R^d \oplus S^d). \]
	Multiplication comes from $R$ and $S$, followed by
	declaring $r \cdot s = 0$ for $r \in R$, $s \in S$.
\end{definition}
Note that this is just graded version of the product ring
defined in \Cref{ex:product_ring}.
\begin{exercise}
	Show that if $R$ and $S$ are graded rings (meaning they have $1_R$ and $1_S$),
	then so is $R \times S$.
\end{exercise}

Now, the theorem is that:
\begin{theorem}
	[Cohomology pseudo-rings of wedge sums]
	We have
	\[
		\wt H^\bullet(X \wedge Y; R)
		\cong \wt H^\bullet(X;R)
		\times \wt H^\bullet(Y;R)
	\]
	as graded pseudo-rings.
\end{theorem}

This allows us to resolve the first question posed at the beginning.
Let $X = \CP^2$ and $Y = S^2 \vee S^4$.
We have that
\[ H^\bullet(\CP^2; \ZZ) \cong \ZZ[\alpha] / (\alpha^3). \]
Hence this is a graded ring generated by there elements:
\begin{itemize}
	\ii $1$, in dimension $0$.
	\ii $\alpha$, in dimension $2$.
	\ii $\alpha^2$, in dimension $4$.
\end{itemize}
Next, consider the reduced cohomology pseudo-ring
\[ \wt H^\bullet(S^2 \vee S^4; \ZZ) \cong
	\wt H^\bullet(S^2; \ZZ)
	\oplus \wt H^\bullet(S^4 ; \ZZ).
\]
Thus the absolute cohomology ring $H^\bullet(S^2 \vee S^4 \; \ZZ)$
is a graded ring also generated by three elements.
\begin{itemize}
	\ii $1$, in dimension $0$ (once we add back in the $0$th dimension).
	\ii $a_2$, in dimension $2$ (from $H^\bullet(S^2 ; \ZZ)$).
	\ii $a_4$, in dimension $4$ (from $H^\bullet(S^4 ; \ZZ)$).
\end{itemize}
Each graded component is isomorphic, like we expected.
However, in the former, the product of two degree $2$ generators is
\[ \alpha \cdot \alpha = \alpha^2. \]
In the latter, the product of two degree $2$ generators is
\[ a_2 \cdot a_2 = a_2^2 = 0 \]
since $a_2 \smile a_2 = 0 \in H^\bullet(S^2; \ZZ)$.

Thus $S^2 \vee S^4$ and $\CP^2$ are not homotopy equivalent.

\section{K\"unneth formula}
We now wish to tell apart the spaces $S^2 \times S^4$ and $\CP^3$.
In order to do this, we will need a formula
for $H^n(X \times Y; R)$ in terms of $H^n(X;R)$ and $H^n(Y;R)$.
Thus formulas are called \vocab{K\"unneth formulas}.
In this section we will only use a very special case,
which involves the tensor product of two graded rings.

\begin{definition}
	Let $A$ and $B$ be two graded rings which are also $R$-modules
	(where $R$ is a commutative ring with $1$).
	We define the \vocab{tensor product} $A \otimes_R B$ as follows.
	As an abelian group, it is
	\[ A \otimes_R B = \bigoplus_{d \ge 0}
		\left( \bigoplus_{k=0}^{d} A^k \otimes_R B^{d-k}  \right). \]
	The multiplication is given on basis elements by
	\[ \left( a_1 \otimes b_1 \right)\left( a_2 \otimes b_2 \right)
		= (a_1a_2) \otimes (b_1b_2).
	\]
	Of course the multiplicative identity is $1_A \otimes 1_B$.
\end{definition}

Now let $X$ and $Y$ be topological spaces, and take the product:
we have a diagram
\begin{diagram}
	&& X \times Y && \\
	X &\ldTo(2,1)^{\pi_X} && \rdTo(2,1)^{\pi_Y} & Y \\
\end{diagram}
where $\pi_X$ and $\pi_Y$ are projections.
As $H^k(-; R)$ is functorial, this gives induced maps
\begin{align*}
	\pi_X^\ast &: H^k(X \times Y; R) \to H^k(X; R) \\
	\pi_Y^\ast &: H^k(X \times Y; R) \to H^k(Y; R)
\end{align*}
for every $k$.

By using this, we can define a so-called cross product.
\begin{definition}
	Let $R$ be a ring, and $X$ and $Y$ spaces.
	Let $\pi_X$ and $\pi_Y$ be the projections of $X \times Y$
	onto $X$ and $Y$.
	Then the \vocab{cross product} is the map
	\[
		H^\bullet(X; R) \otimes_R H^\bullet(Y;R)
		\taking{\times} H^\bullet(X \times Y; R)
	\]
	acting on cocycles as follows:
	$\phi \times \psi = \pi_X^\ast(\phi) \smile \pi_Y^\ast(\psi)$.
\end{definition}

This is just the most natural way to take a $k$-cycle
on $X$ and an $\ell$-cycle on $Y$, and create a $(k+\ell)$-cycle
on the product space $X \times Y$.

\begin{theorem}
	[K\"unneth formula]
	Let $X$ and $Y$ be CW complexes such that $H^k(Y;R)$
	is a finitely generated free $R$-module for every $k$.
	Then the cross product is an isomorphism of anticommutative rings
	\[
		H^\bullet(X;R) \otimes_R H^\bullet(Y;R)
		\to H^\bullet(X \times Y; R).
	\]
\end{theorem}

In any case, this finally lets us resolve the question
set out at the beginning.
We saw that $H_n(\CP^3) \cong H_n(S^2 \times S^4)$ for every $n$,
and thus it follows that $H^n(\CP^3; \ZZ) \cong H^n(S^2 \times S^4; \ZZ)$ too.

But now let us look at the cohomology rings. First, we have
\[ H^\bullet(\CP^3; \ZZ) \cong \ZZ[\alpha] / (\alpha^3)
	\cong \ZZ \oplus \alpha\ZZ \oplus \alpha^2\ZZ \oplus \alpha^3\ZZ
\]
where $|\alpha| = 2$; hence this is a graded ring generated by
\begin{itemize}
	\ii $1$, in degree $0$.
	\ii $\alpha$, in degree $2$.
	\ii $\alpha^2$, in degree $4$.
	\ii $\alpha^3$, in degree $6$.
\end{itemize}

Now let's analyze
\[ H^\bullet(S^2 \times S^4; \ZZ) \cong
	\ZZ[\beta] / (\beta^2)
	\otimes
	\ZZ[\gamma] / (\gamma^2).
\]
It is thus generated thus by the following elements:
\begin{itemize}
	\ii $1 \otimes 1$, in degree $0$.
	\ii $\beta \otimes 1$, in degree $2$.
	\ii $1 \otimes \gamma$, in degree $4$.
	\ii $\beta \otimes \gamma$, in degree $6$.
\end{itemize}
Again in each dimension we have the same abelian group.
But notice that if we square $\beta \otimes 1$ we get
\[ (\beta \otimes 1)(\beta \otimes 1) = \beta^2 \otimes 1 = 0. \]
Yet the degree $2$ generator of $H^\bullet(\CP^3; \ZZ)$
does not have this property.
Hence these two graded rings are not isomorphic.

So it follows that $\CP^3$ and $S^2 \times S^4$ are not homotopy equivalent.

% Borsuk Ulam

\section\problemhead

\begin{dproblem}
	[Symmetry of Betti numbers by Poincar\'e duality]
	\label{prob:betti}
	Let $M$ be a smooth oriented compact $n$-manifold,
	and let $b_k$ denote its Betti number.
	Prove that $b_k = b_{n-k}$.
	\begin{hint}
		Write $H^k(M; \ZZ)$ in terms of $H_k(M)$
		using the UCT, and analyze the ranks.
	\end{hint}
\end{dproblem}

\begin{problem}
	Show that $\RP^n$ is not orientable for even $n$.
	\begin{hint}
		Use the previous result on Betti numbers.
	\end{hint}
\end{problem}

\begin{problem}
	Show that $\RP^3$ is not homotopy equivalent to $\RP^2 \vee S^3$.
	\begin{hint}
		Use the $\Zc2$ cohomologies, and find the cup product.
	\end{hint}
\end{problem}

\begin{problem}
	\gim
	Show that $S^m \vee S^n$ is not a deformation retract
	of $S^m \times S^n$ for any $m,n \ge 1$.
	\begin{hint}
		Assume that $r : S^m \times S^n \to S^m \vee S^n$ is such a map.
		Show that the induced map
		$H^\bullet(S^m \vee S^n; \ZZ) \to H^\bullet(S^m \times S^n; \ZZ)$
		between their cohomology rings is monic
		(since there exists an inverse map $i$).
	\end{hint}
	\begin{sol}
		See \cite[Example 3.3.14, pages 68-69]{ref:maxim752}.
	\end{sol}
\end{problem}


\documentclass[11pt]{article}
\usepackage{mathptmx}
\usepackage[small,compact]{titlesec}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\usepackage{url}
\usepackage{hyperref}
\usepackage{breakurl}
\geometry{letterpaper}                   % ... or a4paper or a5paper or ...
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb, amsmath}
\usepackage{epstopdf}

\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\title{Implicit Springs}
\author{Miles Macklin}
%\date{}                                           % Activate to display a given date or no date

\begin{document}
\maketitle

\section{Implicit Integration}
The backward Euler integration method described in [1][2] requires the Jacobian of spring forces with respect to a particle's position and velocity. This document shows how to derive these Jacobians for use in a semi-implicit integrator.

\subsection{Vector Calculus Basics}

\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}} % for vectors
\newcommand{\uv}[1]{\ensuremath{\mathbf{\hat{#1}}}} % for unit vectors
\newcommand\ddx[1]{\frac{\partial#1}{\partial \v{x} }}
\newcommand\dd[2]{\frac{\partial#1}{\partial #2}}

In order to calculate the force Jacobians we will need to know how to calculate the derivatives of some basic quantities with respect to a vector.

In general the derivative of a scalar valued function with respect to a vector is defined as:

\[\ddx{f} = \begin{bmatrix} \dd{f}{x_i} & \dd{f}{x_j} & \dd{f}{x_k} \end{bmatrix}\]

And for a vector valued function with respect to a vector:

\[\ddx{\v{f}} = \begin{bmatrix} \dd{f_i}{x_i} & \dd{f_i}{x_j} & \dd{f_i}{x_k} \\ \dd{f_j}{x_i} & \dd{f_j}{x_j} & \dd{f_j}{x_k} \\ \dd{f_k}{x_i} & \dd{f_k}{x_j} & \dd{f_k}{x_k} \end{bmatrix}\]

From these definitions we can work out the derivative of some basic geometric quantities. First, the derivative of a dot product of two vectors with respect to one vector:

\[\ddx{\v{x}^T \cdot \v{y}} = \v{y}^T \]

We will explicitly keep track of whether vectors are row vectors or column vectors as it will be important when taking derivatives of spring forces.

The derivative of a vector magnitude with respect to the vector, gives the normalized vector transposed:

\[\ddx{|\v{x}|} = \left(\frac{\v{x}}{|\v{x}|}\right)^T = \uv{x}^T \]

The derivative of a normalized vector $\v{\hat{x}} = \frac{\v{x}}{|\v{x}|} $ can be obtained using the quotient rule:

\[\ddx{\uv{x}} = \frac{\v{I}|\v{x}| - \v{x}\cdot\uv{x}^T}{|\v{x}|^2}\]

Where $\v{I}$ is the $n$ x $n$ identity matrix where n is dimension of $x$, and the product of a column vector and a row vector $\uv{x}\cdot\uv{x}^T$ is the outer product which is an $n$ x $n$ matrix that can be constructed using standard matrix multiplication definition.

Dividing through by $|\v{x}|$ we have:

\[\ddx{\uv{x}} = \frac{\v{I} - \uv{x}\cdot\uv{x}^T}{\v{|x|}}\]

\subsection{Jacobian of Stretch Force}

Recall the equation for the stretch force on a particle $i$ due to an undamped Hookean spring:

\[\v{F_s} = -k_s(|\v{x}_{ij}| - r)\uv{x}_{ij}\]

Where $\v{x}_{ij} = \v{x}_i - \v{x}_j$ is the vector between the two connected particles positions and $r$ is the rest length.

The Jacobian of the stretch force with respect to particle $i$'s position is obtained by using the product rule for the two $\v{x}_i$ dependent terms in $\v{F_s}$:

\[\dd{\v{F_s}}{\v{x}_i} = -ks\left[(|\v{x}_{ij}| - r)\dd{\uv{x}_{ij}}{\v{x}_i} + \uv{x}_{ij}\dd{(|\v{x}_{ij}| - r)}{\v{x}_i}\right]\]

Using the previously derived formulas for the derivative of a vector magnitude and normalized vector we have:

\[\dd{\v{F_s}}{\v{x}_i} = -ks\left[(|\v{x}_{ij}| - r)\left(\frac{\v{I} - \uv{x}_{ij}\cdot \uv{x}_{ij}^T}{|\v{x}_{ij}|}\right) + \uv{x}_{ij}\cdot \uv{x}_{ij}^T\right]\]

Dividing the first two terms through by $|\v{x}_{ij}|$:

\[\dd{\v{F_s}}{\v{x}_i} = -ks\left[(1 - \frac{r}{|\v{x}_{ij}|})\left(\v{I} - \uv{x}_{ij}\cdot \uv{x}_{ij}^T\right) + \uv{x}_{ij}\cdot \uv{x}_{ij}^T\right]\]

Due to the symmetry in the definition of $\v{x}_{ij}$ we have:

\[\dd{\v{F_s}}{\v{x}_j}  = -\dd{\v{F_s}}{\v{x}_i}\]

\subsection{Jacobian of Damping Force}

The equation for the damping force on a particle $i$ due to a spring:

\[\v{F_d} = -k_d\cdot\uv{x}(\v{v}_{ij}\cdot \uv{x}_{ij})\]

Where $\v{v}_{ij} = \v{v}_i-\v{v}_j$ is the relative velocities of the two particles. This is the preferred formulation because it damps only velocities along the spring axis.

Taking the derivative with respect to $\v{v}_i$:

\[\dd{\v{F_d}}{\v{v}_i} = -k_d\cdot\uv{x}\cdot\uv{x}^T\]

As with stretching, the force on the opposite particle is simply negated:

\[\dd{\v{F_d}}{\v{v}_j} = -\dd{\v{F_d}}{\v{v}_i} \]

\section {References}

\begin{itemize}
\item{[Baraff Witkin] - Physically Based Modelling, SIGGRAPH course - \url{http://www.pixar.com/companyinfo/research/pbm2001/}}
\item{[Baraff Witkin] - Large Steps in Cloth Simulation - \url{http://run.usc.edu/cs599-s10/cloth/baraff-witkin98.pdf}}
\item{[N. Joubert] - An Introduction to Simulation (\url{http://njoubert.com/teaching/cs184_sp09/section/simulation.pdf})}
\item{[D Prichard] - Implementing Baraff and Witkin's Cloth Simulation - \url{http://davidpritchard.org/freecloth/docs/report.pdf}}
\item{[Choi] - Stable but Responsive Cloth - \url{http://graphics.snu.ac.kr/~kjchoi/publication/cloth.pdf}}
\item{Numerical Recipes, 3rd edition 2007 - ch17.5}
\end{itemize}
\end{document}


\documentclass[twoside]{MATH77}
\usepackage[\graphtype]{mfpic}
\usepackage{multicol}
\usepackage[fleqn,reqno,centertags]{amsmath}
\begin{document}
\opengraphsfile{pl02-16}
\begmath 2.16 Complex Error Function $w(z)$

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

\subsection{Purpose}

Compute the Fadeeva function $w(z)$, defined by Equation~7.1.3 in \cite{ams55}:%
\begin{equation}\label{w_def}
w(z)=e^{-z^2}\left[ 1+\frac{2i}{\sqrt{\pi }}\int_0^ze^{t^2}dt\right] .
\end{equation}
The Fadeeva function is related to the error function by%
\begin{equation*}
w(z)=e^{-z^2}\erfc (-iz),
\end{equation*}
to Dawson's integral%
\begin{equation*}
F(z)=e^{-z^2}\int_0^ze^{t^2}dt,\text{ by}\quad \frac{2i}{\sqrt{\pi }}%
F(z)=w(z)-e^{-z^2},
\end{equation*}
to the Fresnel integrals%
\begin{equation*}
\hspace{-10pt}C(z)=\int_0^z\cos \left( \frac \pi 2t^2\right) dt,\ \text{and}\ \
S(z)=\int_0^z\sin \left( \frac \pi 2t^2\right) dt,
\end{equation*}
by
\begin{equation*}
C(z)+iS(z)=\frac{1+i}2\left[ 1- e^{i \pi z^2 / 2}w\left( \frac{\sqrt{\pi
}}2(1+i)z\right) \right] ,
\end{equation*}
and to the Voigt functions $V(x,y)$ and $L(x,y)$ (used in spectroscopy and
astronomy --- see \cite{Penner:1959:QMS}) by $V(x,y)=\Re w(z)$ and
$L(x,y)=\Im w(z)$, where $z=x+iy.$

\subsection{Usage}

\subsubsection{Program Prototype, Single Precision}

\begin{description}
\item[COMPLEX]  \ {\bf Z, W}

\item[INTEGER]  \ {\bf IFLAG}
\end{description}

$$
\fbox{{\bf CALL CWOFZ (Z, W, IFLAG)}}
$$

\subsubsection{Argument Definitions}

\begin{description}
\item[Z]  \ [in] Argument at which the function is to be evaluated.

\item[W]  \ [out] Value of $w(z)$, where $z$ is given by the argument Z.

\item[IFLAG]  \ [out] A flag indicating success or failure of the
computation:

\begin{itemize}
\item[0]  means $w(z)$ was successfully calculated,

\item[$+1$]  means $w(z)$ was not successfully calculated because it would
have no significant digits.

\item[$-1$]  means $w(z)$ was not successfully calculated because it would
overflow.
\end{itemize}

See Section E, Error Procedures and Restrictions, for a discussion of values
of Z that result in nonzero values of IFLAG. If IFLAG is nonzero, the real
and imaginary parts of W are set to the largest representable number.
\end{description}

\subsubsection{Modifications for Double Precision}

Change the subprogram name to ZWOFZ. On computers that support a double
precision complex data type, frequently spelled COMPLEX*16, and on which
double precision complex is represented by an array of two double precision
numbers, with the first being the real part, and the second being the
imaginary part, change the type declarations of Z and W so that Z and W are
declared to be of type double precision complex. On machines that do not
support double precision complex, change the declarations of Z and W to

{\bf DOUBLE PRECISION \ Z(2), W(2)}

In the latter case, put the real part of $z$ into Z(1), and the imaginary
part of $z$ into Z(2), and find the real and imaginary parts of $w(z)$ in
W(1) and W(2), respectively.

\subsection{Examples and Remarks}

See DRCWOFZ and ODCWOFZ for an example of the usage of this subprogram.

\subsection{Functional Description}

From Eq.~\eqref{w_def} it is clear that $w(z)$ is analytic in the entire
plane.  In the upper half-plane, $0 \leq |w(z)| < 1$, which may have been
the original reason to consider $w(z)$ to be a generalization of erfc.

$w(z)$ satisfies the differential equation $w^{\prime}(z) + 2zw(z) = 2i/%
\sqrt{\pi }$.  Since $w(z)$ is analytic it satisfies the Cauchy-Riemann
conditions.  If we let $w(z) = u(z) + iv(z)$, and $z = x + iy$, where $u$,
$v$, $x$ and $y$ are real, the Cauchy-Riemann conditions, together with
the differential equation, give us $u_x = 2yv - 2xu \text{ and } u_y = 2xv
+ 2yu - 2\pi ^{1/2} $.  In some applications, particularly related to
spectroscopy, one needs $V(x,y)$, $L(x,y)$, $V_x(x,y)$ and $V_y(x,y)$.  We
have already, above, identified $V(x,y)$ as $u(z)$ and $L(x,y)$ as $v(z)$.
Thus, one can compute these four functions by computing $w(z)$ alone.

These subprograms are based on a subprogram by G. P. M. Poppe and C. M. J.
Wijers described in \cite{Poppe:1990:MEC} and \cite{Poppe:1990:AEC}. The subprogram by Poppe and
Wijers was modified to work in either single or double precision, and some
tests of argument range were changed to be invoked only when necessary.
Machine characteristics are discovered, and errors are processed, using
MATH77 conventions. The subprogram name was changed to conform to
MATH77 naming conventions.

The algorithm uses three different methods. Inside the ellipse $%
(x/6.3)^2+(y/4.4)^2\leq .292^2$ the algorithm uses the series approximation
given by Equation~7.1.6 in \cite{ams55}. In the elliptic annulus $%
.292^2<(x/6.3)^2+(y/4.4)^2\leq 1.0$ the algorithm uses a Taylor series, with
derivatives calculated by the Laplace continued fraction. Outside the latter
ellipse, a Laplace continued fraction is used.
% \input prepic.tex
% \input pictex.tex
% \input postpic.tex
% \beginpicture \ninepoint
% \setcoordinatesystem units <   .786in,   .864in>
% \setplotarea x from    .000 to   3.500, y from  -2.500 to   3.000
% \axis left label {$\Im z$\hspace{-6pt}} ticks in numbered from -2.5 to
% 3.0 by .5 /
% \axis right ticks in quantity 12 /
% \axis top ticks in quantity 8 /
% \axis bottom label {} ticks in withvalues 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 / at 0 .5 1 1.5 2 2.5 3 3.5 / /
% \put {$0.2$} at   1.080  2.460
% \put {$0.3$} at    .750  1.500
% \put {$0.5$} at    .420   .700
% \put {$1$} at    .280  -.040
% \put {$2$} at    .250  -.550
% \put {$5$} at    .250 -1.010
% \put {$10$} at    .250 -1.300
% \put {$30$} at    .250 -1.670
% \put {$100$} at    .250 -2.000
% \put {$300$} at    .250 -2.260
% \put {$45$} at   1.100   .640
% \put {$90$} at   1.260  -.400
% \put {$135$} at   1.280  -.920
% \put {$180$} at   1.350 -1.200
% \put {$-90$} at   1.480 -1.600
% \put {$0$} at   1.640 -1.900
% \put {$90$} at   1.830 -2.120
% \put {$180$} at   2.050 -2.300
% \put {$-90$} at   2.290 -2.400
% \put {$0$} at   2.590 -2.400
% \put {$90$} at   2.840 -2.400
% \setsolid
% \setquadratic \plot
%   .1225 -2.2415   .1050 -2.2406   .0700 -2.2392   .0350 -2.2384
%   .0000 -2.2382
% /
% \setquadratic \plot
%   .1225 -1.9820   .0700 -1.9796   .0000 -1.9785
% /
% \setquadratic \plot
%   .1575 -1.6553   .0875 -1.6506   .0000 -1.6486
% /
% \setquadratic \plot
%   .1575 -1.2904   .0875 -1.2848   .0000 -1.2823
% /
% \setquadratic \plot
%   .1750 -1.0094   .0875 -1.0015   .0000  -.9989
% /
% \setquadratic \plot
%   .1750  -.5257   .1050  -.5190   .0000  -.5151
% /
% \setquadratic \plot
%   .3150  -.5498   .3850  -.5671   .4375  -.5826   .4900  -.6005
%   .5425  -.6203   .5775  -.6350   .6265  -.6575   .6650  -.6764
%   .7000  -.6950   .7350  -.7150   .7761  -.7400   .8183  -.7675
%   .8575  -.7949   .8925  -.8209   .9275  -.8485   .9622  -.8775
%    .9934  -.9050   1.0150  -.9247   1.0500  -.9585   1.0787  -.9875
%   1.1047 -1.0150   1.1375 -1.0509   1.1725 -1.0913   1.2004 -1.1250
%   1.2250 -1.1555
% /
% \setquadratic \plot
%   1.3271 -1.2900   1.3475 -1.3178   1.3825 -1.3652   1.4081 -1.4000
%   1.4350 -1.4355   1.4700 -1.4812   1.4930 -1.5100
% /
% \setquadratic \plot
%   1.6100 -1.6430   1.6416 -1.6750   1.6702 -1.7025   1.6999 -1.7300
%   1.7325 -1.7588   1.7675 -1.7886   1.8200 -1.8317   1.8550 -1.8599
%   1.8982 -1.8950   1.9318 -1.9225   1.9775 -1.9608   2.0125 -1.9916
%   2.0562 -2.0325   2.0842 -2.0600   2.1350 -2.1131   2.1616 -2.1425
%   2.2050 -2.1924   2.2324 -2.2250   2.2575 -2.2550   2.2784 -2.2800
%   2.3018 -2.3075
% /
% \setquadratic \plot
%   2.4150 -2.4307   2.4500 -2.4649   2.4877 -2.5000
% /
% \setquadratic \plot
%   2.5200 -2.4074   2.4850 -2.3730   2.4500 -2.3351   2.4274 -2.3075
%   2.3865 -2.2525   2.3625 -2.2169   2.3317 -2.1700   2.3100 -2.1361
%   2.2750 -2.0833   2.2400 -2.0343   2.2050 -1.9897   2.1695 -1.9500
%   2.1175 -1.8986   2.0825 -1.8683   2.0473 -1.8400   2.0110 -1.8125
%   1.9600 -1.7754   1.9075 -1.7378   1.8601 -1.7025   1.8200 -1.6702
%   1.7675 -1.6233   1.7369 -1.5925   1.7120 -1.5650   1.6800 -1.5253
%   1.6489 -1.4825   1.6275 -1.4492   1.5989 -1.4000   1.5750 -1.3536
%   1.5575 -1.3173   1.5334 -1.2625   1.5108 -1.2075   1.4998 -1.1800
%   1.4875 -1.1486
% /
% \setquadratic \plot
%   1.4675 -1.0975   1.4458 -1.0425   1.4175  -.9737
% /
% \setquadratic \plot
%   1.3469  -.8225   1.3174  -.7675   1.2852  -.7125   1.2600  -.6727
%   1.2250  -.6215   1.1904  -.5750   1.1686  -.5475   1.1375  -.5104
%   1.1025  -.4715   1.0850  -.4530   1.0500  -.4181   1.0150  -.3854
%   .9802  -.3550   .9625  -.3400   .9275  -.3122   .8925  -.2860
%   .8575  -.2614   .8326  -.2450   .8050  -.2273   .7700  -.2062
%   .7175  -.1770   .6891  -.1625   .6650  -.1505   .6314  -.1350
%   .5950  -.1190   .5663  -.1075   .5425  -.0981   .5075  -.0855
%   .4725  -.07376   .4025  -.05318   .3500  -.03987
% /
% \setquadratic \plot
%   .2100  -.01412   .1050  -.00344   .0000   .00006
% /
% \setquadratic \plot
%   .2800   .7484   .1400   .7640   .0000   .7691
% /
% \setquadratic \plot
%   .5600   .6844   .6257   .6625   .6825   .6415   .7350   .6201
%   .7875   .5967   .8225   .5799   .8759   .5525   .9256   .5250
%    .9717   .4975   1.0149   .4700   1.0555   .4425   1.0937   .4150
%   1.1298   .3875   1.1639   .3600   1.1964   .3325   1.2272   .3050
%   1.2600   .2742   1.2845   .2500   1.3125   .2210   1.3475   .1827
%   1.3825   .1415   1.4058   .1125   1.4350   .0740   1.4660   .0300
%   1.4875  -.0025   1.5182  -.0525   1.5488  -.1075   1.5630  -.1350
%   1.5890  -.1900   1.6009  -.2175   1.6227  -.2725   1.6417  -.3275
%   1.6581  -.3825   1.6720  -.4375   1.6834  -.4925   1.6924  -.5475
%   1.6991  -.6025   1.7063  -.7125   1.7071  -.7675   1.7063  -.8225
%   1.7043  -.8775   1.6998  -.9600   1.6968 -1.0150   1.6938 -1.0975
%   1.6935 -1.1250   1.6947 -1.1800   1.6975 -1.2190   1.7027 -1.2625
%   1.7135 -1.3175   1.7210 -1.3450   1.7413 -1.4000   1.7544 -1.4275
%   1.7850 -1.4775   1.8102 -1.5100   1.8375 -1.5391   1.8900 -1.5830
%   1.9425 -1.6175   1.9978 -1.6475   2.0825 -1.6886   2.1350 -1.7156
%   2.2022 -1.7575   2.2400 -1.7871   2.2923 -1.8400   2.3322 -1.8950
%   2.3753 -1.9775   2.3974 -2.0325   2.4178 -2.0875   2.4325 -2.1261
%   2.4502 -2.1700   2.4850 -2.2376   2.5353 -2.3075
% /
% \setquadratic \plot
%   2.6101 -2.3075   2.5809 -2.2800   2.5419 -2.2250   2.5290 -2.1975
%   2.5119 -2.1425   2.5026 -2.0875   2.5000 -2.0600   2.4966 -2.0050
%   2.4911 -1.9225   2.4850 -1.8779   2.4692 -1.8125   2.4458 -1.7575
%   2.4077 -1.7025   2.3625 -1.6614   2.3100 -1.6310   2.2575 -1.6118
%   2.1700 -1.5932   2.1000 -1.5816   2.0125 -1.5617   1.9522 -1.5375
%   1.8900 -1.4958   1.8725 -1.4793   1.8375 -1.4334   1.8201 -1.4000
%   1.8035 -1.3450   1.7995 -1.3175   1.7981 -1.2900   1.8020 -1.2350
%   1.8072 -1.2075   1.8200 -1.1616   1.8340 -1.1250   1.8465 -1.0975
%   1.8725 -1.0480   1.8900 -1.0187   1.9075  -.9913   1.9250  -.9650
%   1.9477  -.9325   1.9670  -.9050   1.9950  -.8643   2.0125  -.8387
%   2.0416  -.7950   2.0586  -.7675   2.0825  -.7256   2.1000  -.6927
%   2.1172  -.6575   2.1294  -.6300   2.1508  -.5750   2.1602  -.5475
%   2.1762  -.4925   2.1875  -.4433   2.1940  -.4100   2.2020  -.3550
%   2.2073  -.3000   2.2100  -.2450   2.2103  -.2175   2.2092  -.1625
%   2.2057  -.1075   2.2031  -.0800   2.1963  -.0250   2.1875   .0278
%   2.1818   .0575   2.1700   .1096   2.1623   .1400   2.1525   .1752
%   2.1380   .2225   2.1289   .2500   2.1089   .3050   2.0866   .3600
%   2.0650   .4088   2.0475   .4456   2.0211   .4975   1.9907   .5525
%   1.9578   .6075   1.9036   .6900   1.8375   .7796   1.7850   .8440
%   1.7264   .9100   1.6800   .9586   1.6275  1.0099   1.5867  1.0475
%   1.5230  1.1025   1.4700  1.1452   1.4172  1.1850   1.3650  1.2222
%   1.2966  1.2675   1.2425  1.3010   1.1725  1.3413   1.1043  1.3775
%   1.0325  1.4127    .9625  1.4441    .8750  1.4796
% /
% \setquadratic \plot
%   .6125  1.5633   .5425  1.5803   .4550  1.5983   .3500  1.6157
%   .2450  1.6284   .1225  1.6376   .0000  1.6407
% /
% \setquadratic \plot
%   .0000  2.6529   .1400  2.6499   .2800  2.6408   .4200  2.6258
%   .5425  2.6075   .6499  2.5875   .7729  2.5600   .8575  2.5382
%   .9450  2.5130
% /
% \setquadratic \plot
%   1.2075  2.4206   1.2950  2.3840   1.3914  2.3400   1.4875  2.2922
%   1.5750  2.2450   1.6483  2.2025   1.7325  2.1504   1.8025  2.1042
%   1.8900  2.0424   1.9600  1.9896   2.0371  1.9275   2.1013  1.8725
%   2.1875  1.7935   2.2575  1.7244   2.3275  1.6504   2.4212  1.5425
%   2.5076  1.4325   2.5725  1.3416   2.6388  1.2400   2.6775  1.1757
%   2.7300  1.0813   2.7615  1.0200   2.8000   .9390   2.8175   .8995
%   2.8475   .8275   2.8686   .7725   2.8875   .7197   2.9050   .6671
%   2.9225   .6100   2.9386   .5525   2.9526   .4975   2.9651   .4425
%   2.9813   .3600   2.9903   .3050   2.9979   .2500   3.0042   .1950
%   3.0090   .1400   3.0109   .1125   3.0136   .0575   3.0148   .0025
%   3.0149  -.0250   3.0139  -.0800   3.0115  -.1350   3.0097  -.1625
%   3.0049  -.2175   2.9985  -.2725   2.9905  -.3275   2.9808  -.3825
%   2.9693  -.4375   2.9575  -.4865   2.9487  -.5200   2.9400  -.5501
%   2.9225  -.6057   2.9043  -.6575   2.8827  -.7125   2.8525  -.7809
%   2.8175  -.8507   2.7871  -.9050   2.7530  -.9600   2.7300  -.9945
%   2.6950 -1.0425   2.6775 -1.0651   2.6502 -1.0975   2.6253 -1.1250
%   2.6075 -1.1436   2.5900 -1.1592   2.5395 -1.1800   2.5368 -1.1800
%   2.5025 -1.1697   2.4738 -1.1525   2.4500 -1.1405   2.4221 -1.1250
%   2.3800 -1.1065   2.3450 -1.0932   2.2925 -1.0783   2.2050 -1.0660
%   2.1175 -1.0704   2.0650 -1.0818   2.0125 -1.1016   1.9775 -1.1206
%   1.9425 -1.1459   1.9250 -1.1618   1.8900 -1.2044   1.8556 -1.2900
%   1.8529 -1.3175   1.8550 -1.3500   1.8696 -1.4000   1.8856 -1.4275
%   1.9075 -1.4528   1.9489 -1.4825   2.0125 -1.5039   2.1000 -1.5042
%   2.1875 -1.4811   2.2400 -1.4581   2.2750 -1.4393   2.2969 -1.4275
%   2.3275 -1.4078   2.3625 -1.3843   2.3975 -1.3593   2.4184 -1.3450
%   2.4500 -1.3204   2.4675 -1.3064   2.5025 -1.2817   2.5550 -1.2687
%   2.5900 -1.2935   2.6103 -1.3175   2.6425 -1.3656   2.6597 -1.4000
%   2.6775 -1.4446   2.6995 -1.5375   2.7039 -1.5925   2.7021 -1.6475
%   2.6950 -1.6971   2.6882 -1.7300   2.6717 -1.7850   2.6600 -1.8159
%   2.6425 -1.8578   2.6264 -1.8950   2.6142 -1.9225   2.6022 -1.9500
%   2.5807 -2.0050   2.5651 -2.0600   2.5582 -2.1150   2.5630 -2.1700
%   2.5840 -2.2250   2.6035 -2.2525   2.6337 -2.2800   2.6775 -2.3041
%   2.7125 -2.3149
% /
% \setquadratic \plot
%   2.7125 -2.3640   2.6950 -2.3568   2.6600 -2.3402
% /
% \setquadratic \plot
%   2.6600 -2.4085   2.6775 -2.4194   2.7125 -2.4397
% /
% \setquadratic \plot
%   2.9750 -2.3417   3.0176 -2.3625   3.0625 -2.4036   3.0871 -2.4450
%   3.1036 -2.5000
% /
% \setquadratic \plot
%   2.1525 -2.4999   2.1175 -2.4686   2.0650 -2.4221   2.0475 -2.4065
%   2.0282 -2.3900
% /
% \setquadratic \plot
%   1.9250 -2.3011   1.8725 -2.2575   1.8323 -2.2250
% /
% \setquadratic \plot
%   1.7325 -2.1461   1.6975 -2.1191   1.6625 -2.0923   1.6275 -2.0657
%   1.5832 -2.0325   1.5467 -2.0050   1.5050 -1.9735   1.4700 -1.9473
%   1.4175 -1.9075   1.3825 -1.8813   1.3300 -1.8422   1.2950 -1.8160
%   1.2600 -1.7899   1.2250 -1.7641   1.1900 -1.7386   1.1550 -1.7133
%   1.1025 -1.6766   1.0675 -1.6524   1.0325 -1.6288    .9975 -1.6059
%   .9450 -1.5728   .9100 -1.5516   .8575 -1.5212   .8225 -1.5019
%   .7852 -1.4825   .7350 -1.4573   .6825 -1.4328   .6300 -1.4102
%   .5775 -1.3895   .5250 -1.3709   .4550 -1.3486   .4200 -1.3387
%   .3500 -1.3214
% /
% \setquadratic \plot
%   .3150 -1.0326   .3566 -1.0425   .4200 -1.0592   .4725 -1.0756
%   .5339 -1.0975   .5775 -1.1144   .6300 -1.1370   .6650 -1.1535
%   .7176 -1.1800   .7682 -1.2075   .8151 -1.2350   .8575 -1.2613
%   .8925 -1.2841   .9275 -1.3080   .9625 -1.3330   .9975 -1.3589
%   1.0500 -1.4000   1.0841 -1.4275   1.1200 -1.4572   1.1550 -1.4868
%   1.1900 -1.5170   1.2250 -1.5478   1.2600 -1.5789   1.3055 -1.6200
%   1.3475 -1.6574
% /
% \setquadratic \plot
%   1.3977 -1.7025   1.4289 -1.7300   1.4604 -1.7575   1.4923 -1.7850
%   1.5245 -1.8125   1.5572 -1.8400   1.5750 -1.8544
% /
% \setquadratic \plot
%   1.7150 -1.9682   1.7500 -1.9963   1.7945 -2.0325
% /
% \setquadratic \plot
%   1.9250 -2.1418   1.9572 -2.1700   1.9878 -2.1975
% /
% \setquadratic \plot
%   1.8834 -2.5000   1.8470 -2.4725   1.8025 -2.4391   1.7675 -2.4135
%   1.7150 -2.3753   1.6800 -2.3504   1.6450 -2.3259   1.6100 -2.3017
%   1.5575 -2.2657   1.5225 -2.2421   1.4875 -2.2190   1.4350 -2.1843
%   1.3825 -2.1505   1.3475 -2.1282   1.2950 -2.0953   1.2600 -2.0737
%   1.2075 -2.0419   1.1725 -2.0211   1.1200 -1.9905   1.0850 -1.9708
%   1.0325 -1.9418    .9959 -1.9225    .9450 -1.8961    .9100 -1.8783
%   .8575 -1.8531   .8225 -1.8373   .7655 -1.8125   .7175 -1.7925
%   .6650 -1.7723   .6229 -1.7575   .5600 -1.7364   .5075 -1.7207
%   .4378 -1.7025   .4025 -1.6938   .3500 -1.6828
% /
% \setquadratic \plot
%   .3850 -2.0145   .4550 -2.0291   .5250 -2.0455   .5775 -2.0600
%   .6300 -2.0748   .6825 -2.0915   .7506 -2.1150   .8050 -2.1346
%   .8575 -2.1550   .8933 -2.1700   .9578 -2.1975   .9975 -2.2148
%   1.0500 -2.2390   1.0850 -2.2560   1.1375 -2.2819   1.1900 -2.3086
%   1.2425 -2.3361   1.2950 -2.3644   1.3475 -2.3934   1.3897 -2.4175
%   1.4372 -2.4450   1.4837 -2.4725   1.5293 -2.5000
% /
% \setquadratic \plot
%   1.1130 -2.5000   1.0675 -2.4797   1.0150 -2.4574    .9625 -2.4362
%   .9100 -2.4163   .8575 -2.3967   .8050 -2.3782   .7525 -2.3614
%   .6651 -2.3350   .5950 -2.3156   .5250 -2.2986   .4550 -2.2839
%   .3850 -2.2708
% /
% \setquadratic \plot
%   1.9189 -1.3725   1.9334 -1.4000   1.9600 -1.4231   1.9950 -1.4345
%   2.0437 -1.4275   2.0977 -1.3725   2.1035 -1.3450   2.1000 -1.3161
%   2.0650 -1.2678   2.0300 -1.2529   1.9672 -1.2625   1.9195 -1.3175
%   1.9189 -1.3725
% /
% \setquadratic \plot
%   2.6238 -2.1975   2.6414 -2.2250   2.6775 -2.2483   2.7125 -2.2539
%   2.7475 -2.2466   2.7825 -2.2261   2.8065 -2.1975   2.8175 -2.1662
%   2.8197 -2.1425   2.8135 -2.1150   2.7957 -2.0875   2.7475 -2.0606
%   2.7125 -2.0591   2.6775 -2.0692   2.6301 -2.1150   2.6196 -2.1425
%   2.6238 -2.1975
% /
% \setdashes
% \setquadratic \plot
%    .1570 -2.5000    .1606 -2.4450    .1662 -2.3625
% /
% \setquadratic \plot
%    .1808 -2.1700    .1831 -2.1425    .1878 -2.0875
% /
% \setquadratic \plot
%    .2065 -1.8950    .2124 -1.8400    .2220 -1.7575
% /
% \setquadratic \plot
%    .2474 -1.5650    .2598 -1.4825    .2732 -1.4000
% /
% \setquadratic \plot
%   .3090 -1.2075   .3265 -1.1250   .3500 -1.0229   .3675  -.9527
%   .3875  -.8775   .4030  -.8225   .4276  -.7400   .4449  -.6850
%   .4724  -.6025   .4900  -.5525   .5075  -.5045   .5250  -.4582
%   .5439  -.4100   .5600  -.3701   .5777  -.3275   .5950  -.2871
%   .6135  -.2450   .6300  -.2085   .6514  -.1625   .6650  -.1337
%   .6912  -.08000   .7049  -.05250   .7330   .00250   .7474   .03000
%   .7620   .0575   .7769   .0850   .8050   .1362   .8225   .1672
%   .8384   .1950   .8543   .2225   .8750   .2577   .8925   .2870
%   .9202   .3325   .9450   .3726   .9719   .4150   .9975   .4550
%   1.0253   .4975   1.0435   .5250   1.0619   .5525
% /
% \setquadratic \plot
%   1.1900   .7367   1.2159   .7725   1.2562   .8275   1.2775   .8563
%   1.3178   .9100   1.3475   .9492   1.3825   .9948   1.4235  1.0475
%   1.4668  1.1025   1.5050  1.1505   1.5400  1.1941   1.5773  1.2400
%   1.6275  1.3013   1.6679  1.3500   1.7138  1.4050   1.7500  1.4480
%   1.8025  1.5099   1.8375  1.5508   1.8900  1.6118   1.9425  1.6723
%   1.9950  1.7323   2.0458  1.7900   2.0945  1.8450   2.1434  1.9000
%   2.1926  1.9550   2.2421  2.0100   2.2925  2.0658   2.3450  2.1237
%   2.4150  2.2005   2.4672  2.2575   2.5200  2.3149   2.5725  2.3718
%   2.6425  2.4474   2.6950  2.5039   2.7475  2.5602   2.8175  2.6351
%   2.8761  2.6975   2.9400  2.7656   3.0100  2.8398   3.0835  2.9175
%   3.1618  3.0000
% /
% \setquadratic \plot
%   3.5000  -.00009   3.0625  -.00113   2.6075  -.00962   2.4675  -.01671
%   2.3275  -.02768   2.2225  -.03918   2.1284  -.05250   2.0650  -.06316
%   1.9807  -.0800   1.9250  -.0927   1.8550  -.1109   1.8025  -.1262
%   1.7500  -.1430   1.7150  -.1551   1.6800  -.1680   1.6450  -.1816
%   1.6100  -.1960   1.5750  -.2113   1.5400  -.2274   1.5050  -.2446
%   1.4700  -.2625   1.4516  -.2725   1.4029  -.3000   1.4000  -.3016
%   1.3650  -.3227
% /
% \setquadratic \plot
%   1.1550  -.4757   1.1357  -.4925   1.1025  -.5223   1.0758  -.5475
%   1.0477  -.5750   1.0150  -.6087    .9800  -.6467    .9468  -.6850
%   .9241  -.7125   .8925  -.7523   .8575  -.7993   .8225  -.8494
%   .7875  -.9029   .7691  -.9325   .7350  -.9905   .7000 -1.0546
%   .6650 -1.1240   .6388 -1.1800   .6030 -1.2625   .5704 -1.3450
%   .5407 -1.4275   .5050 -1.5375   .4725 -1.6498   .4317 -1.8125
%   .3964 -1.9775   .3911 -2.0050   .3850 -2.0371
% /
% \setquadratic \plot
%   .3758 -2.0875   .3675 -2.1352   .3617 -2.1700
% /
% \setquadratic \plot
%   .3323 -2.3625   .3212 -2.4450   .3141 -2.5000
% /
% \setquadratic \plot
%   .4712 -2.5000   .5166 -2.2800   .5775 -2.0388   .6210 -1.8950
%   .6795 -1.7300   .7175 -1.6370   .7700 -1.5231   .8203 -1.4275
%   .8692 -1.3450   .9052 -1.2900   .9450 -1.2341   .9873 -1.1800
%   1.0346 -1.1250   1.0850 -1.0724   1.1200 -1.0392   1.1375 -1.0235
%   1.1550 -1.0085
% /
% \setquadratic \plot
%   1.2491 -1.2900   1.2075 -1.3271   1.1550 -1.3798   1.0896 -1.4550
%   1.0325 -1.5304    .9625 -1.6373    .8925 -1.7628    .8060 -1.9500
%   .7333 -2.1425   .6808 -2.3075   .6283 -2.5000
% /
% \setquadratic \plot
%   1.2566 -2.5000   1.3475 -2.3310   1.4525 -2.1615   1.5050 -2.0851
%   1.5750 -1.9902
% /
% \setquadratic \plot
%   1.7150 -1.8177   1.7500 -1.7765   1.8025 -1.7145   1.8351 -1.6750
%   1.8725 -1.6276   1.8981 -1.5925   1.9337 -1.5375   1.9488 -1.5100
%   1.9729 -1.4550   1.9815 -1.4275   1.9903 -1.3725
% /
% \setquadratic \plot
%   1.9950 -1.3666   2.0087 -1.3725   2.0262 -1.4000   2.0475 -1.4630
%   2.0516 -1.5100   2.0475 -1.5480   2.0369 -1.5925   2.0148 -1.6475
%   1.9950 -1.6852   1.9487 -1.7575   1.9075 -1.8131   1.8375 -1.9009
%   1.7528 -2.0050   1.6461 -2.1425   1.5400 -2.2933   1.4782 -2.3900
%   1.4135 -2.5000
% /
% \setquadratic \plot
%   1.5704 -2.5000   1.6612 -2.3625   1.7621 -2.2250
% /
% \setquadratic \plot
%   1.9200 -2.0325   1.9600 -1.9862   2.0125 -1.9253   2.0383 -1.8950
%   2.0825 -1.8410   2.1046 -1.8125   2.1436 -1.7575   2.1609 -1.7300
%   2.1875 -1.6794   2.2160 -1.5925   2.2195 -1.5375   2.2087 -1.4825
%   2.1961 -1.4550   2.1767 -1.4275   2.1525 -1.4048   2.1175 -1.3825
%   2.0825 -1.3680   2.0475 -1.3597   1.9950 -1.3581
% /
% \setquadratic \plot
%   1.9950 -1.3496   2.0047 -1.3450   2.0274 -1.3175   2.0475 -1.2923
%   2.0650 -1.2686   2.0825 -1.2421   2.1000 -1.2101   2.1199 -1.1525
%   2.1253 -1.0975   2.1176 -1.0425   2.1088 -1.0150   2.0825  -.9640
%   2.0475  -.9197   1.9996  -.8775   1.9569  -.8500   1.9075  -.8262
%   1.8550  -.8081   1.8025  -.7963   1.7500  -.7895   1.6625  -.7885
%   1.5925  -.7963   1.5225  -.8110   1.4700  -.8267   1.4525  -.8328
%   1.4175  -.8463
% /
% \setquadratic \plot
%   1.4875 -1.1440   1.5400 -1.1263   1.5925 -1.1134   1.6975 -1.1042
%   1.8156 -1.1250   1.8550 -1.1413   1.8900 -1.1624   1.9116 -1.1800
%   1.9385 -1.2075   1.9583 -1.2350   1.9725 -1.2625   1.9775 -1.2734
%   1.9884 -1.3175
% /
% \setquadratic \plot
%   1.9648 -2.1975   2.0151 -2.1425   2.0681 -2.0875   2.1175 -2.0388
%   2.1535 -2.0050   2.1875 -1.9744   2.2400 -1.9296   2.2750 -1.9018
%   2.3100 -1.8757   2.3450 -1.8516   2.3975 -1.8197   2.4500 -1.7936
%   2.5025 -1.7744   2.6075 -1.7607   2.7125 -1.7884   2.7650 -1.8278
%   2.8000 -1.8784   2.8145 -1.9225   2.8171 -1.9500   2.8101 -2.0050
%   2.7866 -2.0600   2.7693 -2.0875   2.7481 -2.1150   2.7253 -2.1425
%   2.6950 -2.1732
% /
% \setquadratic \plot
%   2.6950 -2.1913   2.7092 -2.1975   2.7235 -2.2250   2.7311 -2.2525
%   2.7329 -2.3075
% /
% \setquadratic \plot
%   2.7125 -2.3800   2.6940 -2.4175   2.6600 -2.4710
% /
% \setquadratic \plot
%   2.6517 -2.3075   2.6772 -2.2525   2.6896 -2.1975
% /
% \setquadratic \plot
%   2.6950 -2.1822   2.7475 -2.1854   2.7825 -2.2003   2.8141 -2.2250
%   2.8336 -2.2525   2.8350 -2.2559   2.8500 -2.3075
% /
% \setquadratic \plot
%   2.9976 -2.5000   3.0416 -2.4725   3.0800 -2.4525   3.1150 -2.4391
%   3.1675 -2.4278   3.2375 -2.4330   3.2900 -2.4570   3.3091 -2.4725
%   3.3322 -2.5000
% /
% \setquadratic \plot
%   2.6875 -2.1425   2.6775 -2.1093   2.6425 -2.0605   2.6075 -2.0351
%   2.5725 -2.0205   2.4850 -2.0133   2.3975 -2.0349   2.3427 -2.0600
%   2.2925 -2.0896   2.2400 -2.1266   2.1875 -2.1694   2.1868 -2.1700
%   2.1559 -2.1975
% /
% \setquadratic \plot
%   1.9735 -2.3900   1.9285 -2.4450   1.8856 -2.5000
% /
% \setquadratic \plot
%   1.9250 -2.2431   1.8550 -2.3281   1.7866 -2.4175   1.7665 -2.4450
%   1.7277 -2.5000
% /
% \setquadratic \plot
%   2.5023 -2.5000   2.5025 -2.4998   2.5200 -2.4802
% /
% \setquadratic \plot
%    .7855 -2.5000    .8828 -2.2250   1.0087 -1.9500   1.1047 -1.7850
%   1.2250 -1.6199   1.3300 -1.5067   1.4525 -1.4054   1.5225 -1.3611
%   1.6100 -1.3192   1.6625 -1.3012   1.7325 -1.2860   1.8200 -1.2825
%   1.8900 -1.2952   1.9250 -1.3079   1.9600 -1.3264   1.9775 -1.3393
%   1.9950 -1.3534
% /
% \setquadratic \plot
%   1.9950 -1.3592   1.9425 -1.3581   1.8900 -1.3673   1.8550 -1.3768
%   1.7908 -1.4000   1.7327 -1.4275   1.6839 -1.4550   1.6450 -1.4799
%   1.6023 -1.5100
% /
% \setquadratic \plot
%   1.3955 -1.7025   1.3300 -1.7811   1.2659 -1.8675   1.1937 -1.9775
%   1.1200 -2.1056   1.0338 -2.2800    .9625 -2.4483    .9531 -2.4725
%    .9426 -2.5000
% /
% \setquadratic \plot
%   1.0996 -2.5000   1.1900 -2.3103   1.2950 -2.1234   1.3650 -2.0150
%   1.4350 -1.9173   1.4875 -1.8501   1.5422 -1.7850   1.5916 -1.7300
%   1.6441 -1.6750   1.6800 -1.6393   1.7288 -1.5925   1.7585 -1.5650
%   1.7889 -1.5375   1.8200 -1.5099   1.8550 -1.4793   1.8822 -1.4550
%   1.9075 -1.4334   1.9250 -1.4183   1.9600 -1.3878   1.9719 -1.3725
%   1.9950 -1.3650
% /
% \setquadratic \plot
%   2.2254 -2.3075   2.3100 -2.2365   2.3975 -2.1791   2.4500 -2.1540
%   2.5200 -2.1334   2.5900 -2.1303   2.6425 -2.1441   2.6775 -2.1609
%   2.6950 -2.1791
% /
% \setquadratic \plot
%   2.6950 -2.1847   2.6425 -2.1822   2.5900 -2.1963   2.5375 -2.2192
%   2.4850 -2.2490   2.4500 -2.2725   2.4034 -2.3075
% /
% \setquadratic \plot
%   2.4150 -2.4399   2.4653 -2.3900   2.5200 -2.3377
% /
% \setquadratic \plot
%   2.5522 -2.3075   2.5725 -2.2891   2.6075 -2.2568   2.6250 -2.2412
%   2.6600 -2.2097   2.6687 -2.1975   2.6950 -2.1902
% /
% \setquadratic \plot
%   2.1419 -2.3900   2.0915 -2.4450   2.0442 -2.5000
% /
% \endpicture\vspace{-5pt}
%\centerline{$\Re z$}\vspace{5pt}
%\centerline{\bf Modulus and phase of $w(z).$}
%
\subparagraph{Accuracy Tests}

The accuracy of the approximations was analyzed by Poppe and Wijers. They
concluded that relative accuracy is maintained within~14 significant digits,
except inside a circle of radius~0.126 around a zero of the function (all
zeros of $w(z)$ are in the lower half-plane), where absolute accuracy is
retained but relative accuracy is not. They also compared the accuracy of $%
w(z)$ to $\erfc z$ for several purely imaginary values of $z$. Their testing
procedure is reported in \cite{Poppe:1990:MEC}.

We tested CWOFZ in four regions along the imaginary axis, where $w(z)$ is
real, on an IBM PC/AT, by comparing to DERFCE. Each region was divided into
500 subregions, and a point was randomly selected in each subregion. The
maximum errors are shown below, where ULP means ``error in units of last
position of the reference result," and $\rho \approx 1.192\times 10^{- 7}$ is the
round-off level for IEEE single precision arithmetic.\vspace{-5pt}
\begin{center}
\begin{tabular}{lrrr}
\multicolumn{1}{c}{\bf Range} & {\bf ULP} &
\multicolumn{1}{c}{\bf Absolute} & \multicolumn{1}{c}{\bf Relative}\\
$[$0..0.75$]$ & 2.42 & 1.21 $\rho $\rule{.1in}{0pt} & 2.29 $\rho $\rule{.05in}{0pt}\\
$[$0.75..1.2848$]$ & 19.05 & 4.76 $\rho $\rule{.1in}{0pt} & 12.95 $\rho $\rule{.05in}{0pt}\\
$[$1.2848..4.4$]$ & 6.05 & 1.23 $\rho $\rule{.1in}{0pt} & 3.49 $\rho $\rule{.05in}{0pt}\\
$[$4.4..100$]$ & 2.19 & 0.12 $\rho $\rule{.1in}{0pt} & 1.43 $\rho $\rule{.05in}{0pt}
\end{tabular}
\end{center}\vspace{-5pt}
In the range [0.75..1.2848] errors grow as $x$ increases. Errors are four
times larger near~1.2848 than near~0.75.

We tested ZWOFZ in five regions along the imaginary axis, where $w(z)$ is
real, on an IBM PC/AT, by comparing to an extended precision calculation of $%
\exp (x^2) \erfc x.$ Each region was divided into~200 subregions, and a
point was randomly selected in each subregion. The maximum errors are shown
below, where $\rho \approx 2.22\times 10^{-16}$ is the round-off level for IEEE
double precision arithmetic.\vspace{-5pt}
\begin{center}
\begin{tabular}{lrrr}
\multicolumn{1}{c}{\bf Range} & {\bf ULP} &
\multicolumn{1}{c}{\bf Absolute} & \multicolumn{1}{c}{\bf Relative}\\
$[$0..0.75$]$ & 1.47 & 0.73 $\rho $\rule{.1in}{0pt} & 1.35 $\rho $\rule{.05in}{0pt}\\
$[$0.75..1.2848$]$ & 14.29 & 3.57 $\rho $\rule{.1in}{0pt} & 9.84 $\rho $\rule{.05in}{0pt}\\
$[$1.2848..3.4469$]$ & 6.23 & 0.78 $\rho $\rule{.1in}{0pt} & 4.44 $\rho $\rule{.05in}{0pt}\\
$[$3.4469..4.4$]$ & 14.20 & 1.78 $\rho $\rule{.1in}{0pt} & 13.42 $\rho $\rule{.05in}{0pt}\\
$[$4.4..100$]$ & 3.02 & 0.19 $\rho $\rule{.1in}{0pt} & 1.52 $\rho $\rule{.05in}{0pt}
\end{tabular}
\end{center}\vspace{-5pt}
In the range [0.75..1.2848] errors grow as $x$ increases. Errors are four
times larger near~1.2848 than near~0.75.

We tested ZWOFZ in four regions along the real axis on an IBM PC/AT, by
comparing the imaginary part of the result to an extended precision
calculation of Dawson's integral, $F(x)$. Each region was divided into~200
subregions, and a point was randomly selected in each subregion. The maximum
errors are as follows.\vspace{-5pt}
\begin{center}
\begin{tabular}{lrrr}
\multicolumn{1}{c}{\bf Range} & {\bf ULP} &
\multicolumn{1}{c}{\bf Absolute} & \multicolumn{1}{c}{\bf Relative}\\
$[$0..1.83960$]$ & 2.21 & 0.93 $\rho $\rule{.1in}{0pt} & 1.73 $\rho $\rule{.05in}{0pt}\\
$[$1.8396..2.95$]$ & 17.28 & 3.90 $\rho $\rule{.1in}{0pt} & 11.20 $\rho $\rule{.05in}{0pt}\\
$[$2.95..6.3$]$ & 8.99 & 1.12 $\rho $\rule{.1in}{0pt} & 6.24 $\rho $\rule{.05in}{0pt}\\
$[$6.3..100$]$ & 1.59 & 0.06 $\rho $\rule{.1in}{0pt} & 0.90 $\rho $\rule{.05in}{0pt}
\end{tabular}
\end{center}\vspace{-5pt}
We tested ZWOFZ along the real axis on an IBM PC/AT, by comparing the real
part of the result to an extended precision calculation of $\exp (-x^2)$, in
the range [0..10]. The maximum error was 2.04~ULP; the maximum absolute
error was 0.26\ $\rho $; the maximum relative error was 0.45\ $\rho $. The
largest errors occurred near the change of method at $x = 1.8396.$

\bibliography{math77}
\bibliographystyle{math77}

\subsection{Error Procedures and Restrictions}

$w(z)$ is computable throughout the upper half plane without restriction. To
compute $w(z)$ in the lower half plane we use $w(-z) = 2 \exp (-z^2)-w(z)$.
Since $\exp (-z^2) = \exp (\Re z^2) [\cos (\Im z^2) + i \sin(\Im z^2)]$, we
must have $x^2 - y^2 < \ln \ \Omega $, where $\Omega $ is the largest
representable floating point number. Argument reduction in computing sin and
cos causes loss of precision, and so we restrict $2|xy| < \rho ^{-1/2}$,
where $\rho $ is the smallest positive number such that the floating point
representation of $1.0 + \rho $ is different from~1.0. If $y < 0$ and $x^2 -
y^2 \geq \ln \ \Omega $ the error processor (see Chapter~19.2) is invoked
with LEVEL = 2, and IFLAG is set to $-$1. If $y < 0$ and $2|xy| \geq \rho
^{-1/2}$ the error message processor is invoked with LEVEL = 2, and IFLAG is
set to +1. The usual action of the error message processor when invoked with
LEVEL = 2 is to halt execution of the program. This action may be altered by
calling ERMSET (see Chapter~19.2).

\subsection{Supporting Information}

\begin{tabular}{@{\bf}l@{\hspace{5pt}}l}
\bf Entry & \hspace{.35in} {\bf Required Files}\vspace{2pt} \\
CWOFZ & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
AMACH, CWOFZ, ERFIN, ERMOR, ERMSG, SERV1\rule[-5pt]{0pt}{8pt}}\\ZWOFZ & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
AMACH, DERV1, ERFIN, ERMOR, ERMSG, ZWOFZ\rule[-5pt]{0pt}{8pt}}\\\end{tabular}

Present version converted from ACM TOMS Algorithm~680, \cite{Poppe:1990:AEC}, by W.
V. Snyder, 1991.

\begcodenp

\medskip\

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

\centerline{\bf \large DRCWOFZ}\vspace{5pt}
\lstinputlisting{\codeloc{cwofz}}

\vspace{10pt}\centerline{\bf \large ODCWOFZ}\vspace{5pt}
\lstset{language={}}
\lstinputlisting{\outputloc{cwofz}}
\closegraphsfile
\end{document}


\chapter{mathematical tool solutions}
\begin{abox}
	Practice set 1 solutions
	\end{abox}
\begin{enumerate}
	\begin{minipage}{\textwidth}
		\item Consider a particle in a one dimensional potential that satisfies $V(x)=V(-x)$. Let $\left|\psi_{0}\right\rangle$ and $\left|\psi_{1}\right\rangle$ denote the ground and the first excited states, respectively, and let $|\psi\rangle=\alpha_{0}\left|\psi_{0}\right\rangle+\alpha_{1}\left|\psi_{1}\right\rangle$ be a normalized state with $\alpha_{0}$ and $\alpha_{1}$ being real constants. The expectation value $\langle x\rangle$ of the position operator $x$ in the state $|\psi\rangle$ is given by
		\exyear{NET DEC 2011}
	\end{minipage}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\alpha_{0}^{2}\left\langle\psi_{0}|x| \psi_{0}\right\rangle+\alpha_{1}^{2}\left\langle\psi_{1}|x| \psi_{1}\right\rangle$
		\task[\textbf{B.}]$\alpha_{0} \alpha_{1}\left[\left\langle\psi_{0}|x| \psi_{1}\right\rangle+\left\langle\psi_{1}|x| \psi_{0}\right\rangle\right]$
		\task[\textbf{C.}]$\alpha_{0}^{2}+\alpha_{1}^{2}$
		\task[\textbf{D.}]$2 \alpha_{0} \alpha_{1}$
	\end{tasks}
\begin{answer}
 Since $V(x)=V(-x)$ so potential is symmetric.
	$$
	\begin{aligned}
	&\left\langle\psi_{0}|x| \psi_{0}\right\rangle=0,\left\langle\psi_{1}|x| \psi_{1}\right\rangle=0 \\
	&\langle\psi|x| \psi\rangle=\left(\alpha _ { 0 } \left\langle\psi_{0}\left|+\alpha_{1}\left\langle\psi_{1}\right|\right) \times\left(\alpha_{0}\left|\psi_{0}\right\rangle+\alpha_{1}\left|\psi_{1}\right\rangle\right)=\alpha_{0} \alpha_{1}\left[\left\langle\psi_{0}|x| \psi_{1}\right\rangle+\left\langle\psi_{1}|x| \psi_{0}\right\rangle\right]\right.\right.
	\end{aligned}
	$$
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item The wave function of a particle at time $t=0$ is given by $|\psi(0)\rangle=\frac{1}{\sqrt{2}}\left(\left|u_{1}\right\rangle+\left|u_{2}\right\rangle\right)$, where
	$\left|u_{1}\right\rangle$ and $\left|u_{2}\right\rangle$ are the normalized eigenstates with eigenvalues $E_{1}$ and $E_{2}$ respectively, $\left(E_{2}>E_{1}\right)$. The shortest time after which $|\psi(t)\rangle$ will become orthogonal to $|\psi(0)\rangle$ is
	\exyear{NET DEC 2011}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{-\hbar \pi}{2\left(E_{2}-E_{1}\right)}$
	\task[\textbf{B.}]$\frac{\hbar \pi}{E_{2}-E_{1}}$
	\task[\textbf{C.}]$\frac{\sqrt{2} \hbar \pi}{E_{2}-E_{1}}$
	\task[\textbf{D.}]$\frac{2 \hbar \pi}{E_{2}-E_{1}}$
\end{tasks}
\begin{answer}
	$|\psi(0)\rangle=\frac{1}{\sqrt{2}}\left(\left|u_{1}\right\rangle+\left|u_{2}\right\rangle\right) \Rightarrow|\psi(t)\rangle=\frac{1}{\sqrt{2}}\left(\left|u_{1}\right\rangle e^{\frac{-i E_{1} t}{\hbar}}+\left|u_{2}\right\rangle e^{\frac{-i E_{2} t}{\hbar}}\right)$\\
	$|\psi(t)\rangle$ is orthogonal to $|\psi(0)\rangle \Rightarrow\langle\psi(0) \mid \psi(t)\rangle=0 \Rightarrow \frac{1}{2} e^{\frac{-i E_{1} t}{\hbar}}+\frac{1}{2} e^{\frac{-i E_{2} t}{\hbar}}=0$
	\begin{align*}
	&\Rightarrow e^{\frac{-i E_{1} t}{\hbar}}+e^{\frac{-i E_{2} t}{\hbar}}=0 \Rightarrow e^{\frac{-i E_{1} t}{\hbar}}=-e^{\frac{-i E_{2} t}{\hbar}} \Rightarrow e^{i \frac{\left(E_{2}-E_{1}\right)}{\hbar}}=-1 \\
	&\Rightarrow \cos \frac{\left(E_{2}-E_{1}\right) t}{\hbar}=\cos \pi \Rightarrow t=\frac{\pi \hbar}{E_{2}-E_{1}}
	\end{align*}
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item $\text { The commutator }\left[x^{2}, p^{2}\right] \text { is }$
	\exyear{NET JUNE 2012}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $2 i \hbar x p$
	\task[\textbf{B.}]$2 i \hbar(x p+p x)$
	\task[\textbf{C.}]$2 i \hbar p x$
	\task[\textbf{D.}]$2 i \hbar(x p-p x)$
\end{tasks}
\begin{answer}
$\left[x^{2}, p^{2}\right]=x\left[x, p^{2}\right]+\left[x, p^{2}\right] x=x p[x, p]+x[x, p] p+p[x, p] x+[x, p] p x$\\
$$\left[x^{2}, p^{2}\right]=x p(i \hbar)+x(i \hbar) p+p(i \hbar) x+(i \hbar) p x=2 i \hbar(x p+p x)$$
The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Which of the following is a self-adjoint operator in the spherical polar coordinate system $(r, \theta, \phi)$ ?
	\exyear{NET JUNE 2012}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-\frac{i \hbar}{\sin ^{2} \theta} \frac{\partial}{\partial \theta}$
	\task[\textbf{B.}]$-i \hbar \frac{\partial}{\partial \theta}$
	\task[\textbf{C.}] $-\frac{i \hbar}{\sin \theta} \frac{\partial}{\partial \theta}$
	\task[\textbf{D.}] $-i \hbar \sin \theta \frac{\partial}{\partial \theta}$
\end{tasks}
\begin{answer}
	$\frac{-i \hbar}{\sin \theta} \frac{\partial}{\partial \theta} \text { is Hermitian. }$\\
	The correct option is \textbf{c}
\end{answer}
\begin{minipage}{\textwidth}
	\item Given the usual canonical commutation relations, the commutator $[A, B]$ of $A=i\left(x p_{y}-y p_{x}\right)$ and $B=\left(y p_{z}+z p_{y}\right)$ is
	\exyear{NET DEC 2012}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\hbar\left(x p_{z}-p_{x} z\right)$
	\task[\textbf{B.}]$-\hbar\left(x p_{z}-p_{x} z\right)$
	\task[\textbf{C.}]$\hbar\left(x p_{z}+p_{x} z\right)$
	\task[\textbf{D.}]$-\hbar\left(x p_{z}+p_{x} z\right)$
\end{tasks}
\begin{answer}

	\begin{align*}
		&[A, B]=\left\lfloor\left(i x p_{y}-i y p_{x}\right),\left(y p_{z}+z p_{y}\right)\right]\\
		&{[A, B]=i\left[x p_{y}, y p_{z}\right]-i\left[y p_{x}, y p_{z}\right]+i\left\lfloor x p_{y}, z p_{y}\right\rfloor-i\left\lfloor y p_{x}, z p_{y}\right\rfloor} \\
		&\left.\left.[A, B]=i\left[x p_{y}, y p_{z}\right]-0+0-i \mid y p_{x}, z p_{y}\right\rfloor=i\left[x p_{y}, y p_{z}\right\rfloor-i \mid y p_{x}, z p_{y}\right\rfloor \\
		&\left.[A, B]=i x\left[p_{y}, y p_{z}\right\rfloor+i\left[x, y p_{z}\right] p_{y}-i y \mid p_{x}, z p_{y}\right\rfloor-i\left|y, z p_{y}\right| p_{x} \\
		&\left.[A, B]=i x\left[p_{y}, y p_{z}\right\rfloor+0-0-i\left\lfloor y, z p_{y}\right\rfloor p_{x}=i x \mid p_{y}, y p_{z}\right\rfloor-i\left\lfloor y, z p_{y}\right\rfloor p_{x} \\
		&{[A, B]=i x \times(-i \hbar) p_{z}-i z i \hbar \times p_{x}=\hbar\left[x p_{z}+z p_{x}\right]} \\
		&{[A, B]=\hbar\left(x p_{z}+p_{x} z\right)}
	\end{align*}
	The correct option is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
	\item If the operators $A$ and $B$ satisfy the commutation relation $[A, B]=I$, where $I$ is the identity operator, then
	\exyear{NET JUNE 2013}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\left[e^{A}, B\right]=e^{A}$
	\task[\textbf{B.}]$\left[e^{A}, B\right]=\left[e^{B}, A\right]$
	\task[\textbf{C.}]$\left[e^{A}, B\right]=\left[e^{-B}, A\right]$
	\task[\textbf{D.}]$\left[e^{A}, B\right]=I$
\end{tasks}

\begin{answer}
	\begin{align*}
	&[A, B]=I \text { and } e^{A}=\left[1+\frac{A}{1}+\frac{A^{2}}{\lfloor 2}+\ldots \ldots . .\right]\\
	&{\left[e^{A}, B\right]=\left[1+\frac{A}{1}+\frac{A^{2}}{L 2}+\ldots \ldots . B\right]=[1, B]+[A, B]+\frac{\left[A^{2}, B\right]}{\lfloor 2}+\frac{\left[A^{3}, B\right]}{\lfloor 3} \ldots .} \\
	&{\left[e^{A}, B\right]=0+I+\frac{A[A, B]+[A, B] A}{2 !}+\frac{A\left[A^{2}, B\right]+\left[A^{2}, B\right] A}{3 !}+\ldots .} \\
	&{\left[e^{A}, B\right]=1+A+\frac{A^{2}}{2 !}+\ldots .=e^{A} \text { where }[A, B]=I,\left[A^{2}, B\right]=2 A \text { and }\left[A^{3}, B\right]=3 A^{2} .}
	\end{align*}
	The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Suppose Hamiltonian of a conservative system in classical mechanics is $H=\omega x p$, where $\omega$ is a constant and $x$ and $p$ are the position and momentum respectively. The corresponding Hamiltonian in quantum mechanics, in the coordinate representation, is
	\exyear{NET DEC 2014}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-i \hbar \omega\left(x \frac{\partial}{\partial x}-\frac{1}{2}\right)$
	\task[\textbf{B.}]$-i \hbar \omega\left(x \frac{\partial}{\partial x}+\frac{1}{2}\right)$
	\task[\textbf{C.}] $-i \hbar \omega x \frac{\partial}{\partial x}$
	\task[\textbf{D.}]$-\frac{i \hbar \omega}{2} \times \frac{\partial}{\partial x}$
\end{tasks}
\begin{answer}
	$\text { Classically } H=\omega x p \text {, quantum mechanically } H \text { must be Hermitian, }$\\
	So, $H=\frac{\omega}{2}(x p+p x)$ and $H \psi=\frac{\omega}{2}(x p \psi+p x \psi)$
	\begin{align*}
	&\Rightarrow H \psi=\frac{\omega}{2}\left(x(-i \hbar) \frac{\partial \psi}{\partial x}+\frac{-i \hbar \partial(x \psi)}{\partial x}\right)=\frac{\omega}{2}(-i \hbar)\left(x \frac{\partial \psi}{\partial x}+x \frac{\partial \psi}{\partial x}+\psi\right) \\
	&\Rightarrow H \psi=\frac{-i \hbar \omega}{2}\left(2 x \frac{\partial \psi}{\partial x}+\psi\right)=-i \hbar \omega\left(x \frac{\partial}{\partial x}+\frac{1}{2}\right) \psi
	\end{align*}
The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Let $x$ and $p$ denote, respectively, the coordinate and momentum operators satisfying the canonical commutation relation $[x, p]=i$ in natural units $(\hbar=1)$. Then the commutator $\left[x, p e^{-p}\right]$ is
	\exyear{NET DEC 2014}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i(1-p) e^{-p}$
	\task[\textbf{B.}]$i\left(1-p^{2}\right) e^{-p}$
	\task[\textbf{C.}]$i\left(1-e^{-p}\right)$
	\task[\textbf{D.}]ipe $^{-p}$
\end{tasks}
\begin{answer}
	$\because[x, p]=i$\\
	\begin{align*}
		\left[x, p e^{-p}\right] &=[x, p] e^{-p}+p\left[x, e^{-p}\right]=i e^{-p}+p\left[x, 1-p+\frac{p^{2}}{\lfloor 2}-\frac{p^{3}}{\lfloor 3} \ldots . .\right] \\
		&=i e^{-p}+p\left[[x, 1]-[x, p]+\left[x, \frac{p^{2}}{L 2}\right] \ldots\right]=i e^{-p}+p\left[0-i+\frac{2 i p}{\lfloor 2}-\frac{3 i p^{2}}{\lfloor 3} \ldots \ldots\right] \\
		\Rightarrow\left[x, p e^{-p}\right] &=i e^{-p}-i\left[p-p^{2}+\frac{p^{3}}{\lfloor 2} \ldots . .\right]=i e^{-p}-i p e^{-p}=i(1-p) e^{-p}
	\end{align*}
	The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item The wavefunction of a particle in one-dimension is denoted by $\psi(x)$ in the coordinate representation and by $\phi(p)=\int \psi(x) e^{\frac{-i p x}{\hbar}} d x$ in the momentum representation. If the action of an operator $\hat{T}$ on $\psi(x)$ is given by $\hat{T} \psi(x)=\psi(x+a)$, where $a$ is a constant then $\hat{T} \phi(p)$ is given by
	\exyear{NET JUNE 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-\frac{i}{\hbar} \operatorname{ap} \phi(p)$
	\task[\textbf{B.}]$e^{\frac{-i a p}{\hbar}} \phi(p)$
	\task[\textbf{C.}]$e^{\frac{+i a p}{\hbar}} \phi(p)$
	\task[\textbf{D.}]$\left(1+\frac{i}{\hbar} a p\right) \phi(p)$
\end{tasks}
\begin{answer}
	$\phi(p)=\int \psi(x) e^{\frac{-i p x}{\hbar}} d x$\\
	\begin{align*}
		&T \psi(x)=\psi(x+a) \\
		&T \phi(p)=\int T \psi(x) e^{\frac{-i p x}{\hbar}} d x=\int \psi(x+a) e^{\frac{-i p x}{\hbar}} d x=e^{\frac{i p a}{\hbar}} \int \psi(x+a) e^{\frac{-i p(x+a)}{\hbar}} d x \\
		&\Rightarrow T \phi(p)=e^{\frac{i p a}{\hbar}} \phi(p)
	\end{align*}
	The correct option is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Two different sets of orthogonal basis vectors $\left\{\left(\begin{array}{l}1 \\ 0\end{array}\right),\left(\begin{array}{l}0 \\ 1\end{array}\right)\right\}$ and $\left\{\frac{1}{\sqrt{2}}\left(\begin{array}{l}1 \\ 1\end{array}\right), \frac{1}{\sqrt{2}}\left(\begin{array}{c}1 \\ -1\end{array}\right)\right\}$ are given for a two dimensional real vector space. The matrix representation of a linear operator $\hat{A}$ in these basis are related by a unitary transformation. The unitary matrix may be chosen to be
	\exyear{NET JUNE 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\left(\begin{array}{cc}0 & -1 \\ 1 & 0\end{array}\right)$
	\task[\textbf{B.}]$\left(\begin{array}{ll}0 & 1 \\ 1 & 0\end{array}\right)$
	\task[\textbf{C.}]$\frac{1}{\sqrt{2}}\left(\begin{array}{cc}1 & 1 \\ 1 & -1\end{array}\right)$
	\task[\textbf{D.}] $\frac{1}{\sqrt{2}}\left(\begin{array}{ll}1 & 0 \\ 1 & 1\end{array}\right)$
\end{tasks}
\begin{answer}
$u_{1}=\left(\begin{array}{ll}
	1 & 0 \\
	0 & 1
\end{array}\right), u_{2}=\frac{1}{\sqrt{2}}\left(\begin{array}{cc}
	1 & 1 \\
	1 & -1
\end{array}\right) \Rightarrow u=u_{1} \otimes u_{2}=\frac{1}{\sqrt{2}}\left(\begin{array}{cc}
	1 & 1 \\
	1 & -1
\end{array}\right)$\\
The correct option is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
\item A Hermitian operator $\hat{O}$ has two normalized eigenstates $|1\rangle$ and $|2\rangle$ with eigenvalues 1 and 2 , respectively. The two states $|u\rangle=\cos \theta|1\rangle+\sin \theta|2\rangle$ and $|v\rangle=\cos \phi|1\rangle+\sin \phi|2\rangle$ are such that $\langle v|\hat{O}| v\rangle=7 / 4$ and $\langle u \mid v\rangle=0$. Which of the following are possible values of $\theta$ and $\phi$ ?
	\exyear{NET DEC 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\theta=-\frac{\pi}{6}$ and $\phi=\frac{\pi}{3}$
	\task[\textbf{B.}]$\theta=\frac{\pi}{6}$ and $\phi=\frac{\pi}{3}$
	\task[\textbf{C.}]$\theta=-\frac{\pi}{4}$ and $\phi=\frac{\pi}{4}$
	\task[\textbf{D.}]$\theta=\frac{\pi}{3}$ and $\phi=-\frac{\pi}{6}$
\end{tasks}
\begin{answer}
	$|u\rangle=\cos \theta|1\rangle+\sin \theta|2\rangle, \quad|v\rangle=\cos \phi|1\rangle+\sin \phi|2\rangle$\\\\
	it is given
	$\hat{O}|1\rangle=|1\rangle, \quad \hat{O}|2\rangle=2|2\rangle \Rightarrow\langle v|\hat{O}| v\rangle=\frac{7}{4}$\\
	\begin{align*}
		&\cos ^{2} \phi+2 \sin ^{2} \phi=\frac{7}{4} \Rightarrow \cos ^{2} \phi+\sin ^{2} \phi=1 \Rightarrow \sin ^{2} \phi=\frac{7}{4}-1 \\
		&\sin \phi=\frac{\sqrt{3}}{2} \Rightarrow \phi=\frac{\pi}{3} \\
		&\langle u \mid v\rangle=0 \Rightarrow \cos \theta \cos \phi+\sin \theta \sin \phi=0 \Rightarrow \cos (\theta-\phi)=0 \\
		&\Rightarrow \theta-\phi=\frac{\pi}{2} \text { or } \phi-\theta=\frac{\pi}{2} \Rightarrow \theta=\frac{\pi}{2}+\frac{\pi}{3} \text { or } \theta=\frac{\pi}{3}-\frac{\pi}{2} \Rightarrow \theta=\frac{5 \pi}{6} \text { or } \theta=-\frac{\pi}{6}
	\end{align*}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $\hat{L}_{x}, \hat{L}_{y}, \hat{L}_{z}$ are the components of the angular momentum operator in three dimensions the commutator $\left[\hat{L}_{x}, \hat{L}_{x} \hat{L}_{y} \hat{L}_{z}\right]$ may be simplified to
	\exyear{NET JUNE 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i \hbar L_{x}\left(\hat{L}_{z}^{2}-\hat{L}_{y}^{2}\right)$
	\task[\textbf{B.}]$i \hbar \hat{L}_{z} \hat{L}_{y} \hat{L}_{x}$
	\task[\textbf{C.}]$i \hbar L_{x}\left(2 \hat{L}_{z}^{2}-\hat{L}_{y}^{2}\right)$
	\task[\textbf{D.}]0
\end{tasks}
\begin{answer}
	\begin{align*}
		&:\left[L_{x}, L_{x} L_{y} L_{z}\right]=L_{x}\left[L_{x}, L_{y} L_{z}\right]+\left[L_{x}, L_{x}\right] L_{y} L_{z} \\
		=& L_{x}\left[L_{x}, L_{y}\right] L_{z}+L_{x} L_{y}\left[L_{x}, L_{z}\right]+0=L_{x}\left[i \hbar L_{z}\right] L_{z}+L_{x} L_{y}\left(-i \hbar L_{y}\right) \\
		=& i \hbar L_{x} L_{z}^{2}-i \hbar L_{x} L_{y}^{2}=i \hbar L_{x}\left(L_{z}^{2}-L_{y}^{2}\right)
	\end{align*}
	The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Consider the operator, $a=x+\frac{d}{d x}$ acting on smooth function of $x$. Then commutator $[\alpha, \cos x]$ is
	\exyear{NET DEC 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-\sin x$
	\task[\textbf{B.}]$\cos x$
	\task[\textbf{C.}]$-\cos x$
	\task[\textbf{D.}]0
\end{tasks}
\begin{answer}

	\begin{align*}
	&a=x+\frac{d}{d x}\\
		&{[a, \cos x]=\left[x+\frac{d}{d x}, \cos x\right]=[x, \cos x]+\left[\frac{d}{d x}, \cos x\right]=0+\left[\frac{d}{d x}, \cos x\right]} \\
		&{\left[\frac{d}{d x}, \cos x\right] \psi(x)=\frac{d}{d x} \cos x \psi(x)-\cos x \frac{d \psi}{d x}} \\
		&=\cos x \frac{d \psi}{d x}+(-\sin x) \psi-\frac{\cos x d \psi}{d x}=-\sin x \psi \\
		&{[a, \cos x] \psi(x)=-\sin x \psi} \\
		&{[a, \cos x]=-\sin x}
	\end{align*}
	The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Consider the operator $\vec{\pi}=\vec{p}-q \vec{A}$, where $\vec{p}$ is the momentum operator, $\vec{A}=\left(A_{x}, A_{y}, A_{z}\right)$ is the vector potential and $q$ denotes the electric charge. If $\vec{B}=\left(B_{x}, B_{y}, B_{z}\right)$ denotes the magnetic field, the $z$-component of the vector operator $\vec{\pi} \times \vec{\pi}$ is
	\exyear{NET DEC 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i q \hbar B_{z}+q\left(A_{x} p_{y}-A_{y} p_{x}\right)$
	\task[\textbf{B.}]$-i q \hbar B_{z}-q\left(A_{x} p_{y}-A_{y} p_{x}\right)$
	\task[\textbf{C.}]$-i q \hbar B_{2}$
	\task[\textbf{D.}] $i q \hbar B_{z}$
\end{tasks}
\begin{answer}
	$\vec{\pi}=\vec{p}-q \vec{A}$\\
	\begin{align*}
	&(\vec{\pi} \times \vec{\pi}) \psi=(\vec{p}-q \vec{A}) \times(\vec{p}-q \vec{A}) \psi=\vec{p} \times \vec{p} \psi-q \vec{p} \times \vec{A} \psi-q \vec{A} \times \vec{p} \psi+q^{2} \vec{A} \times \vec{A} \psi \\
	&\vec{p} \times \vec{p} \psi=0 \\
	&-q \vec{p} \times \vec{A} \psi=-q(-i \hbar \vec{\nabla} \times \vec{A}) \psi=q i \hbar \vec{B} \psi \\
	&q \vec{A} \times \vec{p} \psi=q(\vec{A}(-i \hbar \vec{\nabla})) \psi=0 \\
	&q^{2} \vec{A} \times \vec{A} \psi=0 \\
	&\vec{\pi} \times \vec{\pi}=q i \hbar \vec{B}
	\end{align*}
	So, $z$ component is given by $q i \hbar B_{z}$\\
	The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item $\text { The two vectors }\left(\begin{array}{l}
		a \\
		0
	\end{array}\right) \text { and }\left(\begin{array}{l}
		b \\
		c
	\end{array}\right) \text { are orthonormal if }$
	\exyear{NET JUNE 2017}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $a=\pm 1, b=\pm 1 / \sqrt{2}, c=\pm 1 / \sqrt{2}$
	\task[\textbf{B.}] $a=\pm 1, b=\pm 1, c=0$
	\task[\textbf{C.}]$a=\pm 1, b=0, c=\pm 1$
	\task[\textbf{D.}] $a=\pm 1, b=\pm 1 / 2, c=1 / 2$
\end{tasks}
\begin{answer}
	$\left|\phi_{1}\right\rangle=\left(\begin{array}{l}
		a \\
		0
	\end{array}\right),\left|\phi_{2}\right\rangle=\left(\begin{array}{l}
		b \\
		c
	\end{array}\right)$\\
	$\begin{array}{ll}
		\left\langle\phi_{1} \mid \phi_{1}\right\rangle=1 & \Rightarrow a=\pm 1 \\
		\left\langle\phi_{2} \mid \phi_{2}\right\rangle=1 & \Rightarrow|b|^{2}+|c|^{2}=1 \\
		\left\langle\phi_{1} \mid \phi_{2}\right\rangle=0 & \Rightarrow\left(\begin{array}{ll}
			a & 0
		\end{array}\right)\left(\begin{array}{l}
			b \\
			c
		\end{array}\right)=0 \\
		& a . b+0 \cdot c=0 \Rightarrow a \cdot b=0 \\
		|c|^{2}=1, \quad & \quad c=\pm 1 \quad \text { so } b=0 \\
		a=\pm 1, \quad & b=0, \quad c=\pm 1
	\end{array}$\\
	The correct option  is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Let $x$ denote the position operator and $p$ the canonically conjugate momentum operator of a particle. The commutator
	$$
	\left[\frac{1}{2 m} p^{2}+\beta x^{2}, \frac{1}{m} p^{2}+\gamma x^{2}\right]
	$$
	where $\beta$ and $\gamma$ are constants, is zero if
	\exyear{NET DEC 2017}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\gamma=\beta$
	\task[\textbf{B.}]$\gamma=2 \beta$
	\task[\textbf{C.}]$\gamma=\sqrt{2} \beta$
	\task[\textbf{D.}]$2 \gamma=\beta$
\end{tasks}
\begin{answer}
	\begin{align*}
		&{\left[\frac{1}{2 m} p^{2}+\beta x^{2}, \frac{1}{m} p^{2}+\gamma x^{2}\right]=0 \Rightarrow \frac{1}{2 m} \gamma\left[p^{2}, x^{2}\right]+\frac{\beta}{m}\left[x^{2}, p^{2}\right]=0} \\
		&-\frac{\gamma}{2 m}\left[x^{2}, p^{2}\right]+\frac{\beta}{m}\left[x^{2}, p^{2}\right]=0 \Rightarrow \frac{1}{m}\left[x^{2}, p^{2}\right]\left[\frac{-\gamma}{2}+\beta\right]=0 \Rightarrow \gamma=2 \beta
	\end{align*}
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Consider the operator $A_{x}=L_{y} p_{z}-L_{z} p_{y}$, where $L_{i}$ and $p_{i}$ denote, respectively, the components of the angular momentum and momentum operators. The commutator $\left[A_{x}, x\right]$ where $x$ is the $x$ - component of the position operator, is
	\exyear{NET DEC 2018}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-i \hbar\left(z p_{z}+y p_{y}\right)$
	\task[\textbf{B.}]$-i \hbar\left(z p_{z}-y p_{y}\right)$
	\task[\textbf{C.}]$i \hbar\left(z p_{z}+y p_{y}\right)$
	\task[\textbf{D.}]$i \hbar\left(z p_{z}-y p_{y}\right)$
\end{tasks}
\begin{answer}
	 $A_{x}=L_{y} p_{z}-L_{z} p_{y}, L_{y}=z p_{x}-x p_{z}, L_{z}=x p_{y}-y p_{x}$
	\begin{align*}
	&{\left[A_{x}, x\right]=\left[L_{y} p_{z}, x\right]-\left[L_{z} p_{y}, x\right]=\left[L_{y}, x\right] p_{z}-\left[L_{z}, x\right] p_{y}} \\
	&=\left[z p_{x}, x\right] p_{z}+\left[y p_{x}, x\right] p_{y}=z\left[p_{x}, x\right] p_{z}+y\left[p_{x}, x\right] p_{y} \\
	&=\left(-i \hbar z p_{z}\right)+\left(-i \hbar y p_{y}\right)=-i \hbar\left(z p_{z}+y p_{y}\right)
	\end{align*}
	The correct option is \textbf{(a)}
\end{answer}
\end{enumerate}

\newpage
\begin{abox}
	Practice set 2 solutions
	\end{abox}
\begin{enumerate}
\begin{minipage}{\textwidth}
	\item The quantum mechanical operator for the momentum of a particle moving in one dimension is given by
	\exyear{GATE 2011}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i \hbar \frac{d}{d x}$
	\task[\textbf{B.}]$-i \hbar \frac{d}{d x}$
	\task[\textbf{C.}]$i \hbar \frac{\partial}{\partial t}$
	\task[\textbf{D.}]$-\frac{\hbar^{2}}{2 m} \frac{d^{2}}{d x^{2}}$
\end{tasks}
\begin{answer}
	The correct option \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $L_{x}, L_{y}$ and $L_{z}$ are respectively the $x, y$ and $z$ components of angular momentum operator $L$. The commutator $\left[L_{x} L_{y}, L_{z}\right]$ is equal to
	\exyear{GATE 2011}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i \hbar\left(L_{x}^{2}+L_{y}^{2}\right)$
	\task[\textbf{B.}]$2 i \hbar L_{z}$
	\task[\textbf{C.}]$i \hbar\left(L_{x}^{2}-L_{y}^{2}\right)$
	\task[\textbf{D.}] 0
\end{tasks}
\begin{answer}
$\left\lfloor L_{x} L_{y}, L_{z}\right]=L_{x}\left[L_{y} L_{z}\right]+\left[L_{x}, L_{z}\right] L_{y}=i \hbar\left(L_{x}^{2}-L_{y}^{2}\right)$\\
The correct option is \textbf{(c)}
\end{answer}
\textbf{common data questions 3 and 4 }\\
In a one-dimensional harmonic oscillator, $\varphi_{0}, \varphi_{1}$ and $\varphi_{2}$ are respectively the ground, first and the second excited states. These three states are normalized and are orthogonal to one another $\psi_{1}$ and $\psi_{2}$ are two states defined by
$$
\psi_{1}=\varphi_{0}-2 \varphi_{1}+3 \varphi_{2}, \psi_{2}=\varphi_{0}-\varphi_{1}+\alpha \varphi_{2}, \psi_{2}=\varphi_{0}-\varphi_{1}+\alpha \varphi_{2}
$$
where $\alpha$ is a constant\\
\begin{minipage}{\textwidth}
	\item $\text { The value of } \alpha \text { which } \psi_{2} \text { is orthogonal to } \psi_{1} \text { is }$
	\exyear{GATE 2011}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}]2
	\task[\textbf{B.}]1
	\task[\textbf{C.}]-1
	\task[\textbf{D.}]-2
\end{tasks}
\begin{answer}
	$\text { For orthogonal condition scalar product }\left(\psi_{2}, \psi_{1}\right)=0, \text { so } 1+2+3 \alpha=0 \Rightarrow \alpha=-1$\\
	The correct option is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
	\item For the value of $\alpha$ determined in $\mathrm{Q} 3$, the expectation value of energy of the oscillator in the state $\psi_{2}$ is
\end{minipage}
\begin{tasks}(1)
	\task[\textbf{A.}] $\hbar \omega$
	\task[\textbf{B.}]$3 \hbar \omega / 2$
	\task[\textbf{C.}]$3 \hbar \omega$
	\task[\textbf{D.}]$9 \hbar \omega / 2$
\end{tasks}
\begin{answer}
	$\psi_{2}=\phi_{0}-\phi_{1}+\alpha \phi_{2} \text { put } \alpha=-1,\langle H\rangle=\frac{\left\langle\psi_{2}|H| \psi_{2}\right\rangle}{\left\langle\psi_{2} \mid \psi_{2}\right\rangle}=\frac{\frac{\hbar \omega}{2}+\frac{3 \hbar \omega}{2}+\frac{5 \hbar \omega}{2}}{3}=\frac{3}{2} \hbar \omega$\\
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Which one of the following commutation relations is NOT CORRECT? Here, symbols have their usual meanings.
	\exyear{GATE 2013}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\left[L^{2}, L_{z}\right]=0$
	\task[\textbf{B.}]$\left\lfloor L_{x}, L_{y}\right\rfloor=i \hbar L_{z}$
	\task[\textbf{C.}]$\left[L_{z}, L_{+}\right]=\hbar L_{+}$
	\task[\textbf{D.}] $\left[L_{z}, L_{-}\right]=\hbar L_{-}$
\end{tasks}
\begin{answer}
	The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Let $\vec{L}$ and $\vec{p}$ be the angular and linear momentum operators, respectively, for a a particle. The commutator $\left\lfloor L_{x}, p_{y}\right\rfloor$ gives
	\exyear{GATE 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-i \hbar p_{z}$
	\task[\textbf{B.}]0
	\task[\textbf{C.}]$i \hbar p_{x}$
	\task[\textbf{D.}]$i \hbar p_{z}$
\end{tasks}
\begin{answer}
\begin{align*}
	&:\left[L_{x}, p_{y}\right]=\left[y p_{z}-z p_{y}, p_{y}\right]=\left[y p_{z}, p_{y}\right]-\left[z p_{y}, p_{y}\right]=\left[y, p_{y}\right] p_{z} \\
	&\cdot\left[p_{y}, p_{y}\right]=0 \text { and }\left[z, p_{y}\right]=0 \Rightarrow\left[L_{x}, p_{y}\right]=i \hbar p_{z} \quad \because\left[y, p_{y}\right]=i \hbar
\end{align*}
The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item $\text { Which of the following operators is Hermitian? }$
	\exyear{GATE 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{d}{d x}$
	\task[\textbf{B.}]$\frac{d^{2}}{d x^{2}}$
	\task[\textbf{C.}]$i \frac{d^{2}}{d x^{2}}$
	\task[\textbf{D.}]$\frac{d^{3}}{d x^{3}}$
\end{tasks}
\begin{answer}
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $x$ and $p$ are the $x$ components of the position and the momentum operators of a particle respectively, the commutator $\left[x^{2}, p^{2}\right]$ is
	\exyear{GATE 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i \hbar(x p-p x)$
	\task[\textbf{B.}]$2 i \hbar(x p-p x)$
	\task[\textbf{C.}]$i \hbar(x p+p x)$
	\task[\textbf{D.}]$2 i \hbar(x p+p x)$
\end{tasks}\begin{answer}
$\left[x^{2}, p^{2}\right]=p\left[x^{2}, p\right]+\left[x^{2} p\right] p=2 i \hbar p x+2 i \hbar x p \Rightarrow 2 i \hbar(x p+p x)$\\
The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item $\text { For the parity operator } P, \text { which of the following statements is NOT true? }$
	\exyear{GATE 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $P^{\dagger}=P$
	\task[\textbf{B.}] $P^{2}=-P$
	\task[\textbf{C.}] $P^{2}=I$
	\task[\textbf{D.}]$P^{\dagger}=P^{-1}$
\end{tasks}
\begin{answer}
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item $\text { Which one of the following operators is Hermitian? }$
	\exyear{GATE 2017}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i \frac{\left(p_{x} x^{2}-x^{2} p_{x}\right)}{2}$
	\task[\textbf{B.}]$i \frac{\left(p_{x} x^{2}+x^{2} p_{x}\right)}{2}$
	\task[\textbf{C.}]$e^{i p_{x} a}$
	\task[\textbf{D.}]$e^{-i p_{x} a}$
\end{tasks}
\begin{answer}
	$A=i \frac{\left(p_{x} x^{2}-x^{2} p_{x}\right)}{2}, A^{\dagger}=-i \frac{\left(\left(p_{x} x^{2}\right)^{\dagger}-\left(x^{2} p_{x}\right)^{\dagger}\right)}{2}=i \frac{\left(p_{x} x^{2}-x^{2} p_{x}\right)}{2}$\\
	The correct option is \textbf{(a)}
\end{answer}
\end{enumerate}

QM -CSIR/chapter/mathematical tool solutions.tex


%!TEX root = ../COSCFair.tex

\section{Theoretical Analysis}
\label{sec:theory}

In this section, we discuss the fairness metrics and perform a theoretical analysis to improve the fairness in the predictions of a given classifier. We provide formal definitions of the fairness metrics with more details than our discussion in Section \ref{sec:related}.

\subsection{Fairness Measures}

The concept of fairness is vague and can be interpreted in different ways. For that reason, there are multiple fairness measures that are similar in the intent. However, these measures (metrics) differ in the way of treating the protected groups and conflict with each other in some cases. We list here five of the well-known fairness metrics.

\stitle{Demographic Parity (DP):} this metric states that, the instances in both protected (unprivileged) and unprotected (privileged) groups should have equal probability of being predicted as positive outcome. This metric can be applied on the original class labels in a dataset as well as on the classifier predictions. For a dataset to be fair, the following condition must be satisfied:
\[P\left[Y({\bf x})=1\ |\ S({\bf x})=G' \right]  = P\left[Y({\bf x})=1\ |\ S({\bf x}) = G \right].\] That means,
% \begin{equation} \label{eq:DPDiff}
% \small
% DP_{diff} = P\left[Y({\bf x})=1\ |\ S({\bf x})=G' \right] - P\left[ {Y({\bf x})}=1\ |\ S({\bf x}) = G \right] \approx 0.
% \end{equation}
\begin{align} \label{eq:DPDiff}
\begin{split}
DP_{diff} = &\ P\left[Y({\bf x})=1\ |\ S({\bf x})=G' \right]
    \\& - P\left[ {Y({\bf x})}=1\ |\ S({\bf x}) = G \right] \approx 0.
\end{split}
\end{align}
The same definition can be applied to ensure the classifier's fairness by substituting the original labels by the predicted ones.% in the Equations.

\stitle{Disparate Impact Ratio (DIR):} is defined as the ratio between the probability of protected and unprotected groups getting positive or desired outcomes. Based on a legal rule \cite{US_guideline}, a dataset or a classifier is considered fair if its $DIR$ is at least 0.8, which is also known as the \emph{80\%-rule}. $DIR$ can be formulated as:
\begin{equation}\label{eq:di}
DIR(D) = \frac{ P\left[({\bf x}) = 1 | S({\bf x}) = G\right]} {P\left[Y({\bf x}) = 1 | S({\bf x})=G'\right]}.
\end{equation}
In this research we target increasing the value of $DIR$ to be close to or greater than $0.8$. Similar to demographic parity, this metric can also be used to measure the fairness of the classifier's predictions.

\stitle{Equalized Odds (EO):} this metric states that instances from protected and unprotected groups should have equal True Positive Rate (TPR) and False Positive Rate (FPR).
if we denote, \\
\begin{center}
$P_1 = P\left[ \widehat{Y}({\bf x})=1\ |\ S({\bf x})=G', Y ({\bf x})=1 \right],$\\
$P_2 = P\left[ \widehat{Y}({\bf x})=1\ |\ S({\bf x})=G, Y({\bf x})=1 \right],$\\
$P_3 = P\left[ \widehat{Y}({\bf x})=1\ |\ S({\bf x})=G', Y({\bf x})=0 \right]$, \\
$P_4 = P\left[ \widehat{Y}({\bf x})=1\ |\ S({\bf x})=G, Y({\bf x})=0 \right]$.\\
\end{center}
then the EO is defined as:
\begin{equation}\label{eq:eo}
P_1 = P_2\ \text{and}\ P_3 = P_4 \\
\end{equation}
In our experiments, we use the Average Equalized Odds difference (AEO Diff.), which is defined as:
\[
AEO_{diff} = \frac{(P_1 - P_2)+(P_3 - P_4)}{2}.
\]
According to AEO Diff., a classifier is fair if the $AEO_{diff}$ value should be close to $0$.

\stitle{Predictive Parity:} to deem a classifier as fair in terms of predictive parity, both protected and unprotected groups should have the same positive predictive value. It is formalized as:\\
\begin{small}
\[
P\left[Y({\bf x}) = 1\ |\ \widehat{Y}({\bf x})=1, S({\bf x})=G\right] = P\left[Y({\bf x}) = 1\ |\ \widehat{Y}({\bf x})=1, S({\bf x})=G'\right].
\]
\end{small}

\stitle{Consistency:} this individual fairness metric measures how similar the labels are for the similar instances in a dataset based on the k-neighbors of the instance. Thus, instances should have the same labels if they are similar in terms of features. This metric is formulated as:

% $ y_{NN} = 1 - \frac{1}{n}\sum_{i=1}^n |\hat{y}_i - \frac{1}{{k_{neighbors}}}  \sum_{j\in\mathcal{N}_{{n_{neighbors}}}(x_i)} \hat{y}_j|$.

%this is directly from AIF360 Consistency computation
\[
Consistency = 1 - \frac{1}{|D|}\sum_{i=1}^{|D|} \left| \widehat{y}({\bf x}_i) -
           \frac{1}{\left|kNN({\bf x}_i)\right|} \sum_{{\bf x}_j\in kNN({\bf x}_i)} \widehat{y}({\bf x}_j) \right|,
\]
where $\left|kNN({\bf x})\right|$ represents the set of closed $k$ neighbors for the kNN computation.

Even though the intention of these definitions of fairness through the different metrics is clear, there is no agreement on what should be considered fair/unfair. For example, for an algorithm to be deemed fair, the equalized odds difference should be close to $0$. However, there is no agreement on the cutoff value to consider the algorithm as fair or not. The only exception is the Disparate Impact Ratio (DIR) which is based on the $80\%$ legal rule. Moreover, it is mathematically impossible to satisfy a set of measures at the same time \cite{chouldechova2017fair,kleinberg2017inherent,pleiss2017calibration}. For these reasons, we focus on how to improve the $DIR$ of a dataset (or the output of a ML algorithm) and how the improvement in the $DIR$ values will affect the other metrics such as accuracy and F1-Score.

Let $|D|$ be the number of instances in the dataset $D$, $N_p$ %= \# +ve
be the total number positive examples in the dataset, $N_{G_p}/N_{G'_p}$ %  = \# +ve | S = G
be the number positive examples from the unprivileged/privileged groups, respectively. Let $\xi$ be the percentage value of $DIR$ for the original dataset ($DIR(D) = \xi/100$). Our goal is to increase the value of $DIR$ by $\delta/100$, with $0 < \delta < 125 - \xi $, to make $DIR(C)$ close to or greater than $80\%$, where $C$ is a given classifier. To do so, we should increase/decrease the number of instances that are predicted positive from the unprivileged/privileged groups. If $p(Y({\bf x}) = 1\ |\ S({\bf x}) = G) = \frac{N_{G_p}}{N_G}$, and $p(Y({\bf x}) = 1\ |\ S({\bf x}) = G') = \frac{N_{G'_p}}{N_{G'}}$.
% \fixme{--Hakim: I finished revising the analysis up to this point}
Since, $DIR(D) = \xi\%$ then:
\begin{equation} \label{eq:NGP}
\frac{N_{G_p}/{N_G}}{N_{G'_p}/{N_{G'}}} = \frac{\xi}{100}\ \text{and}\ N_{G_p} = \frac{\xi N_G N_{G'_p}}{100N_{G'}}.
\end{equation}
To increase the value of $DIR(C)$ to $(\xi+\delta)\%$, we need:
\begin{equation}\label{eq:general}
\frac{\left(N_{G_p}+\epsilon\right)/{N_G}}{\left(N_{G'_p}-\gamma\right)/{N_{G'}}} = \frac{\xi+\delta}{100},
% \frac{N_G+\epsilon}{W-\omega-\gamma} = \frac{\xi+\delta}{100}.
\end{equation}
where $\epsilon$ is the number of instances (records) from the unprivileged group that should be predicted positive while their original label is negative.
Conceptually, $\epsilon$ can take any integer value between $0$ and $N_G - N_{G_p}$.
Conversely, $0 < \gamma < N_{G'_p}$ is the number of instances from the privileged group that should be predicted negative while their original label is positive.
Solving for $\epsilon$ and $\gamma$, we get:
\begin{equation} \label{eq:compute_eps_gam}
    \frac{\left(N_{G_p}+\epsilon\right){N_{G'}}}{\left(N_{G'_p}-\gamma\right){N_{G}}} = \frac{\xi+\delta}{100}.
\end{equation}

Substituting $N_{G_P}$ from Eq. (\ref{eq:NGP}) in Eq. (\ref{eq:compute_eps_gam}), we get:
\[
\left(\xi + \delta\right)\left(N_{G'_p}-\gamma\right)N_{G} = 100 N_{G'} \left(\frac{\xi N_G N_{G'_p}}{100N_{G'}} + \epsilon\right)
\]
Hence:
\[
100 \epsilon N_{G'} +\gamma \left(\xi + \delta\right) N_{G} = \delta N_{G'_p} N_G
\]
We can distinguish between three special cases:
\begin{enumerate}[label=\textbf{C\arabic*:}]
    \item $\epsilon = \gamma$, in this case we need to increase the number of instances from the protected group that are predicted positive by $\epsilon = \frac{\delta N_{G'_p} N_G}{100N_{G'}+\left(\xi+\delta\right)N_G}$ and decrease the number of instances from the unprotected group that are predicted positive by the same amount.
    \item $\gamma = 0$, in this case we need to increase the number of instances from the protected group that are predicted positive by $\epsilon = \frac{\delta N_{G'_p} N_G}{100N_{G'}}$ while keeping the same number of positives from the unprotected group.
    \item $\epsilon = 0$, in this case we need to decrease the number of instances from the unprotected group that are predicted positive by $\gamma = \frac{\delta N_{G'_p} N_G}{\left(\xi+\delta\right)N_G}$ while keeping the same number of positives from the protected group.
\end{enumerate}

Since the number of instances (records) from the unprivileged group is significantly smaller than the number of instances from the privileged group, it can be easily shown that increasing the positives of the unprivileged group while keeping the number of positives from the privileged group unchanged will incur the minimum number of changes (case {\bf C2}: $\gamma = 0$). This cannot be achieved in real life scenarios but we can increase the probability of classifying an instance as positive given that it is from the unprivileged group.
To do so, we consider generating more examples from the  unprivileged group with positive label.To do so, we use oversampling technique to generate synthetic data from the class of the minority. Since the synthetic data generator, such as SMOTE~\cite{smote}, interpolates the original instances in the training set to generate new instances, the quality of the generated instances depends on the similarity between the interpolated instances. To increase the similarity between the instances, we cluster the data before generating the new instances.
In the evaluation section, we report the number of instances that have been predicted differently due to our solution.

It should be noted that improving the $DIR$ metric will certainly affect the other metrics. For example, according to Eq. (\ref{eq:general}), increasing $DIR$ by $\delta$ will have the following effects: i) the number of True Positives (TP) will be decreased by $\gamma$. We assume that we have trained a perfect classifier, which can predict all the labels in the test set correctly. Based on the required changes in the classifier's predictions, if the original true positives is $TP$ then the new true positives $TP'= TP - \gamma$; ii) similarly, the True Negatives will be decreased by $\epsilon$ (i.e. $TN'= TN -\epsilon$); iii) The False Positives (FP) will be increased by $\epsilon$ ($FP'= FP + \epsilon$) and the False Negatives (FN) will be increased by $\gamma$ ($FN'= FN + \gamma$). Thus, the perfect classifier's accuracy will be decreased by $\left(\frac{\gamma+\epsilon}{|D|}\right)$. If $F'_1$ is the new $F1\text{-}Score$, then $F'_1 = \frac{2*(TP-\gamma)}{2*TP+FN+FP+\epsilon-\gamma}$. For the case of perfect classifier, $F_1 = 1$ and $F'_1 = \frac{2(TP-\gamma)}{2TP -\gamma+\epsilon}$. The decrease in the $F1\text{-}Score$ will be $1 - \frac{2(TP-\gamma)}{2TP -\gamma+\epsilon}$.

\begin{example}
\noindent The German dataset \cite{UCIdfs} has 1000 instances. We split the dataset for training and testing using the 70/30 rule with stratification. In the test set $T$, we have $N_{G'} = 181$ instances from the privileged group and $N_G = 31$ from the unprivileged group. The number of positive instances from privileged/unprivileged is $(N_{G'_p} = 134)$/$(N_{G_p} = 17)$, respectively. In this case, improving $DIR(C)$ from $74\%$ to be greater than $80\%$ while considering $\epsilon = 0$ in Eq. (\ref{eq:general}) and assuming that we have a perfect classifier, we will need to predict approximately $10$ instances from the privileged group to be negative instead of their original positive label. In this case, the accuracy of the perfect classifier will decrease by $10/300 = 3.3\%$ and $F1\text{-}Score$ will be reduced by $\frac{10}{2*210-10}= 2.4\%$. However, when $\gamma = 0$, $\epsilon$ will be 2 and the decrease in accuracy and $F1\text{-}Score$ will be $0.6\%$ and $0.5\%$, respectively.
\end{example}

% Based on our analysis and the statistics from the data, we can conclude that the classifier fail to predict more positive instances from the unprivileged group because the number of positive instances in the training set is small compared to the number of positive instances from the privileged group. To solve the problem, we consider generating more examples from the  unprivileged group with positive label.To do so, we use oversampling technique to generate synthetic data from the class of the minority. Since the synthetic data generator, such as SMOTE~\cite{smote}, interpolates the original instances in the training set to generate new instances, the quality of the generated instances depends on the similarity between the interpolated instances. To increase the similarity between the instances, we cluster the data before generating the new instances.