\documentclass[.\jobname.tex]{subfiles}
\begin{document}

\chapter{Differential Evolution Pseudocodes}

\section{JADE Pseudocode}
\label{chap:pscode_jade}

\begin{algorithm}[H]
	\SetAlgoNoLine
	\DontPrintSemicolon
	\SetKwFunction{FJADE}{JADE}
	\SetKwProg{Fn}{Function}{:}{}
	\Fn{\FJADE{$\mathbf{X}_{g=0}$, $p$, $c$, $function$, $minError$, $maxFE$}}{
		$fValue_{g=0} \gets function(\mathbf{x}_{g=0})$\;
		$\mu_{CR} \gets 0.5$\;
		$\mu_{F}  \gets 0.5$\;
		$A        \gets \emptyset$\;
		\While {$fe \leq maxFE$}{
			$g \gets g + 1$\;
			$S_F \gets \emptyset$\;
			$S_{CR} \gets \emptyset$\;
			\For {$i = 1$ to $NP$} {
				$F_i  \gets randc_i(\mu_{F},0.1)$\;
				$v_i \gets mutationCurrentToPBest1(\mathbf{x}_{i,g}, A, fValue_g, F_i, p)$\;

				$CR_i \gets randn_i(\mu_{CR},0.1)$\;
				$u_i  \gets crossoverBIN(\mathbf{x}_{i,g}, v_i, CR_i)$\;

				\If {$function(\mathbf{x}_{i,g}) \geq function(\mathbf{u}_{i,g})$} {
					$\mathbf{x}_{i,g+1} \gets \mathbf{x}_{i,g}$\;
				}
				\Else
				{
					$\mathbf{x}_{i,g+1} \gets \mathbf{u}_{i,g}$\;
					$fValue_{i,g+1} \gets function(\mathbf{u}_{i,g})$\;
					$\mathbf{x}_{i,g} \rightarrow \mathbf{A}$\;
					$CR_i \rightarrow S_{CR}$\;
					$F_i \rightarrow S_F$\;
				}
			}
			\tcp{resize $A$ to size of $\mathbf{x}_g$}
			\If{$|A| > NP$} {
				$A \gets A \setminus A_{rand_i}$
			}
			$fe \gets fe + size(\mathbf{X})$\;
			$\mu_{CR} \gets (1-c) \cdot \mu_{CR} + c \cdot arithmeticMean(S_{CR})$\;
			$\mu_{F} \gets (1-c) \cdot \mu_{F} + c \cdot lehmerMean(S_{F})$\;
		}
	}
	\unterschrift{JADE Pseudocode}{}{}
	\label{algo: jade}
\end{algorithm}

\section{SHADE Pseudocode}
\label{chap:pscode_shade}

\begin{algorithm}[H]
	\SetAlgoNoLine
	\DontPrintSemicolon
	\SetKwFunction{FSHADE}{SHADE}
	\SetKwProg{Fn}{Function}{:}{}
	\Fn{\FSHADE{$\mathbf{x}_{G=0}$, $p$, $H$, $function$, $minError$, $maxFE$}}{
		$M_{CR} \gets 0.5 \text{; } M_{F} \gets 0.5 \text{; } A \gets \emptyset \text{; } G \gets 0 \text{; }k \gets 1$\;
		$fValue_{G=0} \gets function(\mathbf{x}_{G=0})$\;
		\While{termination condition not met}
		{
			$S_{CR} \gets \emptyset \text{; } S_F \gets \emptyset$\;
			\For{$i = 1$ to $N$}{
				$r_i \gets rand_{int}(1,H)$\;
				$CR_{i,G} \gets randn_i(M_{CR,r_i},0.1) \text{; }F_{i,G}  \gets randc_i(M_{F,r_i},0.1)$\;
				$v_i \gets mutationCurrentToPBest1(\mathbf{x}_{i,G}, A, fValue_G, F_i, p)$\;
				$u_i  \gets crossoverBIN(pop, v_i, CR)$\;
			}
			\For{$i = 1$ to $N$}{
				\If{$function(u_{i,G}) \leq function(x_{i,G})$} {
					$x_{i,G+1} \gets u_{i,G} \text{; } fValue_{i,G+1} \gets function(\mathbf{u}_{i,G})$\;
				}
				\Else{
					$x_{i,G+1} \gets x_{i,G}$\;
				}
				\If{$function(u_{i,G}) < function(x_{i,G})$} {
					$x_{i,G} \rightarrow A \text{; } CR_{i,G} \rightarrow S_{CR} \text{; } F_{i,G} \rightarrow S_{F}$\;
				}
			}
			\If{$|A| > N$} {
				$A \gets A \setminus A_{rand_i}$
			}
			\If{$S_{CR} \neq \emptyset \land S_F \neq \emptyset$} {

				$M_{CR,k,G+1} = \begin{cases}
				arithmeticMean(S_{CR}) & \text{if $S_{CR} \neq \emptyset$}\\
				M_{CR,k,G}             & otherwise
				\end{cases}$\;

				$M_{F,k,G+1} = \text{ } \begin{cases}
				lehmerMean(S_{F}) & \text{if $S_{F} \neq \emptyset$}\\
				M_{F,k,G}             & otherwise
				\end{cases}$\;

				$k \gets k + 1$\;
				\If{$k > H$} {$k \gets 1$\;}
			}
			$G \gets G + 1$\;
		}
	}
	\unterschrift{SHADE Pseudocode}{}{}
	\label{algo: shade}
\end{algorithm}

\section{L-SHADE Pseudocode}
\label{chap:pscode_lshade}

\begin{algorithm}[H]
	\SetAlgoNoLine
	\DontPrintSemicolon
	\SetKwFunction{FLSHADE}{LSHADE}
	\SetKwProg{Fn}{Function}{:}{}
	\Fn{\FLSHADE{$\mathbf{x}_{G=0}$, $p$, $H$, $function$, $minError$, $maxFE$}}{
		$M_{CR} \gets 0.5 \text{; } M_{F} \gets 0.5 \text{; } A \gets \emptyset \text{; } G \gets 0 \text{; }k \gets 1$\;
		$fValue_{G=0} \gets function(\mathbf{x}_{G=0}) \text{; } NG_{init} \gets size(\mathbf{x}_{G=0}) \text{; }NG_{min} = \lceil 1/p \rceil$\;
		\While{termination condition not met}
		{
			$S_{CR} \gets \emptyset \text{; } S_F \gets \emptyset$\;
			\For{$i = 1$ to $N$}{
				$r_i \gets rand_{int}(1,H)$\;
				$CR_{i,G} \gets randn_i(M_{CR,r_i},0.1) \text{; }F_{i,G}  \gets randc_i(M_{F,r_i},0.1)$\;
				$v_i \gets mutationCurrentToPBest1(\mathbf{x}_{i,G}, A, fValue_G, F_i, p)$\;
				$u_i  \gets crossoverBIN(pop, v_i, CR)$\;
			}
			\For{$i = 1$ to $N$}{
				\If{$function(u_{i,G}) \leq function(x_{i,G})$} {
					$x_{i,G+1} \gets u_{i,G} \text{; } fValue_{i,G+1} \gets function(\mathbf{u}_{i,G})$\;
				}
				\Else{
					$x_{i,G+1} \gets x_{i,G}$\;
				}
				\If{$function(u_{i,G}) < function(x_{i,G})$} {
					$x_{i,G} \rightarrow A \text{; } CR_{i,G} \rightarrow S_{CR} \text{; } F_{i,G} \rightarrow S_{F}$\;
				}
			}
			\If{$|A| > N$} {
				$A \gets A \setminus A_{rand_i}$
			}
			\If{$S_{CR} \neq \emptyset \land S_F \neq \emptyset$} {

				$M_{CR,k,G+1} = \begin{cases}
				arithmeticMean(S_{CR}) & \text{if $S_{CR} \neq \emptyset$}\\
				M_{CR,k,G}             & otherwise
				\end{cases}$\;

				$M_{F,k,G+1} = \text{ } \begin{cases}
				lehmerMean(S_{F}) & \text{if $S_{F} \neq \emptyset$}\\
				M_{F,k,G}             & otherwise
				\end{cases}$\;

				$k \gets k + 1$\;
				\If{$k > H$} {$k \gets 1$\;}
			}
			$\mathbf{x}_{G+1} \gets popSizeRed(\mathbf{x}_{G+1}, fValue, G, maxGen, NG_{init}, NGmin)$\;
			$G \gets G + 1$\;
		}
	}
	\unterschrift{L-SHADE Pseudocode}{}{}
	\label{algo: lshade}
\end{algorithm}

\chapter{Testbed}
\label{chap:testbed}

The following pages describe the testbed that is used for all experiments. The problems are structured in these major points:
\begin{itemize}
	\item differential equation
	\begin{itemize}
		\item differential equation
		\item domain $\Omega$
		\item Dirichlet bounday condition obtained by evaluating the solution on the boundary
	\end{itemize}
	\item solution
	\item plot of the solution over the domain
\end{itemize}

\newpage

\underline{\textbf{PDE 0A: Gauss Kernel}}

\underline{Problem PDE: }
\begin{equation}
\label{eq:pde0a}
\begin{split}
\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = (18x^2-6)e^{-1.5(x^2 + y^2)} + (18y^2-6)e^{-1.5(x^2 + y^2)} \\
+6(6x^2+12x+5)e^{-3((x+1)^2+(y+1)^2)} + 6(6y^2+12y+5)e^{-3((x+1)^2+(y+1)^2)} \\
+6(6x^2-12x+5)e^{-3((x-1)^2+(y+1)^2)} + 6(6y^2+12y+5)e^{-3((x-1)^2+(y+1)^2)} \\
+6(6x^2+12x+5)e^{-3((x+1)^2+(y-1)^2)} + 6(6y^2-12y+5)e^{-3((x+1)^2+(y-1)^2)} \\
+6(6x^2-12x+5)e^{-3((x-1)^2+(y-1)^2)} + 6(6y^2-12y+5)e^{-3((x-1)^2+(y-1)^2)} \\
\text{on the domain } \Omega : x, y \in [-2,2] \\
\text{subjected to: } \\
u(x,2) = 2e^{-1.5(x^2 + 4)} + e^{-3((x+1)^2 + 9)} + e^{-3((x+1)^2 + 1)} + e^{-3((x-1)^2 + 9)} + e^{-3((x-1)^2 + 1)} \\
u(x,-2)= 2e^{-1.5(x^2 + 4)} + e^{-3((x+1)^2 + 1)} + e^{-3((x+1)^2 + 9)} + e^{-3((x-1)^2 + 1)} + e^{-3((x-1)^2 + 9)} \\
u(2,y) = 2e^{-1.5(4 + y^2)} + e^{-3(9 + (y+1)^2)} + e^{-3(9 + (y-1)^2)} + e^{-3(1 + (y+1)^2)} + e^{-3(1 + (y-1)^2)} \\
u(-2,y)= 2e^{-1.5(4 + y^2)} + e^{-3(1 + (y+1)^2)} + e^{-3(1 + (y-1)^2)} + e^{-3(9 + (y+1)^2)} + e^{-3(9 + (y-1)^2)} \\
\end{split}
\end{equation}

