\documentclass{article} \usepackage{amsmath,graphicx} \usepackage[usenames,dvipsnames,svgnames]{xcolor} \usepackage{enumerate} % uncomment to suppress solutions %\usepackage[pdftex,nosolutions,pointsonleft]{eqexam} % Uncomment to see solutions \usepackage[pdftex,answerkey,pointsonleft]{eqexam} \title{Quiz \#4} \author{David Arnold} \subject{Math 55 --- Differential Equations} \university{College of the Redwoods} \begin{document} \maketitle \begin{exam}{Quiz3} \begin{instructions} This quiz is open notes, open book. This includes any supplementary texts or online documents. You are not allowed to work in groups or pairs on the quiz. You are not allowed to enlist the aid of a tutor or friend to help with the quiz. You are not allowed to share your work with your fellow students. You must answer all of the exercises on your own. \end{instructions} \begin{problem*}[10ea] Consider the following initial value problem. \begin{equation*} xy'-2y=x^3\cos x,\quad y(1)=0 \end{equation*} Perform each of the following tasks. \begin{parts} \item Solve the initial value problem by hand, without the use of software of any kind. \begin{solution} Take the equation \begin{equation*} xy'-2y=x^3\cos x \end{equation*} and divide both sides by $x$. \begin{equation}\label{eq:one} y'-\frac2x y=x^2\cos x \end{equation} The result is a linear first order ordinary differential equation. The first step is to find an integrating factor. \begin{align*} u&=e^{\int (-2/x)\, dx}\\ &=e^{-2\ln x}\\ &=e^{\ln x^{-2}}\\ &=x^{-2}\\ &=\frac{1}{x^2} \end{align*} Next, multiply both sides of equation~\eqref{eq:one} by the integrating factor. \begin{equation*} \frac{1}{x^2}y'-\frac{2}{x^3}y=\cos x \end{equation*} Check that the left-hand side is the derivative of the product of the integrating factor and $y$. \begin{equation*} \left(\frac1{x^2}y\right)'=\cos x \end{equation*} Integrate both sides. \begin{equation}\label{eq:two} \frac{1}{x^2}y=\sin x+K \end{equation} Use the initial condition $y(1)=0$ to determine the integration constant $K$. \begin{align*} y(1)&=0\\ (1)^2\sin 1+L(1)^2&=0\\ \sin 1+K&=0\\ K&=-\sin 1 \end{align*} Substitute $K=-\sin 1$ in equation~\eqref{eq:two}. \begin{equation} \frac{1}{x^2}y=\sin x-\sin 1 \end{equation} Multiply both sides by $x^2$. \begin{equation*} y=x^2\sin x-(\sin 1)x^2, \end{equation*} or equivalently, \begin{equation}\label{eq:three} y=x^2(\sin x-\sin 1). \end{equation} \end{solution} \item Use MATLAB to sketch the solution on the interval $[-2\pi,2\pi]$. Submit a printout of the resulting graph as well as a printout of your code with your quiz. \begin{solution} First, produce a set of $x$-values between $-2\pi$ and $2\pi$, then use the solution $y=x^2(\sin x-\sin 1)$ to compute the $y$-values. Plot the result. \begin{verbatim} x=linspace(-2*pi,2*pi,1000); y=x.^2.*(sin(x)-sin(1)); plot(x,y) \end{verbatim} Next, tighten the plot, add a grid and annotations. \begin{verbatim} axis tight grid on title('Solution of $xy'' - 2y = x^2 cos(x), y(1)=0') xlabel('x-axis') ylabel('y-axis') \end{verbatim} Plot the initial condition and format it nicely. \begin{verbatim} hl=line(1,0,'Marker','o'); set(hl,... 'MarkerEdgeColor','black',... 'MarkerFaceColor',[255,204,153]/255) ht=text(1,-5,'(-1,0)'); set(ht,... 'HorizontalAlignment','center',... 'Margin',4,... 'BackgroundColor',[255,204,153]/255,... 'EdgeColor','black') \end{verbatim} Finally, save the image for use in your \LaTeX\ file. \begin{verbatim} set(gcf,'PaperSize',[4,3]) set(gcf,'PaperPosition',[0,0,4,3]) saveas(gcf,'quiz4','pdf') \end{verbatim} The result is shown in Figure~\ref{fig:one}. \begin{figure} \centering \includegraphics{quiz4plot} \caption{Plotting $y=x^2(\sin x-\sin 1)$ on $[-2\pi,2\pi]$.\label{fig:one}} \end{figure} \end{solution} \end{parts} \end{problem*} \end{exam} \end{document}