\section{Differentiation}
Until further notice, we will just study differentiation of a function $f:I\to\mathbb R$ where $I$ is an interval.
\subsection{The Derivative}
\begin{definition}
    If $a\in I$ and we have
    $$\lim_{x\to a}\frac{f(x)-f(a)}{x-a}$$
    exists and equals $c\in\mathbb R$, we say $f$ is differentiable at $a$ and the derivative is $f^\prime(a)=c$.
    Moreover, if $f$ is differentiable at all $a\in I$, we say $f$ is differentiable.
\end{definition}
Geometrically $f^\prime(a)$ is the slope of the tangent line of $f$ at $a$.\\
Another (formal) way to put this is to observe that the definition is essentially $\forall \epsilon>0,\exists\delta>0$,
$$|x-a|<\delta\implies\left|\frac{f(x)-f(a)}{x-a}-c\right|<\epsilon\implies |f(x)-f(a)-c(x-a)|<\epsilon|x-a|$$
Another way we can write is
$$f^\prime(a)=\lim_{h\to 0}\frac{f(a+h)-f(a)}{h}$$
where $h\in I-a$.
\begin{example}
    1. The constant function is differentiable everywhere and has zero derivative everywhere.\\
    2. The identity function is differentiable everywhere and has derivative $1$.\\
    3. $f:(0,\infty)\to\mathbb R$ by $x\mapsto 1/x$ is differentiable and has derivative $f^\prime(a)=-a^{-2}$.\\
    4. (non-example) The function $x\mapsto |x|$ is not differentiable at $0$.
\end{example}
\begin{lemma}
    Suppose $f$ is differentiable at $a$ with derivative $f^\prime(a)$ iff
    $$f(a+h)=f(a)+f^\prime(a)h+\alpha(h)h$$
    where $\alpha(0)=0$ and $\alpha$ is continuous at $0$.
\end{lemma}
Note that given this formula, then $\alpha(h)$ is completely deterined by $f$ and $f^\prime(a)$.
\begin{proof}
    Obvious.
\end{proof}
\begin{corollary}
    $f$ is differentiable at $a$ implies $f$ is continuous at $a$.
\end{corollary}
\begin{proof}
    Follows directly.
\end{proof}
\begin{proposition}
    If $f,g:I\to\mathbb R$ are differentiable at some $a\in I$, so are $f+g,fg$ with derivatives $f^\prime(a)+g^\prime(a),f^\prime(a)g(a)+f(a)g^\prime(a)$ respectively.
\end{proposition}
\begin{proof}
    Trivial.
\end{proof}
\begin{theorem}[Chain Rule]
    Suppose $f:I_1\to I_2$ is differentiable at $a\in I_1$ and $g:I_2\to\mathbb R$ is differentiable at $f(a)$, then $(g\circ f)^\prime(a)=g^\prime(f(a))f^\prime(a)$.
\end{theorem}
\begin{proof}
    Let $b=f(a)$, then by our conditions,
    $$f(a+h)=f(a)+f^\prime(a)h+\alpha(h)h,g(b+k)=g(b)+g^\prime(b)k+\beta(k)k$$
    And $\alpha(0)=\beta(0)=0$ and they are both continuous at $0$.
    Take $k=f(a+h)-f(a)=f^\prime(a)h+\alpha(h)h$, so
    \begin{align*}
        (g\circ f)(a)&=g(b+k)\\
        &=g(b)+g^\prime(b)k+\beta(k)k\\
        &=g(b)+g^\prime(b)(f^\prime(a)h+\alpha(h)h)+\beta(f^\prime(a)h+\alpha(h)h)(f^\prime(a)h+\alpha(h)h)\\
        &=(g\circ f)(a)+g^\prime(f(a))f^\prime(a)h+\phi(h)h
    \end{align*}
    Where $\phi(h)=g^\prime(b)\alpha(h)+\beta(f^\prime(a)h+\alpha(h)h)(f^\prime(a)+\alpha(h))$ which is $0$ at $0$ and is continuous at $0$.
    The chain rule follows.
\end{proof}
\begin{corollary}
    Suppose $f,g:I\to\mathbb R$ are differentiable at $a$ and $g(a)\neq 0$, then $f/g$ is differentiable at $a$ and $(f/g)^\prime=(f^\prime g-fg^\prime)/g^2$.
\end{corollary}
\begin{proof}
    Immediate from the chain rule.
\end{proof}
\begin{corollary}
    The polynomial $p(x)=a_0+a_1x+\cdots+a_nx^n$ is differentiable at all $x\in\mathbb R$, and if $p,q$ are polynomials, $p/q$ is differentiable at $a$ when $q(a)\neq 0$.
\end{corollary}
\begin{proof}
    Trivial.
\end{proof}
\subsection{Mean Value Theorem}
Suppose we have some $f:I\to\mathbb R$.
\begin{definition}
    We say some $c\in I$ is a global maximum of $f$ if $\forall x\in I,f(x)\le f(c)$ and a global minimum if $\forall x\in I,f(x)\ge f(c)$.
\end{definition}
We know that if $I$ is a closed bounded interval, then $f$ has global maxima and minima.
\begin{definition}
    Some $c\in I$ is called a local maximum of $f$ if $\exists\epsilon>0,\forall x\in (c-\epsilon,c+\epsilon)\cap I,f(x)\le f(c)$.
    Similarly it is a local minimum if $\exists\epsilon>0,\forall x\in (c-\epsilon,c+\epsilon)\cap I,f(x)\ge f(c)$.
\end{definition}
\begin{definition}
    $c\in I$ is called an interior point of $I$ if $\exists \epsilon>0,(c-\epsilon,c+\epsilon)\subset I$.
\end{definition}
\begin{proposition}
    Suppose $f:I\to\mathbb R$ and $c$ is an interior point of $I$ where $f$ attains local maximum or local minimum at $c$ and $f$ is differentiable at $c$, then $f^\prime(c)=0$.
\end{proposition}
\begin{proof}
    Suffice to prove the local maximum case.
    Since $c$ is an interior point of $I$, we can choose $\epsilon'>0,(c-\epsilon',c+\epsilon')\subset I$.
    As $c$ is a local maximum, then there is some $\epsilon$ such that $0<\epsilon\le\epsilon'$ and that $\forall x\in (c-\epsilon,c+\epsilon),f(x)\le f(c)$.
    We can easily find sequences $(x_n^-)\in (c-\epsilon,c),(x_n^+)\in (c,c+\epsilon)$ both converging to $c$.
    Let $g:(c-\epsilon,c+\epsilon)\setminus\{c\}\to\mathbb R$ defined by $g(x)=(f(x)-f(c))/(x-c)$, then
    \begin{align*}
        0&\le\lim_{n\to\infty}\frac{f(x_n^-)-f(c)}{x_n^--c}\\
        &=\lim_{x\to c^-}g(x)=\lim_{x\to c}g(x)=\lim_{x\to c^+}g(x)\\
        &=\lim_{n\to\infty}\frac{f(x_n^+)-f(c)}{x_n^+-c} \le 0
    \end{align*}
    Hence $f^\prime(c)=\lim_{x\to c}g(x)=0$.