\underline{Solution: }
\begin{equation}
\label{eq:sol0A}
\begin{split}
u_{ext}(x,y) = 2e^{-1.5(x^2 + y^2)} & + e^{-3((x+1)^2 + (y+1)^2)} + e^{-3((x+1)^2 + (y-1)^2)} \\
                              & + e^{-3((x-1)^2 + (y+1)^2)} + e^{-3((x-1)^2 + (y-1)^2)} \\
\end{split}
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.5\textwidth]{../../code/testbed/pde0A/sol_pde_0a.pdf}
	}
	\unterschrift{PDE 0A Gauss Kernel solution plot}{}{}
	\label{fig:sol_plot_0A}
\end{figure}

\underline{\textbf{PDE 0B: Gauss Sine Kernel}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde0b}
\begin{split}
\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = \\
2 e^{-2   (x^2 + y^2)} (2   sin(-2   (x^2 + y^2)) + 2   (1-8   x^2) cos(-2   (x^2 + y^2))) + \\
2 e^{-2   (x^2 + y^2)} (2   sin(-2   (x^2 + y^2)) + 2   (1-8   y^2) cos(-2   (x^2 + y^2))) + \\
2 e^{-1   (x^2 + y^2)} (1   sin(-1   (x^2 + y^2)) + 1   (1-4   x^2) cos(-1   (x^2 + y^2))) + \\
2 e^{-1   (x^2 + y^2)} (1   sin(-1   (x^2 + y^2)) + 1   (1-4   y^2) cos(-1   (x^2 + y^2))) + \\
2 e^{-0.1 (x^2 + y^2)} (0.1 sin(-0.1 (x^2 + y^2)) + 0.1 (1-0.4 x^2) cos(-0.1 (x^2 + y^2))) + \\
2 e^{-0.1 (x^2 + y^2)} (0.1 sin(-0.1 (x^2 + y^2)) + 0.1 (1-0.4 y^2) cos(-0.1 (x^2 + y^2))) \\
\text{on the domain } \Omega : x, y \in [-2,2] \\
\text{subjected to: } \\
u(x,2) =	 e^{-2  (x^2 + 4  )}  sin(2  ((x^2 + 4  ))) + e^{-1  (x^2 + 4  )}  sin(1  ((x^2 + 4  ))) + e^{-0.1(x^2 + 4  )}  sin(0.1((x^2 + 4  ))) \\				u(x,-2)= 	 e^{-2  (x^2 + 4  )}  sin(2  ((x^2 + 4  ))) + e^{-1  (x^2 + 4  )}  sin(1  ((x^2 + 4  ))) + e^{-0.1(x^2 + 4  )}  sin(0.1((x^2 + 4  ))) \\				u(2,y) = 	 e^{-2  (4   + y^2)}  sin(2  ((4   + y^2))) + e^{-1  (4   + y^2)}  sin(1  ((4   + y^2))) + e^{-0.1(4   + y^2)}  sin(0.1((4   + y^2))) \\
u(-2,y)= 	 e^{-2  (4   + y^2)}  sin(2  ((4   + y^2))) + e^{-1  (4   + y^2)}  sin(1  ((4   + y^2))) + e^{-0.1(4   + y^2)}  sin(0.1((4   + y^2))) \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol0B}
\begin{split}
u_{ext}(x,y) = & e^{-2  (x^2 + y^2)}  sin(2  ((x^2 + y^2))) + e^{-1  (x^2 + y^2)}  sin(1  ((x^2 + y^2))) \\ + & e^{-0.1(x^2 + y^2)}  sin(0.1((x^2 + y^2))) \\
\end{split}
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.46\textwidth]{../../code/testbed/pde0B/sol_pde_0b.pdf}
	}
	\unterschrift{PDE 0B Gauss Sine Kernel solution plot}{}{}
	\label{fig:sol_plot_0B}
\end{figure}

\newpage

\underline{\textbf{PDE 1: Polynomial 2D}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde1}
\begin{split}
-\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = \\
-2^{40}y^{10}(1-y)^{10}[90x^8(1-x)^{10} -200x^9(1-x)^9 + 90x^{10}(1-x)^8] \\
-2^{40}x^{10}(1-x)^{10}[90y^8(1-y)^{10} -200y^9(1-y)^9 + 90y^{10}(1-y)^8] \\
\text{on the domain } \Omega: x,y \in [0,1] \\
\text{subjected to: } \\
u(x,1) = 0 \\
u(x,0) = 0 \\
u(1,y) = 0 \\
u(0,y) = 0 \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol1}
u_{ext}(x,y) = 2^{40}x^{10}(1-x)^{10}y^{10}(1-y)^{10}
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.6\textwidth]{../../code/testbed/pde1/sol_pde_1.pdf}
	}
	\unterschrift{PDE 1 Polynomial 2D solution plot}{}{}
	\label{fig:sol_plot_1}
\end{figure}

\newpage

\underline{\textbf{PDE 2: Chaquet PDE 1}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde2}
\begin{split}
\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = e^{-x} (x-2 + y^3 + 6y) \\
\text{on the domain } \Omega: \mathbf{x} \in [0,1] \\
\text{subjected to: } \\
u(x,0) = xe^{-x}
u(x,1) = (x + 1)e^{-x}
u(0,y) = y^3 \\
u(1,y) = (1 + y^3) e^{-1}
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol2}
u_{ext}(x,y) = (x + y^3) e^{-x}
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.6\textwidth]{../../code/testbed/pde2/sol_pde_2.pdf}
	}
	\unterschrift{PDE 2 Chaquet PDE 1 solution plot}{}{}
	\label{fig:sol_plot_2}
\end{figure}

\newpage

\underline{\textbf{PDE 3: Chaquet PDE 3}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde3}
\begin{split}
\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = 4 \\
\text{on the domain } \Omega: \mathbf{x} \in [0,1] \\
\text{subjected to: } \\
u(x,0) = x^2 + x + 1 \\
u(x,1) = x^2 + x + 3 \\
u(1,y) = y^2 + y + 3 \\
u(0,y) = y^2 + y + 1 \\
\end{split}
\end{equation}

\underline{Solution}
\begin{equation}
\label{eq:sol3}
u_{ext}(x,y) = x^2 + y^2 + x + y + 1
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.6\textwidth]{../../code/testbed/pde3/sol_pde_3.pdf}
	}
	\unterschrift{PDE 3 Chaquet PDE 3 solution plot}{}{}
	\label{fig:sol_plot_3}
\end{figure}

\newpage

\underline{\textbf{PDE 4: Sine Bump 2D}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde4}
\begin{split}
-\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = 2\pi^2 sin(\pi x) sin(\pi y) \\
\text{on the domain } \Omega: \mathbf{x} \in [0,1] \\
\text{subjected to: } \\
u(x,0) = 0 \\
u(x,1) = 0 \\
u(0,y) = 0 \\
u(1,y) = 0 \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol4}
u_{ext}(x,y) = sin(\pi x)sin(\pi y)
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.6\textwidth]{../../code/testbed/pde4/sol_pde_4.pdf}
	}
	\unterschrift{PDE 4 Sine Bump 2D solution plot}{}{}
	\label{fig:sol_plot_4}
\end{figure}

\newpage

\underline{\textbf{PDE 5: Arctan Circular Wave Front}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde5}
\begin{split}
-\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = \frac{16000(\sqrt{(x - 0.05)^2 + (y - 0.05)^2} -0.7)}{(1 + 400 (-0.7 + \sqrt{(x - 0.05)^2 + (y - 0.05)^2})^2)^2} \\
+ \frac{20 (x - 0.05)^2 + 20 (y - 0.05)^2}{(1 + 400 (\sqrt{(x - 0.05)^2 + (y - 0.05)^2} -0.7)^2) ((x - 0.05)^2 + (y - 0.05)^2)^{3/2}} \\
- \frac{40}{(1 + 400 (\sqrt{(y - 0.05)^2 + (x - 0.05)^2} -0.7)^2) \sqrt{(y - 0.05)^2 + (x - 0.05)^2}} \\
\text{on the domain } \Omega: \mathbf{x} \in [0,1] \\
\text{subjected to: } \\
u(x,0) = tan^{-1}\left(20 \left(\sqrt{(x-0.05)^2 + 0.0025} -0.7\right)\right) \\
u(x,1) = tan^{-1}\left(20 \left(\sqrt{(x-0.05)^2 + 0.9025} -0.7\right)\right) \\
u(0,y) = tan^{-1}\left(20 \left(\sqrt{0.0025 + (y-0.05)^2} -0.7\right)\right) \\
u(1,y) = tan^{-1}\left(20 \left(\sqrt{0.9025 + (y-0.05)^2} -0.7\right)\right) \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol5}
u_{ext}(x,y) = tan^{-1}\left(20 \left(\sqrt{(x-0.05)^2 + (y-0.05)^2} -0.7\right)\right)
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.58\textwidth]{../../code/testbed/pde5/sol_pde_5.pdf}
	}
	\unterschrift{PDE 5 Arctan Circular Wave Front solution plot}{}{}
	\label{fig:sol_plot_5}
\end{figure}

\newpage

\underline{\textbf{PDE 6: Peak 2D}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde6}
\begin{split}
-\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = \\
-(4 \cdot 10^6 x^2 -4 \cdot 10^6 x + 998 \cdot 10^3)e^{-1000((x-0.5)^2 + (y-0.5)^2)} \\
-(4 \cdot 10^6 y^2 -4 \cdot 10^6 y + 998 \cdot 10^3)e^{-1000((x-0.5)^2 + (y-0.5)^2)} \\
\text{on the domain } \Omega: \mathbf{x} \in [0,1] \\
\text{subjected to: } \\
u(x,0) = e^{-1000((x-0.5)^{2} + 0.25)} \\
u(x,1) = e^{-1000((x-0.5)^{2} + 0.25)} \\
u(0,y) = e^{-1000(0.25 + (y-0.5)^{2})} \\
u(1,y) = e^{-1000(0.25 + (y-0.5)^{2})} \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol6}
u_{ext}(x,y) = e^{-1000((x-0.5)^{2} + (y-0.5)^{2})}
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.6\textwidth]{../../code/testbed/pde6/sol_pde_6.pdf}
	}
	\unterschrift{PDE 6 Peak 2D solution plot}{}{}
	\label{fig:sol_plot_6}
\end{figure}

\newpage

\underline{\textbf{PDE 7: Boundary Line Singularity}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde7}
\begin{split}
-\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = 0.24 x^{-1.4}\\
\text{on the domain } \Omega: \mathbf{x} \in [0,1] \\
\text{subjected to: } \\
u(x,0) = x^{0.6} \\
u(x,1) = x^{0.6} \\
u(0,y) = 0 \\
u(1,y) = 1^{0.6} \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol7}
u_{ext}(x,y) = x^{0.6}
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.6\textwidth]{../../code/testbed/pde7/sol_pde_7.pdf}
	}
	\unterschrift{PDE 7 Boundary Line Singularity solution plot}{}{}
	\label{fig:sol_plot_7}
