%------------------------------------------------------------------------------------------------------------------------------------%
\typeout{<----------- PREAMBLE OG EKSTRA KOMMANDOER ----------->}
\input{../preamble.tex}                  %Input af preamble
%\usepackage[notref,notcite]{showkeys}   %Hvis aktiv vises labels i margin - bør kun anvendes i draft
\newcommand{\theaflnr}{2}                %Definition af afleveringsnummer, til sektionsnummerering, forside og sidehoved
\linespread{1.2}
%------------------------------------------------------------------------------------------------------------------------------------%
\typeout{<----------- START PÅ DOKUMENT MED FORSIDE ----------->}
\begin{document}                         % Starter dokumentet efter preamble
\pagestyle{empty}                        % Sidehoved og sidefod for forsiden
\input{../forside.tex}                   % Input af forsiden, der ligger i forside.tex
%------------------------------------------------------------------------------------------------------------------------------------%
\typeout{<---------- START PÅ AFLEVERINGSOPGAVEN SELV ---------->}
\newpage                                 % Ny side efter forsiden er indsat
\pagestyle{fancy}                        % Sidehoved og sidefod for resten af dokumentet
\setcounter{page}{2}                     % Resten af afleveringen har sidenummer 2 og frem
\setcounter{section}{\theaflnr}          % reset tælleren til at nummerere sections (ugeopgavenummer)

%------------------------------------------------------------------------------------------------------------------------------------%
\subsubsection*{Notice}
{\footnotesize In this assignment I'll refer to theorems, definitions and so forth. When I do this, I don't make any references to where they're coming from -- but unless I state anything else -- they're from the notes we use in the course, \cite{notes}. }


\setcounter{subsection}{1}
\subsection*{Problem 1}
\ramme{ Consider the function 
        \begin{equation}
         f(x) = \big( |x| - 1 \big)^2
         \label{eq:p1:fdefined}
        \end{equation}
        defined on $\mathbb{R}$. }

