\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Kamva} \pdfinfo{ /Title (numerical-methods-262.pdf) /Creator (Cheatography) /Author (Kamva) /Subject (Numerical Methods 262 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{C21CFF} \definecolor{LightBackground}{HTML}{FBF0FF} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Numerical Methods 262 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Kamva} via \textcolor{DarkBackground}{\uline{cheatography.com/169429/cs/35481/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Kamva \\ \uline{cheatography.com/kamva} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 14th November, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Curve fitting: Higher order Polynomials}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{The formula: ax + by + cz = 1 \newline `A= {[}-1 -1 -3;1 0 0;2 1 2;2 3 6{]};` \newline `b = {[}1;1;1;1{]};` \newline `x = A\textbackslash{}b;` \newline NOTE: A{\bf{x}} = b...{\bf{backslash(\textbackslash{})}} to solve for {\bf{a}},{\bf{b}},{\bf{c}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Curve fitting: linearization}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{{\bf{Exponential linearized function}} \newline The formula is {\emph{y = be\textasciicircum{}mx\textasciicircum{}}}: \newline `x = {[}1 2 3 4{]}; y = {[}6 3 2 1{]}; ` {\emph{Given}} \newline `a = polyfit(x,log(y),1)` \newline `\textgreater{}\textgreater{}a = -0.5781 2.3411; ` \newline `m = a(1) ` \newline `\textgreater{}\textgreater{}m = -0.5781;` \newline `b = exp(a(2));` \newline `\textgreater{}\textgreater{}b = 10.3923;` \newline The final product: {\emph{y = 10.39e\textasciicircum{}-0.5781x\textasciicircum{}}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Eigenvalues \& Eigenvectors}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`A={[}2 -1 0;-1 2 -1;0 -1 2{]}; a=eig(A);` \newline `{[}V,D{]} = eig(A)` {\emph{V - eigenvectors}} \newline `V(:,1)`:{\emph{get 1st column}} \newline `v1 = V(:,1);` \newline `v1 = v1/v1(1);`: normalise eigenvector} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{ODEs using ode45}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`a = 0.1; b = 0.002; c = 0.0025; d = 0.2;` \newline `f = @(t,x) {[}-a{\emph{x(1)+b}}x(1){\emph{x(2);` \newline `d}}x(2)-c{\emph{x(1)}}x(2){]};` \newline `X0 = {[}20; 100{]};` \newline `Tspan = linspace(0,150,1000);` \newline `{[}T,X{]} = ode45(f,Tspan,X0);` \newline `plot(T,X,'LineWidth',2);`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{ODEs using ode45}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`a = 0.1; b = 0.002; c = 0.0025; d = 0.2;` \newline `f = @(t,x) {[}-a{\emph{x(1)+b}}x(1){\emph{x(2);` \newline `d}}x(2)-c{\emph{x(1)}}x(2){]};` \newline `X0 = {[}20; 100{]};` \newline `Tspan = linspace(0,150,1000);` \newline `{[}T,X{]} = ode45(f,Tspan,X0);` \newline `plot(T,X,'LineWidth',2);`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Gauss Integration}} \tn % Row 0 \SetRowColor{LightBackground} Gauss 2-pt rule & Gauss 3-pt rule \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`f=@(x) 1/2{\emph{sqrt(16+(x+3).\textasciicircum{}4)./(x+3)\textasciicircum{}2;` \newline `G2=f(-1/sqrt(3))+f(1/sqrt(3));` \newline `\textgreater{}\textgreater{}G2= 1.1289;` \newline and \newline `G3=5/9}}f(-sqrt(3/5))+8/9{\emph{f(0)+5/9}}f(sqrt(3/5));` \newline `\textgreater{}\textgreater{}G3= 1.1319;`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{ODEs: Boundary-value problems (BVPs)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Finite Difference Method} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`y0=1;y1=2; \% N = 1/h;h = 0.2` \newline `i = {[}1:N-1{]}';` \newline `xi = i{\emph{h; \% Interior nodes` \newline `A=(h\textasciicircum{}2-2)}}eye(N-1); \% Diagonal part of A ` \newline `A=A+diag(1-0.5{\emph{h}}xi(2:N-1),-1);\% Add sub- and superdiagonal` \newline `A=A+diag(1+0.5{\emph{h}}xi(1:N-2),+1);\% Add sub- and superdiagonal` \newline `b = 2{\emph{h\textasciicircum{}2}}xi;\% RHS refined formula` \newline `b(1)=b(1)-(1-0.5{\emph{h}}xi(1)){\emph{y0;\% Add boundary contributions` \newline `b(N-1)=b(N-1)-(1+0.5}}h{\emph{xi(N-1))}}y1;\% Add boundary contributions` \newline `y = sparse(A)\textbackslash{}b; \% Solve`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Finite Difference: Laplace\&Poisson PDEs}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{3.833cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/kamva_1668461848_Capture4.PNG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{You then use backslash after you have the equations} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Multiple Integrals}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`f = @(x,y) x.\textasciicircum{}2-y.\textasciicircum{}2-1;` \newline `a = 0; b = 3; g = 0; p = 1;` \newline `integral2(f,a,b,g,p);` \newline `\textgreater{}\textgreater{}ans = 5.000000000001309;` \newline or \newline `f = @(x,y) y;` \newline `a = 0; b = pi/4;` \newline `g = @(x) sin(x); p = @(x) cos(x);` \newline `m = integral2(f,a,b,g,p);` \newline `\textgreater{}\textgreater{}m = 0.250000000000013;`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Curve fitting\& Interpolation}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Least Squares: Backslash \& Polyfit} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{{\bf{y = a0 + a1x + a2x\textasciicircum{}2\textasciicircum{}}}: \newline `x = {[}1; 2; 3; 4{]}; y = {[}6; 3; 2; 1{]};` \newline `A = {[}ones(4,1) x x.ˆ2{]}; a = A\textbackslash{}y` \newline `a = 9.5000 -4.1000 0.5000` \newline `a2 = polyfit(x,y,2)` \newline `xx = linspace(0,5);` \newline `y2 = polyval(a2,xx);` \newline `plot(x,y,'r.',xx,y2,'b-')`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Error,Residual,Norms,Condition number}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`x = {[}1; -1; 3; -5{]};` \newline `norm(x,inf)` ||x||inf(subscript) \newline ||A||2 = (||A{\bf{x}}||2)/(||{\bf{x}}||2) \newline \textasciitilde{} cond(A) = (||A||)(||A\textasciicircum{}-1\textasciicircum{}||) \newline \textasciitilde{}`cond(A)` \textgreater{}\textgreater{} 1:ill-conditioned\&close singular matrix \newline \textasciitilde{}`cond(A)` ≈ 1:well-conditioned \newline \textasciitilde{} decimals digits that trustworthy = 10\textasciicircum{}-a\textasciicircum{} = 10\textasciicircum{}c\textasciicircum{} x 10\textasciicircum{}-d\textasciicircum{} \newline a = d-c \newline \textasciitilde{}r = b - A{\bf{x}} \newline det (A) = 0; No A\textasciicircum{}-1\textasciicircum{}; Singular matrix \newline test singularity: `cond,condest,rank`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{2.12846 cm} p{1.30454 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Built-in Functions}} \tn % Row 0 \SetRowColor{LightBackground} Integral & Trapz \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`f=@(x)sqrt(1+x.\textasciicircum{}4)./x.\textasciicircum{}2;` \newline `L=integral(f,1,2);` \newline `\textgreater{}\textgreater{}L=1.132090393305918;` \newline or \newline `y={[}0 0.3 0.5 1 1.5 2 2.5 3 4 5{]};` \newline `v={[}0 0.4 0.5 0.56 0.6 0.63 0.66 0.68 0.71 0.72{]};` \newline `Q=10*trapz(y,v);` \newline `\textgreater{}\textgreater{}Q=30.8000;`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Euler's Method}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{3.833cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/kamva_1668460132_Capture17.PNG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{`f=@(x,y) -x{\emph{y; \% Define rhs` \newline `N=100; \% Number of steps` \newline `a=1; b=2; \% Interval` \newline `h=(b-a)/N; \% step size` \newline `x(1)=1; y(1)=4; \% Initial values` \newline `for i=1:N` \newline `y(i+1)=y(i)+h}}f(x(i),y(i)); \% Euler` \newline `x(i+1)=x(i)+h;` \newline `end`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Runge-Kutta Methods}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`f = @(x,y) -x{\emph{y; \%Define rhs` \newline `N = 100; \% Number of steps ` \newline .... \newline `for i = 1:N` \newline `K1 = f(x(i),y(i));` \newline `K2 = f(x(i)+0.5}}h,y(i)+0.5{\emph{h}}K1);` \newline `K3 = f(x(i)+0.5{\emph{h,y(i)+0.5}}h{\emph{K2);` \newline `K4 = f(x(i+1),y(i)+h}}K3);` \newline `x(i+1) = x(i)+h;` \newline `y(i+1) = y(i)+(1/6){\emph{h}}(K1+2K2+2K3+K4);` \newline `end`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Runge-Kutta Methods}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`f = @(x,y) -x{\emph{y; \%Define rhs` \newline `N = 100; \% Number of steps ` \newline .... \newline `for i = 1:N` \newline `K1 = f(x(i),y(i));` \newline `K2 = f(x(i)+0.5}}h,y(i)+0.5{\emph{h}}K1);` \newline `K3 = f(x(i)+0.5{\emph{h,y(i)+0.5}}h{\emph{K2);` \newline `K4 = f(x(i+1),y(i)+h}}K3);` \newline `x(i+1) = x(i)+h;` \newline `y(i+1) = y(i)+(1/6){\emph{h}}(K1+2K2+2K3+K4);` \newline `end`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Numerical Differentiation}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{3.833cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/kamva_1668457102_Capture10.PNG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{`x = 0;` \newline `f = @(x) sqrt(1-2{\emph{sin(x));` \newline `h = {[}0.002 0.001 0.0005 0.00025{]};` \newline `D2f = @(h) (f(x)-2}}f(x+h)+f(x+2{\emph{h))./h.\textasciicircum{}2;` \newline `D2f(h) = -1.0040 -1.0020 -1.0010 -1.0005; `}}error decreases by factor 2 thus n = 1} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Composite Simpson's Rule}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Remember: N even} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`f = @(x) sqrt(1+x.\textasciicircum{}4)./x.\textasciicircum{}2;` \newline `a = 1; b = 2;` \newline `N = 100; h = (b-a)/N;` \newline `x = a+{[}0:N{]}{\emph{h;` \newline `fx = f(x);` \newline `L = h/3}}(fx(1)+4{\emph{sum(fx(2:2:N))+2}}sum(fx(3:2:N-1))+fx(N+1))` \newline or \newline `w = ones(size(x)); w(2:2:N) = 4; w(3:2:N-1) = 2;` \newline `L = h/3{\emph{sum(w.}}f(x))` \newline `\textgreater{}\textgreater{}L = 1.132090394695845;`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Composite Trapezium Rule}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`f = @(x) sqrt(1+x.\textasciicircum{}4)./x.\textasciicircum{}2;` \newline `a = 1; b = 2;` \newline `N = 100; h = (b-a)/N;` \newline `x = a+{[}0:N{]}{\emph{h;` \newline `fx = f(x);` \newline `L = h3}}( 0.5{\emph{fx(1) + sum(fx(2:N)) + 0.5}}fx(N+1) )` \newline or \newline `w = ones(size(x)); w(1) = 0.5; w(N+1) = 0.5;` \newline `L = h{\emph{sum(w.}}f(x));` \newline `\textgreater{}\textgreater{}L = 1.132101672788808;`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Numerical Partial Differentiation}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{3.833cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/kamva_1668457464_Capture11.PNG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{`x = 0; y = 0;` \newline `f = @(x,y) sqrt(1+2{\emph{x-3}}y.\textasciicircum{}2);` \newline `h = {[}0.2 0.1 0.05 0.025{]};` \newline `Lapf = @(h) (f(x+h,y)+f(x-h,y)+f(x,y+h)+f(x,y-h)-4*f(x,y))./h.\textasciicircum{}2; ` \newline `Lapf(h) = -4.1505 -4.0356 -4.0088 -4.0022;`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Modified Euler}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{3.833cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/kamva_1668460466_Capture18.PNG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{`f = @(x,y) -x{\emph{y; \% Define rhs` \newline `N = 100; \% Number of steps` \newline `a = 1; b = 2; \% Interval` \newline `h= (b-a)/N; \% step size` \newline `x(1)=1;y(1) = 4; \% Initial values` \newline `for i = 1:N7` \newline `yeu = y(i)+h}}f(x(i),y(i)); \% Euler` \newline `x(i+1) = x(i)+h;` \newline `y(i+1) = y(i)+0.5{\emph{h}}(f(x(i),y(i))+f(x(i+1),yeu));` \newline `end`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} p{0.3433 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Spline}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Extrapolate data set} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`x = {[}22 35 48 61 74{]};` \newline `y = {[}320 490 540 500 480{]};` \newline `yy = spline(x,y,42);` {\emph{not-a-knot}} \newline `\textgreater{}\textgreater{}yy = 531.1971;` \newline `xx = linspace(20,80,1000);` \newline *clamped conditions: `{[}0 y 0{]} ` \newline `ss = spline(x,y,xx);` \newline `plot(x,y,'r.',xx,ss,'b-');`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}