\end{figure}

\newpage

\underline{\textbf{PDE 8: Interior Point Singularity}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde8}
\begin{split}
\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = \frac{1}{\sqrt{x^2 - x + y^2 - y + 0.5}} \\
\Omega: \mathbf{x} \in [0,1] \\
\text{on the domain } \text{subjected to: } \\
u(x,0) = \sqrt{(x-0.5)^2 + 0.25} \\
u(x,1) =  \sqrt{(x-0.5)^2 + 0.25} \\
u(0,y) = \sqrt{0.25 + (y-0.5)^2} \\
u(1,y) =  \sqrt{0.25 + (y-0.5)^2} \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol8}
u_{ext}(x,y) = \sqrt{(x-0.5)^2 + (y-0.5)^2}
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.6\textwidth]{../../code/testbed/pde8/sol_pde_8.pdf}
	}
	\unterschrift{PDE 8 Interior Point Singularity solution plot}{}{}
	\label{fig:sol_plot_8}
\end{figure}

\newpage

\underline{\textbf{PDE 9: Arctan Wave Front Homogeneous Boundary Conditions 2D}}

\underline{Problem PDE:}
\begin{equation}
\label{eq:pde9}
\begin{split}
-\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = \\
\frac{20\sqrt{2}(x^2 + y^2 -2x^2y - 2xy^2 + 4xy - x - y)}{400(\frac{x+y}{\sqrt{2}}-0.8)^2+1} \\
+\frac{16000(1-x)x(1-y)y(\frac{x+y}{\sqrt{2}}-0.8)}{(400(\frac{x+y}{\sqrt{2}}-0.8)^2+1)^2} \\
+ tan^{-1}\left(20\left(\frac{x+y}{\sqrt{2}}-0.8\right)\right)(2(1-y)y + 2(1-x)x)  \\
\text{on the domain } \Omega: \mathbf{x} \in [0,1] \\
\text{subjected to: } \\
u(x,0) = 0 \\
u(x,1) = 0 \\
u(0,y) = 0 \\
u(1,y) = 0 \\
\end{split}
\end{equation}

\underline{Solution:}
\begin{equation}
\label{eq:sol9}
u_{ext}(x,y) = tan^{-1}\left(20\left(\frac{(x + y)}{\sqrt{2}} -0.8\right)\right)x(1-x)y(1-y)
\end{equation}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{
		\includegraphics[width=0.54\textwidth]{../../code/testbed/pde9/sol_pde_9.pdf}
	}
	\unterschrift{PDE 9 Arctan Wave Front Homogeneous Boundary Conditions 2D solution plot}{}{}
	\label{fig:sol_plot_9}
\end{figure}

\chapter{Software Architecture}
\label{chap:appendix_software_architecture}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=\linewidth}{\includegraphics[width=0.9\textwidth]{../../code/uml_diag/testbench_uml_class.pdf}
	}
	\unterschrift{This \gls{uml} class diagram describes the software architecture defined to prepare, run and evaluate the experiments. }{}{}
	\label{fig:software_architecture}
\end{figure}

\chapter{Post-Processing Module Description}
\label{chap:apendix_post_proc}
The post-processing module includes these functions. Their implementation is described in the following list. These functions are used to interpret the results in the experiments chapters.