\subsubsection*{Question a}
\ramme{ Find the convex hull of $f$. }
On figure \vref{fig:p1:grafer} I have plotted the function $f(x)$ in blue. The convex hull is easily seen to be given by the piecewise defined function
\begin{equation}
 f^c(x) = \left\{ \begin{array}{ll}  
                   f(x)& \quad\text{if } x \in \mathbb{R} \setminus ]-1,1[ \\
                   0&    \quad\text{if } x \in [-1,1] .
                  \end{array} \right.
 \label{eq:p1:fcdefined}
\end{equation}
But I have to show that this function $f^c$ really \emph{is} the convex hull for $f$. I'll show that $f^c$ is convex, and that $f^c \leq f$ for all $x \in \mathbb{R}$. At last, I'll show that $f^c$ is really the largest convex function under $f$, and hence is the convex hull of $f$ according to Theorem 3.10. 
\\ \\
\noindent To show that $f^c$ is convex, I have to look at six different types of lines between points on the graph of $f^c$, all shown on figure \vref{fig:p1:linier}. They are as follows:
\begin{enumerate}\ns
 \item[$\L_1$:] A line between two points both on the graph where $x > 1$.
 \item[$\L_2$:] A line between two points both on the graph where $x < -1$.
 \item[$\L_3$:] A line between a point on the graph where $x > 1$ and a point on the graph where $x < -1$.
 \item[$\L_4$:] A line between a point on the graph where $x > 1$ and a point on the graph where $-1 < x < 1$.
 \item[$\L_5$:] A line between a point on the graph where $x < -1$ and a point on the graph where $-1 < x < 1$.
 \item[$\L_6$:] A line between two points both on the graph where $-1 < x < 1$.
\end{enumerate}




\begin{figure}[tb]
 \centering
  %\begin{center}
  \psset{xunit=13mm,
         yunit=7mm}
  \begin{pspicture}(-3.5,-0.5)(3.5,4.3) %\psgrid
   %Koordinatsystem:
   \psline[arrows=->](-3.5,0)(3.5,0)    \uput[-90](3.5,0){$x$}
   \psline[arrows=->](0,-0.5)(0,4)      %\uput[180](0,4){$y$}
   %Punkter på koordinatsystemets akser:
   \psline[linewidth=1pt](1,0)(1,-0.2)    \uput[-90](1,-0.1){\footnotesize$1$}
   \psline[linewidth=1pt](-1,0)(-1,-0.2)  \uput[-90](-1,-0.1){\footnotesize$-1$}
   \psline[linewidth=1pt](0,1)(-0.1,1)    \uput[180](-0.025,1){\footnotesize$1$}
   %Kurver:
   \pscurve[linewidth=1.5pt,linecolor=Periwinkle]{c-c}(-3,4)(-2.9,3.61)(-2.8,3.24)(-2.7,2.89)(-2.6,2.56)(-2.5,2.25)(-2.4,1.96)(-2.3,1.69)
   (-2.2,1.44)(-2.1,1.21)(-2,1)(-1.9,0.81)(-1.8,0.64)(-1.7,0.49)(-1.6,0.36)(-1.5,0.25)(-1.4,0.16)(-1.3,0.09)(-1.2,0.04)(-1.1,0.01)(-1,0)
   (-0.9,0.01)(-0.8,0.04)(-0.7,0.09)(-0.6,0.16)(-0.5,0.25)(-0.4,0.36)(-0.3,0.49)(-0.2,0.64)(-0.1,0.81)(0,1)
   \pscurve[linewidth=1.5pt,linecolor=Periwinkle]{c-c}(0,1)(0.1,0.81)(0.2,0.64)(0.3,0.49)(0.4,0.36)(0.5,0.25)(0.6,0.16)(0.7,0.09)
   (0.8,0.04)(0.9,0.01)(1,0)(1.1,0.01)(1.2,0.04)(1.3,0.09)(1.4,0.16)(1.5,0.25)(1.6,0.36)(1.7,0.49)(1.8,0.64)(1.9,0.81)(2,1)(2.1,1.21)
   (2.2,1.44)(2.3,1.69)(2.4,1.96)(2.5,2.25)(2.6,2.56)(2.7,2.89)(2.8,3.24)(2.9,3.61)(3,4)
   \pscurve[linewidth=0.9pt,linecolor=SpringGreen]{c-c}(-3,4)(-2.9,3.61)(-2.8,3.24)(-2.7,2.89)(-2.6,2.56)(-2.5,2.25)(-2.4,1.96)(-2.3,1.69)
   (-2.2,1.44)(-2.1,1.21)(-2,1)(-1.9,0.81)(-1.8,0.64)(-1.7,0.49)(-1.6,0.36)(-1.5,0.25)(-1.4,0.16)(-1.3,0.09)(-1.2,0.04)(-1.1,0.01)(-1,0)
   (-0.9,0)(-0.8,0)(-0.7,0)(-0.6,0)(-0.5,0)(-0.4,0)(-0.3,0)(-0.2,0)(-0.1,0)(0,0)(0.1,0)(0.2,0)(0.3,0)(0.4,0)(0.5,0)(0.6,0)(0.7,0)(0.8,0)
   (0.9,0)(1,0)(1.1,0.01)(1.2,0.04)(1.3,0.09)(1.4,0.16)(1.5,0.25)(1.6,0.36)(1.7,0.49)(1.8,0.64)(1.9,0.81)(2,1)(2.1,1.21)(2.2,1.44)
   (2.3,1.69)(2.4,1.96)(2.5,2.25)(2.6,2.56)(2.7,2.89)(2.8,3.24)(2.9,3.61)(3,4)
   %Labels:
   \uput[0](0.2,1){{\color{Periwinkle}$f(x)$}}
   \uput[0](2.5,2){{\color{SpringGreen}$f^c(x)$}}
  \end{pspicture}
  %\end{center}
 \caption{Plot of the function $f(x)$ from \eqref{eq:p1:fdefined}, in blue, along with the convex hull of the function, $f^c(x)$, from 
          \eqref{eq:p1:fcdefined}, in green.}
 \label{fig:p1:grafer}
\end{figure}



\begin{figure}[tb]
 \centering
  %\begin{center}
  \psset{xunit=13mm,
         yunit=7mm}
  \begin{pspicture}(-3.5,-0.5)(3.5,4.3) %\psgrid
   %Koordinatsystem:
   \psline[arrows=->](-3.5,0)(3.5,0)    \uput[-90](3.5,0){$x$}
   \psline[arrows=->](0,-0.5)(0,4)      %\uput[180](0,4){$y$}
   %Punkter på koordinatsystemets akser:
   \psline[linewidth=1pt](1,0)(1,-0.2)        \uput[-90](1,-0.1){\footnotesize$1$}
   \psline[linewidth=1pt](-1,0)(-1,-0.2)      \uput[-90](-1,-0.1){\footnotesize$-1$}
   %\psline[linewidth=1pt](0,1)(-0.1,1)       \uput[180](-0.025,1){\footnotesize$1$}
   \psline[linewidth=1pt,linestyle=dotted](-2.2,1.44)(-2.2,0)
   \psline[linewidth=1pt](-2.2,0)(-2.2,-0.2)  \uput[-90](-2.2,-0.1){\footnotesize$x_1$}
   \psline[linewidth=1pt](-0.5,0)(-0.5,-0.2)  \uput[-90](-0.5,-0.1){\footnotesize$x_2$}
   %Kurver:
   \pscurve[linewidth=1.5pt,linecolor=SpringGreen]{c-c}(-3,4)(-2.9,3.61)(-2.8,3.24)(-2.7,2.89)(-2.6,2.56)(-2.5,2.25)(-2.4,1.96)(-2.3,1.69)
   (-2.2,1.44)(-2.1,1.21)(-2,1)(-1.9,0.81)(-1.8,0.64)(-1.7,0.49)(-1.6,0.36)(-1.5,0.25)(-1.4,0.16)(-1.3,0.09)(-1.2,0.04)(-1.1,0.01)(-1,0)
   (-0.9,0)(-0.8,0)(-0.7,0)(-0.6,0)(-0.5,0)(-0.4,0)(-0.3,0)(-0.2,0)(-0.1,0)(0,0)(0.1,0)(0.2,0)(0.3,0)(0.4,0)(0.5,0)(0.6,0)(0.7,0)(0.8,0)
   (0.9,0)(1,0)(1.1,0.01)(1.2,0.04)(1.3,0.09)(1.4,0.16)(1.5,0.25)(1.6,0.36)(1.7,0.49)(1.8,0.64)(1.9,0.81)(2,1)(2.1,1.21)(2.2,1.44)
   (2.3,1.69)(2.4,1.96)(2.5,2.25)(2.6,2.56)(2.7,2.89)(2.8,3.24)(2.9,3.61)(3,4)
   %Linier:
   \pcline[linewidth=0.5pt,linestyle=dashed,linecolor=Red]{-*}(-2.2,1.44)(-1,0)
   \pcline[linewidth=0.5pt,linestyle=dashed,linecolor=Red]{*-}(-1,0)(-0.5,0)
   \pcline[linewidth=0.5pt,linecolor=Periwinkle]{*-*}(2,1)(2.8,3.24)          \aput[0.5pt]{0}{$\L_1$}
   \pcline[linewidth=0.5pt,linecolor=Periwinkle]{*-*}(-2.9,3.61)(-2.2,1.44)   \aput[0.5pt]{0}{$\L_2$}
   \pcline[linewidth=0.5pt,linecolor=Periwinkle]{*-*}(-2.9,3.61)(2,1)         \aput[0.5pt]{0}{$\L_3$}
   \pcline[linewidth=0.5pt,linecolor=Periwinkle]{*-*}(2,1)(0.9,0)             \bput[0.5pt]{0}{$\L_4$}
   \pcline[linewidth=0.5pt,linecolor=Periwinkle]{*-*}(-2.2,1.44)(-0.5,0)      \aput[0.5pt]{0}{$\L_5$}
   \pcline[linewidth=0.5pt,linecolor=Periwinkle]{*-*}(0.9,0)(-0.5,0)          \bput[1.0pt]{0}{$\L_6$}
   %Labels:
   \uput[0](2.5,2){{\color{SpringGreen}$f^c(x)$}}
  \end{pspicture}
  %\end{center}
 \caption{Plot of the function $f^c(x)$ from \eqref{eq:p1:fcdefined} along with the six different types of lines between points on the graph. With
          two dashed red lines I have shown how the path of the line $\L_5$ can be split up.}
 \label{fig:p1:linier}
\end{figure}




\noindent By noting that the graph of $f^c$ on the intervals $]-\infty,-1]$ and $[1,\infty[$ equals $f$, which here is continous and twice differentiable with the second differential equal to $f''(x) = 2 > 0$, it is trivial that the lines $\L_1$ and $\L_2$ are actually over or on the graph of $f^c$ for all $x$ in the two intervals (this follows from Theorem 3.12). Hence, $f^c$ is convex when looking at lines of the form of $\L_1$ and $\L_2$. 

A line of the form of $\L_6$ will also never get under the graph of $f^c$, because it will always lie \emph{on} the graph of $f^c$ -- simply according to the definition of $f^c$ on the interval $[-1,1]$.
\\ \\
\noindent From this it follows that the types of lines $\L_3$, $\L_4$ and $\L_5$ also lies above or on the graph of $f^c$. I will only show this for $\L_5$, but it is done with exactly the same arguments for lines of the types $\L_3$ and $\L_4$. 

I see that the path from a point $(x_1,f^c(x_1))$, where $x_1<-1$, to a point $(x_2,f^c(x_2))$, where $-1<x_2<1$, can be split up to two lines: One from $(x_1,f^c(x_1))$ to the point $(-1,0)$ and one from the point $(-1,0)$ to $(x_2,f^c(x_2))$. This is shown on figure \vref{fig:p1:linier} as two red dashed lines. These two individual lines will, from the arguments of the lines $\L_2$ and $\L_6$, %combined with the obvious continuity of $f^c$ at $x=-1$, be connected and 
be over or on the graph of $f^c$ (note that $f$ was also twice differentiable at $x=-1$, so the double derivative still makes sence here). And since the point $(-1,0)$ is always below or equal to the point $(x_1,f^c(x_1))$, it is obvious that the line $\L_5$ will be over or on both of the two lines. Hence lines of the type $\L_5$ is also always over or on the graph of $f^c$. 
\\ \\
After having argued that $f^c$ is actually convex, I have to show that $f^c\leq f$ for all $x \in \mathbb{R}$. This is useful because I know that $f^c \leq f^c_{\text{ac}} \leq f$, because the actual convex hull $f^c_{\text{ac}}$ of $f$ by definition is the largest convex function under $f$. So in the end, I just have to find that $f^c_{\text{ac}} = f^c$. 

To show that $f^c\leq f$ for all $x \in \mathbb{R}$, I split the problem up into three intervals. On the intervals $]-\infty,-1]$ and $[1,\infty[$ I already know that $f^c=f$, so here the inequality is an equality, and trivially true. On the interval $[-1,1]$, however, I only know that $f^c=0$, and that $f^c=f$ in the end points. But it is then trivial that $f^c \leq f$ over this interval too, since $f$ is always non-negative (because of the square in the definition of $f$). Hence $f^c \leq f$ for all $x\in\mathbb{R}$. 

Now I note that it is only possible to find a convex function $f^c_{\text{ac}} \geq f^c$ that also satisfies that $f^c_{\text{ac}} \leq f$ if $f^c_{\text{ac}} = f^c$. Such a function $f^c_{\text{ac}}$ would have to have a value larger than or equal to zero on the interval $[-1,1]$, but if the value is larger than zero it becomes non-convex (because it has to have the value zero at the points where $x = -1$ and $x = 1$), so it is only possible if it is actually equal to $f^c$. Hence $f^c$ in \eqref{eq:p1:fcdefined} must be the largest convex function under $f$, and is then the convex hull of $f$. 




\subsubsection*{Question b}
\ramme{ Find the Legendre transform of $f$. }
To find the Legendre transform of $f$, I first look at the function $g$ defined by the supremum from Definition 3.14, by
\begin{equation*}
 g(p) = \sup{\{ x p - f(x) \,|\, x \in \mathbb{R} \}} .
\end{equation*}
I want to find out for which $p$ this supremum is finite, to find the domain on which $g$ is defined, where it equals the Legendre transform $f^\ast$ of $f$. So I rewrite the supremum by inserting $f$ from \eqref{eq:p1:fdefined} and splitting it up for positive and negative $x$, by
\begin{align*}
 &\sup{\{ x p - f(x) \,|\, x \in \mathbb{R} \}} \\
      &\quad= \sup{\{ x p - (|x|-1)^2 \,|\, x \in \mathbb{R} \}} \\
      &\quad= \sup{\{ x p - |x|^2 + 2 |x| - 1 \,|\, x \in \mathbb{R} \}} \\
      &\quad= \sup{\{ x p - x^2 + 2 |x| \,|\, x \in \mathbb{R} \}} - 1 \\
      &\quad= \max{\big\{ \sup{\{ x p - x^2 + 2 x \,|\, x \geq 0 \}} , \sup{\{ x p - x^2 - 2 x \,|\, x \leq 0 \}} \big\} } - 1  \\
      &\quad= \max{\big\{ \sup{\{ x (p + 2) - x^2 \,|\, x \geq 0 \}} , \sup{\{ x (p - 2) - x^2 \,|\, x \leq 0 \}} \big\} } - 1 .
\end{align*}
These two expressions I want to take the suprema of are second order polynomials. Since the sign in front of the $x^2$ term is always minus, independent of $p$, they will have supremum either at the top point or at one of the end points (the ``legs'' of the parabolas points downwards). For a second order polynomial of the form $y(x)=bx-x^2$, the top point is at $x = b/2$ with value $y = b^2/4$, and the graph of the polynomial always goes through origo. 
\\ \\
\noindent So the suprema above can only appear at the origo or at the top points of the two parabolas 
\begin{equation*}
 g_1(x) = x (p + 2) - x^2  \qquad\text{and}\qquad  g_2(x) = x (p - 2) - x^2 .
\end{equation*}
The supremum over $g_1$ is taken for $x \geq 0$, so for the supremum to be at origo, the slope at $x=0$ must be $g_1'(0) \leq 0$. This happens when $p \leq -2$ because
\begin{equation*}
 g_1'(0) = (p + 2) - 2 \cdot 0 = (p + 2) .
\end{equation*}
When, on the other hand, $p \geq -2$, the supremum is the top point of the parabola, so the supremum is at $x = (p+2)/2$ with the value $(p+2)^2/4$ for $p \leq -2$. 

In a similar way, the supremum over $g_2$ is taken for $x \leq 0$, so for the supremum to be at origo, the slope at $x=0$ must be $g_1'(0) \geq 0$. This happens when $p \geq 2$ because
\begin{equation*}
 g_2'(0) = (p - 2) - 2 \cdot 0 = (p - 2) .
\end{equation*}
When $p \leq 2$, the supremum is instead at the top point of the parabola, so the supremum is at $x = (p-2)/2$ with the value $(p-2)^2/4$ for $p \geq 2$. 
\\ \\
\noindent Now I know that when $p \leq -2$, the supremum of $g_1$ is in origo while the supremum of $g_2$ is it's top point. The maximum of these two must be the top point of $g_2$, since this is non-negative for all $p$, and therefore of course larger or equal to zero. So I know that
\begin{equation}
 g(p) = \frac{(p-2)^2}{4} - 1
      \qquad\text{for } p \leq -2 .
 \label{p1:qb:gafp1}
\end{equation}
I also know that when $p \geq 2$, the supremum of $g_2$ is in origo while the supremum of $g_1$ is it's top point. The maximum of these two is the top point of $g_1$, by the same argument as before, so I know that
\begin{equation}
 g(p) = \frac{(p+2)^2}{4} - 1
      \qquad\text{for } p \geq 2 .
 \label{p1:qb:gafp2}
\end{equation}
But when $-2 \leq p \leq 2$, both the supremum of $g_1$ and the supremum of $g_2$ is at their respective top points, so here I need to find the largest of these two suprema. This is simply
\begin{equation*}
 \max{\left\{ \frac{(p+2)^2}{4} , \frac{(p-2)^2}{4} \middle| -2 \leq p \leq 2 \right\}} 
    = \left\{ \begin{array}{ll}
               \dfrac{(p-2)^2}{4} \quad&\text{for } -2 \leq p \leq 0 \\
               \dfrac{(p+2)^2}{4} \quad&\text{for } 0 \leq p \leq 2 .
              \end{array} \right.
\end{equation*}
So in conclusion, by the expression above combined with the two expressions in \eqref{p1:qb:gafp1} and \eqref{p1:qb:gafp2}, I know that $g(p)$ is defined for all $p \in \mathbb{R}$, so the Legendre transformation of $f(x)$ is equal to $g(p)$ for all $p$, and hence is
\begin{equation}
 f^\ast(p) = g(p)
           = \left\{ \begin{array}{ll}
                      \dfrac{(p-2)^2}{4} - 1 \quad&\text{for } p \leq 0 \\
                      \dfrac{(p+2)^2}{4} - 1 \quad&\text{for } p \geq 0 .
                     \end{array} \right.
 \label{p1:q2:legendretransf}
\end{equation}
I have plotted this function on figure \vref{fig:p1:grafafgp}, where it is easily seen that it is a convex function, as a Legendre transformation should be according to Theorem 3.17. 



\vspace{5cm}
\begin{figure}[htb]
 \centering
  %\begin{center}
  \psset{xunit=10mm,
         yunit=3mm}
  \begin{pspicture}(-5,0)(5,13) %\psgrid
   %Koordinatsystem:
   \psline[arrows=->](-5,1)(5,1)      \uput[-90](5,1){$p$}
   \psline[arrows=->](0,0.8)(0,12.25)   %\uput[180](0,4){$y$}
   %Kurver:
   \pscurve[linewidth=1.5pt,linecolor=Periwinkle]{c-c}(-5,12.25)(-4.75,11.390625)(-4.5,10.5625)(-4.25,9.765625)(-4,9)(-3.75,8.265625)
   (-3.5,7.5625)(-3.25,6.890625)(-3,6.25)(-2.75,5.640625)(-2.5,5.0625)(-2.25,4.515625)(-2,4)(-1.75,3.515625)(-1.5,3.0625)(-1.25,2.640625)
   (-1,2.25)(-0.75,1.890625)(-0.5,1.5625)(-0.25,1.265625)(0,1)
   \pscurve[linewidth=1.5pt,linecolor=Periwinkle]{c-c}(0,1)(0.25,1.265625)(0.5,1.5625)(0.75,1.890625)(1,2.25)(1.25,2.640625)(1.5,3.0625)
   (1.75,3.515625)(2,4)(2.25,4.515625)(2.5,5.0625)(2.75,5.640625)(3,6.25)(3.25,6.890625)(3.5,7.5625)(3.75,8.265625)(4,9)(4.25,9.765625)
   (4.5,10.5625)(4.75,11.390625)(5,12.25)
   %Labels:
   \uput[0](1.5,7){{\color{Periwinkle}$f^\ast(p)$}}
   \end{pspicture}
  %\end{center}
 \caption{Plot of the Legendre tranformation $f^\ast$ of $f$, defined in \eqref{p1:q2:legendretransf}.}
 \label{fig:p1:grafafgp}
\end{figure}









\clearpage
\setcounter{subsection}{2}
\subsection*{Problem 2}
\ramme{ {\bfseries\sffamily Exercise 2.12 in the notes} \\
        In this exercise we study a 1-dimensional particle of mass $m>0$ moving in a harmonic oscillator with potential function 
        $V : \mathbb{R} \rightarrow \mathbb{R}$ given by $V(q) = \frac{1}{2} k q^2$, where $k>0$ is the spring constant. Thus the Lagrangian 
        function for this system is
        \begin{equation}
         L(q,v) = \frac{1}{2} m v^2 - \frac{1}{2} k q^2 .
         \label{p2:lagrangian}
        \end{equation}\vspace{-0.5cm} }

\subsubsection*{Question a}
\ramme{ Determine all solutions $\gamma(t)$ to the equation of motion satisfying $\gamma(0)=0$. }
To find the solutions to the equation of motion, I first have to \emph{find} the equation of motion. This is done by calculating the Euler-Lagrange equation, given by Theorem 2.10 as
\begin{equation*}
 0 = \dd{}{t} \left( \pd{L}{v} \big( \gamma(t),\dot\gamma(t) \big) \right) - \pd{L}{q} \big( \gamma(t),\dot\gamma(t) \big) .
\end{equation*}
So by inserting my expression of the Lagrangian from equation \eqref{p2:lagrangian}, I get that
\begin{equation*}
 0 = \dd{}{t} \big( m \dot\gamma(t) \big) + k \gamma(t)
   = m \ddot\gamma(t) + k \gamma(t) ,
\end{equation*}
and hence my final equation of motion (which with the following rewriting of course only makes sence since I know that $m>0$) is 
\begin{equation}
 \ddot\gamma(t) = - \frac{k}{m} \gamma(t) .
 \label{p2:qa:equationofmotion}
\end{equation}
This is a second order ordinary differential equation, for which I find the solution by looking at the roots of the charachteristic polynomium, given by
\begin{equation*}
 r^2 + \frac{k}{m} = 0 .
\end{equation*}
It has the two complex roots $r_1 = i \sqrt{k/m}$ and $r_2 = -i \sqrt{k/m}$, so according to Theorem 10.5.14 in \citetalias{kalkulus}, \citet{kalkulus}, the general solution of the differential equation is
\begin{equation*}
 \gamma(t) = A \sin{\sqrt{\frac{k}{m}} t} + B \cos{\sqrt{\frac{k}{m}} t} , \qquad A,B \in \mathbb{R} ,
\end{equation*}


Since I had to find solutions where $\gamma(0) = 0$, I must have that $B=0$ for the condition to hold for the solutions. So all the solutions to the equation of motion in \eqref{p2:qa:equationofmotion} with the given initial condition are simply
\begin{equation}
 \gamma(t) = A \sin{\sqrt{\frac{k}{m}} t} , \qquad A \in \mathbb{R} .
 \label{p2:qa:motion}
\end{equation}



\subsubsection*{Question b}
\ramme{ Show that all these solutions satisfy $\gamma(\pi \sqrt{m/k}) = 0$. }
I see that inserting $t = \pi \sqrt{m/k}$ into the motion in \eqref{p2:qa:motion} makes the argument of the sine $\pi$, so the motion becomes $0$ for all $A \in \mathbb{R}$:
\begin{equation*}
 \gamma(\pi \sqrt{m/k}) = A \sin{\left( \sqrt{\frac{k}{m}} \pi \sqrt{\frac{m}{k}} \right)} 
                        = A \sin{\pi} 
                        = 0 ,
\end{equation*}
just as expected.


\subsubsection*{Question c}
\ramme{ Conclude that the equation of motion with the boundary values $\gamma(0) = 0$ and $\gamma(\pi \sqrt{m/k}) = 0$ has infinitely 
        many solutions. Prove that all these solutions satisfy that the action $\S^L(\gamma) = 0$. }
Since the motion in \eqref{p2:qa:motion} is a solution to the equation of motion in \eqref{p2:qa:equationofmotion} with the boundary conditions $\gamma(0) = 0$ and $\gamma(\pi \sqrt{m/k}) = 0$ for all $A \in \mathbb{R}$ there must be infinitely many solutions -- simply because I can choose infinitely many different values of $A$. 

To find the action $\S^L(\gamma)$ I simply use Definition 2.16 that defines the action as the integral in equation (2.11). Into this I insert the Lagrangian from \eqref{p2:lagrangian}, my motion in \eqref{p2:qa:motion} and the first time-derivative of the motion,
\begin{equation*}
 \dot\gamma(t) = A \sqrt{\frac{k}{m}} \cos{\sqrt{\frac{k}{m}} t} ,
\end{equation*}
so that I have the expression
\begin{align*}
 \S^L(\gamma) &= \int_0^{\pi\sqrt{\frac{m}{k}}} \frac{1}{2} m A^2 \frac{k}{m} \cos^2{\sqrt{\frac{k}{m}} t} 
                                                - \frac{1}{2} k A^2 \sin^2{\sqrt{\frac{k}{m}} t} \,\di t \\
              &= \frac{1}{2} k A^2 \int_0^{\pi\sqrt{\frac{m}{k}}} \cos^2{\sqrt{\frac{k}{m}} t}  \,\di t 
                 - \frac{1}{2} k A^2 \int_0^{\pi\sqrt{\frac{m}{k}}} \sin^2{\sqrt{\frac{k}{m}} t} \,\di t .
%\end{align*}
\intertext{I can solve these two integrals by using the substitution $u = \sqrt{k/m} t$, where I get that $\di t = \sqrt{m/k} \,\di u$ while the limits becomes 0 and $\pi$, so}
%\begin{align*}
 \S^L(\gamma) &= \frac{1}{2} k A^2 \sqrt{\frac{m}{k}} \int_0^{\pi} \cos^2{u}  \,\di u 
                 - \frac{1}{2} k A^2 \sqrt{\frac{m}{k}} \int_0^{\pi} \sin^2{u} \,\di u  \\
              &= \frac{1}{2} A^2 \sqrt{mk} \left( \int_0^{\pi} \cos^2{u}  \,\di u - \int_0^{\pi} \sin^2{u} \,\di u \right)  \\
              &= \frac{1}{2} A^2 \sqrt{mk} \left( \frac{\pi}{2} - \frac{\pi}{2} \right)  
               = 0 ,
\end{align*}
independently of the value of $A$, just as expected. 



\clearpage
\subsubsection*{Question d}
\ramme{ Conclude that the equation of motion with the boundary values $\gamma(0) = 0$ and $\gamma(\pi \sqrt{m/k}) = x$ has no solution 
        for all $x \in \mathbb{R} \setminus \{ 0 \}$. }
In question a I found that a solution to the equation of motion had to be of the form in \eqref{p2:qa:motion}, $\gamma(t) = A \sin{\sqrt{k/m} t}$ where $A \in \mathbb{R}$, if it should satisfy the single initial condition $\gamma(0) = 0$. 

But if I set $t = \pi \sqrt{m/k}$, I know from the properties of the sinus function that $\gamma(t) = 0$, by the same calculation as I did in question b. Hence I know that
\begin{equation*}
 \gamma(\pi \sqrt{m/k}) \neq x ,
\end{equation*}
for all $x \in \mathbb{R} \setminus \{ 0 \}$, so the equation of motion cannot have a solution for these boundary conditions. 



\subsubsection*{Question e}
\ramme{ Show that for all $T>0$ and $T \notin \big\{ n \pi \sqrt{m/k} | n \in \mathbb{N} \big\}$ the equation of motion with boundary 
        values $\gamma(0) = 0$ and $\gamma(T) = 0$ has exactly one solution and that this solution also satisfies $\S^L(\gamma) = 0$. }
First I note that \emph{if} $T$ was in the set $\big\{ n \pi \sqrt{m/k} | n \in \mathbb{N} \big\}$, then it has already been shown in question c that $\gamma(T)=0$ (there I actually only argumented for the case where $n=1$, but the argument is trivial to extend to larger $n$, simply by noting that $\sin{n\pi} = 0$ for all $n \in \mathbb{N}$), but that gave rise to infinitely many solutions, which is \emph{not} what I want. 

I already know that the motion $\gamma(t) = A \sin{\sqrt{k/m} t}$ in \eqref{p2:qa:motion} solves the equation of motion with the initial condition $\gamma(0) = 0$, so to make sure that the motion also comply with the condition that $\gamma(T) = x$, I see that the constant $A \in \mathbb{R}$ must be found from
\begin{equation*}
 \gamma(T) = A \sin{\sqrt{\frac{k}{m}} T} = 0 ,  \qquad\text{so}\qquad   A = 0 ,
\end{equation*}
when $T \neq 0$ and $T \notin \big\{ n \pi \sqrt{m/k} | n \in \mathbb{N} \big\}$ -- otherwise the sine could become zero, and then $A$ could again be any number in $\mathbb{R}$. So there is only one solution to the equation of motion with the given boundary values, namely
\begin{equation*}
 \gamma(t) = 0 .
\end{equation*}

It is here easy to calculate the action. I simply do as in question c, but here both my motion and it's first time-derivative equals zero, and then I have that
\begin{equation*}
 \S^L(\gamma) = \int_0^T \frac{1}{2} m \cdot 0 - \frac{1}{2} k \cdot 0 \,\di t = 0 .
\end{equation*}





\subsubsection*{Question f}
\ramme{ Prove that for all $T>0$ we can find a $C^1$ function $\gamma : [0,T] \rightarrow \mathbb{R}$ with $\gamma(0) = 0$ and 
        $\gamma(T) = 0$ such that the corresponding action $\S^L(\gamma) < 0$ if the spring constant $k>0$ is sufficiently large. }
If I have a motion $\gamma \in C^1_{0,0}([0,T],\mathbb{R})$ it exactly holds all the demands above. This function is continous differentiable, so $\dot\gamma$ is continous. Hence I can calculate the action $\S^L(\gamma)$ as I did it in question c and e, simply by inserting
\begin{align*}
 \S^L(\gamma) &= \int_0^T \frac{1}{2} m \dot\gamma(t)^2 - \frac{1}{2} k \gamma(t)^2 \,\di t  \\
              &= \frac{1}{2} m  \int_0^T \dot\gamma(t)^2 \,\di t - \frac{1}{2} k  \int_0^T \gamma(t)^2 \,\di t .
\end{align*}
Since I know that $m > 0$ and that $\dot\gamma$ is continous on the integration interval, the first part of the above is a real positive number, only dependent of the given $T$ and $m$, call it $C_1$. I also know that $\gamma$ itself is continous, so the integral on the right side above is also just a real positive number, only dependent of the given $T$, call it $C_2$. So I must have that
\begin{equation*}
 \S^L(\gamma) = C_1 - k C_2 ,
\end{equation*}
but then it is obvious that I, for a given $T$ and $m$, always can choose a $k$ sufficienctly large such that $\S^L(\gamma) < 0$, simply by noting that $k$ must satisfy $k > C_1/C_2$. 





\subsubsection*{Question g}
\ramme{ Show that for all $T>0$ and all $k>0$ we can find a $C^1$ function $\gamma : [0,T] \rightarrow \mathbb{R}$ with $\gamma(0) = 0$ and 
        $\gamma(T) = 0$ such that the corresponding action $\S^L(\gamma) > 0$. }
To do this, I use the background knowledge I have from the solutions of the equation of motion -- that the integrals of the action are easy to solve. I choose a motion 
\begin{equation*}
 \gamma(t) = \sin{\sqrt{\frac{k'}{m}} t} ,
\end{equation*}
which complies with $\gamma(0)=0$ and $\gamma(T)=0$, if $T = n \pi \sqrt{m/k'}$ for $n\in\mathbb{N}$. So $\gamma \in C^1_{0,0}([0,T],\mathbb{R})$ for such $T$. Note that $k'$ is \emph{not} the spring constant, it is simply a constant for this motion. 

If I use this motion to calculate my action (by noting that the first time-derivative is $\dot\gamma(t)=\sqrt{k'/m}\cos{\sqrt{k'/m}t}$), I get that
\begin{align*}
 \S^L(\gamma) 
     &= \int_0^{n \pi \sqrt{\frac{m}{k'}}} \frac{1}{2} m \frac{k'}{m} \cos^2{\sqrt{\frac{k'}{m}} t} - \frac{1}{2} k \sin^2{\sqrt{\frac{k'}{m}} t} \\
     &= \frac{1}{2} k' \int_0^{n \pi \sqrt{\frac{m}{k'}}} \cos^2{\sqrt{\frac{k'}{m}} t} \,\di t 
        - \frac{1}{2} k \int_0^{n \pi \sqrt{\frac{m}{k'}}} \sin^2{\sqrt{\frac{k'}{m}} t} \,\di t ,
\intertext{where I again can use the substitution I used in question c, such that $u = \sqrt{k'/m} t$, and the upper limit now becomes $n \pi$, so}
 \S^L(\gamma) 
     &= \frac{1}{2} k' \sqrt{\frac{m}{k'}} \int_0^{n \pi} \cos^2{u} \,\di u - \frac{1}{2} k \sqrt{\frac{m}{k'}} \int_0^{n \pi} \sin^2{u} \,\di u \\
     &= \frac{1}{2} k' \sqrt{\frac{m}{k'}} \frac{n\pi}{2} - \frac{1}{2} k \sqrt{\frac{m}{k'}} \frac{n\pi}{2} \\
     &= (k'-k) \sqrt{\frac{m}{k'}} \frac{n\pi}{4} .
\end{align*}
This expression can always be made positive if I choose $k'$ large enough, but it must be done such that $T = n \pi \sqrt{m/k'}$ where $n$ is found such that $T > n \pi \sqrt{m/k}$. This can be done for all given $T>0$ and $k>0$, so it \emph{is} possible to find a motion $\gamma : [0,T] \rightarrow \mathbb{R}$ such that $\S^L(\gamma) > 0$. 






\subsubsection*{Question h}
\ramme{ Conclude that there are values of $T>0$ and $k>0$ such that the solutions to the equation of motion with boundary values 
        $\gamma(0) = 0$ and $\gamma(T) = 0$ is neither a minimizer nor a maximizer for the action $\S^L$ on the set $C_{0,0}^1([0,T],\mathbb{R})$. }
First I note that the motions I used in question f and g both were within the set $C^1_{0,0}([0,T],\mathbb{R})$, and according to the calculation in question b (where $T = \pi \sqrt{m/k}$), also my general solution in \eqref{p2:qa:motion} to the equation of motion is within this set. 

But since the motion in \eqref{p2:qa:motion}, the solution to the equation of motion, resulted in an action $\S^L(\gamma) = 0$, and it was both possible to find motions in $C^1_{0,0}([0,T],\mathbb{R})$ such that $\S^L(\gamma) < 0$ (question f) and such that $\S^L(\gamma) > 0$ (question g), it cannot be neither a minimizer nor a maximizer for the action on this set. 




\vspace{0.5cm}
\bibliography{../bibliography}

\label{lastpage}
\end{document}