\documentclass[11pt]{article}


% commnet out the next two lines to see the default page geometry
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ... 
%\geometry{landscape}                % Activate for for rotated page \

%\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent

% load two different graphics packages:
\usepackage{graphicx,epsfig}

%% various math symbols
\usepackage{amssymb}
\usepackage{amsmath}

% google "xcolor" and goto wikibooks for the 64 standard colors
% provided by this package
\usepackage{xcolor}

%% Some user defined shortcuts to save typing
\newcommand{\ep}{\epsilon}
\newcommand{\beq}{\begin{equation}}
\newcommand{\eeq}{\end{equation}}

% use roman font in math mode for special objects, 
% such as differentials and number such as \sqrt{-1}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\ii}{\mathrm{i}}
\newcommand{\ee}{\mathrm{e}}

\newcommand{\la}{\langle}
\newcommand{\ra}{\rangle}
\newcommand{\defn}{\stackrel{\text{def}}{=}}



\title{SIO203C/MAE294C Assignment 37}
\author{\textcolor{red}{Rufus T. Firefly}}
\date{\today}      % Activate to display a given date or no date. 

%To use the current date, try \today
%\date{\today} 

\begin{document}
\maketitle


\subsubsection*{An oscillator problem}
Consider the nonlinearly damped oscillator
\begin{equation}
\ddot x + \beta \dot x^3 + x =0\, , \qquad x(0) =1\, , \qquad \dot x(0) =0 \, .
\label{cubedamp1}
\end{equation}
Assuming that  $\beta \ll 1$,  use the energy equation and the method of averaging to determine the slow
evolution of the amplitude $a$ in the approximate solution (8.24). Take $\beta =1$ and use \texttt{ode45} to compare a numerical solution with the method of averaging.

\subsubsection*{Answer}

The energy equation for the oscillator in \eqref{cubedamp1}  is
\beq
\frac{\dd E}{\dd t} = - \beta \dot x^4\, ,\qquad \text{with} \qquad E \defn\frac{1}{2} \left( \dot x^2 + x^2\right)\, .
\eeq
Using the approximate solution $x(t) \approx a \cos t$, with $a$ a function of the slow time $\beta t$, we have\beq
E \approx  \la \dot x^2 \ra\approx \la x^2\ra = \frac{1}{2} a^2\, ,
\eeq
and\footnote{You can look up this integral, or calculate it like this
$$
\la \sin^4 t\ra = \frac{1}{(2 \ii)^4}\Big\langle \ee^{4 \ii t} + 4 \ee^{2 \ii t} + 6 + 4 \ee^{-2 \ii t} + \ee^{-4 \ii t}\Big\rangle = \frac{3}{8}\, .
$$}
\beq
\la \dot x^4 \ra \approx a^4 \la \sin^4 t \ra = \frac{3}{8} a^4 = \frac{3}{2} E^2\, .
\eeq
Thus the averaged energy equation is 
\beq
\frac{\dd E }{\dd t} = -\frac{3 \beta }{2}  E^2 \, ,
\eeq
with solution
\beq
E = \frac{2 E_0}{2 + 3 \beta t E_0}\, .
\eeq
 Using the initial condition in \eqref{cubedamp1},  the initial energy is $E_0 = 1/2$ and the approximate solution is therefore 
\beq
x = \underbrace{ \sqrt{\frac{4}{4+3\beta t}}  }_{a(t) }\cos t \, . \label{approxSol}
\eeq
 Notice that   $ a \sim t^{-1/2}$ as $t \to \infty$. This algebraic  decay is much slower than exponential decay characteristic of linear damping.  The frictional force  varies with the cube of the amplitude and thus  as the oscillations get smaller the damping becomes increasingly weak.

\vskip 0.2truein 

\noindent
Note the use of roman d for differentials $\dd E/\dd t$ etc. Common mathematical functions should be typeset with in roman using special latex definitions such as \begin{verbatim} 
              \cos           \tan        \ln         \log\end{verbatim} This is how it should look
\beq
\cos \theta\, ,  \qquad  \tan \phi\, , \qquad \ln x \, , \qquad \log (2 \pi r)\, , \qquad \text{etc.} 
\eeq
Not like this ugly mess
\beq
cos \theta\, ,  \qquad tan \phi\, , \qquad ln x \, , \qquad log (2 \pi r)\, , \qquad \text{etc.} 
\eeq
Text, such as etc. above, can be put into equations with the``text"  command. All equations should be punctuated with commas, periods  and so on. Use ``quads'' and ``qquads'' to put spaces between different mathematical expressions on the same line, as above. Without the qquad's it's a real mess:
\beq
cos \theta\, ,  tan \phi\, ,  ln x \, ,  log (2 \pi r)\, ,  \text{etc.} 
\eeq


\subsubsection*{Acknowledgments} 

I collaborated with Gloria Teasdale and Harpo `Pinky' Marx on this homework. 



%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%  FIGURE %%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}
\epsfig{file=averagingComparison,width=0.9\textwidth}
\caption{Comparison of the numerical solution of \eqref{cubedamp1} with the approximate solution in \eqref{approxSol}. Even though $\beta =1$ there is good agreement between the approximate solution \eqref{approxSol} and the \texttt{matlab} numerical solution.  }
\label{Fig1}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%  FIGURE %%%%%%

% start a new page:
\clearpage

% This is the verbatim environment for listing computer code etc
\begin{verbatim}
function nonLinDamp
%oscillator with cubic damping and the method of averaging
tspan = [0  40*pi];    t = linspace(0,max(tspan),600);
beta = 1;
options = odeset('AbsTol',1e-7, 'RelTol',1e-4);
aZero = [ 1 0 ]; 
sola = ode45(@ndamp,tspan,aZero,options);
xa = deval(sola,t);
subplot(2,1,1)
% The method of averaging approxiamtion:
a = sqrt(4./(4+3*beta*t)); xApprox = a.*cos(t); 
plot(t,xa(1,:),'b-',t,xApprox,'g--')
xlabel('$t$','interpreter','latex','fontsize',20)
ylabel('$x(t)$','interpreter','latex','fontsize',20)
legend('ode45','averaging')
text(10,0.8,'$\beta=1$','interpreter','latex','fontsize',20)
axis tight

%------- nested function --------%
    function dxdt = ndamp(t,x)
    dxdt = [ x(2); - beta*x(2).^3 - x(1)];
    end

end

\end{verbatim}





\end{document}   