\begin{itemize}
	\item
	\inlinecode{bool saveExpObj(obj, filename)} \\
	Save an \inlinecode{CiPdeN} object as a \gls{json} file. The filename parameter can include a path, but it must end with .json. The results execution time, memory usage, solution quality and all intergenerational data of the optimisation algorithm are stored in the file.
	\item \inlinecode{dict loadExpObject(filename)} \\
	Loads the \gls{json} file located at the specified filename, which again can include a path. A dictionary with the saved \inlinecode{CiPdeN} parameters is returned.
	\item
	\inlinecode{dict loadExpObjectFast(filename)} \\
	When solving a \gls{pde} with more function evaluation, the result file can become very large (>400Mb @ $10^6$ \#FE). For evaluating such large files, this function can be used. It does not load the generation data (meaning population, function value, F and CR). Since the standard \gls{json} interpreter in Python loads files in a serial manner, a new interpreter is needed. To that extent, \textit{bigjson} from \cite{heino_henubigjson_2020} is used. This package accesses only the parts of a \gls{json} file that are actually needed.
	\item \inlinecode{bool drawGaussKernel(parameter, ggb)} \\
	Draws a solution approximated by Gauss kernels and with the specified parameters to a GeoGebra file. If the filename provided in the \textit{ggb} argument does not exist, the function searches for a template and prints to a copy of that file.
	\item \inlinecode{bool drawGSinKernel(parameter, ggb)} \\
	This is similar to the \inlinecode{drawGaussKernel} method - but it takes parameters for a Gauss Sine kernel.
	\item
	\inlinecode{float calcRSME(solve_dict)} \\
	To compare the obtained results with previous works, the \gls{rmse} quality metric (as described in the chapter \ref{chap:metric_quality}) must be computed. This is done from a single dictionary, as obtained by the functions \inlinecode{loadExpObject} or \inlinecode{loadExpObjectFast}.
	\item
	\inlinecode{None plotApprox3D(kernel, parameter, lD, uD, name=None)} \\
	The approximate solution of a \gls{pde} can be plotted over the domain with this function. Only square sized domains are accepted, as specified by the lower and the upper domain parameters \inlinecode{lD} and \inlinecode{uD}. If \textit{name} is of type string, the plot is saved as this file.
	\item
	\inlinecode{string statsWilcoxon(a, b, alpha=0.05)} \\
	This function is a wrapper for the \inlinecode{scipy.stats.wilcoxon} (\cite{scipy_scipystatswilcoxon_2020}). The default significance level is set to 0.05. A string is returned that describes if the mean and median of \inlinecode{a} is significantly smaller than the mean and median of \inlinecode{b}. The result is one of these strings:
	\begin{itemize}
		\item sig. worse: the distributions are different; the mean and the median of \inlinecode{a} are larger than the mean and the median of \inlinecode{b}
		\item sig. better: the distributions are different; the mean and the median of \inlinecode{a} are smaller than the mean and the median of \inlinecode{b}
		\item unsig. worse: the distributions are similar; the mean and the median of \inlinecode{a} are larger than the mean and the median of \inlinecode{b}
		\item unsig. better: the distributions are similar; the mean and the median of \inlinecode{a} are smaller than the mean and the median of \inlinecode{b}
		\item unsig. undecided: the distributions are similar; the mean is larger, the median is smaller or vice versa
	\end{itemize}
	Example distributions with the corresponding results are shown in figure \ref{fig:stats_wilcoxon_examples} below.
	\item \inlinecode{None plotFEDynamic(FEDynamic, name=None)} \\
	This method plots the function value dynamic of the population on a y-axis logarithmic plot. It can also cope with a varying population size. The plot can be saved with an optional argument.
	\item \inlinecode{None plotError3D(kernel, parameter, pdeName, lD, uD, name=None)} \\
	Similar to the 	\inlinecode{plotApprox3D} method, a 3D graph of the solution is plotted. Instead of the function value, the error is shown. The error is calculated by $E  = u_{apx}(x,y) - u_{ext}(x,y) \forall x,y \in \Omega$.
	\item \inlinecode{None plotABSError3D(kernel, parameter, pdeName, lD, uD, name=None)} \\
	Similar to the 	\inlinecode{plotError3D} method, a 3D graph of the solution is plotted. The absolute error is shown. The error is calculated by $E_{abs}  = \left| u_{apx}(x,y) - u_{ext}(x,y) \right| \forall x,y \in \Omega$.
	\item \inlinecode{None plotKernelAdaption(obj_dict, title, 'green', 'red', name=None)} \\
	This function plot the fitness difference over all generations. Additionally, it marks if the number of kernels (and thus the search dimension) is increased or reduced.
	\item \inlinecode{(float, float) calcSingleERT(rundata, target)} \\
	Calculates the expected running time and the success probability for a single target value. The expected running time is corrected by the success probability.
\end{itemize}

\begin{figure}[H]
	\centering
	\begin{subfigure}[b]{0.5\linewidth}
		\centering
		\includegraphics[width=1\textwidth]{../img/pdf/sig_better.pdf}
		\caption{A is significantly better than B}
		\label{fig:stats_wilcoxon_examples_sigificantly_better}
	\end{subfigure}%
	%
	\begin{subfigure}[b]{0.5\linewidth}
		\centering
		\includegraphics[width=1\textwidth]{../img/pdf/sig_worse.pdf}
		\caption{A is sigificantly worse than B}
		\label{fig:stats_wilcoxon_examples_sigificantly_worse}
	\end{subfigure}%
	\\
	\begin{subfigure}[b]{0.5\linewidth}
		\centering
		\includegraphics[width=1\textwidth]{../img/pdf/unsig_better.pdf}
		\caption{A is unsignificantly better than B}
		\label{fig:stats_wilcoxon_examples_insigificantly_better}
	\end{subfigure}%
	%
	\begin{subfigure}[b]{0.5\linewidth}
		\centering
		\includegraphics[width=1\textwidth]{../img/pdf/unsig_worse.pdf}
		\caption{A is unsignificatnly worse than B}
		\label{fig:stats_wilcoxon_examples_insigificantly_worse}
	\end{subfigure}%
	\unterschrift{Example distributions for different results of the statsWilcoxon method.}{}{}%
	\label{fig:stats_wilcoxon_examples}
\end{figure}

\chapter{Solve Method}
\label{chap:solve_function}

\begin{algorithm}[H]
	\SetAlgoNoLine
	\DontPrintSemicolon
	\SetKwFunction{Fsolve}{solve}
	\SetKwProg{Fn}{Function}{:}{}
	\Fn{\Fsolve{}}{
		$gc.disable()$\;
		\While{$gc.isenabled()$} {
			$time.sleep(0.1)$\;
		}
		$process = psutil.Process()$\;
		$memstart = process.memory\text{\textunderscore}info().vms$\;
		$t\text{\textunderscore}start = time.time()$\;
		\tcp{perform solver steps}
		\tcp{that are particular}
		\tcp{to FEM or CI solver}
		$self.\text{\textunderscore}exec\text{\textunderscore}time = time.time() - t\text{\textunderscore}{start}$\;
		$memstop = process.memory\text{\textunderscore}info().vms - memstart$\;
		$gc.enable()$\;
		$gc.collect()$\;
	}
	\unterschrift{Solve Method Pseudocode}{}{}
	\label{algo: solve}
\end{algorithm}

\chapter{pJADE}
\label{chap:pseudocode_pjade}

\begin{algorithm}[H]
	\SetAlgoNoLine
	\DontPrintSemicolon
	\SetKwFunction{FpJADE}{pJADE}
	\SetKwFor{PFor}{for}{do parallel}{end}
	\SetKwProg{Fn}{Function}{:}{}
	\Fn{\FpJADE{$\mathbf{X}_{g=0}$, $p$, $c$, $function$, $minError$, $maxFE$}}{
		$fValue_{g=0} \gets function(\mathbf{x}_{g=0})$\;
		$\mu_{CR} \gets 0.5$\;
		$\mu_{F}  \gets 0.5$\;
		$A        \gets \emptyset$\;
		\While {$fe \leq maxFE$}{
			$g \gets g+1$\;
			$S_F \gets \emptyset$\;
			$S_{CR} \gets \emptyset$\;
			$pResults \gets \emptyset$\;
			\PFor {$i = 1$ to $NP$} {
				$F_i  \gets randc_i(\mu_{F},0.1)$\;
				$v_i \gets mutationCurrentToPBest1(\mathbf{x}_{i,g}, A, fValue_g, F_i, p)$\;

				$CR_i \gets randn_i(\mu_{CR},0.1)$\;
				$u_i  \gets crossoverBIN(\mathbf{x}_{i,g}, v_i, CR_i)$\;
				$(u_i, function(u_i)) \rightarrow pResults$
			}
			\For {$i = 1$ to $NP$} {
				\If {$function(\mathbf{x}_{i,g}) \geq pResults_{i,f,g}$} {
					$\mathbf{x}_{i,g+1} \gets \mathbf{x}_{i,g}$\;
				}
				\Else
				{
					$\mathbf{x}_{i,g+1} \gets pResults_{i,u,g}$\;
					$fValue_{i,g+1} \gets pResults_{i,f,g}$\;
					$\mathbf{x}_{i,g} \rightarrow \mathbf{A}$\;
					$CR_i \rightarrow S_{CR}$\;
					$F_i \rightarrow S_F$\;
				}
			}
			\tcp{resize $A$ to size of $\mathbf{x}_g$}
			\If{$|A| > NP$} {
				$A \gets A \setminus A_{rand_i}$
			}
			$fe \gets fe + size(\mathbf{X})$\;
			$\mu_{CR} \gets (1-c) \cdot \mu_{CR} + c \cdot arithmeticMean(S_{CR})$\;
			$\mu_{F} \gets (1-c) \cdot \mu_{F} + c \cdot lehmerMean(S_{F})$\;
		}
	}
	\unterschrift{Pseudocode of pJADE}{}{}
	\label{algo: pjade}
\end{algorithm}

\chapter{paJADE}
\label{chap:pseudocode_pajade}

\begin{algorithm}[H]
	\SetAlgoNoLine
	\DontPrintSemicolon
	\SetKwFunction{FpaJADE}{paJADE}
	\SetKwFor{PFor}{for}{do parallel}{end}
	\SetKwProg{Fn}{Function}{:}{}
	\Fn{\FpaJADE{$\mathbf{X}_{g=0}$, $p$, $c$, $dT$, $function$, $minError$, $maxFE$}}{
		$fValue_{g=0} \gets function(\mathbf{x}_{g=0})$\;
		$\mu_{CR} \gets 0.5$\;
		$\mu_{F}  \gets 0.5$\;
		$A        \gets \emptyset$\;
		\While {$fe \leq maxFE$}{
			$g \gets g+1$\;
			$S_F \gets \emptyset$\;
			$S_{CR} \gets \emptyset$\;
			$pResults \gets \emptyset$\;
			\PFor {$i = 1$ to $NP$} {
				$F_i  \gets randc_i(\mu_{F},0.1)$\;
				$v_i \gets mutationCurrentToPBest1(\mathbf{x}_{i,g}, A, fValue_g, F_i, p)$\;

				$CR_i \gets randn_i(\mu_{CR},0.1)$\;
				$u_i  \gets crossoverBIN(\mathbf{x}_{i,g}, v_i, CR_i)$\;
				$(u_i, function(u_i)) \rightarrow pResults$
			}
			\For {$i = 1$ to $NP$} {
				\If {$function(\mathbf{x}_{i,g}) \geq pResults_{i,f,g}$} {
					$\mathbf{x}_{i,g+1} \gets \mathbf{x}_{i,g}$\;
				}
				\Else
				{
					$\mathbf{x}_{i,g+1} \gets pResults_{i,u,g}$\;
					$fValue_{i,g+1} \gets pResults_{i,f,g}$\;
					$\mathbf{x}_{i,g} \rightarrow \mathbf{A}$\;
					$CR_i \rightarrow S_{CR}$\;
					$F_i \rightarrow S_F$\;
				}
			}
			\tcp{resize $A$ to size of $\mathbf{x}_g$}
			\If{$|A| > NP$} {
				$A \gets A \setminus A_{rand_i}$
			}
			$fe \gets fe + size(\mathbf{X})$\;
			$\mu_{CR} \gets (1-c) \cdot \mu_{CR} + c \cdot arithmeticMean(S_{CR})$\;
			$\mu_{F} \gets (1-c) \cdot \mu_{F} + c \cdot lehmerMean(S_{F})$\;

			\tcp{state detector}
			\If {$min(function(\mathbf{X}_{g-dT}) - function(\mathbf{X}_g)) < minError$} {
				break\;
			}
		}
	}
	\unterschrift{Pseudocode of paJADE}{}{}
	\label{algo: pajade}
\end{algorithm}

\chapter{Adaptive Kernel Scheme}
\label{chap:appendix_adaptive_scheme}

\begin{algorithm}[H]
	\SetAlgoNoLine
	\DontPrintSemicolon
	\SetKwFunction{FmpaJADE}{memeticpJADEadaptive}
	\SetKwProg{Fn}{Function}{:}{}
	\Fn{\FmpaJADE{$\mathbf{X}$, $func$, $kSize$, $minErr$, $maxFE$}}{
		$dim$, $popsize$ $\gets size(\mathbf{X})$\;
		\tcp{number of kernels}
		$\kappa$ $\gets$ $dim/kSize$ \;
		$p \gets 0.3$\;
		$c \gets 0.5$\;
		$dT$ $\gets 100$\;
		$fecounter \gets 0$\;
		$bestFE \gets \infty$\;
		$\mathbf{\mathbf{bestPop}} \gets \emptyset$\;
		$popFactor$ $\gets$ $popsize/dim$\;
		\While{$fecounter < maxFE$}{
			$\mathbf{pop}$, $\mathbf{FE}$, $F$, $CR$ $\gets paJADE($$\mathbf{X}$, $p$, $c$, $dT$, $func$, $minErr$, $maxFE - 2 \cdot dim$ $)$\;
			$fecounter \gets fecounter + len(F)\cdot popsize$\;
			$bestIndex \gets argmin(\mathbf{FE})$\;
			$bestSol \gets \mathbf{pop}[bestIndex]$\;
			$\mathbf{pop}$, $\mathbf{FE}$ $ \gets ds$($func$, $bestSol$, $minErr$, $2 \cdot dim)$\;
			$fecounter \gets fecounter + 2 \cdot dim$\;
			\If{$min(\mathbf{FE}) < bestFE$}{
				\tcp{increase dimension}
				$\mathbf{X} \gets appendRndKernel(\mathbf{pop}, popsize, kSize)$\;
				$\kappa \gets \kappa+1$ \;
				\tcp{adapt population size to dimension}
				$\mathbf{X} \gets appendRndPop(\mathbf{X}, popFactor, kSize)$\;
				$bestFE \gets min(\mathbf{FE})$\;
				$\mathbf{bestPop} \gets \mathbf{pop}$\;
				$dim$, $popsize$ $\gets size(\mathbf{X})$\;
			}
			\Else {
				\tcp{reduce dimension}
				\tcp{restart around previous best}
				$\mathbf{X} \gets \mathbf{bestPop} + \mathbf{\mathcal{N}}(size(\mathbf{bestPop}))$\;
				$\kappa \gets \kappa - 1$ \;
				$dim$, $popsize$ $\gets size(\mathbf{X})$ \;
			}
		}
		\Return $\mathbf{pop}$, $\mathbf{FE}$, $F$, $CR$
	}
	\unterschrift{Pseudocode of memetic parallel JADE with adaptive kernels}{}{}
	\label{algo: memeticpJADEadaptive}
\end{algorithm}

\chapter{PDE 2 3 4 and 7 Kernel Adaption}
\label{chap: appendix kernel bar plot}

The following plots show the fitness difference in relation to the kernel adaption. Darker grey and black areas represent a strong decline of the fitness value over multiple generations, while lighter areas mean that the fitness value is stagnating. Following lighter areas, often comes a green bar, which means that a new kernel is introduced. Similarly, red lines represent the reduction by one kernel. The plots compare the best and the worst replications with $minError = 0$ produced in the experiment chapter \ref{chap:experimet_2}.

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde2_worst_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the worst result of \gls{pde}2 in experiment 2.}{}{}
	\label{fig:pajade_pde2_worst_kernelbars}
\end{figure}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde2_best_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the best result of \gls{pde}2 in experiment 2.}{}{}
	\label{fig:pajade_pde2_best_kernelbars}
\end{figure}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde3_worst_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the worst result of \gls{pde}3 in experiment 2.}{}{}
	\label{fig:pajade_pde3_worst_kernelbars}
\end{figure}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde3_best_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the best result of \gls{pde}3 in experiment 2.}{}{}
	\label{fig:pajade_pde3_best_kernelbars}
\end{figure}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde4_worst_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the worst result of \gls{pde}4 in experiment 2.}{}{}
	\label{fig:pajade_pde4_worst_kernelbars}
\end{figure}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde4_best_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the best result of \gls{pde}4 in experiment 2.}{}{}
	\label{fig:pajade_pde4_best_kernelbars}
\end{figure}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde7_worst_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the worst result of \gls{pde}7 in experiment 2.}{}{}
	\label{fig:pajade_pde7_worst_kernelbars}
\end{figure}

\begin{figure}[H]
	\centering
	\noindent\adjustbox{max width=1\linewidth}{
		\includegraphics[width=\textwidth]{../../code/experiments/experiment_2/pde7_best_result_kernelbars.pdf}
	}
	\unterschrift{Kernel Bars Plot on the best result of \gls{pde}7 in experiment 2.}{}{}
	\label{fig:pajade_pde7_best_kernelbars}
\end{figure}

\end{document}


\documentclass[12pt,a4paper,twosided]{article}
\usepackage{amsmath,bm}
%\usepackage[T1]{fontenc}
%\usepackage[QX]{fontenc}
%\usepackage[normalsections]{savetrees}
\usepackage{tgschola}
\usepackage[latin1]{inputenc}
\usepackage{paralist}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{xspace}
\usepackage{booktabs}
\usepackage{listings}
\usepackage[per=frac,fraction=nice]{siunitx}
\usepackage[colorlinks=true,linkcolor=black,urlcolor=black,hyperfootnotes=false]{hyperref}
\pdfpagewidth=210mm
\pdfpageheight=297mm
% +++++++++++++++++++++++++++++++++++++++++++
\newcommand{\wnat}{\omega_\text{n}}
\newcommand{\fmax}{f_\text{max}}
\newenvironment{enumin}%
% {\begin{inparaenum}[\hspace{1em}(1)]\hspace{-1em}\ignorespaces}%
   {\begin{inparaenum}[\hspace{0.6em}(1)]}%
   {\end{inparaenum}}
