%------------------------------------------------------------------------------------------------------------------------------------%
\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}{1}                %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{ {\bfseries\sffamily Exercise 1.23 in the notes} \\
        Consider a particle in one dimension with potential energy $U(x) = -x^4$, i.e. its equation of motion is 
        \begin{equation}
         m \ddot x = - U'(x) = 4 x^3 .
         \label{eq:p1qa:newton}
        \end{equation}\vspace{-0.5cm}}

\subsubsection*{Question a}
\ramme{ Show that the energy 
        \begin{equation}
         E = \frac{1}{2} m \dot x^2 - x^4
         \label{eq:p1qa:energy}
        \end{equation}
        is conserved. }
Since there exists a potential energy function $U(x)$, such that $F(x) = - \nabla U(x)$ (where $F(x)$ is on the right-hand side of Newtons equation of motion in \eqref{eq:p1qa:newton}), I know from Theorem 1.10 that the force $F(x)$ on the particle in the motion is conservative. Then I know from the conservation of energy in Theorem 1.11 that the energy in equation \eqref{eq:p1qa:energy} is conserved. 


\subsubsection*{Question b}
\ramme{ Use question a to show that for a solution $x(t)$, $t \in [t_1, t_2]$, the time $t_2 - t_1$ it takes to move from a point $x_1$ to a point 
        $x_2$ is given by
        \begin{equation*}
         t_2 - t_1 = \int_{x_1}^{x_2} \frac{\di x}{\sqrt{\frac{2}{m} \big( E + x^4 \big)}} ,
        \end{equation*}
        assuming that $x_1 < x_2$ and that $\dot x \neq 0$ on $[t_1, t_2]$. }
From the expression of the energy in \eqref{eq:p1qa:energy}, I get that
\begin{equation*}
 \dot x^2 = \frac{2}{m} \big( E + x^4 \big)   \qquad\Rightarrow\qquad   \dot x = \pm \sqrt{\frac{2}{m} \big( E + x^4 \big)} ,
\end{equation*}
and since I know that $\dot x \neq 0$ and $x_1 < x_2$, $x$ must be monotonely increasing on the interval $[t_1,t_2]$. Hence $\dot x > 0$ for all $t \in [t_1,t_2]$, so I have to choose the positive root from the equation above, which means that
\begin{equation*}
 \dot x = \sqrt{\frac{2}{m} \big( E + x^4 \big)} .
\end{equation*}
I can solve this first-order ordinary differential equation by using separation of the variables. First, if $x(t)$ is a solution to the equation, it must be true that
\begin{equation*}
 \dot x(t) = \sqrt{\frac{2}{m} \big( E + x(t)^4 \big)} ,
\end{equation*}
so, when the square root is not equal to zero (it will never be zero, because it equals the time-derivative $\dot x(t)$, which has been noted never to equal zero), I have that
\begin{equation*}
 1 = \frac{\dot x(t)}{\sqrt{\frac{2}{m} \big( E + x(t)^4 \big)}} ,
\end{equation*}
which I integrate wrt. the time $t$ on both sides, so
\begin{equation*}
 \int_{t_1}^{t_2} 1 \,\di t = \int_{t_1}^{t_2} \frac{\dot x(t)}{\sqrt{\frac{2}{m} \big( E + x(t)^4 \big)}} \,\di t  . %\qquad\Rightarrow\qquad
 %t_2 - t_1 = \int_{t_1}^{t_2} \frac{\dot x(t)}{\sqrt{\frac{2}{m} \big( E + x(t)^4 \big)}} \,\di t .
\end{equation*}
Now, I change the variable to $x=x(t)$ on the right-hand-side integral, so I can write $\di t = \dot x(t) \di x$, and the limits of the integral becomes $x(t_1)=x_1$ and $x(t_2)=x_2$. Then the equation above simplifies to
\begin{equation}
 t_2 - t_1 = \int_{x_1}^{x_2} \frac{\di x}{\sqrt{\frac{2}{m} \big( E + x^4 \big)}} ,
 \label{eq:p1qb:integral}
\end{equation}
which was exactly the expression I had to show. 


