\documentclass[hyperref={colorlinks=true}]{beamer}
\usepackage{amsmath,amsfonts,amsthm}
% Not in French
%\usepackage[latin1]{inputenc}
%\usepackage[OT2,T1]{fontenc}
%\usepackage[frenchb]{babel}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz,tikz-cd,tikz-3dplot}
\usetikzlibrary{matrix,calc,arrows}

\DeclareMathOperator{\coker}{coker}

\usepackage[all,cmtip]{xy}
\usepackage{verbatim}
\newcommand{\ignore}[1]{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Choose a theme:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usetheme{Berlin}
%\usetheme{Copenhagen}
%\usetheme{Darmstadt}
%\usetheme{Marburg}
\usetheme{Singapore}
%\usetheme{Szeged}
%\usetheme{Warsaw}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Choose a color theme:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usecolortheme{crane}
%\usecolortheme{dove}
%\usecolortheme{dolphin}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Choose a font theme:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usefonttheme{structurebold}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamercovered{dynamic}

\begin{document}

\title{A picture is worth 1024 words}
\author{David Kohel\newline
Institut de Math\'ematiques de Marseille}
\date{Marseille \newline 21 January 2019}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TITLEPAGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\titlepage\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TABLE OF CONTENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\tableofcontents\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Diagrams and graphs}

\begin{frame}[fragile]
\frametitle{Commutative diagrams: The snake lemma with {\tt tikz}}
\begin{tikzpicture}[>=triangle 60]
  \matrix[matrix of math nodes,column sep={60pt,between origins},row
    sep={60pt,between origins},nodes={asymmetrical rectangle}] (s)
  {
    &|[name=ka]| \ker f &|[name=kb]| \ker g &|[name=kc]| \ker h \\
    %
    &|[name=A]| A' &|[name=B]| B' &|[name=C]| C' &|[name=01]| 0 \\
    %
    |[name=02]| 0 &|[name=A']| A &|[name=B']| B &|[name=C']| C \\
    %
    &|[name=ca]| \coker f &|[name=cb]| \coker g &|[name=cc]| \coker h \\
  };
  \draw[->] (ka) edge (A)
            (kb) edge (B)
            (kc) edge (C)
            (A) edge (B)
            (B) edge node[auto] {\(p\)} (C)
            (C) edge (01)
            (A) edge node[auto] {\(f\)} (A')
            (B) edge node[auto] {\(g\)} (B')
            (C) edge node[auto] {\(h\)} (C')
            (02) edge (A')
            (A') edge node[auto] {\(i\)} (B')
            (B') edge (C')
            (A') edge (ca)
            (B') edge (cb)
            (C') edge (cc)
  ;
  \draw[->,gray] (ka) edge (kb)
                 (kb) edge (kc)
                 (ca) edge (cb)
                 (cb) edge (cc)
  ;
  \draw[->,gray,rounded corners] (kc) -| node[auto,text=black,pos=.7]
    {\(\partial\)} ($(01.east)+(.5,0)$) |- ($(B)!.35!(B')$) -|
    ($(02.west)+(-.5,0)$) |- (ca);
\end{tikzpicture}
\end{frame}

\begin{frame}[fragile] % for verbatim text
\frametitle{Graph flow diagram with {\tt tikz}}

\begin{center}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=25mm]
  \tikzstyle{every pin edge}=[<-,shorten <=1pt]
  \tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
  \tikzstyle{input neuron}=[neuron, fill=yellow!100];
  \tikzstyle{output neuron}=[neuron, fill=red!90];
  \tikzstyle{hidden neuron}=[neuron, fill=blue!80];
  \tikzstyle{annot} = [text width=4em, text centered];
  % Draw the input layer nodes
  \foreach \name / \y in {1,...,4}
    % This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
    \node[input neuron, pin=left:Source \#\y] (I-\name) at (0,-\y) {};
  % Draw the hidden layer nodes
  \foreach \name / \y in {1,...,5}
    \path[yshift=0.5cm]
      node[hidden neuron] (H-\name) at (25mm,-\y cm) {};
  % Draw the output layer node
  \node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {};
  % Connect every node in the input layer with every node in the % hidden layer.
  \foreach \source in {1,...,4}
    \foreach \dest in {1,...,5}
      \path (I-\source) edge (H-\dest);
  % Connect every node in the hidden layer with the output layer
  \foreach \source in {1,...,5}
    \path (H-\source) edge (O);
  % Annotate the layers
  \node[annot,above of=H-1, node distance=1cm] (hl) {Mixing};
  \node[annot,left of=hl] (hi) {Dispatch};
  \node[annot,left of=hi, node distance=2cm] {Input};
  \node[annot,right of=hl] {Merging};
\end{tikzpicture}
\end{center}
\end{frame}

\section{2D-plots}

\begin{frame}[fragile] % for verbatim text
\frametitle{Function plots with {\tt pgfplots} and {\tt tikz}}
\begin{tikzpicture}
   \begin{axis}[
      xmin=0.05, xmax=2,
      xticklabel style={/pgf/number format/.cd,fixed},
      width=80mm, height=80mm,
      grid = major,
      grid style={gray!30},
      ymin=-1, ymax= 1,
      axis background/.style={fill=white},
      xlabel={$x$}, ylabel={$y$},
      tick align=outside
      ]
    \addplot[domain=0.05:2, blue, thick,samples=5000] {sin(deg(pi/(x)))};
    \node[tdplot_screen_coords] at (5,5) {$y = \sin(\pi/x)$};
    \end{axis}
\end{tikzpicture}
\end{frame}

\begin{frame}[fragile] % for verbatim text
\frametitle{Riemann integral with {\tt pgfplots} and {\tt tikz}}

\pgfplotsset{
    integral segments/.code={\pgfmathsetmacro\integralsegments{#1}},
    integral segments=3,
    integral/.style args={#1:#2}{
        ybar interval,
        domain=#1+((#2-#1)/\integralsegments)/2:#2+((#2-#1)/\integralsegments)/2,
        samples=\integralsegments+1,
        x filter/.code=\pgfmathparse{\pgfmathresult-((#2-#1)/\integralsegments)/2}
    }
}

\begin{tikzpicture}[/pgf/declare function={f=-15*(x-5)+(x-5)^3+50;}]
\begin{axis}[domain=0:10,samples=100,axis lines=middle]
  \addplot [thick] {f};
  \addplot [fill=yellow, integral segments=10,integral=2:8] {f};
\addplot [thick] {f};
\end{axis}
\end{tikzpicture}

\end{frame}

\section{3D-plots}

\begin{frame}[fragile] % for verbatim text
\frametitle{Spherical parametric surfaces with {\tt tikz}}

\noindent{\bf Syntax:}
\begin{verbatim}
\tdplotsphericalsurfaceplot[fill color style]%
  {theta steps}{phi steps}%
  {function}{line color}{fill color}%
  {x axis}{y axis}{z axis}
\end{verbatim}

The function is of the form $r = f(\theta,\phi)$ in spherical coordinates.
\end{frame}

\begin{frame}[fragile] % for verbatim text
\frametitle{Parametric surface: color parametrization in $\phi$}
\begin{center}
\tdplotsetmaincoords{70}{135}
\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.5]
\pgfsetlinewidth{.2pt}
\tdplotsphericalsurfaceplot[parametricfill]{72}{36}%
{sin(\tdplottheta)*cos(\tdplottheta)}{black}{\tdplotphi}%
{\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}%
\node[tdplot_screen_coords,fill opacity=0.5] at (0,-1) {Parametric plot $r = \sin(\theta)\cos(\theta)$};
\end{tikzpicture}
\end{center}
\vspace{-1mm}

\noindent{\bf Definition:}
\begin{verbatim}
\tdplotsphericalsurfaceplot[parametricfill]{72}{36}%
  {sin(\tdplottheta)*cos(\tdplottheta)}{black}{\tdplotphi}%
  {\draw[color=black,thick,->] (0,0,0) -- (1,0,0)}%
  {\draw[color=black,thick,->] (0,0,0) -- (0,1,0)}%
  {\draw[color=black,thick,->] (0,0,0) -- (0,0,1)}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Parametric surface, color parametrization in $r$}
\begin{center}
\tdplotsetmaincoords{70}{135}
\begin{tikzpicture}[scale=2,tdplot_main_coords,line join=bevel,fill opacity=.8]
\pgfsetlinewidth{.1pt}
\tdplotsphericalsurfaceplot[parametricfill]{72}{36}%
{0.5*abs(cos(\tdplottheta))}{black}{2*abs(\tdplotr)}%
{\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}%
\node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Plot of $r = 0.5\mid\!\cos(\theta)\!\mid$};
\end{tikzpicture}
\begin{tikzpicture}[scale=2,tdplot_main_coords,line join=bevel,fill opacity=.8]
\pgfsetlinewidth{.1pt}
\tdplotsphericalsurfaceplot[parametricfill]{72}{36}%
{0.5*abs(sin(\tdplottheta))}{black}{2*abs(\tdplotr)}%
{\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}%
\node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Plot of $r = 0.5\mid\!\sin(\theta)\!\mid$};
\end{tikzpicture}
\end{center}
\vspace{-1mm}

\noindent{\bf Definition:}
\begin{verbatim}
\tdplotsphericalsurfaceplot[parametricfill]{72}{36}%
  {0.5*abs(cos(\tdplottheta))}{black}{2*abs(\tdplotr)}%
  {\draw[color=black,thick,->] (0,0,0) -- (1,0,0)}%
  {\draw[color=black,thick,->] (0,0,0) -- (0,1,0)}%
  {\draw[color=black,thick,->] (0,0,0) -- (0,0,1)}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Parametric surface, solid color}
\begin{center}
\tdplotsetmaincoords{70}{135}
\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.7]
\pgfsetlinewidth{.4pt}
\tdplotsphericalsurfaceplot{72}{24}%
{sqrt(3)/2*cos(\tdplottheta)^2}{black}{red!80!black}%
{\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}%
\node[tdplot_screen_coords,fill opacity=1] at (0,-1) {$r = \frac{\sqrt{3}}{2}\cos(\theta)^2$};
\end{tikzpicture}
\end{center}
\vspace{-1mm}

\noindent{\bf Definition:}
\begin{verbatim}
\tdplotsphericalsurfaceplot{72}{24}%
  {sqrt(3)/2*cos(\tdplottheta)^2}{black}{red!80!black}%
  {\draw[color=black,thick,->] (0,0,0) -- (1,0,0)}%
  {\draw[color=black,thick,->] (0,0,0) -- (0,1,0)}%
  {\draw[color=black,thick,->] (0,0,0) -- (0,0,1)}
\end{verbatim}
\end{frame}

\section{Including graphics}

\begin{frame}[fragile]
\frametitle{Include graphics with {\tt graphix}}
\begin{center}
\includegraphics[scale=0.1]{img/TrefoilKnot.png}
\end{center}
\begin{center}
{\bf Trefoil knot from Wikimedia Commons}
\end{center}
\noindent{\bf Syntax:}
\begin{verbatim}
\includegraphics[scale=0.1]{img/TrefoilKnot.png}
\end{verbatim}
\end{frame}


\begin{frame}[fragile]
\frametitle{Include graphics with {\tt graphix}}
\begin{center}
\includegraphics[scale=0.66]{img/SierpinskiTriangle.png}
\end{center}
\begin{center}
{\bf Sierpinski triangle from Wikimedia Commons}
\end{center}
\noindent{\bf Syntax:}
\begin{verbatim}
\includegraphics[scale=0.66]{img/SierpinskiTriangle.png}
\end{verbatim}
\end{frame}

\end{document}