%%%
\graphicspath{{xfig/}}
\title{Dynamics of Structures 2010-2011\\\large 1st home assignment
  due on Tuesday 2011-06-17\\\huge Solutions}
\date{}
\setcounter{tocdepth}{1}
%%%
\begin{document}
\lstset{
  basicstyle=\ttfamily\small,
  backgroundcolor=\color[rgb]{1.00,0.98,0.95},
  language=python,
  showstringspaces= false
}
\maketitle{}
\tableofcontents{}
% +++++++++++++++++++++++++++++++++++++++++++
\section{Impact}
\[\input{xfig/impact.pdf_t}\]
\noindent A body of mass $m_1=\SI{120}{\kilogram}$ hits an undamped
\emph{SDOF} system, of unknown characteristics $k$ and $m_2$, with
velocity $\dot{x}_1=\SI{50}{\meter\per\second}$.

The collision is anelastic, i.e., the two masses are \emph{glued} together
and a measurement of the ensuing free oscillations gives the following
results:
\[ x_\text{max} =\SI{30}{\milli\meter},\qquad
   \dot{x}_\text{max}=\SI{60}{\milli\meter\per\second}.\]
%
Compute:
\begin{enumerate}
\item the total mass $m=m_1+m_2$
\item the mass $m_2$ of the impacted body,
\item the circular frequency of the insuing motion,
\item the spring stiffness $k$.
\end{enumerate}

\subsection{Solution}

After the collision the two \emph{glued} bodies have the same
velocity, so that by the law of conservation of the momentum we can
write
\[m_1\times\dot x_1 + m_2\times0 = (m_1+m_2)\times\dot x_0,\]
where we have denoted the initial velocity of the compound body with
$\dot x_0$.

Observing that the initial conditions for the compound are $x(0)=0$
and $\dot x(0)=\dot x_0$ we can write
\begin{align*}
  x(t)&=\frac{\dot x_0}{\wnat}\,\sin\wnat t,\,&\dot x(t)&=\dot x_0\,\cos\wnat t.\\
  x_\text{max} &= \frac{\dot x_0}{\wnat} = \SI{30}{\mm},&
  \dot x_\text{max} &=\dot x_0=\SI{60}{\milli\meter\per\second}\\
  \intertext{and hence}
  \dot x_0&=\SI{60}{\milli\meter\per\second},&
  \wnat&=\frac{\dot x_\text{max}}{x_\text{max}}={\color{red}\SI{2}{\rad\per\second}}.
\end{align*}

Substituting $\dot x_0=\SI{60}{\mm\per\second}$ in
$m_1\times\dot x_1 + m_2\times0 = (m_1+m_2)\times\dot x_0$ we have
\[\SI{120}{\kg}\times\SI{50000}{\mm\per\second} =
(\SI{120}{\kg}+m_2)\times\SI{60}{\mm\per\second}
\Rightarrow {\color{red}m=\SI{100000}\kg}
\Rightarrow {\color{red}m_2=\SI{99880}\kg}.\]

As for the last question, it is $k=\wnat^2\,m$ and substituting we find
\[{\color{red}k=(\SI{2}{\rad\per\second})^2\,\SI{100000}{\kg}=\SI{400000}{\newton\per\meter}.}\]
\section{Vibration Isolation --- Numerical Integration}
A rotating machine, its mass $M=\SI{35000}{\kg}$, is rigidly connected
to the floor.

Due to unbalances, during steady-state regime the machine is subjected
to a harmonic force $p(t)=\SI{1}{\kilo\newton}\,\sin(2\pi\,\SI{5}\hertz\, t)$.

\subsection{Vibration Isolation}
Considering the floor fixed, design an appropriate suspension system
such that the steady-state transmitted force is reduced to
\SI{300}{\newton}.
\subsection{Numerical Integration}
When the machine is turned on, its full velocity is reached in
\SI{6}{\second}.  The angular velocity and the unbalanced load vary
linearly, from $0$ to their respective maximum values, i.e.,
\[p(t)=
\begin{cases}
  \SI{1}{\kilo\newton}\,\frac{t}{\SI{6}\second}\;
  \sin\left(2\pi\,\SI{2.5}{\hertz}\,\frac{t^2}{\SI{6}{\second}}\right) &  \SI{0}\second \le t \le \SI{6}\second,\\
  \SI{1}{\kilo\newton}\;\sin(2\pi\,\SI{5}{\hertz}\, t) &  \SI{6}\second\le t.
\end{cases}\]\[
\includegraphics{02/p_of_t}
\]

\bigskip\noindent Using the stiffness computed in the previous step,
find  the maximum absolute value of the displacement using either
the constant or the linear acceleration method and plot the response
in the interval $\SI{0}\second \le t \le \SI{10}\second$.

\subsection{Solution}
\subsubsection{Vibration Isolation}
With $\wnat$ being the natural frequency of the system composed by the
machine and the suspension springs, $\beta=\frac\omega\wnat$ the
frequency ratio, the condition on the maximum tranmitted load is
\[\fmax=\frac{p_0}{\beta^2-1}\le\SI{300}{\newton}.\]

Substituting $p_0=\SI{1000}{\newton}$ in the equation above, we have
\[ \beta^2 =\frac{\omega^2}{k/m} \ge \frac{13}{3}
\quad\Rightarrow\quad
k\le\frac{3}{13}(\pi\,\SI{10}{\rad\per\second})^2\SI{35000}\kg=\SI{7971603.}{\newton\per\metre}\]

If we accept a small damping, it must be
\[\text{TR} =
\frac{\sqrt{1^2+(2\beta\zeta)^2}}{\sqrt{(1-\beta^2)^2+(2\beta\zeta)^2}}
=
\frac{\sqrt{1+4\beta^2\zeta^2}}{\sqrt{(1-\beta^2)^2+4\beta^2\zeta^2}}\le0.4\]
with $\omega=2\pi\SI{5}{\rad\per\second}$ and $\wnat^2=k/m$,
substituting the actual value of $m$, solving the quadratic equation
in $k$ and discarding the negative root, it is finally found
\[k\le \left( \sqrt{\left(182 \zeta^2 + 9\right)^2 + 819} - \left(182
    \zeta^2 + 9\right) \right) \frac{\pi^2}
{26}\si{\mega\newton\per\metre}\]
\[\includegraphics{02/stif_from_z}\]

\subsubsection{Numerical Integration}
The response can be computed and printed with the following program
\lstinputlisting{02/integ.py}
and the response time history is
\[\includegraphics{02/displacement}\]
but these displacements are a bit meaningless, let's try to plot
$f_\text{S}=k\,x$
\[\includegraphics{02/force}\]
oh my, it's $f_\text{S}\approx\SI{5}{\kilo\newton}$! just a moment,
the machine weight is about \SI{350}{\kilo\newton} so this harmonic
force is less than 1/70 of the weight, it shouldn't be a structural
problem... on the other hand, there is no dissipation and the effects
of the transient become permanent, it should be obvious that we have to
use a dissipative device.

To get an appreciation of the problem, I have  modified the previous
program so that the integration is run for different values of $t_0$,
the duration of transient, and different values of the damping ratio
$\zeta$; for each value of $\zeta$ $k$ is given by the formula we have
seen before,
\[k\le \left( \sqrt{\left(182 \zeta^2 + 9\right)^2 + 819} - \left(182 \zeta^2 + 9\right) \right) \frac{\pi^2} {26}\si{\mega\newton\per\metre}\]
and the damping coefficient is computed by
\[\wnat=\sqrt{k/m},\qquad c=2\zeta\wnat m.\]

For each iteration on $\zeta,\;t_0$ the program prints the peak value
of the transmitted force, and finally the results are plotted as a
colour map
\[\includegraphics{02/map}\]
% +++++++++++++++++++++++++++++++++++++++++++
%
\section{Estimation of damping ratio}
You want to determine the mass $m$, the stiffness $k$ and the damping
ratio $\zeta$ of a one storey building that can be modeled as a single
degree of freedom system.

A series of 4 dynamical test is performed, loading the building with a
vibrodyne and measuring the amplitude $\rho$ and the phase difference
$\theta$ of the steady state motion (note that the measures of $\rho$
and $\theta$ are affected by a random measurement error).

In each test the load amplitude is $p_0=\SI{600}{\newton}$, while
the excitation frequencies $\omega_n$ (with $n=1,\ldots,4$) are
different.

The relevant data is summarized in the following table
\begin{center}
  \begin{tabular}{rcrr}
    \toprule
    $n$ &
    $\omega_n (\si{\rad\per\second})$ &
    $\rho_n (\si{\micro\metre})$  &
    $\theta_n (\si{\deg})$\\
    \midrule
    1 & 40 & 12.39062 &   7.58258 \\
    2 & 50 & 41.09556 &  33.33505 \\
    3 & 60 & 18.07490 & 163.21210 \\
    4 & 70 &  7.11246 & 171.69968 \\
    \bottomrule
  \end{tabular}
\end{center}
Give your best estimate of $m$, $\zeta$ and $k$.

\subsection{Solution}

When you have a linear system $\bm A\,\bm x=\bm b$ with more equations
than unknowns, it is usually solved under the hypotesis that the
\emph{best} solution is the solution that minimises the sum of the
squares of the residuals $\bm r = \bm b - \bm A\,\bm x$. In a vector
notation, the sum of the
squares of the residuals is
\begin{align*}
  \bm r^T\cdot\bm r & = (\bm b^T - \bm x^T \bm A^T)(\bm b - \bm A\,\bm x )\\
  &=\bm b^T\bm b+ \bm x^T\bm A^T\bm A\,\bm x -\bm x^T \bm  A^T\bm b -\bm b^T\bm A\,\bm x\\
\intertext{the last term is the transpose of the previous one, both
  are scalars, so we can write}
  \bm r^T\cdot\bm r &=\bm b^T\bm b+ \bm x^T\bm A^T\bm A\,\bm x -2\bm x^T \bm  A^T\bm b.
\end{align*}

The square of the residual is positive definite, and its minimum is
achieved when all the partial derivatives with respect to the $x_i$
are equal to zero,
\[\frac{\partial (\bm r^T\cdot\bm r)}{\partial x_i}=0,\qquad
i=1,\ldots,N.\]

These $N$ equations can be conveniently be expressed in matrix format,
\[2(\bm A^T\bm A\,\bm x - \bm A^T  \bm b)=0\quad\Rightarrow\quad \bm
A^T\bm A\,\bm x = \bm A^T  \bm b.\]