%simply by writing\fixme{Argumentér for separation?}
%\begin{equation*}
% \frac{\di x}{\sqrt{\frac{2}{m} \big( E + x^4 \big)}} = \di t  ,
%\end{equation*}
%and integrating on both sides,
%\begin{equation*}
% \int_{x_1}^{x_2} \frac{\di x}{\sqrt{\frac{2}{m} \big( E + x^4 \big)}} = \int_{t_1}^{t_2} \di t   \qquad\Rightarrow\qquad
% t_2 - t_1 = \int_{x_1}^{x_2} \frac{\di x}{\sqrt{\frac{2}{m} \big( E + x^4 \big)}} ,
%\end{equation*}
%which was exactly the expression I had to show. 



\subsubsection*{Question c}
\ramme{ Use question b to show that, for $E > 0$, the particle escapes to infinity in finite time, i.e. the solution is not globally defined. }
I'll start by looking at the denominator of the integrand in equation \eqref{eq:p1qb:integral}, where I see that
\begin{equation*}
 \sqrt{\frac{2}{m} \big( E + x^4 \big)} = \sqrt{\frac{2}{m}} \sqrt{ E + x^4 }
                                     \geq \sqrt{\frac{2}{m}} \sqrt{ x^4 }
                                        = \sqrt{\frac{2}{m}} x^2 ,
\end{equation*}
for $E>0$. So for all $x \neq 0$ (and for $\sqrt{2(E+x^4)/m} \neq 0$, which is always true from the same argument as in question a) I have that
\begin{equation}
 \frac{1}{\sqrt{\frac{2}{m} \big( E + x^4 \big)}} \leq \frac{1}{\sqrt{\frac{2}{m}} x^2} .
 \label{eq:p1qc:relation}
\end{equation}
By letting $x_2 \rightarrow \infty$ in the integral in \eqref{eq:p1qb:integral}, I see what happens to the time difference while the particle in the system goes from $x_1$ towards infinity. I can compare this integral to an integral I know, by ``Sammenligningskriteriet'' in Theorem 9.5.11 in \citetalias{kalkulus} (\cite{kalkulus}). Since I have already shown the relation in \eqref{eq:p1qc:relation}, and I know from Setning 9.5.4 in \citetalias{kalkulus} that
\begin{equation*}
 \sqrt{\frac{m}{2}} \int_{x_1}^{x_2} \frac{\di x}{x^2} < \infty   \qquad\text{for}\qquad  x_2\rightarrow\infty  ,
\end{equation*}
I can conclude that
\begin{equation*}
 \int_{x_1}^{x_2} \frac{\di x}{\sqrt{\frac{2}{m} \big( E + x^4 \big)}} < \infty  \qquad\text{for}\qquad  x_2\rightarrow\infty  .
\end{equation*}
This means that the time it takes (according to equation \eqref{eq:p1qb:integral}) for a particle in this system to travel all the way to infinity, is less than infinity. This was exactly what I was supposed to show. 

%Above, I used that $x \neq 0$ to get the inequality. This makes sence since $x$ only equals zero... 

%But, for the record, I just want to show that my calculation above is also true when $x=0$. Then I have the special case that the denominator of the integrand in equation \eqref{eq:p1qb:integral} is equal to 
%\begin{equation*}
% \sqrt{\frac{2}{m} E}
%\end{equation*}





%lad være med at løse integralet, du skal bare se hvad der er mindre end den. hvis x er stor nok så er sqrt(2/m(E+x^4) mindre end eller lig cx^2  hvis E mindre end x^2 )
%lad x_2 gå mod uendelig
% hvis integranten er mindre end noget er integralet det også
%bemærk at det skal ske altid!




\clearpage
\setcounter{equation}{0}
\setcounter{subsection}{2}
\subsection*{Problem 2}
\ramme{ {\bfseries\sffamily Exercise 2.19 in the notes} }

\subsubsection*{Question a}
\ramme{ Consider the force field $F:\mathbb{R}^2 \rightarrow \mathbb{R}^2$ given by
        \begin{equation*}
         F(x,y) = (2x+y,x+2y) .
        \end{equation*}
        Show that $F$ is a conservative force field. } 
The function $V:\mathbb{R}^2 \rightarrow \mathbb{R}$ defined by $V(x,y) = - x^2 - y^2 - xy$ has the gradient
\begin{equation*}
 \nabla V (x,y) = \left( \pd{V}{x}(x,y) , \pd{V}{y}(x,y) \right) 
                = (-2x-y , -2y-x) .