\end{proof}
\begin{theorem}[Rolle's Theorem]
    Suppose $f:[a,b]\to\mathbb R$ is continuous and is differentiable in $(a,b)$ and $f(a)=f(b)=0$, then there is some $c\in (a,b)$, $f^\prime(c)=0$.
\end{theorem}
\begin{proof}
    It is obvious if $f\equiv 0$, otherwise WLOG $f$ attains some positive value.
    Then let $c$ be a global maximum of $f$, then $c$ is a local maximum and an interior point of $f$ (since $f$ is zero on endpoints but we have assumed that $f$ attains some positive value), then $c\in (a,b)$ and we have $f^\prime(c)=0$ by the preceding proposition.
\end{proof}
\begin{theorem}[Mean Value Theorem]
    If $f:[a,b]\to\mathbb R$ is continuous on $[a,b]$ and differentiable on $(a,b)$, then there is some $c\in (a,b)$ with $f^\prime(c)=(f(b)-f(a))/(b-a)$.
\end{theorem}
\begin{proof}
    Let
    $$p(x)=\frac{1}{b-a}((x-a)f(b)-(x-b)f(a))$$
    which although looks dreadful is just a linear polynomial.
    Note that $p(a)=f(a),p(b)=f(b)$, so it is just a line joining the endpoints.
    Then $g(x)=f(x)-p(x)$ is continuous on $[a,b]$ and differentiable on $(a,b)$, so by Rolle's Theorem, there is some $c\in (a,b)$ sucb that
    $$0=g^\prime(c)=f^\prime(c)-\frac{f(b)-f(a)}{b-a}\implies f^\prime(c)=\frac{f(b)-f(a)}{b-a}$$
    As desired.
\end{proof}
\begin{proposition}
    Suppose $f:[a,b]\to\mathbb R$ is continuous and differentiable in $(a,b)$.\\
    1. $f^\prime\equiv 0\iff f$ is constant.\\
    2. $f^\prime\ge 0\iff f$ is increasing.\\
    3. $f^\prime>0\implies f$ is strictly increasing.
\end{proposition}
\begin{proof}
    Immediate from Mean Value Theorem.
\end{proof}
Note that the converse of the third statement is false in general.
E.g, $f(x)=x^3$.\\
Note that all these depends on the least upper bound property since we used the Mean Value Theorem which depends on Rolle's Theorem which depends on maximum value theorem which depends on Bolzano-Weierstrass Theorem which depends on the Monotone Sequence Theorem which depends on the least-upper-bound property.
\subsubsection{Inverse Function Theorem}
\begin{lemma}
    If $f:[a,b]\to\mathbb R$ satisfies $f^\prime(x)>0$ for all $x\in [a,b]$, then $f:[a,b]\to[f(a),f(b)]$ is a bijection.
\end{lemma}
\begin{proof}
    Injectivity is obvious by Mean Value Theorem.
    For surjectivity we can just exploit Intermediate Value Theorem.
\end{proof}
\begin{lemma}
    Let $I$ be an interval.
    Suppose $f:I\to f(I)$ is a continuous bijection, then $f^{-1}:f(I)\to I$ is also continuous.
\end{lemma}
\begin{proof}
    Just check definition.
\end{proof}
\begin{theorem}[Inverse Function Theorem]
    Suppose $I\subset R$ is an interval and $f^\prime(x)>0$ for any $x\in I$, then the continuous inverse (exists by the preceding lemmas) $f^{-1}:f(I)\to I$ is differentiable and $(f^{-1})^\prime(y)=1/f^\prime(f^{-1}(y))$.
\end{theorem}
\begin{example}
    1. $f:x\mapsto x^n$ on $(0,\infty)$ satisfies the conditions, so its inverse $f^{-1}:y\mapsto y^{1/n}$ has $(f^{-1})^\prime(y)=(1/n)y^{1/n-1}$.\\
    2. Consider $\tan:(-\pi/2,\pi/2)\to\mathbb R$, it shall be invertible with differentiable inverse $\tan^{-1}$, then we can calculate, by the formula, that $(\tan^{-1})(y)=1/(y^2+1)$
\end{example}
\begin{proof}[Proof assuming differentiability]
    Assuming $f^{-1}$ is differentiable, then we know that $f(f^{-1}(y))=y$, then by the chain rule, we get $f^\prime(f^{-1}(y))(f^{-1})^\prime(y)=1$, rearrange to give the formula.
\end{proof}
\begin{proof}[Actual proof]
    Fix $b\in f(I)$ and let $a=f^{-1}(b)$.
    Suppose $(y_n)$ is a sequence in $f(I)\setminus \{b\}$ with $y_n\to b$, and let $x_n=f^{-1}(y_n)$.
    We know that $f$ is differentiable hence continuous, so $f^{-1}$ is continuous by the preceding lemma.
    Therefore $x_n=f^{-1}(y_n)\to f^{-1}(b)=a$.
    Since we know that
    $$\lim_{x\to a}\frac{f(x)-f(a)}{x-a}=f^\prime(a)$$
    We have
    $$\frac{f(x_n)-f(a)}{x_n-a}\to f^\prime(a)$$
    By hypothesis, $f^\prime(a)\neq 0$, so
    $$\frac{f^{-1}(y_n)-f^{-1}(b)}{y_n-b}=\frac{x_n-a}{f(x_n)-f(a)}\to\frac{1}{f^\prime(a)}=\frac{1}{f^\prime(f^{-1}(b))}$$
    which is true for every sequence $y_n\to b$, so the theorem is proved.
\end{proof}
\subsubsection{L'H\^opital's Rule}
\begin{proposition}[L'H\^opital's Rule]
    Suppose $f,g:I\to\mathbb R$ are differentiable with $f(a)=g(a)=0$, and $\exists r>0, g(x)\neq 0\neq g^\prime(x)$ for $0<|x-a|<r$.
    Then if $\lim_{x\to a}f^\prime(a)/g^\prime(a)$ exists and equals $k$, then
    $$\lim_{x\to a}\frac{f(x)}{g(x)}=k$$
\end{proposition}
\begin{proof}
    Suppose $x\in I$ and $x>a$.
    Consider $h(t)=f(t)g(x)-f(x)g(t),t\in [a,x]$.
    Since $f,g$ are differentiable and we have $h(a)=h(a)=0$, so by Rolle's Theorem, there is some $c\in (a,x)$ with $f^\prime(c)g(x)-f(x)g^\prime(c)=h^\prime(c)=0$.
    Therefore
    $$\frac{f^\prime(c)}{g^\prime(c)}=\frac{f(x)}{g(x)}$$
    Same for $x<a$.\\
    Given $\epsilon>0$, choose $\delta>0$ such that
    $$0<|c-a|<\delta\implies\left|\frac{f^\prime(c)}{g^\prime(c)}-k\right|<\epsilon$$
    So when $0<|x-a|<\delta$, one can find $c$ such that $0<|c-a|<|x-a|<\delta$ and $f^\prime(c)/g^\prime(c)=f(x)/g(x)$, which means that
    $$\left|\frac{f(x)}{g(x)}-k\right|=\left|\frac{f^\prime(c)}{g^\prime(c)}-k\right|<\epsilon$$
    which is as we wanted.
\end{proof}
\subsection{Higher Derivatives and Taylor Series}
\begin{definition}
    We say (inductively) that $f:I\to\mathbb R$ is $k$ times differentiable with $k^{th}$ derivative $f^{(k)}$ if $f$ is $(k-1)$ times differentiable with differentiable $(k-1)^{th}$ derivative $f^{(k-1)}$ and $f^{(k-1)})^\prime=f^{(k)}$.