In our case, it is
\[1\cdot k - \omega^2_n\,m=p_0\frac{\cos\theta_n}{\rho_n},\qquad
n=1,\ldots,4\]
or, matricially
\[
\begin{bmatrix}  1&-1600\\1&-2500\\1&-3600\\1&-4900\end{bmatrix}\,
\begin{Bmatrix}k\\m\end{Bmatrix}=
\begin{Bmatrix} +48.000\\+12.198\\-31.780\\-83.475\end{Bmatrix}\,\si{\mega\newton\per\metre}
\]
(note that the coefficients of $m$ are, dimensionally, a square
frequency) premultiplying both members by the transpose of the
coefficient matrix we write
\[\left\{
  \begin{matrix}
    +4 \cdot k & -\SI{2600}{\per\second\squared} \cdot m &=&
    \SI{-55.058e6}{\newton\per\metre}\\
     - \SI{2600}\cdot k &+ \SI{45780000}{\per\second\squared} \cdot m &=&\SI[retainplus]{+416.14e+9}{\newton\per\metre}
  \end{matrix}
\right.,\]
where the second equation was multiplied by \si{\second\squared}.

Solving the previos linear system gives the best estimates
${\color{red}k=\SI{111.78e6}{\newton\per\metre}}$ and
${\color{red}m={39854}{\kg}}$, in good agrement with the data entered in
the simulation. The damping ratio, computations omitted, is
${\color{red}\zeta\approx3.8\%}$.
% +++++++++++++++++++++++++++++++++++++++++++
\section{Generalised Coordinates (rigid bodies)}

%\[\resizebox{0.8\textwidth}{!}{\input{xfig/newtrab.pdf_t}}\]
\[\input{xfig/newtrab.pdf_t}\]

\renewcommand{\ss}{\textsf}
\noindent The articulated system in figure, composed by
\begin{itemize}
\item two rigid bars, \begin{enumin}\item \textsf{ABC} and
  \item\textsf{CDE},
  \end{enumin}
\item three fixed constraints,
  \begin{enumin}
  \item a horizontal roller in \textsf{A},
  \item an internal hinge in \textsf{C} and
  \item a hinge in \textsf{E},
  \end{enumin}
\item two deformable constraints,
  \begin{enumin}
  \item a horizontal spring in \textsf{A}, its stiffness${}=k$ and
  \item a vertical dashpot in \textsf{C}, its damping
    coefficient${}=c$,
  \end{enumin}
\end{itemize}
is excited by a horizontal harmonic  force applied in \textsf{B},
\(p(t)=p_0\,\sin\omega t.\)

The vertical parts of the two bars, \textsf{AB} and \textsf{ED}, are
massless while both the horizontal parts, \textsf{BC} and \textsf{CD},
have a constant unit mass $\overline m$, with $\overline m\,L=m$.

\medskip\noindent Using $u_\textsf{A}$ (the horizontal displacement of
\textsf{A}) as the generalised coordinate
\begin{enumerate}
\item compute the generalised parameters $m^*$,  $c^*$ and $k^*$,
\item compute the generalised loading $p^*(t)$ and
\item write the equation of dynamic equilibrium.
\end{enumerate}
\subsection{Solution}
Our sistem of reference will be centred in \textsf A, so that the
positions of the Center of Instantaneous Rotation (CIR) for the two
rigid bodies are $\Omega_1=(0,3L)$ and
$\Omega_2=(3L,0)\equiv\textsf{E}$. Using $Z=u_\ss A$ as our free
coordinate, the rotation about $\Omega_1$ is $\theta_1=+1/3\,Z/L$, the
rotation about $\Omega_2$ is $\theta_2=-2/3\,Z/L$ (anticlockwise
rotations are positive), and then we can compute the relevant
displacements

\medskip
\centerline{\begin{tabular}{ccc}
  \toprule
  & $u/Z$ & $v/Z$\\
  \midrule
  \ss A           & 1 & 0\\
  \ss B           & 2/3 & 0\\
  \ss C           & 2/3 & 2/3\\
  $\ss G_1$  & 2/3 & 1/3\\
  $\ss G_2$  & 2/3 & 1/3\\
  \bottomrule
\end{tabular}}

\medskip For equilibrium, the external virtual work $\delta W_\text E$ (work of
the external, spring, damper and inertial forces) equals to the
internal virtual work, $\delta W_\text I$ but for a rigid system it is
$\delta W_\text I = 0$, hence our equilibrium equation is
\[\delta W_\text E = 0.\]

In detail,
\begin{multline*}
  p(t)\,\frac23\delta Z + (-kZ)\,\delta Z + (-c\frac23\dot Z)\,(\frac23\delta Z) +\\
  (-(2m)\frac23\ddot Z)\,(\frac23\delta Z) + (-(2m)\frac13\ddot Z)\,(\frac13\delta Z) +
  (-\frac{2m(2L)^2}{12}\frac{\ddot Z}{3L})\,(\frac{1}{3L}\delta Z) +\\
  (-m\frac23\ddot Z)\,(\frac23\delta Z) + (-m\frac13\ddot Z)\,(\frac13\delta Z) +
  (\frac{mL^2}{12}\frac{2\ddot Z}{3L})\,(-\frac2{3L}\delta Z) = 0
\end{multline*}
simplyfying $\delta Z$, collecting $Z$ and its derivatives, moving
$Z$'s on the right side of the equation, it is
\begin{align*}
  \frac23 p(t) &= k\,Z + \frac49c\,\dot Z + (\frac89+\frac29+\frac2{27}+\frac49+\frac19+\frac1{27})m\,\ddot Z\\
               &= \frac{16}9m\,\ddot Z + \frac49c\,\dot Z + k\,Z
\end{align*}

The required answers are
\[\color{red}
m^*=\frac{16}9m,\quad c^*=\frac49c,\quad k^*=k,\quad p^*=\frac23p(t),
\] and
\[\color{red} \frac{16}9m\,\ddot Z + \frac49c\,\dot Z + k\,Z =
\frac23p(t)\]
% +++++++++++++++++++++++++++++++++++++++++++
\section{Rayleigh quotient}
\label{sec:rayleigh}
\[\input{xfig/newtrab2.pdf_t}\]
\noindent The undamped 3 \emph{DOF} system in figure is composed of 3
identical rigid bars, their masses $m_i=m$, and three vertical
springs, their stiffnesses as detailed in figure.  Starting with a
trial shape $\bm{\phi}= \begin{Bmatrix} 1 & 1 & 1
\end{Bmatrix}^T$ so that $u_1=u_2=u_3=Z_0\,\sin\omega t$, give the successive
Rayleigh estimates of (squared) free vibration circular frequency
$R_{00}$, $R_{01}$ and $R_{11}$.

Note
\begin{enumin}
\item that the bars have a not negligible rotatory inertia:
  $J_i=mL^2/12$, that you must take into account and
\item that the free coordinates are not referred to the centres of
  mass of the bars (hence a non-diagonal mass matrix).
\end{enumin}

\smallskip\noindent\textsc{Hint:} {\small
 %
  the nodal inertial forces are $\bm f_\text{I}=\bm M\,\ddot{\bm u}$,
  the mass matrix's coefficients can be deduced comparing an explicit
  derivation of the kinetic energy $T$ in terms of the velocities
  $\dot u_i$, the mass $m$ and the inertia $J$ to the matrix
  expression $T=\frac12 \dot{\bm u}^T \bm M\,\dot{\bm u} = \frac12
  \left( m_{11}\, \dot x_1^2 +\cdots+(m_{12}+m_{21})\,\dot x_1 \dot x_2 +
    \cdots \right)$, where $m_{ij}=m_{ji}$.}

\subsection{Solution}

The displacements $x_i$ of the 3 centres of mass are
\begin{align*}
  x_1&=u_1/2,      &x_2&=(u_2+u_1)/2&x_3&=(u_3+u_2)/2),\\
  \intertext{the rotations $\theta_i$ are}
  \theta_1&=u_1/L, &\theta_2&=(x_2-x_1)/L&\theta_3&=(x_3-x_2)/L.
\end{align*}

The kinetic energy is, summing the contributions from the three
identical bars,
\begin{align*}
  T&=\frac12\left(m(\dot x_1^2 + \dot x_2^2 + \dot
    x_3^2)+\frac{mL^2}{12}(\dot\theta_1^2 + \dot\theta_2^2 +
    \dot\theta_3^2)\right).\\
  \intertext{Substituting the free coordinates, simplifying and
    collecting the similar terms, it is}
  T&=\frac12\,\left(8\,\dot u_1^2 + 8\,\dot u_2^2 + 4\,\dot u_3^2 +
    4\, \dot u_1 \dot u_2 + 4\, \dot u_2 \dot u_3 + 0\, \dot u_3 \dot
    u_1\right)\,\frac m{12}.
\end{align*}

The kinetic energy can be expressed also by a matrix product,
\[T=\frac12\,\bm u^T\bm M\,\bm u=\frac12\left(m_{11}\dot u_1^2
  +\cdots+2\,m_{12}\dot u_1 \dot u_2 + \cdots\right),\]

equating the two right members term by term, we deduce that the mass
matrix coefficients are as in
\[\bm M =\frac m6 \begin{bmatrix}  4&1&0\\1&4&1\\0&1&2 \end{bmatrix}.\]

The stiffness matrix, simply, is
\[\bm K = k \begin{bmatrix} 1&0&0\\0&2&0\\0&0&3 \end{bmatrix}.\]

The Rayleigh procedure starts writing
\begin{align*}
  \bm{u}(t)&=\bm{\phi} Z_0 \sin\omega t,&\dot{\bm u}(t)&=\omega\bm\phi Z_0 \cos\omega t,\\
  V&=\frac12\bm\phi^T\bm{K}\,\bm\phi\,Z_0^2\sin^2\omega{}t,&
  T&=\frac12\omega^2\bm\phi^T\bm{M}\,\bm\phi\,Z_0^2\cos^2\omega{}t,
\end{align*}
so that, by equating the maximum values of energies $V$ and $T$ and
substituting $\bm\phi=\begin{Bmatrix}1&1&1\end{Bmatrix}^T$ we have
\[\omega^2=\frac{\bm\phi^T\bm{K}\,\bm\phi}{\bm\phi^T\bm{M}\,\bm\phi}=\frac{6k}{7/3\;m}=\frac{18}7\frac
km=\color{red}2.5714\frac km.\]

A better approximation of the strain energy is given by
\[V=\frac12\bm{u}_\text{I}^T\bm{f}_\text{I}^{},\] where
\(\bm{f}_\text{I}=-\omega^2\bm{M}\bm{\phi}Z_0\sin\omega{t}\) is the
vector of the inertial forces and
\(\bm{u}_\text{I}=\bm{K}^{-1}\bm{f}_\text{I}=-\omega^2\bm{K}^{-1}\bm{M}\bm{\phi}Z_0\sin\omega{t}\)
is the vector of displacements produced by $\bm{f}\text{I}$.

