\documentclass[10pt, aspectratio=169, usenames, dvipsnames]{beamer}
                   
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{spy, external, intersections}
%\tikzexternalize[prefix=build/]

\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{fillbetween}


\usepackage{listings}
\usepackage{subcaption}
\usepackage{bbm}

\usepackage{xcolor}
\usepackage[outputdir=build/]{minted}
\usemintedstyle{gruvbox-light}

\definecolor{gruvbox-bg}{HTML}{ffffff}
% \definecolor{gruvbox-bg}{HTML}{282828}


%
%
% Custom commands
%
%


\input{lib/latex-common/common.tex}
\pgfplotsset{colorscheme/rocket}

\newcommand{\res}{src/2025-01-07/res}


%
%
% CEL Template
%
%


\newcommand{\templates}{lib/cel-template}

\input{\templates/packages.tex}
\input{\templates/modifications.tex}
\input{\templates/makros_own.tex}

% % Change the way the overview is displayed
% \AtBeginSection[]
% {
%     \begin{frame}[t]
%         \frametitle{Overview}
%     \tableofcontents[sectionstyle=show/shaded,
%                      subsectionstyle=show/show/shaded,
%                      subsubsectionstyle=hide]
%     \end{frame}
% }
% \AtBeginSubsubsection[]{}
% \AtBeginSubsection[]{}


%
%
% Set up document
%
%


\title{HiWi Notes: Minimization Code Constraint Polynomial using Homotopy
    Continuation Methods}
\subtitle{\small 07.01.2025}
\author{\vspace{1.5mm} Andreas Tsouchlos}
\date{ }

\institute{Karlsruhe Institute of Technology (KIT),
    \\ Communications Engineering Lab (CEL) }

\tikzstyle{every node}=[font=\small]
\captionsetup[sub]{font=small}


%
%
% Document body
%
%


\begin{document}


\begin{frame}[plain]
	\maketitle
\end{frame}

\newcommand{\largecitereference}[1]{\textcolor{kit-green100}{ \large \textbf{{[#1]}} }}

\begin{frame}

    \frametitle{Basic Idea of Homotopy Continuation \largecitereference{CL15}}

    \begin{minipage}[c]{0.65\textwidth}
        \begin{itemize}
            \item Goal: Solve system of equations $F(\bm{x}) = \bm{0}, \hspace{2mm} F:\mathbb{R}^n \rightarrow \mathbb{R}^n$
            \item Problem: Depending on $F$, solving this directly may be difficult
            \item Solution: Define \emph{homotopy function} $H(\bm{x}, t)$ with
                \begin{gather*}
                    H(\bm{x}, 0) = G(\bm{x}), \hspace{5mm} H(\bm{x}, 1) = F(\bm{x})
                ,\end{gather*}
                i.e., a deformation between two systems $G(\bm{x})$ and $F(\bm{x})$
                (where the zeros of $G$ can be easily obtained); E.g.,
                \begin{gather*}
                    H(\bm{x}, t) = (t-1)G(\bm{x}) + tF(\bm{x})
                .\end{gather*}
                Then, compute $(\bm{x}_0, 0)$ such that $G(\bm{x}_0) = \bm{0}$ and trace path to $(\bm{x}_1, 1)$ with $F(\bm{x}_1) = \bm{0}$
        \end{itemize}

        \vspace{5mm}

        \addreferences
            {CL15}{Tianran Chen, Tien-Yien Li: \emph{Homotopy continuation method
                for solving systems of nonlinear and polynomial equations}. 2015}
        \stopreferences
    \end{minipage}%
    \hfill
    \begin{minipage}[c]{0.3\textwidth}
        \begin{figure}
            \centering

            \newcommand{\figlength}{0.8\textwidth}

            \vspace*{-2mm}

            \begin{tikzpicture}
                \begin{axis}[
                    xmin=-1,xmax=1,
                    ymin=-1,ymax=1,
                    width=\figlength,
                    height=\figlength,
                    ticks=none,
                    view={0}{90},
                    title={$t=0$},
                    title style={yshift=-1mm},
                    % xlabel={$x_1$},
                    % ylabel={$x_2$},
                    ]
                    \addplot3[point meta=\thisrow{Hmag},
                              point meta min=0,
                              point meta max=2.5,
                              quiver={u=\thisrow{H1},
                                      v=\thisrow{H2},
                                      scale arrows=.25,
                                      every arrow/.append style={%
                                        line width=.5
                                            +\pgfplotspointmetatransformed/1000,
                                        -{Latex[length=0pt 5,width=0pt 3]}
                                      },
                                  },
                                quiver/colored = {mapped color},
                                -stealth,
                              ]
                                table[col sep=comma, discard if not={t}{0.0}] {\res/H.csv};

                            \addplot[mark=*] coordinates {(0,0)} node[above] {$\bm{x}_0$};

                \end{axis}
            \end{tikzpicture}
            \begin{tikzpicture}
                \begin{axis}[
                    xmin=-1,xmax=1,
                    ymin=-1,ymax=1,
                    width=\figlength,
                    height=\figlength,
                    ticks=none,
                    view={0}{90},
                    title={$t=0.5$},
                    title style={yshift=-1mm},
                    % xlabel={$x_1$},
                    % ylabel={$x_2$},
                    ]
                    \addplot3[point meta=\thisrow{Hmag},
                              point meta min=0,
                              point meta max=2.5,
                              quiver={u=\thisrow{H1},
                                      v=\thisrow{H2},
                                      scale arrows=.25,
                                      every arrow/.append style={%
                                        line width=.5
                                            +\pgfplotspointmetatransformed/1000,
                                        -{Latex[length=0pt 5,width=0pt 3]}
                                      },
                                  },
                                quiver/colored = {mapped color},
                                -stealth,
                              ]
                                table[col sep=comma, discard if not={t}{0.5}] {\res/H.csv};

                    \draw[line width=1pt] (0,0) -- (0.25,-0.25);
                    \addplot[mark=*] coordinates {(0.25, -0.25)};
                \end{axis}
            \end{tikzpicture}

            \vspace{2mm}

            \begin{tikzpicture}
                \begin{axis}[
                    xmin=-1,xmax=1,
                    ymin=-1,ymax=1,
                    width=\figlength,
                    height=\figlength,
                    ticks=none,
                    view={0}{90},
                    title={$t=1$},
                    title style={yshift=-1mm},
                    % xlabel={$x_1$},
                    % ylabel={$x_2$},
                    ]
                    \addplot3[point meta=\thisrow{Hmag},
                              point meta min=0,
                              point meta max=2.5,
                              quiver={u=\thisrow{H1},
                                      v=\thisrow{H2},
                                      scale arrows=.25,
                                      every arrow/.append style={%
                                        line width=.5
                                            +\pgfplotspointmetatransformed/1000,
                                        -{Latex[length=0pt 5,width=0pt 3]}
                                      },
                                  },
                                quiver/colored = {mapped color},
                                -stealth,
                              ]
                                table[col sep=comma, discard if not={t}{1.0}] {\res/H.csv};

                    \draw[line width=1pt] (0,0) -- (0.5,-0.5);
                    \addplot[mark=*] coordinates {(0.5,-0.5)} node[below right] {$\bm{x}_1$};
                \end{axis}
            \end{tikzpicture}

            \caption{Visualization of ``snapshots'' of $H$ (e.g., $F, G$) as vector fields}
        \end{figure}
    \end{minipage}
\end{frame}

\end{document}