\end{equation*}
So $F(x,y) = - \nabla V (x,y)$, and hence $F$ is conservative according to Theorem 1.10. 

Note that I could have chosen the potential $V$ as above, but with some arbitrary constant $a\in\mathbb{R}$ added, simply because this potential too would have corresponded to the force $F(x,y)$. I simply choose to let the constant be equal to zero for simplicity. 


\subsubsection*{Question b}
\ramme{ Show that the motion $(x(t), y(t)) = (e^{\sqrt{3} t}, e^{\sqrt{3} t})$ solves Newton's equations of motion corresponding to a particle 
        of mass $m = 1$ moving in the above force field. }
To show this, I start by calculating the double time-derivative of the motion, which is simply found by calculating the time-derivatives of the two components of the motion, so
\begin{equation*}
 \big( \dot x(t), \dot y(t) \big) = \big( \sqrt{3} e^{\sqrt{3} t}, \sqrt{3} e^{\sqrt{3} t} \big) ,
\end{equation*}
and hence
\begin{equation*}
 \big( \ddot x(t), \ddot y(t) \big) = \big( 3 e^{\sqrt{3} t}, 3 e^{\sqrt{3} t} \big) .
\end{equation*}
From equation (1.18) in the notes I know Newton's second law to be $m \ddot x = F(x,t)$, so to show that the motion stated in this question actually solves Newton's equations of motion, I simply insert the force and the motion given above. I see that
\begin{equation*}
 m \big( 3 e^{\sqrt{3} t}, 3 e^{\sqrt{3} t} \big) = \big( 2 e^{\sqrt{3} t} + e^{\sqrt{3} t} , e^{\sqrt{3} t}+2 e^{\sqrt{3} t} \big)
                                                  = \big( 3 e^{\sqrt{3} t} , 3 e^{\sqrt{3} t} \big) ,
\end{equation*}
and since the mass was $m = 1$, the right and left side are equal, so the motion $\big( x(t), y(t) \big)$ really solves Newton's equations of motion for a particle in the stated force field.


\subsubsection*{Question c}
\ramme{ Write down the action corresponding to a 2-dimensional motion of a particle of mass $m = 1$ in the force field from question a starting at 
        time $t = 0$ and ending at time $t = 1$. Calculate the action for the motion in question b. }
For me to write down the action, I first need to find the Lagrangian of the system. This is found by Definition 2.16, from which I for a 2-dimensional motion $\gamma(t) = (x(t),y(t))$ of a single particle get that
\begin{align*}
 L(\gamma(t),\dot\gamma(t)) &= \frac{1}{2} m \dot\gamma(t)^2 - V \big( \gamma(t) \big)  \\
                            &= \frac{1}{2} m (\dot x(t)^2 + \dot y(t)^2) - V \big( x(t), y(t) \big)  \\
                            &= \frac{1}{2} (\dot x(t)^2 + \dot y(t)^2) + x(t)^2 + y(t)^2 + x(t)y(t) ,
\end{align*}
where I have inserted the potential I found in question a and the mass given by $m = 1$. The action is then the integral defined in Definition 2.16, given by
\begin{align}
 \mathcal{S}^L(\gamma) &= \int_{t_1}^{t_2} L(\gamma(t),\dot\gamma(t)) \,\di t  \nn\\
                       &= \int_0^1 \frac{1}{2} (\dot x(t)^2 + \dot y(t)^2) + x(t)^2 + y(t)^2 + x(t)y(t) \,\di t , \label{eq:actiondef}
\end{align}
where I substituted the beginning and ending times $t_1$ and $t_2$ by the given values. 

The action for the motion in question b is then simply calculated by plugging the expressions given for $x(t)$ and $y(t)$ into equation \eqref{eq:actiondef}, by which I get that the action is
\begin{align*}
 \mathcal{S}^L(e^{\sqrt{3} t}, e^{\sqrt{3} t}) 
    &= \int_0^1 \frac{1}{2} ( 3 e^{2 \sqrt{3} t} + 3 e^{2 \sqrt{3} t}) + e^{2 \sqrt{3} t} + e^{2 \sqrt{3} t} + e^{\sqrt{3} t} e^{\sqrt{3} t}  \,\di t \\
    &= \int_0^1 3 e^{2 \sqrt{3} t} + 3 e^{2 \sqrt{3} t}  \,\di t 
     = \int_0^1 6 e^{2 \sqrt{3} t}  \,\di t 
     = \sqrt{3} \big( e^{2 \sqrt{3}} - 1 \big) .