Equating the new maximum value of the strain energy to the old kinetic
energy maximum, it is
\[\omega^2=\frac{\bm\phi^T\bm{M}\,\bm\phi}{\bm\phi^T\bm{M}\,\bm{K}^{-1}\bm{M}\bm\phi}=
\frac{7/3\;m}{23/18\;m^2/k}=\frac{42}{23}\frac
km=\color{red}1.8261\frac km.\]

A better approximation to the kinetic energy is given by
\[T=\frac12 \dot{\bm{u}}_\text{I}^T\bm{M}\,\dot{\bm{u}}_\text{I},\]
where \(\dot{\bm{u}}_\text{I}=-\omega^3\bm{K}^{-1}\bm{M}\bm{\phi}Z_0\cos\omega{t}\)
is the velocity due to  application of the inertial
forces, equating the new max of $T$ to the new max of $V$ we have
\[\omega^2=\frac{\bm\phi^T\bm{M}\,\bm{K}^{-1}\bm{M}\bm\phi}{\bm\phi^T\bm{M}\,\bm{K}^{-1}\bm{M}\,\bm{K}^{-1}\bm{M}\bm\phi}
  =\frac{23/18\;m^2/k}{29/36\;m^3/k^2}=\frac{46}{29}\frac
  km=\color{red}1.5862\frac km.\]
% +++++++++++++++++++++++++++++++++++++++++++
\section{3 DOF System}
With reference to the system of problem \ref{sec:rayleigh}, using the
position \(\omega_0^2=\displaystyle\frac km\)
\begin{enumerate}
\item compute the three eigenvalues of the system and the
  corresponding eigenvectors,
\item normalize the eigenvectors with respect to the mass matrix $\bm
  M$ (it must be $\bm\psi^T\,\bm M\,\bm\psi = m$).
\end{enumerate}
Considering that the system is at rest for $t=0$ and is then loaded by
a load vector \(\bm p(t)\),
\[\bm p(t) = \frac{kL}{200}
\begin{Bmatrix}
  0\\-1\\+1
\end{Bmatrix}
  \sin(7\omega_0 t),
\]
\begin{enumerate}[resume]
\item find the analytical expression of $u_3=u_3(t)$, showing your
  intermediate results and
\item plot $u_3$ in the interval $0 \le \omega_0\,t \le 6$.
\end{enumerate}

\subsection{Solution}

Using the previously computed structural matrices, the eigenvalues are
the roots of the equation
\[\det\left(k \begin{bmatrix} 1&0&0\\0&2&0\\0&0&3 \end{bmatrix}
- \omega^2\frac m6 \begin{bmatrix}  4&1&0\\1&4&1\\0&1&2\end{bmatrix}\right)=0\]
with the position $\omega^2=\Lambda\omega^2_0$, developing the
determinant, simplifying etc it is
\[13\Lambda^3-204\Lambda^2+720\Lambda-648=0,\]
solving for the $\Lambda_i$ and substituting it is
\[\color{red}
\omega^2_1=1.4185\omega^2_0,\quad \omega^2_2=3.1619\omega^2_0,\quad \omega^2_3=11.112\omega^2_0.\]

For algebraic manipulations, it is often convenient to collect the
eigenvalues in a diagonal matrix
\[\bm\Lambda=\omega^2_0\begin{bmatrix}1.4185&0&0\\0&3.1619&0\\0&0&11.112\end{bmatrix}.\]

The eigenvectors are given by solving the following linear systems
\[\left(k \begin{bmatrix} 1&0&0\\0&2&0\\0&0&3 \end{bmatrix}
- \omega^2_i\frac m6 \begin{bmatrix}
  4&1&0\\1&4&1\\0&1&2\end{bmatrix}\right)\,\bm\psi_i=0,\quad
i=1,2,3.\]

Normalising and collecting the eigenvectors in an eigenvector matrix
$\bm\Psi$,
\[\color{red}\bm\Psi=
\begin{bmatrix}
  +1.1324&-0.5408&+0.2015\\
  +0.2594&+1.1369&-0.6973\\
  +0.0243&+0.3079&+1.8347
\end{bmatrix}.\]

The steady state response, $\bm{x}_\text{s-s}(t) = \bm\xi\,
\sin\omega{t}$, can be computed directly in terms of nodal coordinates
\[(\bm K - \omega^2\bm{M})\,\bm\xi\,\sin\omega{t} =
\bm{p}\,\sin\omega{t}\quad\Rightarrow\quad
\bm{\xi} = (\bm K - \omega^2\bm{M})^{-1}\bm{p}\]

Substituting $\omega^2=49\omega_0^2$ let us write
\[
\left(k \begin{bmatrix} 1&0&0\\0&2&0\\0&0&3 \end{bmatrix}
- \frac{49}{6}\omega^2_0 m \begin{bmatrix}
  4&1&0\\1&4&1\\0&1&2\end{bmatrix}\right)\,\bm\xi\sin(7\omega_0 t)=\frac{kL}{200}
\begin{Bmatrix}
  0\\-1\\+1
\end{Bmatrix}
  \sin(7\omega_0 t)
\]
dividing all terms by $k$, simplifying $\sin(7\omega_0 t)$ and
$\omega_0^2\frac mk=1$ and solving for $\bm\xi$ gives
\[\bm\xi=\frac L{200}\begin{bmatrix}
 -0.01765207\\
 +0.06844680\\
 -0.11692366
\end{bmatrix},\qquad
\bm{x}_\text{s-s}(t) =\frac L{200}\begin{bmatrix}
 -0.01765207\\
 +0.06844680\\
 -0.11692366
\end{bmatrix}\,\sin\omega{t}.
\]

Now, write the integral of the homogeneous problem as
\begin{align*}
  \bm{q}(t)&=\begin{bmatrix}\sin\omega_1t&0&0\\0&\sin\omega_2t&0\\0&0&\sin\omega_3t\end{bmatrix}\,\bm{a}
  +\begin{bmatrix}\cos\omega_1t&0&0\\0&\cos\omega_2t&0\\0&0&\cos\omega_3t\end{bmatrix}\,\bm{b}\\
  \bm\Lambda^{-\frac12}\,\dot{\bm{q}}(t)&=\begin{bmatrix}\cos\omega_1t&0&0\\0&\cos\omega_2t&0\\0&0&\cos\omega_3t\end{bmatrix}\,\bm{a}
  -\begin{bmatrix}\sin\omega_1t&0&0\\0&\sin\omega_2t&0\\0&0&\sin\omega_3t\end{bmatrix}\,\bm{b}
\end{align*}
and evaluate modal displacements and modal velocities at $t=0$
\begin{align*}
  \bm{q}_0&=\bm{b},&\dot{\bm{q}}_0&=\bm\Lambda^{\frac12}\,\bm{a}.
\end{align*}

The initial conditons in terms of nodal displacements, for a system
starting from rest conditions, are
\begin{align*}
  \bm{x}_0&=\bm\Psi\,\bm{q}_0+\bm\xi\,\sin\omega0=\bm0,&
  \dot{\bm{x}}_0&=\bm\Psi\,\dot{\bm{q}}_0+\omega\bm\xi\,\cos\omega0=\bm0,\\
  \intertext{substituting the initial values of the modal coordinates}
  \bm\Psi\,\bm{q}_0&=\bm\Psi\,\bm{b}=\bm{0},&
  \bm\Psi\,\dot{\bm{q}}_0&=\bm\Psi\,\bm\Lambda^{\frac12}\,\bm{a}=-\omega\bm\xi,\\
  \intertext{solving for $\bm{a}$ and $\bm{b}$}
  \bm{b}&=\bm{0},   &    \bm{a}&=-\bm{\Lambda}^{-\frac12}\omega\left(\bm{\Psi}^T\frac{\bm{M}}{m}\,\bm\xi\right).
\end{align*}

Substituting the numerical values into the last equation we find
\[\bm{a} = \frac{L}{200}
\begin{Bmatrix}
 -0.02904676\\
 -0.07119805\\
 +0.14033766
\end{Bmatrix}.\]

Finally, $x_3(t)$ is a linear combination of the modal responses by the
third elements of the three eigenvectors, plus the steady state
response $\xi_3\sin7\omega_0$
\begin{align*}
  {\color{red} 200\,x_3(t)/L}
  & = \psi_{31}a_1\sin\omega_1 t +  \psi_{32}a_2\sin\omega_2 t
  +  \psi_{33}a_3\sin\omega_3 t +  \xi_3\sin\omega t \\
  & = (-0.0243\cdot0.0290)\,\sin\omega_1 t + (-0.3079\cdot0.0712)\,\sin\omega_2  t + \\
  &\qquad(+1.8347\cdot0.1403)\,\sin\omega_3 t -0.1169\,\sin\omega t \\
  & \color{red} =
  -0.000705\,\sin1.1911\omega_0 -0.02192\,\sin1.7782\omega_0 t +\\
  & \color{red}
  \qquad +0.2574789\,\sin3.3334\omega_0 -0.11692366\,\sin7\omega_0 t.
\end{align*}

The following short Python program computes and prints the response
using the linear acceleration algorithm, note that it is almost identical
to the program used for the \emph{SDOF} system of problem 2, except
the use of vectors and matrices and the adimensionalisation of all
physical quantities.
\lstinputlisting{06/numeric.py}
In the plot below, you can compare the results of the numerical
integration with the results of the analytical derivation and gain
some confidence in the correctness of both  derivations.
%
%\smallskip
\begin{center}%
\makebox[\textwidth]{\includegraphics{06/comparison}}%
\end{center}\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\documentclass[12pt]{article}
\usepackage{amsfonts}
%\usepackage{mathptmx}

\usepackage[utf8]{inputenc}
\usepackage{comment}

%\usepackage{pgfplots}
%\pgfplotsset{width=10cm, compat=1.9}
%\documentclass[border=2mm,tikz]{standalone}
%\usetikzlibrary{datavisualization}

\usepackage[onehalfspacing]{setspace}
\usepackage{fancyhdr}
\usepackage{comment}
\usepackage[a4paper, top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]%
{geometry}
\usepackage{times}
\usepackage{amsmath}
\usepackage{changepage}
\usepackage{amssymb}
\usepackage{graphicx}