\end{definition}
\begin{example}
    A polynomial is $k$ times differentiable for any $k\in\mathbb N$.
\end{example}
\begin{definition}
    We say $f$ is $C^k$ if $f$ is $k$ times differentiable and $f^{(k)}$ is continuous.
\end{definition}
\begin{example}[Non-example]
    Consider
    $$f(x)=\begin{cases}
        x^2\sin(1/x)\text{, for $x\neq 0$}\\
        0\text{, for $x=0$}
    \end{cases}$$
    So one can verify that $f$ is differentiable but the derivative, namely,
    $$f^\prime(x)=\begin{cases}
        2x\sin(1/x)-\cos(1/x)\text{, for $x\neq 0$}\\
        0\text{, for $x=0$}
    \end{cases}$$
    is not continuous at $0$.
\end{example}
Now, given $f:I\to\mathbb R$, we want a degree $k$ polynomial that best approximates $f$.
The answer depends on the meaning of ``best''.
We can either calculate the total squared difference (we have not defined it and will not care about it), but on the other hand, the theory of differentiation hints that
$$f(x)=f(a)+f^\prime(a)(x-a)=P_1(x)$$
is the best linear approximation of $f$ around $a$.
Why ``around $a$''?
say for example we want to approximate $\sin x$ over a large interval, then the best approximation intuitively might be a line with slope very close to $0$, which is obviously not the tangent at, e.g., $0$.
And we are only interested in the best approximation close to $a$.\\
Now back to our best linear approximation.
The reason we say it is the ``best'' in the sense that $f(x)-P_1(h)=\alpha(h)h$ with $\alpha(0)=0$ and $\alpha$ is continuous at $0$.
We can also easily know that such a $P_1$ is unique so as for such an $\alpha$ to exist by working out their coefficients by substitution and differentiating (with appropriate comments on differentiability, of course).
More generally, for a sufficiently smooth $f$, we can try to approximate $f(a+h)=P_k(a+h)+h^k\alpha(h)$ where $\alpha(0)=0$ and $\alpha$ is continuous at $0$ and $P_k$ is a polynomial.
Using the same trick, such an $P_k$ is unique.
In particular, we obtain $P_k^{(r)}=f^{(r)}$ for any $r\le k$.
\begin{lemma}
    If $a,c_0,c_1,\ldots,c_k\in\mathbb R$, then there is a unique degree $k$ polynomial $P$ with $P^{(i)}(a)=c_i$.
\end{lemma}
\begin{proof}
    Write out $P(x)=a_0+a_1(x-a)+\cdots+a_k(x-a)^k$ and differentiating gives $i!a_i=c_i=P^{(i)}(a)$, so the polynomial is uniquely determined.
\end{proof}
\begin{definition}
    Given $f:I\to\mathbb R$ which is $k$ times differentiable and $a$ is an interior point of $I$, then the $k^{th}$ Taylor polynomial of $f$ centered at $a$ is
    $$P_k(x)=\sum_{i=0}^k\frac{f^{(i)}(a)}{i!}(x-a)^i$$
    which is chosen such that $P_k^{(i)}(a)=f^{(i)}(a)$.
\end{definition}
\begin{remark}
    $P_k(x)$ is the unique polynomial with degree at most $k$ having the property $P_k^{(i)}(a)=f^{(i)}(a)$ by the preceding lemma.
