\documentclass[11pt]{article} \usepackage[breakable]{tcolorbox} \usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour) % Basic figure setup, for now with no caption control since it's done % automatically by Pandoc (which extracts ![](path) syntax from Markdown). \usepackage{graphicx} % Keep aspect ratio if custom image width or height is specified \setkeys{Gin}{keepaspectratio} % Maintain compatibility with old templates. Remove in nbconvert 6.0 \let\Oldincludegraphics\includegraphics % Ensure that by default, figures have no caption (until we provide a % proper Figure object with a Caption API and a way to capture that % in the conversion process - todo). \usepackage{caption} \DeclareCaptionFormat{nocaption}{} \captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt} \usepackage{float} \floatplacement{figure}{H} % forces figures to be placed at the correct location \usepackage{xcolor} % Allow colors to be defined \usepackage{enumerate} % Needed for markdown enumerations to work \usepackage{geometry} % Used to adjust the document margins \usepackage{amsmath} % Equations \usepackage{amssymb} % Equations \usepackage{textcomp} % defines textquotesingle % Hack from http://tex.stackexchange.com/a/47451/13684: \AtBeginDocument{% \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code } \usepackage{upquote} % Upright quotes for verbatim code \usepackage{eurosym} % defines \euro \usepackage{iftex} \ifPDFTeX \usepackage[T1]{fontenc} \IfFileExists{alphabeta.sty}{ \usepackage{alphabeta} }{ \usepackage[mathletters]{ucs} \usepackage[utf8]{inputenc} } \else \usepackage{fontspec} \usepackage{unicode-math} \fi \usepackage{fancyvrb} % verbatim replacement that allows latex \usepackage{grffile} % extends the file name processing of package graphics % to support a larger range \makeatletter % fix for old versions of grffile with XeLaTeX \@ifpackagelater{grffile}{2019/11/01} { % Do nothing on new versions } { \def\Gread@@xetex#1{% \IfFileExists{"\Gin@base".bb}% {\Gread@eps{\Gin@base.bb}}% {\Gread@@xetex@aux#1}% } } \makeatother \usepackage[Export]{adjustbox} % Used to constrain images to a maximum size \adjustboxset{max size={0.9\linewidth}{0.9\paperheight}} % The hyperref package gives us a pdf with properly built % internal navigation ('pdf bookmarks' for the table of contents, % internal cross-reference links, web links for URLs, etc.) \usepackage{hyperref} % The default LaTeX title has an obnoxious amount of whitespace. By default, % titling removes some of it. It also provides customization options. \usepackage{titling} \usepackage{longtable} % longtable support required by pandoc >1.10 \usepackage{booktabs} % table support for pandoc > 1.12.2 \usepackage{array} % table support for pandoc >= 2.11.3 \usepackage{calc} % table minipage width calculation for pandoc >= 2.11.1 \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment) \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout) % normalem makes italics be italics, not underlines \usepackage{soul} % strikethrough (\st) support for pandoc >= 3.0.0 \usepackage{mathrsfs} % Colors for the hyperref package \definecolor{urlcolor}{rgb}{0,.145,.698} \definecolor{linkcolor}{rgb}{.71,0.21,0.01} \definecolor{citecolor}{rgb}{.12,.54,.11} % ANSI colors \definecolor{ansi-black}{HTML}{3E424D} \definecolor{ansi-black-intense}{HTML}{282C36} \definecolor{ansi-red}{HTML}{E75C58} \definecolor{ansi-red-intense}{HTML}{B22B31} \definecolor{ansi-green}{HTML}{00A250} \definecolor{ansi-green-intense}{HTML}{007427} \definecolor{ansi-yellow}{HTML}{DDB62B} \definecolor{ansi-yellow-intense}{HTML}{B27D12} \definecolor{ansi-blue}{HTML}{208FFB} \definecolor{ansi-blue-intense}{HTML}{0065CA} \definecolor{ansi-magenta}{HTML}{D160C4} \definecolor{ansi-magenta-intense}{HTML}{A03196} \definecolor{ansi-cyan}{HTML}{60C6C8} \definecolor{ansi-cyan-intense}{HTML}{258F8F} \definecolor{ansi-white}{HTML}{C5C1B4} \definecolor{ansi-white-intense}{HTML}{A1A6B2} \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF} \definecolor{ansi-default-inverse-bg}{HTML}{000000} % common color for the border for error outputs. \definecolor{outerrorbackground}{HTML}{FFDFDF} % commands and environments needed by pandoc snippets % extracted from the output of `pandoc -s` \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} % Add ',fontsize=\small' for more characters per line \newenvironment{Shaded}{}{} \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} \newcommand{\RegionMarkerTok}[1]{{#1}} \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} \newcommand{\NormalTok}[1]{{#1}} % Additional commands for more recent versions of Pandoc \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}} \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}} \newcommand{\ImportTok}[1]{{#1}} \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}} \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}} \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}} \newcommand{\BuiltInTok}[1]{{#1}} \newcommand{\ExtensionTok}[1]{{#1}} \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}} \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}} \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} \makeatletter \newsavebox\pandoc@box \newcommand*\pandocbounded[1]{% \sbox\pandoc@box{#1}% % scaling factors for width and height \Gscale@div\@tempa\textheight{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}% \Gscale@div\@tempb\linewidth{\wd\pandoc@box}% % select the smaller of both \ifdim\@tempb\p@<\@tempa\p@ \let\@tempa\@tempb \fi % scaling accordingly (\@tempa < 1) \ifdim\@tempa\p@<\p@ \scalebox{\@tempa}{\usebox\pandoc@box}% % scaling not needed, use as it is \else \usebox{\pandoc@box}% \fi } \makeatother % Define a nice break command that doesn't care if a line doesn't already % exist. \def\br{\hspace*{\fill} \\* } % Math Jax compatibility definitions \def\gt{>} \def\lt{<} \let\Oldtex\TeX \let\Oldlatex\LaTeX \renewcommand{\TeX}{\textrm{\Oldtex}} \renewcommand{\LaTeX}{\textrm{\Oldlatex}} % Document parameters % Document title \title{arrays} % Pygments definitions \makeatletter \def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax% \let\PY@ul=\relax \let\PY@tc=\relax% \let\PY@bc=\relax \let\PY@ff=\relax} \def\PY@tok#1{\csname PY@tok@#1\endcsname} \def\PY@toks#1+{\ifx\relax#1\empty\else% \PY@tok{#1}\expandafter\PY@toks\fi} \def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{% \PY@it{\PY@bf{\PY@ff{#1}}}}}}} \def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}} \@namedef{PY@tok@w}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}} \@namedef{PY@tok@c}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}} \@namedef{PY@tok@cp}{\def\PY@tc##1{\textcolor[rgb]{0.61,0.40,0.00}{##1}}} \@namedef{PY@tok@k}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@kp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@kt}{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}} \@namedef{PY@tok@o}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@ow}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} \@namedef{PY@tok@nb}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@nf}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} \@namedef{PY@tok@nc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} \@namedef{PY@tok@nn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} \@namedef{PY@tok@ne}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.80,0.25,0.22}{##1}}} \@namedef{PY@tok@nv}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} \@namedef{PY@tok@no}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}} \@namedef{PY@tok@nl}{\def\PY@tc##1{\textcolor[rgb]{0.46,0.46,0.00}{##1}}} \@namedef{PY@tok@ni}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.44,0.44,0.44}{##1}}} \@namedef{PY@tok@na}{\def\PY@tc##1{\textcolor[rgb]{0.41,0.47,0.13}{##1}}} \@namedef{PY@tok@nt}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@nd}{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} \@namedef{PY@tok@s}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@sd}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@si}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.64,0.35,0.47}{##1}}} \@namedef{PY@tok@se}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.36,0.12}{##1}}} \@namedef{PY@tok@sr}{\def\PY@tc##1{\textcolor[rgb]{0.64,0.35,0.47}{##1}}} \@namedef{PY@tok@ss}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} \@namedef{PY@tok@sx}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@m}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@gh}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} \@namedef{PY@tok@gu}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}} \@namedef{PY@tok@gd}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}} \@namedef{PY@tok@gi}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.52,0.00}{##1}}} \@namedef{PY@tok@gr}{\def\PY@tc##1{\textcolor[rgb]{0.89,0.00,0.00}{##1}}} \@namedef{PY@tok@ge}{\let\PY@it=\textit} \@namedef{PY@tok@gs}{\let\PY@bf=\textbf} \@namedef{PY@tok@gp}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} \@namedef{PY@tok@go}{\def\PY@tc##1{\textcolor[rgb]{0.44,0.44,0.44}{##1}}} \@namedef{PY@tok@gt}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}} \@namedef{PY@tok@err}{\def\PY@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}} \@namedef{PY@tok@kc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@kd}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@kn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@kr}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@bp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} \@namedef{PY@tok@fm}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} \@namedef{PY@tok@vc}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} \@namedef{PY@tok@vg}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} \@namedef{PY@tok@vi}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} \@namedef{PY@tok@vm}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} \@namedef{PY@tok@sa}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@sb}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@sc}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@dl}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@s2}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@sh}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@s1}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} \@namedef{PY@tok@mb}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@mf}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@mh}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@mi}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@il}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@mo}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} \@namedef{PY@tok@ch}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}} \@namedef{PY@tok@cm}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}} \@namedef{PY@tok@cpf}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}} \@namedef{PY@tok@c1}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}} \@namedef{PY@tok@cs}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}} \def\PYZbs{\char`\\} \def\PYZus{\char`\_} \def\PYZob{\char`\{} \def\PYZcb{\char`\}} \def\PYZca{\char`\^} \def\PYZam{\char`\&} \def\PYZlt{\char`\<} \def\PYZgt{\char`\>} \def\PYZsh{\char`\#} \def\PYZpc{\char`\%} \def\PYZdl{\char`\$} \def\PYZhy{\char`\-} \def\PYZsq{\char`\'} \def\PYZdq{\char`\"} \def\PYZti{\char`\~} % for compatibility with earlier versions \def\PYZat{@} \def\PYZlb{[} \def\PYZrb{]} \makeatother % For linebreaks inside Verbatim environment from package fancyvrb. \makeatletter \newbox\Wrappedcontinuationbox \newbox\Wrappedvisiblespacebox \newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}} \newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}} \newcommand*\Wrappedcontinuationindent {3ex } \newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox} % Take advantage of the already applied Pygments mark-up to insert % potential linebreaks for TeX processing. % {, <, #, %, $, ' and ": go to next line. % _, }, ^, &, >, - and ~: stay at end of broken line. % Use of \textquotesingle for straight quote. \newcommand*\Wrappedbreaksatspecials {% \def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}% \def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}% \def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}% \def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}% \def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}% \def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}% \def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}% \def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}% \def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}% \def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}% \def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}% \def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}% \def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}% \def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}% } % Some characters . , ; ? ! / are not pygmentized. % This macro makes them "active" and they will insert potential linebreaks \newcommand*\Wrappedbreaksatpunct {% \lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}% \lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}% \lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}% \lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}% \lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}% \lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}% \lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}% \catcode`\.\active \catcode`\,\active \catcode`\;\active \catcode`\:\active \catcode`\?\active \catcode`\!\active \catcode`\/\active \lccode`\~`\~ } \makeatother \let\OriginalVerbatim=\Verbatim \makeatletter \renewcommand{\Verbatim}[1][1]{% %\parskip\z@skip \sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}% \sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}% \def\FancyVerbFormatLine ##1{\hsize\linewidth \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@ \doublehyphendemerits\z@\finalhyphendemerits\z@ \strut ##1\strut}% }% % If the linebreak is at a space, the latter will be displayed as visible % space at end of first line, and a continuation symbol starts next line. % Stretch/shrink are however usually zero for typewriter font. \def\FV@Space {% \nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font \discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak} {\kern\fontdimen2\font}% }% % Allow breaks at special characters using \PYG... macros. \Wrappedbreaksatspecials % Breaks at punctuation characters . , ; ? ! and / need catcode=\active \OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]% } \makeatother % Exact colors from NB \definecolor{incolor}{HTML}{303F9F} \definecolor{outcolor}{HTML}{D84315} \definecolor{cellborder}{HTML}{CFCFCF} \definecolor{cellbackground}{HTML}{F7F7F7} % prompt \makeatletter \newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep} \makeatother \newcommand{\prompt}[4]{ {\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}} } % Prevent overflowing lines due to hard-to-break entities \sloppy % Setup hyperref package \hypersetup{ breaklinks=true, % so long urls are correctly broken across lines colorlinks=true, urlcolor=urlcolor, linkcolor=linkcolor, citecolor=citecolor, } % Slightly bigger margins than the latex defaults \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} \begin{document} \maketitle \hypertarget{matrixarrays}{% \section{matrixArrays}\label{matrixarrays}} In computer programming, an array is a structure for storing and retrieving data. We often talk about an array as if it were a grid in space, with each cell storing one element of the data. For instance, if each element of the data were a number, we might visualize a ``one-dimensional'' array like a list: \begin{longtable}[]{@{}llll@{}} \toprule 1 & 5 & 2 & 0 \\ \midrule \endhead \bottomrule \end{longtable} A two-dimensional array would be like a table: \begin{longtable}[]{@{}llll@{}} \toprule 1 & 5 & 2 & 0 \\ \midrule \endhead 8 & 3 & 6 & 1 \\ 1 & 7 & 2 & 9 \\ \bottomrule \end{longtable} A three-dimensional array would be like a set of tables, perhaps stacked as though they were printed on separate pages. If we visualize the position of each element as a position in space. Then we can represent the value of the element as a property. In other words, if we were to analyze the stress concentration of an aluminum block, the property would be stress. \begin{itemize} \tightlist \item From \href{https://numpy.org/doc/2.2/user/absolute_beginners.html}{Numpy documentation} \end{itemize} If the load on this block changes over time, then we may want to add a 4th dimension i.e.~additional sets of 3-D arrays for each time increment. As you can see - the more dimensions we add, the more complicated of a problem we have to solve. It is possible to increase the number of dimensions to the n-th order. This course we will not be going beyond dimensional analysis. \begin{center}\rule{0.5\linewidth}{0.5pt}\end{center} \hypertarget{numpy---the-pythons-array-library}{% \section{Numpy - the python's array library}\label{numpy---the-pythons-array-library}} In this tutorial we will be introducing arrays and we will be using the numpy library. Arrays, lists, vectors, matrices, sets - You might've heard of them before, they all store data. In programming, an array is a variable that can hold more than one value at a time. We will be using the Numpy python library to create arrays. Since we already have installed Numpy previously, we can start using the package. Before importing our first package, let's as ourselves \emph{what is a package?} A package can be thought of as pre-written python code that we can re-use. This means the for every script that we write in python we need to tell it to use a certain package. We call this importing a package. \hypertarget{importing-numpy}{% \subsection{Importing Numpy}\label{importing-numpy}} When using packages in python, we need to let it know what package we will be using. This is called importing. To import numpy we need to declare it a the start of a script as follows: \begin{Shaded} \begin{Highlighting}[] \ImportTok{import}\NormalTok{ numpy }\ImportTok{as}\NormalTok{ np} \end{Highlighting} \end{Shaded} \begin{itemize} \tightlist \item \texttt{import} - calls for a library to use, in our case it is Numpy. \item \texttt{as} - gives the library an alias in your script. It's common convention in Python programming to make the code shorter and more readable. We will be using \emph{np} as it's a standard using in many projects. \end{itemize} \begin{center}\rule{0.5\linewidth}{0.5pt}\end{center} \hypertarget{creating-arrays}{% \section{Creating arrays}\label{creating-arrays}} Now that we have imported the library we can create a one dimensional array or \emph{vector} with three elements. \begin{Shaded} \begin{Highlighting}[] \NormalTok{x }\OperatorTok{=}\NormalTok{ np.array([}\DecValTok{1}\NormalTok{,}\DecValTok{2}\NormalTok{,}\DecValTok{3}\NormalTok{])} \end{Highlighting} \end{Shaded} To create a \emph{matrix} we can nest the arrays to create a two dimensional array. This is done as follows. \begin{Shaded} \begin{Highlighting}[] \NormalTok{matrix }\OperatorTok{=}\NormalTok{ np.array([[}\DecValTok{1}\NormalTok{,}\DecValTok{2}\NormalTok{,}\DecValTok{3}\NormalTok{],} \NormalTok{ [}\DecValTok{4}\NormalTok{,}\DecValTok{5}\NormalTok{,}\DecValTok{6}\NormalTok{],} \NormalTok{ [}\DecValTok{7}\NormalTok{,}\DecValTok{8}\NormalTok{,}\DecValTok{9}\NormalTok{]])} \end{Highlighting} \end{Shaded} \emph{Note: for every array we nest, we get a new dimension in our data structure.} \hypertarget{display-arrays}{% \section{Display arrays}\label{display-arrays}} Using command print("") Accessing particular elements of an array \ldots.. \hypertarget{practice-problem}{% \section{Practice Problem}\label{practice-problem}} Problem statement \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{1}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np} \PY{n}{x} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{7}\PY{p}{,} \PY{l+m+mi}{10} \PY{p}{,}\PY{l+m+mi}{12}\PY{p}{]}\PY{p}{)} \PY{n+nb}{print}\PY{p}{(}\PY{n}{x}\PY{p}{)} \PY{n+nb}{print}\PY{p}{(}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)} \end{Verbatim} \end{tcolorbox} \begin{Verbatim}[commandchars=\\\{\}] [ 7 10 12] 10 \end{Verbatim} \hypertarget{numpy-array-creation-functions}{% \subsection{Numpy array creation functions}\label{numpy-array-creation-functions}} Numpy comes with some built-in function that we can use to create arrays quickly. Here are a couple of functions that are commonly used in python. \hypertarget{np.arange}{% \subsubsection{np.arange}\label{np.arange}} The \texttt{np.arange()} function returns an array with evenly spaced values within a specified range. It is similar to the built-in \texttt{range()} function in Python but returns a Numpy array instead of a list. The parameters for this function are the start value (inclusive), the stop value (exclusive), and the step size. If the step size is not provided, it defaults to 1. \begin{Shaded} \begin{Highlighting}[] \OperatorTok{\textgreater{}\textgreater{}\textgreater{}}\NormalTok{ np.arange(}\DecValTok{4}\NormalTok{)} \NormalTok{array([}\FloatTok{0.}\NormalTok{ , }\FloatTok{1.}\NormalTok{, }\FloatTok{2.}\NormalTok{, }\FloatTok{3.}\NormalTok{ ])} \end{Highlighting} \end{Shaded} In this example, \texttt{np.arange(4)} generates an array starting from 0 and ending before 4, with a step size of 1. \hypertarget{np.linspace}{% \subsubsection{np.linspace}\label{np.linspace}} The \texttt{np.linspace()} function returns an array of evenly spaced values over a specified range. Unlike \texttt{np.arange()}, which uses a step size to define the spacing between elements, \texttt{np.linspace()} uses the number of values you want to generate and calculates the spacing automatically. It accepts three parameters: the start value, the stop value, and the number of samples. \begin{Shaded} \begin{Highlighting}[] \OperatorTok{\textgreater{}\textgreater{}\textgreater{}}\NormalTok{ np.linspace(}\FloatTok{1.}\NormalTok{, }\FloatTok{4.}\NormalTok{, }\DecValTok{6}\NormalTok{)} \NormalTok{array([}\FloatTok{1.}\NormalTok{ , }\FloatTok{1.6}\NormalTok{, }\FloatTok{2.2}\NormalTok{, }\FloatTok{2.8}\NormalTok{, }\FloatTok{3.4}\NormalTok{, }\FloatTok{4.}\NormalTok{ ])} \end{Highlighting} \end{Shaded} In this example, \texttt{np.linspace(1.,\ 4.,\ 6)} generates 6 evenly spaced values between 1. and 4., including both endpoints. Try this and see what happens: \begin{Shaded} \begin{Highlighting}[] \NormalTok{x }\OperatorTok{=}\NormalTok{ np.linspace(}\DecValTok{0}\NormalTok{,}\DecValTok{100}\NormalTok{,}\DecValTok{101}\NormalTok{)} \NormalTok{y }\OperatorTok{=}\NormalTok{ np.sin(x)} \end{Highlighting} \end{Shaded} \hypertarget{other-useful-functions}{% \subsubsection{Other useful functions}\label{other-useful-functions}} \begin{itemize} \tightlist \item \texttt{np.zeros()} \item \texttt{np.ones()} \item \texttt{np.eye()} \end{itemize} \hypertarget{practice-problem}{% \subsection{Practice problem}\label{practice-problem}} Problem statement below \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{2}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{n}{y}\PY{o}{=}\PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mi}{10}\PY{p}{,}\PY{l+m+mi}{20}\PY{p}{,}\PY{l+m+mi}{5}\PY{p}{)} \PY{n+nb}{print}\PY{p}{(}\PY{n}{y}\PY{p}{)} \end{Verbatim} \end{tcolorbox} \begin{Verbatim}[commandchars=\\\{\}] [10. 12.5 15. 17.5 20. ] \end{Verbatim} \hypertarget{working-with-arrays}{% \subsection{Working with Arrays}\label{working-with-arrays}} Now that we have been introduced to some ways to create arrays using the Numpy functions let's start using them. \hypertarget{indexing}{% \subsubsection{Indexing}\label{indexing}} Indexing in Python allows you to access specific elements within an array based on their position. This means you can directly retrieve and manipulate individual items as needed. Python uses \textbf{zero-based indexing}, meaning the first element is at position \textbf{0} rather than \textbf{1}. This approach is common in many programming languages. For example, in a list with five elements, the first element is at index \texttt{0}, followed by elements at indices \texttt{1}, \texttt{2}, \texttt{3}, and \texttt{4}. Here's an example of data from a rocket test stand where thrust was recorded as a function of time. \begin{Shaded} \begin{Highlighting}[] \NormalTok{thrust\_lbf }\OperatorTok{=}\NormalTok{ np.array(}\FloatTok{0.603355}\NormalTok{, }\FloatTok{2.019083}\NormalTok{, }\FloatTok{2.808092}\NormalTok{, }\FloatTok{4.054973}\NormalTok{, }\FloatTok{1.136618}\NormalTok{, }\FloatTok{0.943668}\NormalTok{)} \OperatorTok{\textgreater{}\textgreater{}\textgreater{}}\NormalTok{ thrust\_lbs[}\DecValTok{3}\NormalTok{]} \end{Highlighting} \end{Shaded} Due to the nature of zero-based indexing. If we want to call the value \texttt{4.054973} that will be the 3rd index. \hypertarget{operations-on-arrays}{% \subsubsection{Operations on arrays}\label{operations-on-arrays}} \begin{itemize} \tightlist \item Arithmetic operations (\texttt{+}, \texttt{-}, \texttt{*}, \texttt{/}, \texttt{**}) \item \texttt{np.add()}, \texttt{np.subtract()}, \texttt{np.multiply()}, \texttt{np.divide()} \item \texttt{np.dot()} for dot product \item \texttt{np.matmul()} for matrix multiplication \item \texttt{np.linalg.inv()}, \texttt{np.linalg.det()} for linear algebra \end{itemize} \hypertarget{statistics}{% \paragraph{Statistics}\label{statistics}} \begin{itemize} \tightlist \item \texttt{np.mean()}, \texttt{np.median()}, \texttt{np.std()}, \texttt{np.var()} \item \texttt{np.min()}, \texttt{np.max()}, \texttt{np.argmin()}, \texttt{np.argmax()} \item Summation along axes: \texttt{np.sum(arr,\ axis=0)} \end{itemize} \hypertarget{combining-arrays}{% \paragraph{Combining arrays}\label{combining-arrays}} \begin{itemize} \tightlist \item Concatenation: \texttt{np.concatenate((arr1,\ arr2),\ axis=0)} \item Stacking: \texttt{np.vstack()}, \texttt{np.hstack()} \item Splitting: \texttt{np.split()} \end{itemize} \hypertarget{exercise}{% \section{Exercise}\label{exercise}} Let's solve a statics problem given the following problem A simply supported bridge of length L=20L = 20L=20 m is subjected to three point loads: \begin{itemize} \tightlist \item \(P1=1010 kN\) at \(x=5m\) \item \(P2=15 kN\) at \(x=10m\) \item \(P3=20 kN\) at \(x=15m\) \end{itemize} The bridge is supported by two reaction forces at points AAA (left support) and BBB (right support). We assume the bridge is in static equilibrium, meaning the sum of forces and sum of moments about any point must be zero. \hypertarget{equilibrium-equations}{% \paragraph{Equilibrium Equations:}\label{equilibrium-equations}} \begin{enumerate} \def\labelenumi{\arabic{enumi}.} \item \textbf{Sum of Forces in the Vertical Direction}: \(R_A + R_B - P_1 - P_2 - P_3 = 0\) \item \textbf{Sum of Moments About Point A}: \(5 P_1 + 10 P_2 + 15 P_3 - 20 R_B = 0\) \item \textbf{Sum of Moments About Point B}: \(20 R_A - 15 P_3 - 10 P_2 - 5 P_1 = 0\) \end{enumerate} \hypertarget{system-of-equations}{% \paragraph{System of Equations:}\label{system-of-equations}} \[ \begin{cases} R_A + R_B - 10 - 15 - 20 = 0 \\ 5 \cdot 10 + 10 \cdot 15 + 15 \cdot 20 - 20 R_B = 0 \\ 20 R_A - 5 \cdot 10 - 10 \cdot 15 - 15 \cdot 20 = 0 \end{cases} \] \hypertarget{solution}{% \subsubsection{Solution}\label{solution}} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{3}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np} \PY{c+c1}{\PYZsh{} Define the coefficient matrix A} \PY{n}{A} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{p}{[} \PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{o}{\PYZhy{}}\PY{l+m+mi}{20}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{20}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]} \PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} Define the right\PYZhy{}hand side vector b} \PY{n}{b} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{p}{[} \PY{l+m+mi}{45}\PY{p}{,} \PY{l+m+mi}{5}\PY{o}{*}\PY{l+m+mi}{10} \PY{o}{+} \PY{l+m+mi}{10}\PY{o}{*}\PY{l+m+mi}{15} \PY{o}{+} \PY{l+m+mi}{15}\PY{o}{*}\PY{l+m+mi}{20}\PY{p}{,} \PY{l+m+mi}{5}\PY{o}{*}\PY{l+m+mi}{10} \PY{o}{+} \PY{l+m+mi}{10}\PY{o}{*}\PY{l+m+mi}{15} \PY{o}{+} \PY{l+m+mi}{15}\PY{o}{*}\PY{l+m+mi}{20} \PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} Solve the system of equations Ax = b} \PY{c+c1}{\PYZsh{} Using least squares to handle potential overdetermination} \PY{n}{x} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linalg}\PY{o}{.}\PY{n}{lstsq}\PY{p}{(}\PY{n}{A}\PY{p}{,} \PY{n}{b}\PY{p}{,} \PY{n}{rcond}\PY{o}{=}\PY{k+kc}{None}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{c+c1}{\PYZsh{} Display the results} \PY{n+nb}{print}\PY{p}{(}\PY{l+s+sa}{f}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Reaction force at A (R\PYZus{}A): }\PY{l+s+si}{\PYZob{}}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{l+s+si}{:}\PY{l+s+s2}{.2f}\PY{l+s+si}{\PYZcb{}}\PY{l+s+s2}{ kN}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)} \PY{n+nb}{print}\PY{p}{(}\PY{l+s+sa}{f}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Reaction force at B (R\PYZus{}B): }\PY{l+s+si}{\PYZob{}}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{l+s+si}{:}\PY{l+s+s2}{.2f}\PY{l+s+si}{\PYZcb{}}\PY{l+s+s2}{ kN}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)} \end{Verbatim} \end{tcolorbox} \begin{Verbatim}[commandchars=\\\{\}] Reaction force at A (R\_A): 25.11 kN Reaction force at B (R\_B): -24.89 kN \end{Verbatim} % Add a bibliography block to the postdoc \end{document}