\end{align*}

Here it should be noted that the action would have had a different value if I had not chosen the constant $a$ in question a to be zero. Then the action would simply be given by the value above, plus the constant $a$ times the difference of the integral limits, $t_2-t_2$. 





\clearpage
\setcounter{equation}{0}
\setcounter{subsection}{3}
\subsection*{Problem 3}
\ramme{ Consider the set 
        \begin{equation*}
         D = \mathbb{R}^2 \setminus \left\{ (x,y) | y = 0, x \leq 0 \right\}.
        \end{equation*}
        Let $\theta : D \rightarrow (-\pi, \pi)$ be the map defined such that 
        \begin{equation}
         \frac{x}{\sqrt{x^2 + y^2}} = \cos\theta(x,y)  \quad\text{and}\quad  \frac{y}{\sqrt{x^2 + y^2}} = \sin\theta(x,y) .
         \label{eq:p3:relations}
        \end{equation}
        In other words $\theta(x,y)$ is the angle (measured positively in the counter clockwise direction) between the $x$-axis and the
        line joining $(0,0)$ to $(x,y)$. You may assume without arguments that $\theta$ is $C^1$. }

\begin{figure}[htb]
 \centering
  %\begin{center}
  \psset{unit=4mm}
  \begin{pspicture}(0,0)(26,12) %\psgrid
   %Noder:
   \pnode(9.3,10.2){xy}  \uput[r](xy){$(x,y)$}
   \pnode(9.3,6){x}
   \pnode(6,10.2){y}
   %Cirkel:
   \psarc[arcsepB=2pt,linecolor=Periwinkle]{<->}(6,6){5.341348144}{-179.2}{180}
   %\pscircle[linecolor=Periwinkle,linewidth=2pt](6,6){5.341348144}
   %Linier:
   \psline[linewidth=0.5pt,linestyle=dashed,linecolor=Gray](xy)(x)  \uput{5pt}[-90]{0}(x){$\cos\theta$}  \psline[linewidth=0.5pt](x)(9.3,5.8)
   \psline[linewidth=0.5pt,linestyle=dashed,linecolor=Gray](xy)(y)  \uput{5pt}[180]{0}(y){$\sin\theta$}  \psline[linewidth=0.5pt](y)(5.8,10.2)
   \pcline{-*}(6,6)(xy) \Aput{$r$}
   %Koordinatsystem:
   \psline[arrows=->](6,0)(6,12)
   \psline[arrows=->](0,6)(12,6)
   %Theta-vinkel:
   \psarc[arcsepB=2pt]{->}(6,6){1.8}{0}{55}  \rput*(9.3,7.1){$\theta(x,y)$}
   %Tekst til højre:
   \rput[l](15,9){$r = \sqrt{x^2+y^2}$}
   \rput[l](15,6){$\cos\theta(x,y) = \dfrac{x}{r} = \dfrac{x}{\sqrt{x^2+y^2}}$}
   \rput[l](15,3){$\sin\theta(x,y) = \dfrac{y}{r} = \dfrac{y}{\sqrt{x^2+y^2}}$}
  \end{pspicture}
  %\end{center}
 \caption{Illustration to justify that the definition of $\theta(x,y)$ really is the angle between the $x$-axis and the line from origo to the 
          point $(x,y)$. Including the logical derivation of $\theta$ from trigonometric identities.}
 \label{fig:thetadef}
\end{figure}


\subsubsection*{Question a}
\ramme{ Argue that $\theta$ cannot be extended to a continuous function on $\mathbb{R}^2 \setminus \{(0, 0)\}$. }
Since I can assume that $\theta$ is $C^1$ on the domain $D$, I also know that it is continous on this domain. For $\theta$ to be continous on the whole domain $\mathbb{R}^2 \setminus \{(0, 0)\}$ I must then also have that it is continous on the set $\{ (x,y) | y = 0, x < 0 \}$, which is the line on the negative (non-zero) $x$-axis.