\end{remark}
\begin{theorem}[Taylor's Theorem with Remainder]
    Suppose $f:I\to\mathbb R$ is $(k+1)$ times differentiable, and $[a,x]\subset I$, then
    $$f(x)=\left(\sum_{i=0}^k\frac{f^{(i)}(a)}{i!}(x-a)^i\right)+\frac{f^{(k+1)}(c)}{(k+1)!}(x-a)^{k+1}$$
    for some $c\in (a,x)$.
\end{theorem}
For $k=0$, this reduces to the mean value theorem.
\begin{proof}
    Fix $x>a$ and define
    $$g(t)=f(t)+\sum_{i=1}^k\frac{f^{(i)}(t)}{i!}(x-t)^i+\alpha\frac{(x-t)^{k+1}}{(k+1)!}$$
    where $\alpha$ is chosen such that $g(a)=f(x)$ (which exists as a solution to a nondegenerate linear equation).
    Our goal is to find $c\in (a,x)$ such that $f^{(k+1)}(c)=\alpha$.
    We have, by definition,
    $$f(x)=g(a)=f(a)+\sum_{i=1}^k\frac{f^{(i)}(a)}{i!}(x-a)^i+\alpha\frac{(x-a)^{k+1}}{(k+1)!}$$
    Now $f$ is $k+1$ times differentiable so $g$ is differentiable and $g(a)=f(x)=g(x)$, so by Rolle's Theorem, there is some $c\in (a,x)$ such that $g^\prime(c)=0$.
    But we have
    $$g^\prime(t)=f^\prime(t)+\sum_{i=1}^k\left(\frac{f^{(i+1)}(t)}{i!}(x-t)^i-\frac{f^{(i)}(t)}{(i-1)!}(x-t)^{i-1}\right)-\alpha\frac{(x-t)^k}{k!}$$
    The first part of this expression is telescoping, so we can simplify it to
    $$g^\prime(t)=(f^{(k+1)}(t)-\alpha)\frac{(x-t)^k}{k!}$$
    Now plugging in $t=c$ shows $f^{(k+1)}(c)=\alpha$, which completes the proof.
\end{proof}
If $f$ is infinitely differentiable, one can then form the Taylor series
$$\sum_{i=0}^\infty\frac{f^{(i)}(a)}{i!}(x-a)^i$$
as the formal limit of the Taylor polynomilas $P_k(x)$, which sometimes does converge and equals $f$.
If we understand the derivatives of $f$ well-enough and that those derivatives do behave nicely, then it is sometimes possible to use Taylor's Theorem to prove that
$$p(x)=\lim_{n\to\infty}P_n(x)=f(x)$$
\begin{example}
    Take $f(x)=\cos x$ (which, albeit hasn't been properly defined, we shall assume standard facts about), then the Taylor series about $0$ is
    $$1-\frac{x^2}{2!}+\frac{x^4}{4!}-\frac{x^6}{6!}+\cdots=\sum_{n=0}^\infty(-1)^n\frac{x^{2n}}{(2n)!}$$
    The series always converges by the ratio test.
    Must the series converges to $\cos x$ then?
    The $(2k)^{th}$ partial sum of the series is exactly $P_{2k}(x)$ of $\cos$ about $0$, then there is $c\in (0,x)$ with
    $$|f(x)-P_{2k}(x)|=\left|\frac{f^{2k+1}(c)}{(2k+1)!}x^{2k+1}\right|\le\frac{|x|^{2k+1}}{(2k+1)!}\to 0$$
    as $k\to\infty$, so the series does converge to $\cos x$.
\end{example}
\begin{definition}
    We say $f:I\to\mathbb R$ is $C^\infty$ (or smooth) if $f$ is $C^k$ for all $k\in\mathbb N$.
\end{definition}
So for a smooth $f:I\to\mathbb R$, one can form the Taylor series (formally)
$$\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$$
But even if the series converges for all $x\in I$, it may not converge to $f(x)$ for $x\neq a$.
Philosophically, one cannot fully expect that the behaviour of $f$ near $a$ control its global behaviour.
\footnote{For complex-valued functions, however, the local behaviour of a nice enough function $f$ can be controlled by its local properties.}
Indeed, for $f_1,f_2:\mathbb R\to\mathbb R$ smooth and $a<b$, it is possible to construct some smooth $f:\mathbb R\to\mathbb R$ such that $f|_{<a}=f_1|_{<a}$ and $f|_{>b}=f_2|_{>b}$.
This will be proven in example sheet.
\subsection{Complex Differentiation}
\begin{definition}
    If $c\in\mathbb C,r\in[0,\infty)$, we define the open ball of radius $r$ centered at $c$ by $B_r(c)=\{z\in\mathbb C:|z-c|<r\}$.
\end{definition}
\begin{definition}
    A subset $\Omega\subset\mathbb C$ is open if $\forall c\in\Omega,\exists\epsilon>0,B_\epsilon(c)\subset\Omega$.
\end{definition}
\begin{example}
    1. $\mathbb C,\varnothing$ are open.\\
    2. Open balls are open.\\
    3. (non-example) $\{z\in\mathbb C:|z-a|\le r\}$ is not open, but its complement is.
\end{example}
\begin{definition}
    Suppose $\Omega\in\mathbb C$ is open and $c\in\Omega$.
    For a function $f:\Omega\to\mathbb C$, we say $f$ is complex differentiable at $c$ if
    $$\lim_{z\to c}\frac{f(z)-f(c)}{z-c}$$
    exists.
    In case it does exist, we write it as $f^\prime(c)$.
\end{definition}
All the rules in real differentiation still applies, but we don't really have mean value theorem.
We can write $f(x+iy)=u(x,y)+iv(x,y)$ where $u,v:\tilde{\Omega}\to\mathbb R$ where $\tilde{\Omega}=\{(x,y)\in\mathbb R^2:x+iy\in\Omega\}$.
\begin{definition}
    Say $\tilde{\Omega}$ is open if $\Omega$ is.
    Then the partial derivatives of $F:\tilde{\Omega}\to\mathbb R$ at $(a,b)\in\tilde{\Omega}$ are
    \begin{align*}
        \left.\frac{\partial F}{\partial x}\right|_{(a,b)}&=\lim_{h\to 0}\frac{F(a+h,b)-F(a,b)}{h}\\
        \left.\frac{\partial F}{\partial y}\right|_{(a,b)}&=\lim_{h\to 0}\frac{F(a,b+h)-F(a,b)}{h}
    \end{align*}
    Provided that they exist.
\end{definition}
Alternatively we can define $g_b=F(x,b)$ and so
$$\left.\frac{\partial F}{\partial x}\right|_{(a,b)}=g^\prime_b(a)$$
Similar for the other component.
\begin{proposition}
    If $f:\Omega\to\mathbb C$ is complex differentiable at $c=a+ib$ with derivative $f^\prime(c)=\alpha+i\beta$, then the partial derivatives of $u,v$ at $(a,b)$ exist and satisfy
    \begin{align*}
        \left.\frac{\partial u}{\partial x}\right|_{(a,b}&= \left.\frac{\partial v}{\partial y}\right|_{(a,b)}=\alpha\\
        -\left.\frac{\partial u}{\partial y}\right|_{(a,b}&=\left.\frac{\partial v}{\partial x}\right|_{(a,b)}=\beta
    \end{align*}
\end{proposition}
\begin{proof}
    For any sequence $h_n\to 0$ in $\mathbb R\setminus\{0\}$, then it is also a sequence in $\mathbb C\setminus\{0\}$, so since $f$ is differentiable at $c$,
    \begin{align*}
        \alpha+i\beta&=f^\prime(c)\\
        &=\lim_{h\to 0}\frac{f(c+h)-f(c)}{h}\\
        &=\lim_{n\to\infty}\frac{u(a+h_n,b)-u(a,b)}{h_n}+i\lim_{n\to\infty}\frac{v(a+h_n,b)-v(a,b)}{h_n}
    \end{align*}
    So $\partial u/\partial x$ and $\partial v/\partial x$ exist and are $\alpha,\beta$ respectively.
    We can get the other half of the equations by replacing $h_n$ by $ih_n$ and casting exactly the same argument.
\end{proof}
\begin{remark}
    If $f:\Omega\to\mathbb C$ is complex differentiable, then (assuming $C^1$ partial derivatives and symmetry of partial derivatives)
    $$\frac{\partial^2u}{\partial x^2}+\frac{\partial^2u}{\partial y^2}=0$$
    which is the Laplace Equation.
\end{remark}
\begin{proposition}
    Suppose $F:B_r((a,b))\to\mathbb R$ has partial derivatives with
    $$\frac{\partial F}{\partial x}=\frac{\partial F}{\partial y}=0$$
    then $F$ is constant.
\end{proposition}
\begin{proof}
    For $(a',b')\in B_r((a,b))$, we consider the functions $f_b(x)=F(x,b)$ and $f_a(x)=F(a',x)$ on the reals.
    Then they are differentiable and using mean value theorem on $f_b$ wrt $a,a'$ shows $f(a,b)=f(a',b)$, and using it again on $f_a$ wrt $b,b'$ shows $f(a',b)=f(a',b')$, so $f(a,b)=f(a',b')$.
\end{proof}
\begin{corollary}
    If $f:B_r(c)\to\mathbb C$ has derivative zero, then $f$ is constant.
\end{corollary}
\begin{proof}
    Immediate.
\end{proof}
\begin{remark}
    Complex differentiable functions $f:\mathbb C\to\mathbb C$ behave very nicely.
    Firstly, if $f$ is complex differentiable, so is $f^\prime$, consequently $f$ is $C^\infty$.
    Even better, its Taylor series always converges to itself.
    Secondly, if $f$ is bounded then $f$ is constant.
\end{remark}


\section{Notation}

A Markov decision process (MDP) $\mdp$ consists of a tuple $(\mathcal{S}, \mathcal{A}, P, R, \gamma, s_0)$, where $\mathcal{S}$ is the state space, $\mathcal{A}$ is the action space, $P$ is the transition function mapping $\mathcal{S} \times \mathcal{A}$ to distributions on $\mathcal{S}$, $R$ is the scalar reward function on $\mathcal{S} \times \mathcal{A}$, $\gamma$ is the discount factor, and $s_0$ is the starting state.
Note that a single start state can be converted to a start distribution by letting $P(s_0, \cdot)$ be independent of the action taken.
% This work focuses on the episodic setting, where after some number of steps $T$
An \emph{agent} interacts with an MDP by producing a policy $\pi$ at each timestep and observing the transitions it visits.

The \emph{value} of a state $s$ for a policy $\pi$ is the (discounted) sum of future rewards obtained by running that policy starting from the state $s$:
\begin{align}
    V^{\pi}(s) = \E_{\substack{a_t \sim \pi(\cdot \mid s_t) \\ s_{t+1} \sim P(s_t, a_t)}} \sum_{t=0}^\infty \gamma^t R(s_t, a_t) ~\big|~ s_0=s
\end{align}
Similarly the value of a state-action pair $(s, a)$ is written as
\begin{align}
    Q^{\pi}(s, a) = \E_{\substack{a_t \sim \pi(\cdot \mid s_t) \\ s_{t+1} \sim P(s_t, a_t)}} \sum_{t=0}^\infty \gamma^t R(s_t, a_t) ~\big|~ s_0=s, a_0 = a
\end{align}
Any MDP admits a deterministic optimal policy $\pi^*$ with corresponding value functions $V^*$ and $Q^*$ such that $V^*(s) \ge V^\pi(s)$ for all $s$ and $\pi$ \citep{sutton2018reinforcement}.

\section{Discounting and Resets}

When $\gamma < 1$ we say that the setting is \emph{discounted}, and for $\gamma = 1$ we say that it is \emph{undiscounted}.
An environment may have a time limit $T$ such that after every $T$ steps, the state is reset to $s_0$.
In this case we call it \emph{episodic}.
To satisfy the Markov property, episodic environments should include the current timestep $t$ in the state.

For episodic environments, it is natural to define a policy's quality in terms of the total reward earned (on average) in a single episode, with discounted environments preferring rewards obtained earlier in the episode.
For non-episodic environments comparisons between policies are less clear-cut; see Section 2 of \citet{strehl2008analysis} for a discussion.

Common practice in deep reinforcement learning is to train agents with discounting and resets, but not include the timestep in the state observations and simply ignore the transition from $s_T$ to $s_0$.
Policies are typically evaluated by the total undiscounted reward in an episode, despite the conflict with the training setup.
In most cases the rewards are truncated to reflect the limited episode duration \citep{schulman2017proximal,Fujimoto2018AddressingFA,haarnoja2018soft}.
Since the agent is unable to tell when an episode will end, this effectively introduces noise into value prediction targets, and this noise varies by state depending on how often the agent has ended an episode on that state.
In other cases value targets may be bootstrapped from the state $s_T$ as if the environment were not episodic.
This has two issues: (1) it introduces bias by treating an estimate of $V(s_T)$ as the true value, when in some states and environments this estimate may never be updated; and (2) by pretending the environment has no resets, it introduces a mismatch between the training and test objectives.\endnote{This mismatch is decreased if the divergence between the distributions $P(s_T, \pi(\cdot \mid s_T))$ and $s_0$ is smaller. Like most problems in RL, it also becomes smaller if smaller discount factors are used. However in general there are actions which would provide more short-term reward, and thus perform better toward the end of an episode, than the infinite-horizon optimal actions.}
However, it does not introduce noise.

More fundamentally, practically all discounted policy gradient algorithms drop the discounting term from the state distribution.
\citet{Nota2020IsTP} show that this results in following a direction which is not the gradient of any function, and which is not guaranteed to converge to a good solution with respect to the discounted or undiscounted objectives.
While this is deeply worrying, these methods frequently work well in practice.
This may be due to their usage with overparameterized neural network models, which are largely invariant to a reweighting of the data \citep{byrd2018effect,brandfonbrener2021offlinecontextual}.

% This thesis focuses on the episodic setting.
% Following common practice in deep reinforcement learning, agents are trained with algorithms which use $\gamma < 1$, but evaluated according to the total reward earned in an episode.

\section{Defining Sample Complexity}

We say that a policy $\pi$ is $\varepsilon$-optimal if $V^*(s_0) \le V^\pi(s_0) + \varepsilon$.
Define $\bm{\pi} = A(\mdp, i)$ to be the policy obtained by running the agent (i.e. algorithm) $A$ in the environment $\mdp$ for $i$ timesteps, being careful to note that the policy $\bm{\pi}$ is itself a random variable due to the randomness in the experience collected in those $i$ steps.
Let the \emph{sample complexity} of learning a $\varepsilon$-optimal policy on $\mdp$ with $A$ be the expected number of steps (indexed as $i$) such that
\begin{align}
    V^{\pi_i}(s_0) < V^*(s_0) - \varepsilon, && \text{where } \pi_i = A(\mdp, i).
\end{align}
This definition is related to those proposed by \citet{Fiechter1994EfficientRL} and \citet{strehl2008analysis} for PAC learning.
Sometimes it is also useful to consider the "anytime" performance of an algorithm $A$ on an MDP $\mdp$.
An algorithm $A_1$ would dominate $A_2$ if $\forall i$, $V^{A_1(\mdp, i)}(s_0) \ge V^{A_2(\mdp, i)}(s_0)$.

\section{Online and Deployment Settings} \label{sec:regret-deployment}

While the overall MDP framework is largely shared in the community, several different objectives for a learning agent are commonly studied.
The online and offline settings are perhaps the most studied in the theory community, but the "learn-and-deploy" setting has the most relevance for present applications of RL.

\paragraph{The online setting.}
% \side{talk about sample complexity}
Here an RL agent learns by continually interacting with the environment with the goal of maximizing the total reward earned across all time.
This gives rise to the explore-exploit tradeoff when acting: at each moment, the agent may choose to take an action which is uninformative but leads to greater short-term reward, or one which will yield more information at the cost of lower reward.
The objective for this setting is to minimize the rate of accumulation of \emph{regret}, which measures the difference between the total reward obtained by an optimal policy and the agent:
\begin{align}
    L(A, \mdp, T) = \E \left[ \sum_{i=1}^T R(s^*_i, a^*_i) - R(s_i, a_i) \right].
\end{align}
This setting is appropriate when an agent is being trained "on the job," where mistakes early in learning have just as much deleterious effect as those made later.
In this context, sample efficiency controls the total amount of regret the agent will accumulate.

\paragraph{The learn-and-deploy setting.}
% \side{talk about sample complexity}
This setting consists of distinct learning and deployment phases.
In the learning phase, the agent is not required to perform well and may collect whatever data is most informative.
In the deployment phase, the policy is fixed and should be as close to optimal as possible.
Note that the policy produced at the end of the training procedure need bear no resemblance to those used to collect data.
For episodic environments, with a training period consisting of $N$ steps we can write the this objective as
\begin{align}
    L(A, \mdp, N) = V^*(s_0) - V^{\pi_N}(s_0), && \text{where } \pi_N = A(\mdp, N)
\end{align}
Historically this setting has not been much discussed, though it is analagous to the task of best-arm identification in bandits \citep{Russo2016SimpleBA,Kaufmann2016OnTC}.
It is also related to the iterative technique of fitted Q iteration \citep{Ernst2005TreeBasedBM,Riedmiller2005NeuralFQ}.

Crucially, this setting is the one used in practice in nearly every application of reinforcement learning.
RL algorithms are not yet safe and reliable enough to allow them to update a policy on the fly, especially with a physical system which may be damaged or cause injury.
Furthermore, most works studying RL implicitly provide results in this setting by evaluating according to a different policy than the one used for training, for example showing learning curves with a deterministic policy \citep{Mnih2015HumanlevelCT,Lillicrap2016ContinuousCW,Fujimoto2018AddressingFA,haarnoja2018soft}.
Comparisons of final, large-data performance similarly reflect this setting \citep{Silver2016MasteringTG,Vinyals2019GrandmasterLI,openai2019dota,OpenAI2019SolvingRC}.

In this setting, sample efficiency reflects the amount of data the agent needs to collect during training time before it can perform near-optimally at deployment time.

\paragraph{The offline setting.}
% \side{talk about sample complexity}
Also known as the \emph{batch} setting, this consists only of pure policy optimization given a fixed dataset of environment interactions collected by an extrinsic behavior policy.
After learning from this data in whatever way it sees fit, an algorithm produces a fixed policy with the objective of earning as much reward as possible.
Though described as a reinforcement learning setting, it does not include any actual reinforcement as the agent never learns from its own interactions with the environment.
However, this makes the offline RL setting uniquely valuable for isolating how much can be learned from particular data.
This setting is also appealing as it would in principle allow an agent to be trained in a risk-free way by using data collected from a safe policy, and for free (in terms of samples) if data from one experiment can be repurposed as training data for another.\endnote{While there are doubtless some settings where this cross-task data reuse is possible, it has quite clear limits. For a policy to be trained to solve task B using data collected from task A, the policy used for task A would have had to actually also solve task B. It could have been done piecewise rather than in a single good trajectory, but unless the tasks are extremely similar it is vanishingly unlikely. Perhaps a more practical application would be to start with a safe but poor policy for solving a task, then incrementally collect new data, refine the policy using offline RL, validate that the new policy is also safe, and then collect data once more.}
For this setting, sample efficiency must be redefined to include the behavior policy under which the data was collected.
It then reflects the minimum amount of data collected under that behavior policy required for a particular algorithm to recover the optimal policy.\endnote{Note that this quantity of data should be expected to be extraordinarily large for most behavior policies.}

% \side{break into \textbackslash paragraphs}
% \side{write math definitions}
% \side{write sample complexity definitions}
% \begin{itemize}
%     \item The \emph{online} or \emph{regret} setting.

%     \item The \emph{learn-and-deploy} setting.
%     \side{Need a better name for learn-and-deploy}
%     This setting consists of distinct learning and deployment phases. In the learning phase, the agent is not required to perform well and may collect whatever data is most informative. In the deployment phase, the policy is fixed and should be as close to optimal as possible. This setting schematically breaks down into pure data collection followed by pure policy optimization, though in practice policy optimization is an essential tool during exploration.
%     \item The \emph{offline} or \emph{batch} setting.
%     This consists only of pure policy optimization given a fixed dataset of environment interactions collected by an extrinsic behavior policy. After learning from this data in whatever way it sees fit, an algorithm produces a fixed policy with the objective of earning as much reward as possible. Though described as a reinforcement learning setting, it does not include any actual reinforcement as the agent never learns from its own interactions with the environment. However, this makes the offline RL setting uniquely valuable for isolating how much can be learned from particular data.
% \end{itemize}

% \side{Do I want a section on simulated versus physical envs?}
% \section{Simulated and Physical Environments}

\printendnotes


\documentclass{article}

\usepackage{blindtext}
\usepackage{multicol}
\usepackage{caption}
\usepackage{bm}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan,
}
\usepackage{geometry}
\geometry{
	a4paper,
	noheadfoot=true,
	left=1.0in,
	right=1.0in,
	top=1.0in,
	bottom=1.0in
}

% url package
\usepackage{hyperref}
\usepackage{subcaption}

% Titling and Author
\title{Latex Tikz Examples, Annotate on Graph}
\author{\href{https://fanwangecon.github.io/}{Fan Wang}\thanks{https://fanwangecon.github.io, repository: \href{https://fanwangecon.github.io/Tex4Econ/}{Tex4Econ}}}
\date{\today}

\begin{document}

\maketitle

\section{Annotate Text in Figure}

\subsection{Slope and Intercept Annotate}

Draw axis below, and a line, middle of page, and annotate the slope of the intercept with arrows. Annotate with box without color.

\begin{verbatim}
\begin{center}
\begin{tikzpicture}
\draw (0,2) -- (0.25*\textwidth,2);
\draw (0,1) -- (0.5*\textwidth,1);
\end{tikzpicture}
\end{center}
\end{verbatim}
\bigskip
\begin{center}
\begin{tikzpicture}
\draw[->] (-1,0) -- (6,0) node[right] {$N_m$};
\draw[->] (0,-1) -- (0,6) node[above] {$N_{m^{\prime}}$};

% A. Clip area so that line below is only drawn inside finite box
\clip (-3,-1) rectangle (6,6);

% B. Draw a line with intercept and slope
\draw[line width=0.50mm,domain=-1:6,smooth,variable=\x, blue] plot ({\x},{1+\x*1.25});

% C. Draw Line pointing to Intercept of line
\draw[->, line width=0.75mm] (-1.7,2.2) -- (-0.1,1.1);

% D. Draw a transparent text box that wraps text
\node[text width=3cm] at (-1.4,3.25) {\large{$\bm{\alpha_i}$ (this is the position of the \textbf{x-intercept}), wrap text.}};

\end{tikzpicture}
\end{center}

\subsection{Anote Slope, X intercept and Y intercept}

Draw a line, then point to its slope, x and y intercepts.

\begin{enumerate}
  \item Define the slope and y-intercept: $a_i, b_i$
  \item Define and calculate the x-intercept: $c_i = -\frac{a_i}{b_i}$
  \item Define the text that should appear for each element: $a_{desca}$
  \item Drawing lines pointing to $a$, $b$ or $c$ points:
  \begin{itemize}
    \item direction: $d_i \in \left\{NE, SE, SW, NW\right\}$
    \item rotation: $0 <= e_i <= 90$, which direction points to text
    \item dist one: $f_i > 0 $, straight distance from origin
    \item dist two: $g_i > 0 $, distance of line
    \item point start: $h^o_i, h^o_i$, starting point based on the four pieces of information
    \item point end: $h^d_i, h^d_i$, ending point based on the four pieces of information
  \end{itemize}
\end{enumerate}

So end up drawing using $a$, $b$ for line, $h^o$ for one point $h*d$ line small segment.

\begin{verbatim}
\end{verbatim}
\bigskip
\begin{center}
\begin{tikzpicture}
\draw[->] (-1,0) -- (6,0) node[right] {$N_m$};
\draw[->] (0,-1) -- (0,6) node[above] {$N_{m^{\prime}}$};

% A. Clip area so that line below is only drawn inside finite box
\clip (-3,-1) rectangle (6,6);

% B. Draw a line with intercept and slope
\draw[line width=0.50mm,domain=-1:6,smooth,variable=\x, blue] plot ({\x},{1+\x*1.25});

% C. Draw Line pointing to Intercept of line
\draw[->, line width=0.75mm] (-1.7,2.2) -- (-0.1,1.1);

% D. Draw a transparent text box that wraps text
\node[text width=3cm] at (-1.4,3.25) {\large{$\bm{\alpha_i}$ (this is the position of the \textbf{x-intercept}), wrap text.}};

\end{tikzpicture}
\end{center}

\end{document}


\section{Current Operator in Landau Levels}

Now consider about the current density operator for $N$th Landau level. Since we have already found the extact solution for our time depenedent Hamiltonian and we have identify them as Floquet states with quesi energies. From these solutions we can identify the \textit{Floquet modes} as given in Eq. \eqref{3.15} and using quantum numbers we can represent those states as follows
\begin{equation} \label{6.1}
  \ket{\phi_{\alpha}} = \ket{\phi_{n,m}} \equiv \ket{n,k_x} \quad
  \text{where} \quad
  k_x = m \frac{2\pi}{L_x}
\end{equation}
Using above complete set of eigenstates of Floquet Hamiltonian we can represent the single particle current operator's matrix element as
\begin{equation} \label{6.2}
  \qty(\mb{j})_{nm,n'm'} = \mel{n,k_x}{\;\hat{\mb{j}}\;}{n',k'_x}
\end{equation}
where particle current operator for this system will be
\begin{equation} \label{6.3}
  \hat{\mb{j}} = \frac{1}{m} \qty(\hat{\mb{P}} - e\qty[\mb{A}_s + \mb{A}_d(t)]).
\end{equation}
Let's consider the transverse conductivity in $x$ direction and we can identify that $x$ directional current operator as
\begin{equation} \label{6.4}
  \hat{j}_x = \frac{1}{m} \qty(-i\hbar\pdv{x} + eBy).
\end{equation}
Now we can calculate the matrix elements of $x$ directional current operator's matrix in Floquet mode basis as
\begin{equation} \label{6.5}
  \qty({j}_x)_{nm,n'm'} = \mel{n,k_x}{\;\hat{j}_x\;}{n',k'_x} =
  \mel{n,k_x}{\;\frac{1}{m} \qty(-i\hbar\pdv{x} + eBy)\;}{n',k'_x}
\end{equation}
and we can evaluate these using Floquet modes derived in Eq.\eqref{3.15} as follows
\begin{equation} \label{6.6}
  \begin{aligned}
    \qty({j}_x)_{nm,n'm'} & =
    \int dx \int dy \;
    \frac{1}{\sqrt{L_x}} \chi_{n}\big(y - y_0 - \zeta(t)\big)
    \exp(-ik_x x) \\
    & \times
    \frac{1}{m} \qty(-i\hbar\pdv{x} + eBy)
    \frac{1}{\sqrt{L_x}} \chi_{n'}\big(y - y_0 - \zeta(t)\big)
    \exp(i k'_x x)
  \end{aligned}
\end{equation}
and this can be simplified as
\begin{equation} \label{6.7}
  \begin{aligned}
    \qty({j}_x)_{nm,n'm'} & =
    \frac{1}{{mL_x}}
    \int dx \exp(-i(k_x-k'_x) x)
    \int dy \;
     \chi_{n}\big(y - y_0 - \zeta(t)\big) \\
    & \times
    \qty(\hbar k'_x + eBy)
    \chi_{n'}\big(y - y_0 - \zeta(t)\big)
  \end{aligned}
\end{equation}
and
\begin{equation} \label{6.8}
  \begin{aligned}
    \qty({j}_x)_{nm,n'm'} & =
    \frac{1}{{m}}
    \delta_{k_x,k'_x}
    \int dy \;
    \qty(\hbar k'_x + eBy)
     \chi_{n}\big(y - y_0 - \zeta(t)\big)
    \chi_{n'}\big(y - y_0 - \zeta(t)\big).
  \end{aligned}
\end{equation}
Now let $y - y_0 - \zeta(t) = \bar{y}$ and we will get
\begin{equation} \label{6.9}
  \begin{aligned}
    \qty({j}_x)_{nm,n'm'} & =
    \frac{1}{{m}}
    \delta_{k_x,k'_x}
    \int d\bar{y} \;
    \qty(\hbar k'_x + eB\bar{y} + eBy_0 + eB\zeta(t))
     \chi_{n}(\bar{y})
    \chi_{n'}(\bar{y}).
  \end{aligned}
\end{equation}
using definition of $y_0$ given in Eq. \eqref{1.11} this will be modiofied to
\begin{equation} \label{6.10}
  \begin{aligned}
    \qty({j}_x)_{nm,n'm'} & =
    \frac{1}{{m}}
    \delta_{k_x,k'_x}
    \int d\bar{y} \;
    \qty(\hbar k'_x + eB\bar{y} -\hbar k'_x + eB\zeta(t))
     \chi_{n}(\bar{y})
    \chi_{n'}(\bar{y})
  \end{aligned}
\end{equation}
and using integral indentities of Gauss-Hermite functions
\begin{equation} \label{6.11}
    \int d{y} \;
    \chi_{n}({y})
    \chi_{n'}({y}) =
    \delta_{n',n}
\end{equation}
\begin{equation} \label{6.12}
    \int dy \;
    y
    \chi_{n}({y})
    \chi_{n'}({y}) =
    \qty(\sqrt{\frac{n+1}{2}} \delta_{n',n+1} + \sqrt{\frac{n}{2}}
    \delta_{n',n-1})
\end{equation}
this becomes
\begin{equation} \label{6.13}
  \begin{aligned}
    \qty({j}_x)_{nm,n'm'} & =
    \frac{1}{{m}}
    \delta_{k_x,k'_x}
    eB
    \qty[
    \qty(\sqrt{\frac{n+1}{2}} \delta_{n',n+1} + \sqrt{\frac{n}{2}}
    \delta_{n',n-1})
    + \zeta(t) \delta_{n',n}
    ]
  \end{aligned}
\end{equation}
\textcolor{red}{Due to complexity we can only consider the constant contribution and we allows only the one-cycle averaged current flow} and then we can derive the $s=0$ components of the Fourier series as
\begin{equation} \label{6.14}
  \begin{aligned}
    \qty({j}^x_{s=0})_{nm,n'm'} & =
    \frac{1}{T} \int_0^T dt \;
    \frac{1}{{m}}
    \delta_{k_x,k'_x}
    eB
    \qty[
    \qty(\sqrt{\frac{n+1}{2}} \delta_{n',n+1} + \sqrt{\frac{n}{2}}
    \delta_{n',n-1})
    + \frac{eE}{m(\omega_0^2 - \omega^2)}\sin(\omega t) \delta_{n',n}
    ]
  \end{aligned}
\end{equation}
and this can be evaluate and get
\begin{equation} \label{6.15}
  \begin{aligned}
    \qty({j}^x_{s=0})_{nm,n'm'} & =
    \frac{eB}{{m}}
    \delta_{k_x,k'_x}
    \qty(\sqrt{\frac{n+1}{2}} \delta_{n',n+1} + \sqrt{\frac{n}{2}}
    \delta_{n',n-1})
  \end{aligned}
\end{equation}

\noindent
For electric current operator we can introduce the electron's charge and effective mass
\begin{equation} \label{6.16}
  \begin{aligned}
    \qty({j}^x_{s=0})_{nm,n'm'} & =
    \frac{e^2B}{{m_e}}
    \delta_{k_x,k'_x}
    \qty(\sqrt{\frac{n+1}{2}} \delta_{n',n+1} + \sqrt{\frac{n}{2}}
    \delta_{n',n-1})
  \end{aligned}
\end{equation}
\hfill$\blacksquare$

\noindent
Next we can consider the transverse conductivity in $y$ direction and we can identify that $y$ directional current operator as
\begin{equation} \label{6.17}
  \hat{j}_y = \frac{1}{m} \qty(-i\hbar\pdv{y} - \frac{eE}{\omega}\cos(\omega t)).
\end{equation}
Now we can calculate the matrix elements of $y$ directional current operator's matrix in Floquet mode basis as
\begin{equation} \label{6.18}
  \qty({j}_y)_{nm,n'm'} = \mel{n,k_x}{\;\hat{j}_y\;}{n',k'_x} =
  \mel{n,k_x}{\;\frac{-1}{m} \qty(i\hbar\pdv{y} + \frac{eE}{\omega}\cos(\omega t))\;}{n',k'_x}
\end{equation}
and we can evaluate these using Floquet modes derived in Eq.\eqref{3.15} as follows
\begin{equation} \label{6.19}
  \begin{aligned}
    \qty({j}_y)_{nm,n'm'} & =
    \int dx \int dy \;
    \frac{1}{\sqrt{L_x}} \chi_{n}\big(y - y_0 - \zeta(t)\big)
    \exp(-ik_x x) \\
    & \times
    \frac{-1}{m} \qty(i\hbar\pdv{y} + \frac{eE}{\omega}\cos(\omega t))
    \frac{1}{\sqrt{L_x}} \chi_{n'}\big(y - y_0 - \zeta(t)\big)
    \exp(i k'_x x)
  \end{aligned}
\end{equation}
then introducing new variable
\begin{equation} \label{6.20}
  y - y_0 - \zeta(t) = \bar{y} \quad \longrightarrow \quad dy = d{\bar{y}}
\end{equation}
and follwing identity [*Ref: Appendix A Hermite fucntions]
\begin{equation} \label{6.21}
  \pdv{\chi_n(y)}{y} = -\sqrt{\frac{n+1}{2}} \chi_{n+1}(y) +
  \sqrt{\frac{n}{2}} \chi_{n-1}(y)
\end{equation}
above expression can be simplified as previous case (let $y=\bar{y}$)
\begin{equation} \label{6.22}
  \begin{aligned}
    \qty({j}_y)_{nm,n'm'} & =
    \frac{-1}{{m}}
    \delta_{k_x,k'_x}
    \int dy \;
     \chi_{n}(y)
    \qty[-i\hbar \qty(
    \sqrt{\frac{n'+1}{2}} \chi_{n'+1}(y) - \sqrt{\frac{n'}{2}} \chi_{n'-1}(y)
    ) + \frac{eE}{\omega}\cos(\omega t)
    \chi_{n'}(y)].
  \end{aligned}
\end{equation}
Then considering Gauss-Hermite integral indentities we can derive that
\begin{equation} \label{6.23}
  \begin{aligned}
    \qty({j}_y)_{nm,n'm'} & =
    \frac{1}{{m}}
    \delta_{k_x,k'_x}
    \qty[i\hbar \qty(
    \sqrt{\frac{n'+1}{2}} \delta_{n,n'+1}
    - \sqrt{\frac{n'}{2}} \delta_{n,n'-1}
    ) - \frac{eE}{\omega}\cos(\omega t) \delta_{n,n'}]
  \end{aligned}
\end{equation}
\textcolor{red}{Due to complexity we can only consider the constant contribution and we allows only the one-cycle averaged current flow} and then we can derive the $s=0$ components of the Fourier series as
\begin{equation} \label{6.24}
  \begin{aligned}
    \qty({j}^y_{s=0})_{nm,n'm'} & =
    \frac{1}{T} \int_0^T dt \;
    \frac{1}{{m}}
    \delta_{k_x,k'_x}
    \qty[i\hbar \qty(
    \sqrt{\frac{n'+1}{2}} \delta_{n,n'+1}
    - \sqrt{\frac{n'}{2}} \delta_{n,n'-1}
    ) - \frac{eE}{\omega}\cos(\omega t) \delta_{n,n'}]
  \end{aligned}
\end{equation}
and this can be evaluate and get
\begin{equation} \label{6.25}
  \begin{aligned}
    \qty({j}^y_{s=0})_{nm,n'm'} & =
    \frac{i\hbar}{{m}}
    \delta_{k_x,k'_x}
    \qty[
    \sqrt{\frac{n'+1}{2}} \delta_{n,n'+1}
    - \sqrt{\frac{n'}{2}} \delta_{n,n'-1}
    ]
  \end{aligned}
\end{equation}
and this can be re-write as
\begin{equation} \label{6.26}
  \begin{aligned}
    \qty({j}^y_{s=0})_{nm,n'm'} & =
    \frac{i\hbar}{{m}}
    \delta_{k_x,k'_x}
    \qty[
    \sqrt{\frac{n}{2}} \delta_{n',n-1}
    - \sqrt{\frac{n+1}{2}} \delta_{n',n+1}
    ]
  \end{aligned}
\end{equation}

\noindent
For electric current operator we can introduce the electron's charge and effective mass
\begin{equation} \label{6.27}
  \begin{aligned}
    \qty({j}^y_{s=0})_{nm,n'm'} & =
    \frac{ie\hbar}{{m}}
    \delta_{k_x,k'_x}
    \qty[
    \sqrt{\frac{n}{2}} \delta_{n',n-1}
    - \sqrt{\frac{n+1}{2}} \delta_{n',n+1}
    ]
  \end{aligned}
\end{equation}
\hfill$\blacksquare$

xx