\setcounter{MaxMatrixCols}{30}
\newtheorem{theorem}{Theorem}
\newtheorem{acknowledgement}[theorem]{Acknowledgement}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{axiom}{Axiom}
\newtheorem{case}[theorem]{Case}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{conclusion}[theorem]{Conclusion}
\newtheorem{condition}[theorem]{Condition}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{criterion}[theorem]{Criterion}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{exercise}[theorem]{Exercise}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{solution}[theorem]{Solution}
\newtheorem{summary}[theorem]{Summary}
\newenvironment{proof}[1][Proof]{\textbf{#1.} }{\ \rule{0.5em}{0.5em}}

\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\Z}{\mathbb{Z}}

\begin{document}

\title{MAT120: Integral Calculus and
Differential Equations \\
BRAC University}

\author{Syed Zuhair Hossain \\ St. ID - 19101573 \\ Section - 07 \\ Set-Q \\ Assignment - 04}
\date{\today}
\maketitle

%%%%%%%%%%%Starting Point%%%%%%%%%%%%%%%

%%%%%MATH 01%%%%%%%%%%%%
\section{Evaluate the integral \\[5mm]
        $\int_{1}^{2} \int_{z}^{2} \int_{0}^{\sqrt{3}y} \frac{y}{x^2 + y^2} \ dx \ dy \ dz$
        }

\textbf{Solution \ :}
\begin{align*}
    Let,\\
    &u = \frac{x}{y} & \Rightarrow x^2 = y^2 u^2\\
    &du = \frac{1}{y} dx\\
    \therefore \ &dx = y \ du
\end{align*}

\begin{align*}
    \therefore \ \int \frac{y}{x^2 + y^2} \ dx &= \int \frac{y^2}{y^2 u^2 + y^2 } du \\
    &= \int \frac{y^2}{u^2 + 1} du\\
    &= \int \frac{1}{u^2 +1} du\\
    &= tan^{-1}(u)\\
    &= tan^{-1}\frac{x}{y}
\end{align*}

\begin{align*}
    &\int_{1}^{2} \int_{2}^{3} (\frac{\pi}{3}) dy dx\\[3mm]
    &= \int_{1}^{2} \frac{\pi}{3} \times [y]_{z}^{2} \ dz\\[3mm]
    &= \int_{1}^{2} \frac{\pi}{3} (2-z) dz\\[3mm]
    &= \int_{1}^{2} \frac{2\pi}{3} dz - \int_{1}^{2} \frac{\pi}{3} z dz\\[3mm]
    &= \frac{2\pi}{3} \int_{1}^{2} dz - \frac{\pi}{3} \int_{1}^{2} z dz\\[3mm]
    &= \frac{2\pi}{3} \int_{1}^{2} dz - \left[ \frac{\pi}{3} \times \frac{z^2}{2}\right]_{1}^{2}\\
    &= \frac{2\pi}{3} \int_{1}^{2} dz + (- \frac{4 \pi}{6} + \frac{1 \cdot \pi }{6})\\[3mm]
    &= \frac{2\pi}{3} \int_{1}^{2} dz - \frac{\pi}{2}\\[3mm]
    &= \frac{2 \pi \times 2}{3} - \frac{2\pi \cdot 1}{3} - \frac{\pi}{2}\\[3mm]
    &= \frac{2\pi}{3} - \frac{\pi}{2}\\[3mm]
    &= \frac{4\pi-3\pi}{6}\\[3mm]
    &= \frac{\pi}{6} &[Answer]
\end{align*}
%%%%%%%%%%%%%%%%%%%%%%%
\pagebreak
\section{Solve}
\centering $(x+1) \frac{dy}{dx} + y = lnx, y(1) = 10$

\renewcommand{\baselinestretch}{2.0}
\begin{align*}
    \textbf{Converting into standard form:}&\\
    & \frac{dy}{dx} + \left(\frac{1}{x+1}\right) y = \frac{ln(x)}{(x+1)} \ \ \ \ \ \ \ \ \ [\textit{dividing by (x+1) in both side}]\\
    \textbf{according to the formula}&\\
    &y{'} + \rho (t) y = g(t)\\
    \therefore \rho(x) &= e^{\int \frac{1}{x+1}dx}\\
    &= e^{ln(x+1)}\\
    &= (x+1)\\\\
    \raggedright\therefore (x+1) y &= \int ln(x)dx\\
    \Rightarrow(x+1)y &= xln(x) - x + c\\
    \therefore y &= \frac{x(ln(x)-x+c)}{x+1}\\
    \textbf{apply the given condition,}\\
    &y(1) = 10\qquad  x=1\\
    &\Rightarrow \frac{1\times ln(1)-1+c}{1+1} = 10\\
    &\Rightarrow \frac{0-1+c}{2} = 0\\
    &c = 21\\
    &\therefore y = \frac{xln(x) - x + 21}{(x+1)}\qquad \textbf{[Answer]}
\end{align*}
\pagebreak

\raggedright\section{Evaluate \qquad $\int_{1}^{4} \int_{0}^{\sqrt{x}}\frac{3}{2} e^{\frac{y}{\sqrt{x}}} dy dx$}

\begin{align*}
    &= \int_{1}^{4} \frac{3}{2} \left[e^{\frac{y}{\sqrt{x}} \times \sqrt{x}}\right]_{0}^{\sqrt{x}} dx\\
    &= \int_{1}^{4} \frac{3}{2} \left[e^1 \cdot \sqrt{x} - e^0 \cdot \sqrt{x}\right] dx\\
    &= \int_{1}^{4} \frac{3}{2} (e\sqrt{x} - \sqrt{x}) dx\\
    &= \int_{1}^{4} \frac{3}{2} \times \sqrt{x} \times (e-1) dx\\
    &= \frac{3}{2} \int_{1}^{4} \sqrt{x} (e-1) dx\\
    &= \frac{3}{2} \times (e-1) \int_{1}^{4}\sqrt{x} dx\\
    &= \frac{3}{2}(e-1) [\frac{2x^\frac{3}{2}}{3}]_{1}^{4}\\
    &= (e-1) [x^{\frac{3}{2}}]_{1}^{4}\\
    &= (e-1) [4^{\frac{3}{2}}-1]\\
    &= 7(e-1)\\
    &\approx 12.0279728 \hspace{100} \textbf{[Answer]}
\end{align*}
\pagebreak

\section{Solve the differential equation using variables separable method : \qquad x^{2} \frac{dy}{dx} =y-xy; y(-1) = -1.}

\begin{align*}
    &\Rightarrow x^2 \frac{dx}{dy} = y(1-x)\\
    &\Rightarrow \frac{1}{y} \frac{dy}{dx} = \frac{1-x}{x*2} = \frac{1}{x^2} - \frac{1}{x}\\
    &\Rightarrow \int y^{-1} dy = \int \frac{(1-x)}{x^2} dx\\
    \textit{Now, integrating both sides,}\\
    &\int \frac{dy}{y} = \int \frac{1}{x^2}dx - \int \frac{1}{x} dx\\
    &\Rightarrow ln(y) = - \frac{1}{x} - ln(x) + c\\\\
    \textbf{Given that,}\\
    &y=-1 \hspace{20} x=-1\\
    &\therefore ln|-1| = \frac{-1}{-1} - ln|-1| + c\\
    &\Rightarrowln(1) = 1- ln(1) + c\\
    &\therefore c=0\\\\
    &\therefore log y = \frac{1}{x} - log(x)-1\\
    &\Rightarrow log(y) + log(x) = - \frac{1}{x} - 1\\
    &\Rightarrow log(yx) = - \frac{1}{x} -1\\
    &\Rightarrow yx = e^{-\frac{1}{x} -1}\\
    &\Rightarrow yx = e^{\frac{-1}{x}} e^{-1}\\
    &\Rightarrow y = \frac{e^{\frac{-1}{x}}}{e^{x}}\hspace{25} \textbf{[Answer]}
\end{align*}

\newpage

\section{Evaluate the integral: \qquad \int_{0}^{\frac{\pi}{4}} \int_{0}^{1} \int_{0}^{x^2} x cosy \ dz \ dx \ dy }

\begin{align*}
    &= \int_{0}^{\frac{\pi}{4}} \int_{0}^{1} [x z cos y]_{0}^{x^2} dx dy\\
    &= \int_{0}^{\frac{\pi}{4}} \int_{0}^{1} (x \cdot x^2 cosy - x \cdot 0 \cdot cosy) dx dy\\
    &= \int_{0}^{\frac{\pi}{4}} \int_{0}^{1} x^3 cosy dx dy\\
    &= \int_{0}^{\frac{\pi}{4}} cosy \int_{0}^{1} x^3 dx dy\\
    &= \int_{0}^{\frac{\pi}{4}} \left[\frac{x^4}{4} cos(y)\right]_{0}^{1}dy\\
    &= \int_{0}^{\frac{\pi}{4}} \left[\frac{x^4}{4} cos(y) - \frac{0}{4} cos(y) \right]dy\\
    &= \int_{0}^{\frac{\pi}{4}} \frac{cosy}{4} dy\\
    &= \frac{1}{4} \int_{0}^{\frac{\pi}{4}} cos \ y \ dy\\
    &= \left[\frac{1}{4} \times sin y\right]_{0}^{\frac{\pi}{4}}\\
    &= \left[\frac{1}{4} \times sin y \right]_{0}^{\frac{\pi}{4}}\\
    &=(\frac{1}{4} sin \frac{\pi}{4} - \frac{1}{4} sin(0))\\
    &= \frac{1}{4} \times \frac{1}{\sqrt{2}} -0\\
    &= \frac{1}{4\sqrt{2}}\\
    \bigbreak
    &\hspace{200} \textbf{[Answer]}
\end{align*}

\pagebreak

\section{Solve the system for x and y in terms of u and v then find the Jacobian $\frac{\partial(x,y)}{\partial(u,v)} .$}
\centering \bigtitle{\textbf{u = x-y; v = 2x+y}}

\begin{align*}
    Here,\\
    &u = x-y............(1)\\
    &v = 2x+y...........(2)
\end{align*}

\begin{align*}
    \textit{adding equation (1) and (2) we get,}&\\
    & u + v = 3x\\
    & x = \frac{u+v}{3}\\
    & x = \frac{u}{3} + \frac{v}{3}\\
\end{align*}

\begin{align*}
    \textit{Again, extracting equation (2) from (1) we get,}&\\
    & v-u = 2y -x\\
    & 2y = v-u +x\\
    & 2y = v - u + \frac{u}{3} + \frac{v}{3}\\
    & y = \frac{3v-3u+u+v}{3 \times 2}\\
    & y = \frac{4v-2u}{6}\\
    & y = \frac{2v}{3} - \frac{1\cdot u}{3}
\end{align*}
\pagebreak
\begin{align*}
    &\frac{\partial x}{\partial u} =\frac{1}{3} & \frac{\partial y}{\partial u} = -\frac{2}{3}\\
    &\frac{\partial x}{\partial v} =\frac{1}{3} & \frac{\partial y}{\partial u} = \frac{1}{3}\\
\end{align*}

\begin{equation*}
    \textbf{Jacobian,J}
    =\frac{\partial(x,y)}{\partial(u,v)}
    = \begin{vmatrix}
    \frac{\partial x}{\partial u} & \frac{\partial y}{\partial u}\\
    \frac{\partial x}{\partial v} & \frac{\partial y}{\partial u}
    \end{vmatrix}
    =
    \begin{vmatrix}
    \frac{1}{3} & -\frac{2}{3}\\
    \frac{1}{3} & \frac{1}{3}
    \end{vmatrix}
    = \frac{1}{3} \times \frac{1}{3} - \left(-\frac{2}{3} \right) \times \frac{1}{3}
    =\frac{1}{9} + \frac{2}{9} = \frac{1}{3}
\end{equation*}
\bigbreak
\centering \title{\textbf{[Answer]}}
\end{document}