%To show that this is not true, I simply have to look at a single point on this line -- and show that $\theta$ is \emph{not} continous here. I choose the point $(-1,0)$, which is in the set $\{ (x,y) | y = 0, x < 0 \}$. 
On figure \ref{fig:thetadef} it is easy shown that $\theta(x,y)$, when $x<0$ and $y$ goes toward $0$, can approach two different values. Namely, if $y$ approaches $0$ from positive values, $\theta$ approaches the value $\pi$, while $\theta$ will go towards the value $-\pi$ if $y$ approaches $0$ from negative values. Written with less words, for all $x<0$,
\begin{equation}
 \lim_{y\rightarrow0^+} \theta(x,y) \rightarrow \pi  \qquad\text{and}\qquad
 \lim_{y\rightarrow0^-} \theta(x,y) \rightarrow -\pi .
 \label{eq:p3qa:limits}
\end{equation}
%This discontinouity can also be shown by looking at the two definitions in \eqref{eq:p3:relations}, by first noting that $\arcsin{(0)}=0$, $\arccos{(-1)}=\pi$ and $\arccos{(1)}=0$ and by noting that both $\arcsin$ and $\arccos$ are continous on the interval $[-1,1]$. So because
%\begin{equation*}
% \lim_{y\rightarrow0} \frac{y}{\sqrt{x^2+y^2}} \rightarrow 0 \quad\forall x\neq 0 \qquad\text{and}\qquad
% \lim_{y\rightarrow0} \frac{x}{\sqrt{x^2+y^2}} \rightarrow \frac{x}{|x|} \quad\forall x\neq 0 ,
%\end{equation*}
%I have that the two expressions for $\theta(x,y)$ in \eqref{eq:p3:relations} does not go towards the same value when $x<0$, where I have that
%\begin{equation*}
% \lim_{y\rightarrow0} \arcsin{\bigg( \frac{y}{\sqrt{x^2+y^2}} \bigg)} \rightarrow 0 \qquad\text{and}\qquad
% \lim_{y\rightarrow0} \arccos{\bigg( \frac{x}{\sqrt{x^2+y^2}} \bigg)} \rightarrow \pi 
%\end{equation*}
%from the above stated limits. 

%The statement in \eqref{eq:p3qa:limits} and the limits above both gives the same result; By the definition of continuity, $\theta(x,y)$ can not be continous on points $(x,0)$, where $x<0$, and hence it is not continous on the set $\mathbb{R}^2 \setminus \{(0, 0)\}$. 
%\vspace{2cm}

