\documentclass[t,aspectratio=169]{beamer}
\usetheme{metropolis}
\metroset{block=fill}

\input{../../_assets/basicslide1}
\input{../../_assets/macros}

\author{Samuel Vaiter}
\date{}
\institute{
Created: 2023-11-10.\\
Last update: 2023-11-11.\\
Status: inprogress.
}
\title{Complex step approximation}

\begin{document}

\begin{frame}
  \maketitle
\end{frame}


\begin{frame}
  \frametitle{Complex step approximation}
  $f: \CC \to \CC$ analytic function with $f(\RR) \subseteq \RR$\hfill{\small (loc. convergent power series $\sum_{n} a_{n} z^{n}$)}.

  Taylor expansion at order 3
  \[ 
    f(x + ih) = f(x) + i h f'(x) - \frac{h^{2}}{2} f''(x) + O(h^{3}) .  
  \]
  Identifying, imaginary and real part, we have
  \[
    \Re f(x+i\epsilon) = f(x) + O(\epsilon^{2}) \quad \text{and} \quad \mathfrak{I} f(x+i\epsilon) = hf'(x) + O(\epsilon^3) .
  \]

  \[
    f'(x) \approx \mathfrak{I} \frac{f(x + i \epsilon)}{\epsilon}
  \]
\end{frame}

\begin{frame}
  \frametitle{\emph{No round-off error!}}
  \begin{center}
    \begin{tikzpicture}
     \node (img) at (0,0){\includegraphics[width=0.9\linewidth]{figures/error_vs_complex.pdf}};
     \node[rotate=90, left=3pt of img, anchor=center] {$\abs{\Delta_\epsilon f(x) - f'(x)}$};
    \end{tikzpicture}
  \end{center}
\end{frame}

\end{document}