diff --git a/Lectures_my/NumMet/2016/Lecture10/Makefile b/Lectures_my/NumMet/2016/Lecture10/Makefile new file mode 100644 index 0000000..8cdb31b --- /dev/null +++ b/Lectures_my/NumMet/2016/Lecture10/Makefile @@ -0,0 +1,7 @@ +all: lecture10.pdf + +lecture10.pdf: lecture10.tex + xelatex lecture10.tex + xelatex lecture10.tex +clean: + rm *.aux *.bbl *.blg *.log *.out *.pdf *.sh *.xml *.snm *.toc *.nav diff --git a/Lectures_my/NumMet/2016/Lecture10/beamercolorthemeFlip.sty b/Lectures_my/NumMet/2016/Lecture10/beamercolorthemeFlip.sty new file mode 100755 index 0000000..d6b9c50 --- /dev/null +++ b/Lectures_my/NumMet/2016/Lecture10/beamercolorthemeFlip.sty @@ -0,0 +1,179 @@ +% Color style file for the BEAMER FLIP THEME +% Copyright 2012 by Flip Tanedo +% This file may be distributed and/or modified +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. + + + +\mode +\newif\ifbeamer@Flip@dark +\beamer@Flip@darkfalse +\DeclareOptionBeamer{dark}{\beamer@Flip@darktrue} +\ProcessOptionsBeamer + + +% These are a few colors that I like. + +\definecolor{crimsonred}{RGB}{153,0,0} % Neurtal red, good for dark or light bg +\definecolor{darkcharcoal}{RGB}{25,25,25} % Darker gray +\definecolor{charcoal}{RGB}{51,51,51} % Darker gray +\definecolor{ash}{RGB}{100,100,100} % medium gray +\definecolor{paleblue}{RGB}{0,102,102} % More of an `ocean' color +\definecolor{turtlegreen}{RGB}{51,153,0} % A more neutral green +\definecolor{paleale}{RGB}{204,204,102} % Only for dark BG +\definecolor{lager}{RGB}{140,110,10} % Use instead of pale ale for white BG +\definecolor{regal}{RGB}{90,0,120} % A more neutral purple +\definecolor{jeans}{RGB}{20,30,150} % A more neutral blue + + +% Define some "invariant colors" so that a color that doen't work with a +% light/dark background will automatically be substituted with one that does. +% These will be rewritten in beamercolorthemeFlipDark + +\ifbeamer@Flip@dark + \definecolor{FlipSand}{RGB}{204,204,102} % paleale, Only for dark BG + \definecolor{FlipGreen}{RGB}{0,255,0} % Neon-like green, only for dark BG +\else + \definecolor{FlipSand}{RGB}{140,110,10} % lager, Only for light BG + \definecolor{FlipGreen}{RGB}{51,153,0} % turtlegreen, works for both +\fi + +%% Future revision: It would be nice to define these in terms of the palette. + + +\ifbeamer@Flip@dark + \setbeamercolor{normal text}{fg=white, bg=black} + \setbeamercolor{structure}{fg=gray, bg=black} % fg controls bullets + \setbeamercolor*{footerlike}{fg=white,bg=black} % Controls the footerline +\else + % Default to black on white + \setbeamercolor*{footerlike}{fg=white,bg=charcoal} % for charcoal footer + \setbeamercolor{structure}{fg=charcoal, bg=white} % fg controls bullets + % \setbeamercolor{normal text}{fg=white, bg=black} +\fi + + + + + +% These defined colors can be used in \textcolor{colorname}{text in that color}. + +% Colors for Keynote background: DARK +\definecolor{keynotebottom}{rgb}{0.32,0.3,0.38} +\definecolor{keynotemiddle}{rgb}{0.08,0.08,0.16} +\definecolor{keynotetop}{rgb}{0,0,0} +%%% Example of usage: +%% \setbeamertemplate{background canvas}[vertical shading] +%% [bottom=keynotebottom, middle=keynotemiddle, top=keynotetop] + + + + +% ALERT AND COMMENT COLORS (just copies of the above colors) +% (I don't know how ot do this more elegantly) +\ifbeamer@Flip@dark + \definecolor{ALERT}{RGB}{153,0,0} % crimsonred + \definecolor{Alert}{RGB}{51,153,0} % turtlegreen + \definecolor{alert}{RGB}{204,204,102} % paleale + \definecolor{charcoal}{RGB}{51,51,51} % charcoal + \definecolor{comment}{RGB}{80,80,80} % light charcoal + \definecolor{Comment}{RGB}{100,100,100} % ash + \definecolor{COMMENT}{RGB}{80,20,120} % regal +\else +% \definecolor{ALERT}{RGB}{153,0,0} % crimsonred + \definecolor{ALERT}{RGB}{28,134,238} % DodgerBlue2 +% \definecolor{Alert}{RGB}{51,153,0} % turtlegreen + \definecolor{Alert}{RGB}{255,127,36} % chocolate1 +% \definecolor{alert}{RGB}{140,110,10} % lager + \definecolor{alert}{RGB}{0,205,102} % SpringGreen3 + \definecolor{charcoal}{RGB}{80,80,80} % light charcoal + \definecolor{comment}{RGB}{51,51,51} % charcoal + \definecolor{Comment}{RGB}{100,100,100} % ash + \definecolor{COMMENT}{RGB}{80,20,120} % regal +\fi + + +% \definecolor{crimsonred}{RGB}{153,0,0} % Neurtal red, good for dark or light bg +% \definecolor{charcoal}{RGB}{51,51,51} % Darker gray +% \definecolor{ash}{RGB}{100,100,100} % medium gray +% \definecolor{paleblue}{RGB}{0,102,102} % More of an `ocean' color +% \definecolor{turtlegreen}{RGB}{51,153,0} % A more neutral green +% \definecolor{paleale}{RGB}{204,204,102} % Only for dark BG +% \definecolor{lager}{RGB}{140,110,10} % Use instead of pale ale for white BG +% \definecolor{regal}{RGB}{90,0,120} % A more neutral purple +% \definecolor{jeans}{RGB}{20,30,150} % A more neutral blue + + +% A few useful colors +\setbeamercolor{alerted text}{fg=alert} + +%% I would like ot use these colors, but there seems to be a bug in Beamer +%% where the footnote color infects the normal text color +%% See: http://tex.stackexchange.com/questions/8264/beamer-changing-the-footnote-color-also-changes-the-normal-text-color/8268#8268 + +% \setbeamercolor{footnote}{parent=normal text, fg=FlipSand} +% \setbeamercolor{footnote mark}{parent=normal text, fg=FlipSand} + +% Blocks +\setbeamercolor{block title}{fg=gray!30!white,bg=charcoal} +\setbeamercolor{block body}{parent=normal text,bg=gray, fg=white} + +\setbeamercolor{block title example}{fg=turtlegreen!30!white,bg=turtlegreen!40!black} +\setbeamercolor{block body example}{parent=normal text,bg=turtlegreen, fg=white} +% +\setbeamercolor{block title alerted}{fg=crimsonred!30!white,bg=crimsonred!40!black} +\setbeamercolor{block body alerted}{parent=normal text,bg=crimsonred, fg=white} + + + +% These "setbeamercolor" commands are more standardized. + + +%% From the Beamer User Guide: +% Outer themes base the color of navigational elements and, possibly, also of other elements, on the +% four palette colors. The “primary” palette should be used for the most important navigational elements, +% which are usually the ones that change most often and hence require the most attention by the audience. +% The “secondary” and “tertiary” are less important, the “quaternary” one is least important. +% By default, the palette colors do not have a background and the foreground ranges from structure.fg to black. +% For the sidebar, there is an extra set of palette colors, see palette sidebar primary. + +\setbeamercolor*{palette primary}{fg=crimsonred,bg=charcoal} +\setbeamercolor*{palette secondary}{fg=paleale,bg=lager} +\setbeamercolor*{palette tertiary}{fg=turtlegreen,bg=jeans} +\setbeamercolor*{palette quaternary}{fg=paleblue,bg=regal} + +% \setbeamercolor*{palette primary}{fg=crimsonred,bg=white} +% \setbeamercolor*{palette secondary}{fg=charcoal,bg=white} +% \setbeamercolor*{palette tertiary}{fg=paleblue,bg=white} +% \setbeamercolor*{palette quaternary}{fg=turtlegreen,bg=white} + + + +%% These are some structures that I define for use in the outer theme. + +\setbeamercolor*{crimsontown}{fg=paleblue,bg=crimsonred} +\setbeamercolor*{bluetown}{fg=white,bg=DodgerBlue2} +%\setbeamercolor*{titlelike}{fg=crimsonred} +\setbeamercolor*{titlelike}{fg=DodgerBlue2} +\setbeamercolor*{topbarlike}{fg=white, bg=charcoal} + + + + + +%% Some old definitions that I might want to get back to +% +% \setbeamercolor*{frametitle}{bg=white,fg=charcoal} +% \setbeamercolor*{part title}{bg=white,fg=charcoal} +% \setbeamercolor*{item}{fg=charcoal, bg=white} +% +% \setbeamercolor*{separation line}{} +% \setbeamercolor*{fine separation line}{} + + + + + +\mode + diff --git a/Lectures_my/NumMet/2016/Lecture10/beamerinnerthemeFlip.sty b/Lectures_my/NumMet/2016/Lecture10/beamerinnerthemeFlip.sty new file mode 100755 index 0000000..8dc12a0 --- /dev/null +++ b/Lectures_my/NumMet/2016/Lecture10/beamerinnerthemeFlip.sty @@ -0,0 +1,95 @@ +% Inner style file for the BEAMER FLIP THEME +% Copyright 2010 by Flip Tanedo +% This file may be distributed and/or modified +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% Based on: beamerinnerthemeFlip by Marco Barisione + +\mode + +% % Use alternative title page style. +% \DeclareOptionBeamer{alternativetitlepage}[true]{\def\beamer@Flip@alternativetitlepage{#1}} + +% Logo to use in the alternative title page. +% \def\beamer@Flip@titlepagelogo{} +% \DeclareOptionBeamer{titlepagelogo}{\def\beamer@Flip@titlepagelogo{#1}} + +% Bullet shape. +\DeclareOptionBeamer{bullet}{\def\beamer@Flip@bullet{#1}} +\DeclareOptionBeamer{shadow}[true]{\def\beamer@themerounded@shadow{#1}} +\ExecuteOptionsBeamer{shadow=false} + + +% \ExecuteOptionsBeamer{alternativetitlepage=false,bullet=square} +\ProcessOptionsBeamer + + + +% Margins. +\newlength{\beamer@Flip@normalmargin} +\setlength{\beamer@Flip@normalmargin}{.06\paperwidth} +\setbeamersize{text margin left=\beamer@Flip@normalmargin} +\setbeamersize{text margin right=\beamer@Flip@normalmargin} +\setlength\leftmargini{.6\beamer@Flip@normalmargin} +\setlength\leftmarginii{.6\beamer@Flip@normalmargin} +\setlength\leftmarginiii{.6\beamer@Flip@normalmargin} + +% Normal title page. +\defbeamertemplate*{title page normal}{Flip theme}[1][] +{ + \vbox{} + \vfill + \begin{centering} + \begin{beamercolorbox}[wd=\paperwidth,sep=8pt,center,#1]{title page header} + \usebeamerfont{title}\inserttitle\par% + \ifx\insertsubtitle\@empty% + \else% + \vskip0.25em% + {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}% + \fi% + \end{beamercolorbox}% + %\vskip0.5em\par + \begin{beamercolorbox}[sep=8pt,center,#1]{author} + \usebeamerfont{author}\insertauthor + \end{beamercolorbox} + \begin{beamercolorbox}[sep=8pt,center,#1]{institute} + \usebeamerfont{institute}\insertinstitute + \end{beamercolorbox} + \begin{beamercolorbox}[sep=8pt,center,#1]{date} + \usebeamerfont{date}\insertdate + \end{beamercolorbox}\vskip0.5em + {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par} + \end{centering} + \vfill +} + + +% Items. +\defbeamertemplate{itemize item}{squarealt}% +{\tiny\raise.5ex\hbox{\donotcoloroutermaths$\blacksquare$}} +\defbeamertemplate{itemize subitem}{squarealt}% +{\tiny\raise.4ex\hbox{\donotcoloroutermaths$\square$}} +\defbeamertemplate{itemize subsubitem}{squarealt}% +{\tiny\raise.3ex\hbox{\donotcoloroutermaths$\blacksquare$}} +% +\defbeamertemplate{itemize item}{circlealt}% +{\small\raise.2ex\hbox{\donotcoloroutermaths$\bullet$}} +\defbeamertemplate{itemize subitem}{circlealt}% +{\small\raise.1ex\hbox{\donotcoloroutermaths$\circ$}} +\defbeamertemplate{itemize subsubitem}{circlealt}% +{\scriptsize\raise.1ex\hbox{\donotcoloroutermaths$\bullet$}} +\setbeamertemplate{items}[circlealt] +% +\def\circletext{circle} +\ifx\beamer@Flip@bullet\circletext + \setbeamertemplate{items}[circlealt] +\else + \setbeamertemplate{items}[squarealt] +\fi + +\setbeamertemplate{blocks}[rounded][shadow=\beamer@themerounded@shadow] + + +\mode + diff --git a/Lectures_my/NumMet/2016/Lecture10/beamerouterthemeFlip.sty b/Lectures_my/NumMet/2016/Lecture10/beamerouterthemeFlip.sty new file mode 100755 index 0000000..d12f6d6 --- /dev/null +++ b/Lectures_my/NumMet/2016/Lecture10/beamerouterthemeFlip.sty @@ -0,0 +1,189 @@ +% Outer style file for the BEAMER FLIP THEME 212 +% Copyright 2012 by Flip Tanedo +% This file may be distributed and/or modified +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% Based on: beamerouterthemesplit by Till Tantau + + +\mode + +% Watermark +\DeclareOptionBeamer{watermark}{\def\beamer@Flip@watermark{#1}} +\ExecuteOptionsBeamer{watermark=} % Default value is empty + + +\newif\ifbeamer@Flip@bigpagenumber +\beamer@Flip@bigpagenumberfalse +\DeclareOptionBeamer{bigpagenumber}{\beamer@Flip@bigpagenumbertrue} + + +\def\beamer@Flip@truetext{true} % Kludge for true/false so I can use ifx + +\DeclareOptionBeamer{topline}[true]{\def\beamer@Flip@topline{#1}} +\ExecuteOptionsBeamer{topline=false} % Default + + + +% \ExecuteOptionsBeamer{topline=} % Default value is empty + + +\ProcessOptionsBeamer + + +\usepackage{tikz} % For fancy decorations + + +% I should fix these up to be more robust against color changes +\setbeamercolor{section in head/foot}{parent=footerlike} +\setbeamercolor{subsection in head/foot}{parent=footerlike} +\setbeamercolor{author in head/foot}{parent=footerlike} +\setbeamercolor{title in head/foot}{parent=footerlike} + + +% \setbeamercolor{author in head/foot}{parent=section in head/foot} +% \setbeamercolor{title in head/foot}{parent=subsection in head/foot} + +%\setbeamercolor{topbar}{parent=crimsontown} +\setbeamercolor{topbar}{parent=bluetown} + + + + +\usesectionheadtemplate + {\hfill\insertsectionhead} + {\hfill\color{fg!50!bg}\insertsectionhead} + + +%%%%%%%%%%%%%%%%%% +% The footer bar % +%%%%%%%%%%%%%%%%%% + +\defbeamertemplate*{footline}{Flip theme} +{% + \leavevmode% +% OBSERVATION: the "%" symbols inside hbox are all very important here. +% The \hbox enviroment will insert spaces whenever there's whitespace +% Adding a % at the END of each line ensures that any hard returns aren't +% interpreted as white space. This allows the color boxes to be flush against +% one another. If a faint white line appears one could probably do something like +% hspace{-1px} and add an additional pixel-or-two wide beamercolorbox. + +\hbox{% +\begin{beamercolorbox}[wd=.4\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm, rightskip=.3cm plus1fil]{author in head/foot}% + \usebeamerfont{author in head/foot}\insertshortauthor \end{beamercolorbox}% +% +\begin{beamercolorbox}[wd=.6\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}% + \usebeamerfont{title in head/foot}{\textit \insertshorttitle}% + \hskip2ex plus1fill% + % \insertpagenumber\,/\,\insertpresentationendpage %% Want FRAME, not SLIDE number + \insertframenumber/\inserttotalframenumber + \end{beamercolorbox}% +}% + +% This is a complete kludge for the faint white line which appears +% between the beamer color boxes above. (It doesnt appear in presentation mode +% but sometimes looks funny when the pdfs are viewed in a window) +\begin{tikzpicture}[overlay] + \usebeamercolor[bg]{author in head/foot} + \draw[thick] (0,3.625ex) -- (\paperwidth,3.625ex); + \draw (.4\paperwidth,0) -- (.4\paperwidth,3.625ex); + \draw[thick] (0,0) -- (\paperwidth,0); +\end{tikzpicture} + + + +\ifbeamer@Flip@bigpagenumber + \begin{tikzpicture}[overlay] + \usebeamercolor[bg]{author in head/foot} + \draw[fill] (\paperwidth-5ex,3.625ex) circle (6ex); + \usebeamercolor[fg]{author in head/foot} + \draw[fill] (\paperwidth-5ex,3.625ex) circle (5ex); + \usebeamercolor[bg]{author in head/foot} + \node at (\paperwidth-5ex,4ex) {\small$^\text{\insertframenumber}/_\text{\inserttotalframenumber}$}; + \end{tikzpicture} +\fi +} + + + +\defbeamertemplate*{frametitle}{Flip theme}[1][left] +{ +% \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}% +\@tempdima=\textwidth% +\advance\@tempdima by\beamer@leftmargin% +\advance\@tempdima by\beamer@rightmargin% + +\vbox{}\vskip-3.5ex% +% +\begin{beamercolorbox}[sep=0.3cm,#1,wd=\the\@tempdima]{titlelike} + \usebeamerfont{frametitle}% + \vbox{}\vskip-1ex% + \if@tempswa\else\csname beamer@fte#1\endcsname\fi% + % \strut{\bf\insertframetitle}\strut\par% %% Include the \bf + \strut{\insertframetitle}\strut\par% + {% + \ifx\insertframesubtitle\@empty% + \else + {\usebeamerfont{framesubtitle} + \usebeamercolor[fg]{framesubtitle} + \insertframesubtitle\strut\par}% + \fi + }% + % + \vskip-1ex% + \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here... +\end{beamercolorbox}% +%% + +% \def\beamer@fteright{\vskip0.35cm\advance\leftskip by 1.7cm\advance\rightskip by1.7cm} +} + + + + +% Sidebar right is important: anything placed here will be +% visible *behind* the main text. This is where to put any +% interesting watermarks. +% +% +\defbeamertemplate*{sidebar right}{Flip theme} +{ +% \llap{\includegraphics[width=50px]{footdecoration}} +% \llap{\includegraphics[width=\paperwidth,height=\paperheight]{upperleft_watermark_transp}} +% +% THIS WOULD BE A NICE WAY TO PUT THE PARTICLE BUBBLE CHAMBER BG +% ... make a png of the background with TRANSPARENT BG +% ... then put the image here (use \hfill to get it on the left) +% Now one can FURTHER apply a slight gradient in the BG +% +% +% % Top Line +\ifx\beamer@Flip@topline\beamer@Flip@truetext + \begin{tikzpicture}[overlay] + \usebeamercolor[fg]{titlelike} % alternately, topbarlike would be a good beamercolor +% \usebeamercolor[fg]{topbarlike} % alternately, topbarlike would be a good beamercolor + \draw[fill] (-\paperwidth,0) rectangle (0,-3pt); + \end{tikzpicture} +\fi +% +% + \vskip.2\beamer@leftmargin% + %\llap{\insertlogo\hskip.5\beamer@leftmargin}% + \llap{\insertlogo\hskip.08\beamer@leftmargin}% + \vfill% + \if \beamer@Flip@watermark\@empty + % This is kind of a kludge since if I put anything in here, I automatically get errors + % Somehow LaTeX wants to read the \else part! + \else% + \llap{\includegraphics[width=\paperwidth,height=\paperheight]{\beamer@Flip@watermark}} + \fi +} + + + +\mode +\endinput + + diff --git a/Lectures_my/NumMet/2016/Lecture10/beamerouterthemedecolines.sty b/Lectures_my/NumMet/2016/Lecture10/beamerouterthemedecolines.sty new file mode 100755 index 0000000..669e493 --- /dev/null +++ b/Lectures_my/NumMet/2016/Lecture10/beamerouterthemedecolines.sty @@ -0,0 +1,168 @@ +% Copyright 2007 by Marco Barisione +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. + +\mode + +% String used between the current page and the total page count. +\def\beamer@decolines@pageofpages{/} +\DeclareOptionBeamer{pageofpages}{\def\beamer@decolines@pageofpages{#1}} + +% Show a line below the frame title. +\DeclareOptionBeamer{titleline}[true]{\def\beamer@decolines@titleline{#1}} + +% Image used for the watermark. +\def\beamer@decolines@watermarkorig{} +\DeclareOptionBeamer{watermark}{\def\beamer@decolines@watermarkorig{#1}} + +% Height of the watermark. +\def\beamer@decolines@watermarkheight{100px} +\DeclareOptionBeamer{watermarkheight}{\def\beamer@decolines@watermarkheight{#1}} + +% The original image height is watermarkheightmult * watermarkheight. +\def\beamer@decolines@watermarkheightmult{1} +\DeclareOptionBeamer{watermarkheightmult}{\def\beamer@decolines@watermarkheightmult{#1}} + +\ExecuteOptionsBeamer{titleline=false} +\ProcessOptionsBeamer + +% Enable/disable the watermark. +\def\watermarkon{% + \def\beamer@decolines@watermark{\beamer@decolines@watermarkorig}% +} +\def\watermarkoff{\def\beamer@decolines@watermark{}} + +% Initially enable the watermark. +\watermarkon + +% Colors. +\setbeamercolor*{lineup}{parent=palette primary} +\setbeamercolor*{linemid}{parent=palette secondary} +\setbeamercolor*{linebottom}{parent=palette tertiary} +\setbeamercolor*{page header}{parent=titlelike} + +% Lengths +\newlength{\headerheight} +\setlength{\headerheight}{.045\paperheight} +\newlength{\beamer@decolines@lineup} +\setlength{\beamer@decolines@lineup}{.025\paperheight} +\newlength{\beamer@decolines@linemid} +\setlength{\beamer@decolines@linemid}{.015\paperheight} +\newlength{\beamer@decolines@linebottom} +\setlength{\beamer@decolines@linebottom}{.01\paperheight} + +% The height of the watermark part below the 3 bottom lines. +\newlength{\beamer@decolines@watermarkheightbottom} +\addtolength{\beamer@decolines@watermarkheightbottom}{\beamer@decolines@lineup} +\addtolength{\beamer@decolines@watermarkheightbottom}{\beamer@decolines@linemid} +\addtolength{\beamer@decolines@watermarkheightbottom}{\beamer@decolines@linebottom} + +% The height of the watermark part over the 3 bottom lines before shrinking. +\newlength{\beamer@decolines@watermarkheightupperorig} +\setlength{\beamer@decolines@watermarkheightupperorig}{\beamer@decolines@watermarkheight} +\addtolength{\beamer@decolines@watermarkheightupperorig}{-\beamer@decolines@watermarkheightbottom} +\multiply\beamer@decolines@watermarkheightupperorig by \beamer@decolines@watermarkheightmult + +% % Footer. +% \defbeamertemplate*{footline}{decolines theme} +% { +% \leavevmode% +% % Page number. +% \hbox{% +% \begin{beamercolorbox}[wd=.2\paperwidth,ht=0ex,dp=0ex,center]{}% +% \usebeamerfont{palette primary}\insertframenumber{} \beamer@decolines@pageofpages{} \inserttotalframenumber% +% \end{beamercolorbox}% +% \begin{beamercolorbox}[wd=.8\paperwidth,ht=0ex,dp=0ex]{}% +% \end{beamercolorbox}% +% } % +% % First line. +% \hbox{% +% \begin{beamercolorbox}[wd=.2\paperwidth,ht=\beamer@decolines@lineup,dp=0pt]{}% +% \end{beamercolorbox}% +% \begin{beamercolorbox}[wd=.8\paperwidth,ht=\beamer@decolines@lineup,dp=0pt]{lineup}% +% \end{beamercolorbox}% +% } % +% % Second line. +% \hbox{% +% \begin{beamercolorbox}[wd=\paperwidth,ht=\beamer@decolines@linemid,dp=0pt]{linemid}% +% \end{beamercolorbox}% +% } % +% % Third line. +% \hbox{% +% \begin{beamercolorbox}[wd=.1\paperwidth,ht=\beamer@decolines@linebottom,dp=0pt]{}% +% \end{beamercolorbox}% +% \begin{beamercolorbox}[wd=.9\paperwidth,ht=\beamer@decolines@linebottom,dp=0pt]{linebottom}% +% \end{beamercolorbox}% +% }% +% % This seems to fix some alignment problems with the watermark. It has to be +% % always applied if you do not want to see the footer moving up and down when +% % moving from a page with watermark to a page without or vice versa. +% \vskip-.5px% +% % Watermark. +% \if\beamer@decolines@watermark\@empty\else% +% \vskip-\beamer@decolines@watermarkheightbottom% +% \llap{\includegraphics[height=\beamer@decolines@watermarkheightbottom,clip=true,% +% trim=0pt 0pt 0pt \beamer@decolines@watermarkheightupperorig]{\beamer@decolines@watermark}\hskip-\paperwidth}% +% \fi% +% } + +\defbeamertemplate*{headline}{decolines theme} +{ + \leavevmode% + \hbox{% + \begin{beamercolorbox}[wd=\paperwidth,ht=\headerheight,dp=0pt]{page header}% + \end{beamercolorbox}% + } % + \vskip0pt% +} + +\defbeamertemplate*{frametitle}{decolines theme}[1][left] +{ + \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}% + \@tempdima=\textwidth% + \advance\@tempdima by\beamer@leftmargin% + \advance\@tempdima by\beamer@rightmargin% + \vbox{}\vskip-.5\beamer@leftmargin% + \begin{beamercolorbox}[sep=\beamer@leftmargin,#1,wd=\the\@tempdima]{} + \usebeamerfont{frametitle}\usebeamercolor[bg]{framesubtitle}% + \vbox{}\vskip0ex% + \if@tempswa\else\csname beamer@fte#1\endcsname\fi% + \strut\insertframetitle\strut\par% + {% + \ifx\insertframesubtitle\@empty% + \else% + {\usebeamerfont{framesubtitle}\usebeamercolor[bg]{framesubtitle}\insertframesubtitle\strut\par}% + \fi + }% + \vskip-1ex% + \if@tempswa\else\vskip-\beamer@leftmargin\fi + \end{beamercolorbox}% + \def\beamer@decolines@truetext{true}% + \ifx\beamer@decolines@titleline\beamer@decolines@truetext% + \vskip-.5\beamer@leftmargin% + \begin{beamercolorbox}[wd=\textwidth,ht=.1ex,dp=0ex]{linemid}% + \end{beamercolorbox}% + \fi +} + +% Frame title continuations, default +\defbeamertemplate*{frametitle continuation}{decolines theme}{(\insertcontinuationcount)} + + + +\defbeamertemplate*{sidebar right}{decolines theme} +{ + \vskip.1\beamer@leftmargin% + \llap{\insertlogo\hskip.5\beamer@leftmargin}% + \vfill% + \if\beamer@decolines@watermark\@empty\else% + \llap{\includegraphics[height=\beamer@decolines@watermarkheight]{\beamer@decolines@watermark}}% + \vskip-\beamer@decolines@watermarkheightbottom% + \fi +} + +\mode + diff --git a/Lectures_my/NumMet/2016/Lecture10/beamerthemeFlip.sty b/Lectures_my/NumMet/2016/Lecture10/beamerthemeFlip.sty new file mode 100755 index 0000000..a615ff5 --- /dev/null +++ b/Lectures_my/NumMet/2016/Lecture10/beamerthemeFlip.sty @@ -0,0 +1,59 @@ +% Main style file for the BEAMER FLIP THEME 2012 +% Copyright 2012 by Flip Tanedo +% This file may be distributed and/or modified +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% Comments: This is still a work in progress. +% A good way to present: http://www.cs.hmc.edu/~oneill/freesoftware/pdftokeynote.html + +% \usepackage{beamerthemesplit} +\mode + + +%% These are the options that are fed in through the driver file +%% Some of them get passed on to the other theme files +\DeclareOptionBeamer{bullet}{\PassOptionsToPackage{bullet=#1}{beamerinnerthemeFlip}} +\DeclareOptionBeamer{bigpagenumber}{\PassOptionsToPackage{bigpagenumber}{beamerouterthemeFlip}} +\DeclareOptionBeamer{topline}[true]{\PassOptionsToPackage{topline=#1}{beamerouterthemeFlip}} +\DeclareOptionBeamer{shadow}[false]{\PassOptionsToPackage{shadow=#1}{beamerinnerthemeFlip}} + +\DeclareOptionBeamer{watermark}{\PassOptionsToPackage{watermark=#1}{beamerouterthemeFlip}} + +\ProcessOptionsBeamer + +\useinnertheme{Flip} % Calls beamerinnerthemeFlip.sty +\useoutertheme{Flip} % Calls beamerouterthemeFlip.sty +\usecolortheme{Flip} % Calls beamercolorthemeFlip.sty + + + +%%%%%%%%%%%%%%%%%%%%%%%% +% Background Gradient % +%%%%%%%%%%%%%%%%%%%%%%%% + + +%% Usually I would leave this on +%% However, there seems to be problems with XeLaTeX +%% http://tex.stackexchange.com/questions/29497/xelatex-preventing-beamer-from-using-different-backgrounds +\setbeamertemplate{background canvas}[vertical shading][bottom=blue!.1, middle=white, top=white] + +%% HOWEVER: it seems to make it impossible to change this later on in the document + + +%% For a dark background: +% \setbeamertemplate{background canvas}[vertical shading][bottom=keynotebottom, middle=keynotemiddle, top=keynotetop] + + +%% An alternate way: \beamertemplateshadingbackground{blue!.1}{red!2} +%% In general: you want the gradient to be subtle! + + +%%%%%%%%%%%%%%%%%%%%%%% +% Navigation symbols % +%%%%%%%%%%%%%%%%%%%%%%% + +\setbeamertemplate{navigation symbols}{} % Turns off PDF navigation symbols + +\mode +\endinput \ No newline at end of file diff --git a/Lectures_my/NumMet/2016/Lecture10/lecture10.tex b/Lectures_my/NumMet/2016/Lecture10/lecture10.tex new file mode 100644 index 0000000..0a7397b --- /dev/null +++ b/Lectures_my/NumMet/2016/Lecture10/lecture10.tex @@ -0,0 +1,729 @@ +% vim: set sts=4 et : +\documentclass[11 pt,xcolor={dvipsnames,svgnames,x11names,table}]{beamer} + +\usetheme[ + bullet=circle, % Other option: square + bigpagenumber, % circled page number on lower right + topline=true, % colored bar at the top of the frame + shadow=false, % Shading for beamer blocks + watermark=BG_lower, % png file for the watermark + ]{Flip} + +\usepackage{bm} +\usepackage{tikz,pgfplots,pgfplotstable} +\usepgfplotslibrary{fillbetween} +\usepackage{graphicx} + +% SOME COMMANDS THAT I FIND HANDY +% \renewcommand{\tilde}{\widetilde} % dinky tildes look silly, dosn't work with fontspec +\newcommand{\comment}[1]{\textcolor{comment}{\footnotesize{#1}\normalsize}} % comment mild +\newcommand{\Comment}[1]{\textcolor{Comment}{\footnotesize{#1}\normalsize}} % comment bold +\newcommand{\COMMENT}[1]{\textcolor{COMMENT}{\footnotesize{#1}\normalsize}} % comment crazy bold +\newcommand{\Alert}[1]{\textcolor{Alert}{#1}} % louder alert +\newcommand{\ALERT}[1]{\textcolor{ALERT}{#1}} % loudest alert +%% "\alert" is already a beamer pre-defined +\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}% + +\graphicspath{{images/}} % Put all images in this directory. Avoids clutter. + +% suppress frame numbering for backup slides +% you always need the appendix for this! +\newcommand{\backupbegin}{ + \newcounter{framenumberappendix} + \setcounter{framenumberappendix}{\value{framenumber}} +} +\newcommand{\backupend}{ + \addtocounter{framenumberappendix}{-\value{framenumber}} + \addtocounter{framenumber}{\value{framenumberappendix}} +} + +\begin{document} +\tikzstyle{every picture}+=[remember picture] + +{ +\setbeamertemplate{sidebar right}{\llap{\includegraphics[width=\paperwidth,height=\paperheight]{bubble2}}} +\begin{frame}[c]%{\phantom{title page}} +\begin{center} +\begin{center} + \begin{columns} + \begin{column}{0.9\textwidth} + \flushright%\fontspec{Trebuchet MS} + \bfseries \Huge {Ordinary Differential Equations (I)} + \end{column} + \begin{column}{0.2\textwidth} + %\includegraphics[width=\textwidth]{SHiP-2} + \end{column} + \end{columns} +\end{center} + \quad + \vspace{3em} +\begin{columns} +\begin{column}{0.6\textwidth} +\flushright \vspace{-1.8em} {%\fontspec{Trebuchet MS} + \large Marcin Chrzaszcz, Danny van Dyk\\\vspace{-0.1em}\small \href{mailto:mchrzasz@cern.ch}{mchrzasz@cern.ch}, \href{mailto:danny.van.dyk@gmail.com}{danny.van.dyk@gmail.com}} + +\end{column} +\begin{column}{0.4\textwidth} +\includegraphics[height=1.3cm]{uzh-transp} +\end{column} +\end{columns} + +\vspace{1em} +\vspace{0.5em} + \textcolor{normal text.fg!50!Comment}{Numerical Methods, \\ 07. November, 2016} +\end{center} +\end{frame} +} + +\begin{frame}{Plan for today} + \begin{itemize} + \item \alert{Catching up with last time}\\ + \begin{itemize} + \item What does an implicit Runge-Kutta method look like? + \end{itemize} + \vfill + \item \alert{So far we discussed ODEs of first order}\\ + \begin{itemize} + \item How to turn an ODE of order $n$ into a system of $n$ ODEs of first order? + \end{itemize} + \vfill + \item \alert{Specific problem of a given ODE in a boundary value problem}\\ + \begin{itemize} + \item How can we use our knowledge of initial value problems to solve these? + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame}{Implicit Runge-Kutta methods} + Butcher Tableau now fully filled + \begin{center} + \renewcommand{\arraystretch}{1.2} + \begin{tabular}{c|ccccc} + $c_1$ & $a_{1,1}$ & $a_{1,2}$ & $\dots$ & $a_{1,s-1}$ & $a_{1,s}$ \\ + $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\ + $c_s$ & $a_{s,1}$ & $a_{s,2}$ & $\dots$ & $a_{s,s-1}$ & $a_{s,s}$ \\ + \hline + & $b_1$ & $b_2$ & $\dots$ & $b_{s-1}$ & $b_s$ \\ + \end{tabular} + \renewcommand{\arraystretch}{1.0} + \end{center} +\end{frame} + +\begin{frame}{Tangent: Fixed-point problems} + \begin{equation*} + z^{(i + 1)} = f(z_{(i)}) + \end{equation*} + where $i$ denotes the iteration index, and we start at $i=0$. + Convergence? +\end{frame} + +\begin{frame}{Practical Aspects} + We can view implicit single step methods + \begin{equation*} + y' = f(x, y)\qquad y_{n + 1} = y_{n} + \Phi(F; x_n, h; y_n, y_{n+1}) + \end{equation*} + as a fixed point problem: + \begin{itemize} + \item start with a guess for $y_{n,i=0}$, e.g. based on an explicit method + \item compute the new approximation of the implict result for $y_{n+1}$ as + \begin{equation*} + y_{n+1, i+1} = y_n + \Phi(F; x_n, h; y_n, y_{n+1, i}) + \end{equation*} + \item stop after a fixed number of iterations, or when the difference between + previous and current iteration falls below a pre-determined threshold. + \end{itemize} +\end{frame} + +\begin{frame}{Example} +\end{frame} + +\begin{frame}{ODE of order $2$} + Let's start with an explicit ODE of order $2$: + \begin{align*} + y'' & = f(x; y, y') + \end{align*} + Let's rename $y(x) \to z_1(x)$ introduce a new function $z_2(x) = y'(x)$, such that + we can write + \begin{align*} + z_2' & = f_2(x; z_1, z_2) & & [\equiv f(x; y = z_1, y' = z_2)]\\ + z_1' & = f_1(x; z_1) & & [\equiv z_2] + \end{align*} + We can now solve the (vector-valued) ODE of order $1$. +\end{frame} + +\begin{frame}{Generalization to order $N$} +\end{frame} + +\pgfplotstableread{ +x J Jp +1. 0.440051 0.325147 +1.05 0.455897 0.308608 +1.1 0.470902 0.291529 +1.15 0.485041 0.273945 +1.2 0.498289 0.255892 +1.25 0.510623 0.237407 +1.3 0.522023 0.21853 +1.35 0.53247 0.199297 +1.4 0.541948 0.17975 +1.45 0.550441 0.159927 +1.5 0.557937 0.13987 +1.55 0.564424 0.11962 +1.6 0.569896 0.0992172 +1.65 0.574344 0.0787044 +1.7 0.577765 0.058123 +1.75 0.580156 0.0375147 +1.8 0.581517 0.0169214 +1.85 0.581849 -0.00361515 +1.9 0.581157 -0.0240536 +1.95 0.579446 -0.0443527 +2. 0.576725 -0.0644716 +}{\BesselJtable} + +\pgfplotstableread{ +1 0.440051 0.325147 +1.05 0.455468 0.308347 +1.1 0.47002 0.291039 +1.15 0.483683 0.273261 +1.2 0.496435 0.255049 +1.25 0.508257 0.236443 +1.3 0.519132 0.21748 +1.35 0.529042 0.198202 +1.4 0.537974 0.178647 +1.45 0.545917 0.158856 +1.5 0.55286 0.138869 +1.55 0.558797 0.118729 +1.6 0.56372 0.0984759 +1.65 0.567628 0.078151 +1.7 0.570518 0.0577958 +1.75 0.57239 0.0374514 +1.8 0.573248 0.0171588 +1.85 0.573096 -0.00304138 +1.9 0.571941 -0.0231087 +1.95 0.569791 -0.0430032 +}{\numBesselJtable} + + +\begin{frame}{Example} + Let's take the Bessel equation:\hfill\only<2>{in explicit form} + \begin{overlayarea}{\textwidth}{.2\textheight} + \begin{equation*} + \only<1>{ + x^2 y'' + x y' + (x^2 - \nu^2) y = 0 + } + \only<2>{ + y'' = -\frac{1}{x} y' - \left(1 - \frac{\nu^2}{x^2}\right) y + } + \end{equation*} + \end{overlayarea} + \begin{columns} + \begin{column}{.7\textwidth} + \resizebox{\textwidth}{!}{ + \begin{tikzpicture} + \begin{axis}[% + axis x line=center, + axis y line=left, + ymin=-0.25,ymax=+0.65, + xmin=+1.00,xmax=+2.00 + ] + \addplot+[ + ultra thick, + mark=none, + color=blue, + ] table [ + x index=0, + y index=1 + ] {\BesselJtable}; + \addplot+[ + ultra thick, + mark=none, + color=red, + ] table [ + x index=0, + y index=2 + ] {\BesselJtable}; + \addplot+[ + ultra thick, + only marks, + mark=x, + color=blue, + ] table [ + x index=0, + y index=1 + ] {\numBesselJtable}; + \addplot+[ + ultra thick, + only marks, + mark=+, + color=red, + ] table [ + x index=0, + y index=2 + ] {\numBesselJtable}; + \end{axis} + \end{tikzpicture} + } + \end{column} + \begin{column}{.3\textwidth} + \begin{block}{IVP} + $y(1) = 0.44051$\\ + $y'(1) = 0.325147$\\ + $h = 0.05$\\ + + Using implicit Euler method! + \end{block} + \end{column} + \end{columns} +\end{frame} + +\begin{frame}{Boundary Value Problems} + \begin{align*} + y(a) & = y_0 & + y(b) & = Y + \end{align*} +\end{frame} + +\backupbegin + +\begin{frame}\frametitle{Backup} + +\end{frame} + +\begin{frame}{Nomenclature and Preliminaries} + We will discuss \alert{ordinary} \alert{differential equation}s, or \alert{systems} of + \alert{linear} ordinary differential equations: + \begin{overlayarea}{\textwidth}{.7\textheight} + \begin{description} + \item<1->[differential equation] Any equation of the form + \begin{equation*} + F(x; y, y', y^{(2)}, \dots, y^{(n)}) = 0 + \end{equation*} + with $x\in \mathbb{R}$ and $y(x): \mathbb{R} \mapsto \mathbb{R}^m$ + is called a system of ordinary differential equations of \alert{order $n$}.\\ + If $m=1$, it is only \alert{one} ordinary diff.\ equation (ODE).\\ + \only<1>{ + \item[linear] If we can write + \begin{equation*} + F(x; y, \dots, y^{(n)}) = A(x) \cdot \vec{y}(x) + r(x) + \end{equation*} + with $A(x) \in \mathbb{R}^{m\times (n+1)}$, $\vec{y}(x) = (y(x), \dots y^{(n)}(x))^T$ + and $r(x) \in \mathbb{R}^m$, then + $F$ describes a \alert{linear} system of ODEs. + } + \only<2>{ + \item[ordinary] The quality \alert{ordinary} hinges on the fact that $y$ only + depends on $x\in\mathbb{R}$. As soon as $x\in \mathbb{R}^{k}$, and we need to + consider partial derivatives of $y$, we have a \alert{partial} differential equation. + } + \only<3>{ + \item[explicit] If for an $n$th order ODE we can write + \begin{equation*} + y^{(n)} = f(x; y, \dots, y^{(n - 1)}) + \end{equation*} + then we call this an \alert{explicit} ODE. Otherwise, the ODE is \alert{implicit}. + } + \end{description} + \end{overlayarea} +\end{frame} + +\begin{frame}{Explicit linear ODEs of order $n=1$/Initial value problem} + Let's use a well-known linear ODE of 2nd order as an example: + \begin{equation*} + y' = f(x; y) = -y(x) + \end{equation*} + + Solving it, regardless of method, poses an \alert{initial value problem}: + \begin{equation} + \frac{y(x)}{y(x_0)} = \exp(-(x - x_0)) + \end{equation} + We need to know the initial value $y_0\equiv y(x_0)$ to solve this problem. + It must be provided \alert{externally}. +\end{frame} + +\begin{frame}{Single Step Methods} + We want to increment by one \alert{step}, i.e. from the point $(x_n, y_n)$ to the + point $(x_n + h, y_{n + 1})$. + The increment is defined by the incremental function $\Phi$: + \begin{equation*} + y_{n+1} = y_n + \Phi(F; x_n, h; y_n, y_{n+1}); + \end{equation*} + with a step size $h$. This is an implicit method. If $\Phi$ does not depend on + $y_{n+1}$, we have an explicit method. + \vfill + Whatever the choice of $\Phi$, for an implicit method we will need, in general, + to solve a non-linear equation ($\rightarrow$ see lecture on root finding). That + means that an implicit method is computationally more expensive than a similar + explicit method. +\end{frame} + +\begin{frame}{Explicit Single Step Methods: Euler Method} + \begin{block}{First order ODE} + ~\\ + \vspace{-2\bigskipamount} + \begin{align*} + y' & = f(x, y) & + y_{n+1} & = y_n + \Phi(f; x_n, h; y_n) + \end{align*} + \end{block} + Standard procedure for an unknown function: Taylor expand! + \begin{align*} + y(x_n + h) & = y(x_n) + h y'(x_n) + \frac{h^2}{2} y''(x_n) + O(h^3) + \end{align*} + Keeping only terms of order $h$, and substituting $y'(x_n) = f(x_n = x_0 + n\cdot h, y_n)$ + we obtain + \begin{block}{Euler method} + \begin{align*} + y_{n+1} & = y_n + \underbrace{h\,f(x_n, y_n)}_{=\Phi_\text{Euler}(f; x_n, h; y_n)} + \end{align*} + \end{block} +\end{frame} + +\begin{frame}{Local Truncation Error for Euler Method} + The local trunction error (LTE) is introduced as: + \begin{equation*} + y(x_0 + h) - y_0 \equiv \text{LTE} = \frac{h^2}{2} y''(x_0) + O(h^3) + \end{equation*} + \begin{overlayarea}{\textwidth}{.7\textheight} + \begin{columns} + \begin{column}{.4\textwidth} + \begin{block}{Example} + The ODE at hand reads: + \begin{align*} + y' & = -y\,, & + y_0 & = 0.5 + \end{align*} + The analytic solution is: + \begin{equation*} + y(x) = y_0 \, \exp(-x) + \end{equation*} + \end{block} + \end{column} + \begin{column}{.6\textwidth} + \resizebox{\textwidth}{!}{ + \begin{tikzpicture} + \begin{axis}[% + axis x line=center, + axis y line=left, + ymin=0.0,ymax=0.55, + xmin=0.0,xmax=+1, + samples=160 + ] + \addplot[ultra thick,gray,domain=0:+1] { + 0.5 * exp(-x) + }; + \addplot[thick,red,only marks,mark size=3pt] coordinates { + (0.25, 0.375) % h = 0.25 + (0.50, 0.250) % h = 0.50 + (1.00, 0.000) % h = 1.00 + }; + \addplot[thin,red,mark=none] { + 0.5 - 0.5 * x + }; + \end{axis} + \end{tikzpicture} + } + \begin{center}$h$\end{center} + \end{column} + \end{columns} + \end{overlayarea} +\end{frame} + +\newcommand{\hl}[1]{{\color{red}#1}} +\begin{frame}{Explicit Single Step Methods: Runge-Kutta Methods} + For Runge-Kutta methods an alternative derivation for the determination $y_{n+1}$ + uses an integral representation: + \begin{equation*} + y_{n+1} = y_n + \int_{x_n}^{x_n + h} \mathrm{d}x\, f(x, y(x))\,. + \end{equation*} + \vspace{-\medskipamount} + The \alert{$s$}-stage Runge-Kutta method then estimates this integral + \begin{equation*} + y_{n+1} = y_n + \sum_{i=1}^{\alert{s}} \hl{b_i} k_i + \end{equation*} + \vspace{-\medskipamount} + where + \begin{align*} + k_1 & = f(x_n ,& y_n & & )\\ + k_2 & = f(x_n + \hl{c_2} h,& y_n & + h\, \hl{a_{2,1}} k_1 & )\\ + k_3 & = f(x_n + \hl{c_3} h,& y_n & + h\, \hl{a_{3,1}} k_1 + h\,\hl{a_{3,2}} k_2 & )\\ + & \quad\vdots & & \vdots\\ + k_s & = (fx_n + \hl{c_s} h,& y_n & + h\, \hl{a_{s,1}} k_1 + \dots + h\,\hl{a_{s,(s-1)}} k_{s-1} & ) + \end{align*} + Now to determine the coefficients $\lbrace \hl{a_{i,j}} \rbrace$, $\lbrace \hl{b_i} \rbrace$, + and $\lbrace \hl{c_i} \rbrace$. +\end{frame} + +\begin{frame}{Explicit Single Step Methods: Runge-Kutta (cont'd)} + Usual presentation of the necessary coefficients in a \alert{Butcher tableau}: + \begin{center} + \renewcommand{\arraystretch}{1.2} + \begin{tabular}{c|ccccc} + $0$ & \\ + $c_2$ & $a_{2,1}$ \\ + $c_3$ & $a_{3,1}$ & $a_{3,2}$ \\ + $\vdots$ & $\vdots$ & & $\ddots$ \\ + $c_s$ & $a_{s,1}$ & $a_{s,2}$ & $\dots$ & $a_{s,s-1}$ \\ + \hline + & $b_1$ & $b_2$ & $\dots$ & $b_{s-1}$ & $b_s$ \\ + \end{tabular} + \renewcommand{\arraystretch}{1.0} + \end{center} + + To take away: + \begin{itemize} + \item a method of stage $s$ requires \alert{in general} $s$ evaluations of + $f$ + \item the LTE is of order $p$, i.e.: $\text{LTE} = O(h^{p + 1})$ + \item in general $s > p$ + \item up to $s = 4$ there are methods known with $s \geq p$ + \end{itemize} +\end{frame} + +\begin{frame}{Explicit Single Step Methods: Runge-Kutta (cont'd)} + \begin{block}{Euler's method} + \begin{columns} + \begin{column}{.5\textwidth} + \begin{tabular}{c|c} + $0$ & \\ + \hline + & $b_1$ \\ + \end{tabular} + \end{column} + \begin{column}{.5\textwidth} + \begin{itemize} + \item method of stage 1 and order 1 + \end{itemize} + \end{column} + \end{columns} + \end{block} + + \begin{block}{Ralston's method} + \begin{columns} + \begin{column}{.5\textwidth} + \begin{tabular}{c|cc} + $0$ & \\ + $2/3$ & $2/3$ \\ + \hline + & $1/4$ & $3/4$ \\ + \end{tabular} + \end{column} + \begin{column}{.5\textwidth} + \begin{itemize} + \item method of stage 2 and order 2 + \end{itemize} + \end{column} + \end{columns} + \end{block} + + \begin{block}{RK4 (\emph{The} Runge-Kutta method)} + \begin{columns} + \begin{column}{.5\textwidth} + \begin{tabular}{c|ccccc} + $0$ & \\ + $1/2$ & $1/2$ \\ + $1/2$ & $0$ & $1/2$ \\ + $1$ & $0$ & $0$ & $1$ & $0$ \\ + \hline + & $1/6$ & $1/3$ & $1/3$ & $1/6$ \\ + \end{tabular} + \end{column} + \begin{column}{.5\textwidth} + \begin{itemize} + \item method of stage 4 and order 4 + \end{itemize} + \end{column} + \end{columns} + \end{block} +\end{frame} + +\begin{frame}{Global Truncation Error/Accumulated Error} + \begin{columns} + \begin{column}{.7\textwidth} + \resizebox{\textwidth}{!}{ + \begin{tikzpicture} + \begin{axis}[% + axis x line=center, + axis y line=left, + ymin=-1.2040,ymax=-0.59784, + xmin=0.0,xmax=+0.5, + samples=160 + ] + \addplot[ultra thick,gray,domain=0:+1] { + ln(0.5) - x + }; + % Euler, h = 0.125 + \addplot[thick,blue,mark=x,only marks,mark size=3pt] coordinates { + (0.125, -0.82668) % ln(0.43750) + (0.250, -0.96022) % ln(0.38281) + (0.375, -1.09370) % ln(0.33496) + }; + % Runge-Kutta, h = 0.125 + \addplot[thick,red,mark=+,only marks,mark size=3pt] coordinates { + (0.125, -0.81814) % ln(0.44125) + (0.250, -0.94314) % ln(0.38940) + (0.375, -1.06810) % ln(0.34364) + }; + \end{axis} + \end{tikzpicture} + } + \end{column} + \begin{column}{.3\textwidth} + \begin{itemize} + \item[{\color{blue} x}] Euler method\\ + $h = 0.125$\\ + order $p = 1$ + \item[{\color{red} +}] Runge-Kutta 4\\ + $h = 0.125$\\ + order $p = 4$ + \end{itemize} + \end{column} + \end{columns} + The differences in accumulated trunction errors is clearly visible +\end{frame} + +\begin{frame}{Wastefulness of Single-Step Methods} + In order to achieve a single step, the previously shown methods + of stage $s$ evaluate the function $f(x; y)$ in at least $s$ points.\\ + \vfill + However, all the information obtained from these evaluations is + thrown away before the next step.\\ + \vfill + It would be efficient to reuse this information, which gives + rise to the \alert{multiple step methods}. +\end{frame} + +\begin{frame}{Multiple Step Methods} + An explicit \alert{multiple step method} of \alert{length $m$} follows from: + \begin{equation*} + y_{n+1} = -\sum_{j=0}^{m - 1} \hl{a_{j}} \, y_{n - j} + h\,\sum_{j=0}^{m - 1} \hl{b_{j}} \, f(x_{n - j}, y_{n - j}) + \end{equation*} + + Again, one strives to choose the coefficients $\lbrace \hl{a_i}\rbrace$ and $\lbrace \hl{b_i}\rbrace$ + such that the LTE is of high order in $h$. +\end{frame} + +\begin{frame}{Adams-Bashforth methods} + In Adams-Bashforth methods one chooses $\hl{a_0} = -1$, and $\hl{a_i} = 0$ for $i\geq 1$. + The coefficients $\lbrace \hl{b_i} \rbrace$ are chosen such that $y(x)$ is interpolated + in the last $m$ steps: + \begin{equation*} + \hl{b_{m - j - 1}} = \frac{(-1)^j}{j!\, (m - j - 1)!} \int_0^1 \prod_{i=0,i\neq j}^{s - 1} \mathrm{d}u\, (u + i)\,. + \end{equation*} + for $j = 0, \dots, m - 1$.\\[\medskipamount] + + The order $p$ of any Adams-Bashforth method is $p=m$. +\end{frame} + +\begin{frame}{Stiff ODEs} + \begin{block}{Example ODE} + \begin{equation*} + y' = -15\, y\qquad \text{with} \quad y(x_0) = y_0 = 1.0\,. + \end{equation*} + \end{block} + \begin{overlayarea}{\textwidth}{.7\textheight} + \only<1>{ + \vfill + \includegraphics[width=\textwidth]{StiffEquationNumericalSolvers}\\ + ~\hfill{\tiny shamelessly taken from Wikipedia} + } + \only<2>{ + \begin{itemize} + \item a stiff ODE forces you to go to \alert{unreasonably small} + step size $h$ in order to have reasonable convergence of the method + \vfill + \item in general, \alert{explicit} methods demand smaller step sizes + than computationally reasonable + \vfill + \item implicit methods solve this problem at the expense of additional + evaluations of the generation function $F$ when solving for the + increment + \end{itemize} + } + \end{overlayarea} +\end{frame} + +\begin{frame}{Implicit Euler Method} + (Also known as the backward Euler method) + \begin{equation*} + y_{n + 1} = y_n + h\cdot f(x_{n+1}, y_{n+1}) + \end{equation*} + ~\\ + \vspace{-2\bigskipamount} + \begin{block}{Example with stiff ODE} + \begin{equation*} + y' = -y,\qquad \text{with} \quad y_0 = y(x_0) = 0.5 + \end{equation*} + ~\\ + \begin{overlayarea}{\textwidth}{.5\textheight} + \vspace{-2\bigskipamount} + \only<1,3>{ + \begin{columns} + \begin{column}{.6\textwidth} + \resizebox{\textwidth}{!}{ + \begin{tikzpicture} + \begin{axis}[% + axis x line=center, + axis y line=left, + ymin=0.30,ymax=0.51, + xmin=0.00,xmax=0.50, + samples=160 + ] + \addplot[ultra thick,black,domain=0:+1] { + 0.5 * exp(-x) + }; + % Euler, h = 0.125 + \addplot[thick,blue,mark=x,only marks,mark size=3pt] coordinates { + (0.125, 0.43750) + (0.250, 0.38281) + (0.375, 0.33496) + }; + \only<3>{ + % Implict Euler, h = 0.125 + \addplot[thick,red,mark=+,only marks,mark size=3pt] coordinates { + (0.125, 0.444) + (0.250, 0.395) + (0.375, 0.351) + }; + } + \end{axis} + \end{tikzpicture} + } + \end{column} + \begin{column}{.4\textwidth} + \begin{itemize} + \item[{\color{blue} x}] regular Euler\\ + $h = 0.125$ + \item<3>[{\color{red} +}] implicit Euler\\ + $h = 0.125$ + \end{itemize} + \end{column} + \end{columns} + } + \only<2>{ + \begin{align*} + y_{n + 1} & = y_n + h\, f(x_{n+1}, y_{n +1})\\ + & = y_n - h\, y_{\hl{n + 1}}\\ + \Rightarrow + y_{n + 1} & = \frac{y_n}{1 + h} + \end{align*} + This yields the analytic result in the limit $h\to 0$ ($h = h_0 / n$, $n \to \infty$), since: + \begin{equation*} + \lim_{n\to \infty} \frac{y_0}{(1 + \frac{x}{n})^n} = y_0 \exp(-x) + \end{equation*} + } + \end{overlayarea} + \end{block} +\end{frame} + +\begin{frame}{Next time on Ordinary Differential Equations} + \begin{itemize} + \item \alert{implicit} Runge-Kutta methods + \vfill + \item how to turn an $n$-order ODE into an $n$-size \alert{system} of + first-order ODEs + \vfill + \item a glimpse at \alert{boundary problems} + \end{itemize} +\end{frame} + +\backupend +\end{document}