By looking at the expressions in \eqref{eq:p3:relations} and figure \vref{fig:thetadef}, I see that $\theta(x,y)$ can be written as the piecewise defined function
\begin{equation*}
 \theta(x,y) = \left\{ \begin{array}{cl}
                        \arccos{\bigg( \dfrac{x}{\sqrt{x^2+y^2}} \bigg)}&         \quad\text{for }y \geq 0 \\
                        \arccos{\bigg( \dfrac{-x}{\sqrt{x^2+y^2}} \bigg)} - \pi&  \quad\text{for }y \leq 0 .
                       \end{array}  \right.
\end{equation*}
I've plotted this function, to justify that this \emph{is} really a way to define $\theta$, in figure \ref{fig:thetaplot}. This definition was found via a little manipulation of the first of the identities in \eqref{eq:p3:relations}. Because of the ambiguity of the trigonometric functions $\cos$ and $\sin$, I could not just simply invert both of the indentities and get a meaningful result -- I've had to combine them to the expression above. Here it's trivial to see that the limits in \eqref{eq:p3qa:limits} are true. 

So, by the definition of continuity, $\theta(x,y)$ can not be continous on points $(x,0)$, where $x<0$, and hence it is not continous on the set $\mathbb{R}^2 \setminus \{(0, 0)\}$. 

\begin{figure}[bt]
 \centering
  \includegraphics[width=0.50\textwidth]{thetaplot.eps}
 \caption{Plot of the definition of $\theta(x,y)$. Here it is easy to see that the limits in \eqref{eq:p3qa:limits} are really true.}
 \label{fig:thetaplot}
\end{figure}


\clearpage
\subsubsection*{Question b}
\ramme{ Show (by differentiating the above relations) that
        \begin{equation*}
         \frac{-xy}{(x^2 + y^2)^{3/2}} = - \pd{\theta}{y}(x,y) \,\sin\theta(x,y)
        \end{equation*}
        and
        \begin{equation*}
         \frac{-xy}{(x^2 + y^2)^{3/2}} = \pd{\theta}{x}(x,y) \,\cos\theta(x,y) .
        \end{equation*}}
I differentiate the expression for $\cos\theta (x,y)$ in \eqref{eq:p3:relations} on both sides wrt. $y$, and get (by using the chain rule) that
\begin{equation}
 - \sin\theta(x,y) \pd{\theta}{y}(x,y) = - \frac{xy}{(x^2 + y^2)^{3/2}}
 \label{eq:p3qb:sin}
\end{equation} 
which was exactly the expression I was looking for. By differentiating the expression for $\sin\theta (x,y)$ in \eqref{eq:p3:relations} on both sides wrt. $x$, I get (again by using the chain rule) that
\begin{equation}
 \cos\theta(x,y) \pd{\theta}{x}(x,y) = - \frac{xy}{(x^2 + y^2)^{3/2}} ,
 \label{eq:p3qb:cos}
\end{equation} 
which, again, was the expression I was looking for. 



\subsubsection*{Question c}
\ramme{ Use the result from question b to show that the differential of $\theta$ is
        \begin{equation*}
         \di\theta = -\frac{y}{x^2 + y^2} \di x + \frac{x}{x^2 + y^2} \di y .
        \end{equation*}\vspace{-0.5cm}}
%husk du ikke må dividere med nul, så x må ikke være nul når du dividerer med den! men brug at den er C^1, så de partielt afledte er kontinuerte. man må gøre det alle de steder hvor x ikke er nul, og da den er kontinuert må man også de andre  steder... Det er den eneste mulighed! 
By inserting the relations from \eqref{eq:p3:relations} into the two equations in \eqref{eq:p3qb:sin} and \eqref{eq:p3qb:cos}, I get expressions for the two partial derivatives of $\theta$. First, to find the partial derivative wrt. $y$, I insert the expression of $\sin\theta(x,y)$ from \eqref{eq:p3:relations} into equation \eqref{eq:p3qb:sin}, where I get that
\begin{equation*}
 -\frac{xy}{(x^2 + y^2)^{3/2}} = - \pd{\theta}{y}(x,y) \frac{y}{\sqrt{x^2 + y^2}} ,
\end{equation*}
which, for $y \neq 0$, gives me that 
\begin{equation*}
 \pd{\theta}{y}(x,y) = \frac{x}{x^2 + y^2} .
\end{equation*}
If $y=0$ on the other hand, I divide be zero in trying to get to this result, so this instance I'll have to explore separately. The partial derivate wrt. $y$ taken in $y=0$ must be the limit of the expression above, when $y\rightarrow0$, since $\theta(x,y)$ is told to be $C^1$. So, since the fraction in the expression is continous for $y=0$, as long as $x\neq0$ (which will never happen on the domain $D$), this makes sense, and the limit is simply the expression above with $y=0$ inserted. Now I know that
\begin{equation*}
 \pd{\theta}{y}(x,y) = \frac{x}{x^2 + y^2} ,
\end{equation*}
for all $(x,y)\in D$. 

To find the partial derivative wrt. $x$, I insert the expression for $\cos\theta(x,y)$ from \eqref{eq:p3:relations} into equation \eqref{eq:p3qb:cos}, where I get that
\begin{equation*}
 -\frac{xy}{(x^2 + y^2)^{3/2}} = \pd{\theta}{x}(x,y) \frac{x}{\sqrt{x^2 + y^2}} ,
\end{equation*}
which, for $x\neq 0$, gives me that
\begin{equation*}
 \pd{\theta}{x}(x,y) = -\frac{y}{x^2 + y^2} .
\end{equation*}
But if $x = 0$, I again get to divide by zero if I try to get to the expression above, so I'll have to do a little explanation once more. The partial derivative wrt. $x$ taken in $x=0$ must be the limit of the expression above, when $x\rightarrow0$, because $\theta(x,y)$ is known to be $C^1$. And since the fraction above is continous for $x=0$ (again, as long as $y\neq 0$, which never happens because of the definition of the domain $D$), I simply get that this limit makes sense, and that it is the expression above with $x=0$ inserted. So
\begin{equation*}
 \pd{\theta}{x}(x,y) = - \frac{y}{x^2 + y^2} .
\end{equation*}
for all $(x,y)\in D$. 




%\vspace{2cm}
%Above I used that $y=0$ or $x=0$ depending on what partial differential I wanted to find, but I have to show what the differentials are when this is happening. When both $x$ and $y$ are zero, $\theta(x,y)$ is not defined, and hence the differential is not defined here. So I only have to look at the instances where $y=0$ or $x=0$. When $y=0$, the equation from above can only make sence if the limit 
%\begin{equation}
% \lim_{y\rightarrow 0} \frac{xy \sqrt{x^2 + y^2}}{(x^2 + y^2)^{3/2} y}
% \label{eq:p3qc:limity}
%\end{equation}
%exists. By using the rule of L'H$\hat{\text{o}}$pital, I differentiate wrt. $y$ in both numerator and denominator, where I get that
%\begin{equation*}
% \pd{}{y} \left( xy \sqrt{x^2 + y^2} \right) = x \frac{2y^2+x^2}{\sqrt{x^2+y^2}} \qquad\text{and}\qquad
% \pd{}{y} \left( (x^2 + y^2)^{3/2} y \right) = 4 \sqrt{x^2 + y^2} y^2 + \sqrt{x^2 + y^2} x^2 ,
%\end{equation*}
%and since the limit of the fraction of these to is
%\begin{equation*}
% \lim_{y\rightarrow 0} \frac{x \big( 2y^2+x^2 \big)}{\sqrt{x^2+y^2} \big( 4 \sqrt{x^2 + y^2} y^2 + \sqrt{x^2 + y^2} x^2 \big)} = \frac{1}{x} ,
%\end{equation*}
%the limit in \eqref{eq:p3qc:limity} is also this expression, and then I have that
%\begin{equation*}
% \pd{\theta}{y}(x,0) = \frac{1}{x} ,
%\end{equation*}
%which is exactly the same as I found before, just for the special instance where $y=0$. 
%When $x=0$, I find that the equation above only makes sence if the limit
%\begin{equation}
% \lim_{x\rightarrow 0} \frac{xy \sqrt{x^2 + y^2}}{(x^2 + y^2)^{3/2} x}
% \label{eq:p3qc:limitx}
%\end{equation}
%makes sence. Again I differentiate, this time wrt. $x$, in both numerator and denominator, where I find that
%\begin{equation*}
% \pd{}{x} \left( xy \sqrt{x^2 + y^2} \right) = \frac{x^2 y}{\sqrt{x^2+y^2}} + \sqrt{x^2+y^2} y \qquad\text{and}\qquad
% \pd{}{x} \left( (x^2 + y^2)^{3/2} x \right) = 3 \sqrt{x^2+y^2} x^2 
%\end{equation*}
%\fixme{!!!}
%\vspace{2cm}


These two expressions I've found are exactly the partial derivatives I need to make the differential of $\theta$, so from Definition 1.14 I simply have that
\begin{equation*}
 \di\theta = \pd{\theta}{x} (x,y) \di x + \pd{\theta}{y} (x,y) \di y
           = -\frac{y}{x^2 + y^2} \di x + \frac{x}{x^2 + y^2} \di y ,
\end{equation*}
just as expected.



\clearpage
\subsubsection*{Question d}
\ramme{ Explain why the result of question c is not in contradiction with the fact that
        \begin{equation*}
         -\frac{y}{x^2 + y^2} \di x + \frac{x}{x^2 + y^2} \di y .
        \end{equation*}
        is not an exact differential on $\mathbb{R}^2 \setminus \{ (0,0) \}$ (see Exercise 1.19). It is of no importance whether or not you have 
        done Exercise 1.19. }
According to Definition 1.15 of a general differential $\omega$, the definition of an exact differential is only for differentials of $C^1$-functions on open sets. But $\theta$ is \emph{not} $C^1$ on the whole set $\mathbb{R}^2 \setminus \{ (0,0) \}$, it is not even continous on this set -- only on the set $D$. 

So that the differential of $\theta(x,y)$ is not exact on the domain $\mathbb{R}^2 \setminus \{ (0,0) \}$, on which $\theta(x,y)$ is not continous, is no contradiction at all. 



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

\label{lastpage}
\end{document}