4.3 HW3

  4.3.1 Section 2.4 problem 8 (page 122)
  4.3.2 Section 2.4 problem 13 (page 122)
  4.3.3 Section 2.4 problem 25
  4.3.4 Section 2.4 problem 30
  4.3.5 Section 2.5 problem 8
  4.3.6 Section 2.5 problem 13
  4.3.7 Section 2.5 problem 25
  4.3.8 Section 2.5 problem 26
PDF (letter size)
PDF (legal size)

4.3.1 Section 2.4 problem 8 (page 122)

Problem Apply Euler method twice to approximate solution on interval \(\left [ 0,\frac{1}{2}\right ] \) first with step size \(h=0.25\) then with step size \(h=0.1\). Compare to three decimal places values of the two approximation at \(x=\frac{1}{2}\) with the value \(y\left ( \frac{1}{2}\right ) \) of the exact solution. \(y^{\prime }=e^{-y};y\left ( 0\right ) =0\,.\) Exact solution is \(y\left ( x\right ) =\ln \left ( x+1\right ) \)

Solution

Using forward Euler method, we write\[ y_{n+1}=y_{n}+hf\left ( x_{n},y_{n}\right ) \] Here \(f\left ( x,y\right ) =e^{-y}\).

\(h=0.25\)\begin{align*} y\left ( 0\right ) & =0\\ y\left ( h\right ) & =y\left ( 0.25\right ) =y\left ( 0\right ) +he^{-y\left ( 0\right ) }=0+0.25e^{0}=0.25\\ y\left ( 2h\right ) & =y\left ( 0.5\right ) =y\left ( 0.25\right ) +he^{-y\left ( 0.25\right ) }=0.25+0.25e^{-0.25}=0.445 \end{align*}

\(h=0.1\)\begin{align*} y\left ( 0\right ) & =0\\ y\left ( h\right ) & =y\left ( 0.1\right ) =y\left ( 0\right ) +he^{-y\left ( 0\right ) }=0+0.1e^{-0}=0.1\\ y\left ( 2h\right ) & =y\left ( 0.2\right ) =y\left ( 0.1\right ) +he^{-y\left ( 0.1\right ) }=0.1+0.1e^{-0.1}=0.190\\ y\left ( 3h\right ) & =y\left ( 0.3\right ) =y\left ( 0.2\right ) +he^{-y\left ( 0.2\right ) }=0.190+0.1e^{-0.190}=0.273\\ y\left ( 4h\right ) & =y\left ( 0.4\right ) =y\left ( 0.3\right ) +he^{-y\left ( 0.3\right ) }=0.273+0.1e^{-0.273}=0.349\,\\ y\left ( 5h\right ) & =y\left ( 0.5\right ) =y\left ( 0.4\right ) +he^{-y\left ( 0.4\right ) }=0.349+0.1e^{-0.349}=0.420 \end{align*}

Exact solution is \(y\left ( 0.5\right ) =\ln \left ( 0.5+1\right ) =0.405\)



h size \(y\left ( \frac{1}{2}\right ) \)


\(0.25\) \(0.445\)


\(0.1\) \(0.420\)


exact \(0.405\)


4.3.2 Section 2.4 problem 13 (page 122)

Problem Find the exact solution, then apply Euler method twice to approximate to 4 decimal places values the solution on the given interval. First with step \(h=0.01\) then with step \(h=0.005\). Make table showing the approximate values and the actual values, together with percentage error in the more accurate approximation for \(x\) an integral multiple of \(0.2.\) \(yy^{\prime }=2x^{3};y\left ( 1\right ) =3;1\leq x\leq 2\,.\)

Solution

\[ y^{\prime }=\frac{2x^{3}}{y}=f\left ( x,y\right ) \]

Looking at \(f\left ( x\right ) \) we see that solution is not defined at \(y=0\). Otherwise, \(f\left ( x,y\right ) \) is continuous everywhere. Hence solution exist for \(y\neq 0\).  Also \(\frac{\partial f}{\partial y}=-\frac{2x^{3}}{y^{2}}\), hence we see solution is unique, on some interval that does not include \(y=0\). Now we will solve the ODE\begin{align*} y\frac{dy}{dx} & =2x^{3}\\ ydy & =2x^{3}dx \end{align*}

Integrating\[ \frac{1}{2}y^{2}=\frac{1}{2}x^{4}+c \] Applying initial conditions\begin{align*} \frac{1}{2}\left ( 9\right ) & =\frac{1}{2}+c\\ \frac{9}{2}-\frac{1}{2} & =c\\ c & =4 \end{align*}

Hence exact solution is\begin{align*} \frac{1}{2}y^{2} & =\frac{1}{2}x^{4}+4\\ y^{2} & =x^{4}+8\\ y & =\pm \sqrt{x^{4}+8} \end{align*}

Since \(1\leq x\leq 3\) and \(y\left ( 1\right ) =3\), then \(y\) can not become negative (else it will have to cross \(y=0\)). Therefore solution is just the positive branch\[ y_{exact}=\sqrt{x^{4}+8}\] Using Euler, we write\[ y_{n+1}=y_{n}+hf\left ( x_{n},y_{n}\right ) \] But \(f\left ( x_{n},y_{n}\right ) =\frac{2x_{n}^{3}}{y_{n}}\) and \(x_{n}=1+nh\) where \(h\) is the step size. The above becomes\[ y_{n+1}=y_{n}+hf\left ( x_{n},y_{n}\right ) \] Using initial conditions, where \(n=0\), the given values \(y_{0}=3\) at \(x_{0}=1\). A small function was written to implement Euler method and print table. Source code is given below. Here is the final table generated

pict

Source code listing:

pict

4.3.3 Section 2.4 problem 25

Problem Apply Euler method for \(\frac{dv}{dt}=32-1.6v\,\) with \(v\left ( 0\right ) =0\). For \(0\leq t\leq 2\), using step size \(h=0.01,h=0.005\), round \(v\) to one decimal point. What percentage of limiting velocity \(20\) ft/sec has been attained after \(1\) second? After \(2\) seconds?

Solution

The exact solution is\[ \frac{dv}{dt}+1.6v=32 \] \(\mu =e^{\int 1.6dt}=e^{1.6t}\), hence\[ \frac{d}{dt}\left ( e^{1.6t}v\right ) =32e^{1.6t}\] Integrating\begin{align*} e^{1.6t}v & =32\int e^{1.6t}dt\\ & =\frac{32}{1.6}e^{1.6t}+c \end{align*}

Hence\[ v\left ( t\right ) =\frac{32}{1.6}+ce^{-1.6t}\] Applying initial conditions\begin{align*} 0 & =\frac{32}{1.6}+c\\ c & =-\frac{32}{1.6} \end{align*}

Therefore, exact solution is\begin{align*} v\left ( t\right ) & =\frac{32}{1.6}-\frac{32}{1.6}e^{-1.6t}\\ & =20\left ( 1-e^{-1.6t}\right ) \end{align*}

The Euler method is\[ y_{n+1}=y_{n}+hf\left ( x_{n},y_{n}\right ) \] Where here \[ f\left ( x_{n},y_{n}\right ) =32-1.6y_{n}\] Small function was written to find \(v\left ( t\right ) \) at \(t=1,2\) seconds using Euler, with the different step sizes. It prints the value of \(v\) when iteration reaches \(1\) and \(2\) seconds. Here is the screen output

data1 = makeTable[0.01, 0, 2, 0];
At one second, using h=0.01 speed is 16.078 at step n = 100
At 2 seconds, using h=0.01 speed is 19.206 at step n = 200
data2 = makeTable[0.005, 0, 2, 0];
At one second, using h=0.005 speed is 16.02 at step n = 200
At 2 seconds, using h=0.005 speed is 19.195 at step n = 400

Therefore (where percentage below, is percentage of limiting speed of \(20\) ft/sec)




h speed at 1 second speed at 2 seconds



\(0.01\) \(16.078\) \(19.206\)



\(0.005\) \(16.02\ \left ( 80.1\%\right ) \) \(19.195\ \left ( 95.98\%\right ) \)



The source code written for this problem is given below

pict

4.3.4 Section 2.4 problem 30

Problem Apply Euler method with successively smaller step sizes on the interval \(\left [ 0,2\right ] \) to verify empirically that the solution of \(y^{\prime }=x^{2}+y^{2};y\left ( 0\right ) =0\) has vertical asymptote near \(x=2.003147\). Contrast this with example 2, in which \(y\left ( 0\right ) =1\).

Solution

Small function was written to implement Forward Euler for this problem.

pict

The above function was called for \(h=0.1,0.01,0.001\) which showed that better and better approximation, the numerical solution approached asymptote near \(x=2.003147\). For \(h=0.1\), here is the output

pict

For \(h=0.01\), here is the output

pict

For \(h=0.001\), here is the output

pict

4.3.5 Section 2.5 problem 8

Apply improved Euler method to approximate solution on interval \(\left [ 0,\frac{1}{2}\right ] \) with step size \(h=0.1\) Construct table showing 4 decimal places values of approximation solution and exact solution at points \(0.1,0.2,0.3,0.4,0.5.\)\[ y^{\prime }=e^{-y};y\left ( 0\right ) =0 \] Exact solution is \(y\left ( x\right ) =\ln \left ( x+1\right ) \)

Solution

Improved Euler method uses\begin{align*} k_{1} & =f\left ( x_{n},y_{n}\right ) \\ u_{n+1} & =y_{n}+hk_{1}\\ k_{2} & =f\left ( x_{n+1},u_{n+1}\right ) \\ y_{n+1} & =y_{n}+h\frac{k_{1}+k_{2}}{2} \end{align*}

A small function was written to implement the above improved Euler method. The following is source code

pict

This function was called to generate the table and format it. Here is the result

pict

Then Euler method was compared to Improved Euler for the same step size \(h=0.1\), by plotting them on the same figure. Here is the result. The red line is the Euler method, and the blue line is the improved Euler method. We see the difference between them increases as more steps are taken.

pict

4.3.6 Section 2.5 problem 13

Problem Find the exact solution, then apply improved Euler method twice to approximate to 5 decimal places values the solution on the given interval. First with step \(h=0.01\) then with step \(h=0.005\). Make table showing the approximate values and the actual values, together with percentage error in the more accurate approximation for \(x\) an integral multiple of \(0.2.\) \(yy^{\prime }=2x^{3};y\left ( 1\right ) =3;1\leq x\leq 2\,.\)

Solution

The analytical solution is the same as in problem 13, section 2.5 and hence will not be repeated again. The improved Euler function, which was written for problem 8 above, was now used for \(h=0.01\) and \(h=0.005\). Source code is given above in problem 8. Here is the final table generated

pict

To better compare the improved Euler method, with the Euler method, a new table was generated. This gives result only for \(h=0.01\). Here is the result. This used the Euler function which was written for section 2.4 and listed above. The table also includes the difference at each \(x\) between the two methods. We see from this table, that as more steps are made (at \(x=2\,\)) that the difference between the improved Euler and Euler method has increased.

pict

4.3.7 Section 2.5 problem 25

Problem Apply improved Euler method for \(\frac{dv}{dt}=32-1.6v\,\) with \(v\left ( 0\right ) =0\). For \(0\leq t\leq 2\), using step size \(h=0.01,h=0.005\), round \(v\) to one decimal point. What percentage of limiting velocity \(20\) ft/sec has been attained after \(1\) second? After \(2\) seconds?

Solution The exact solution we derived in section 2.4 above. The improved Euler method, implemented in the function shown above, was used in this problem to generate similar table to section 2.4, problem 25. But now using the improved Euler. Here is the resulting table.

data1 = makeTableImproved[0.01, 0, 2, 0];
At one second, using h=0.01 speed is 15.96179 at step n = 100
At 2 seconds, using h=0.01 speed is 19.18464 at step n = 200
data2 = makeTableImproved[0.005, 0, 2, 0];
At one second, using h=0.005 speed is 15.962 at step n = 200
At 2 seconds, using h=0.005 speed is 19.18473 at step n = 400

Therefore, improved Euler method result is




h speed at 1 second speed at 2 seconds



\(0.01\) \(15.96179\) \(19.18464\)



\(0.005\) \(15.962\ \left ( 79.81\%\right ) \) \(19.18473\ \left ( 95.923\%\right ) \)



This can be compared with Euler method in problem 2.4.25. We see small difference in speeds at 1 and 2 seconds. The improved Euler result should be taken as the more accurate. Here is the Euler method result, copied from 2.4.25 to make it easier to compare with




h speed at 1 second speed at 2 seconds



\(0.01\) \(16.078\) \(19.206\)



\(0.005\) \(16.02\ \left ( 80.1\%\right ) \) \(19.195\ \left ( 95.98\%\right ) \)



4.3.8 Section 2.5 problem 26

Problem Deer population \(P\left ( t\right ) \) in small forest initially numbered \(25\) and satisfies logistic equation \(\frac{dP}{dt}=0.0225P\left ( t\right ) -0.0003P^{2}\). With \(t\) in months. Use improved Euler method to approximate solution for \(10\) years. First with step \(h=1\) and then with \(h=0.5\) rounding off \(P\) to 3 decimal points. What percentage of the limiting population of \(75\) deer has been attained after \(5,10\) years?

Solution The improved Euler method \begin{align*} k_{1} & =f\left ( x_{n},y_{n}\right ) \\ u_{n+1} & =y_{n}+hk_{1}\\ k_{2} & =f\left ( x_{n+1},u_{n+1}\right ) \\ y_{n+1} & =y_{n}+h\frac{k_{1}+k_{2}}{2} \end{align*}

With initial conditions \(y_{0}=25\) was used to solve this ODE with \(f\left ( x,y\right ) =0.0225y-0.0003y^{2}\). The same improved Euler method function listed earlier was used. The following table summarizes the results




h (moths) \(p\left ( t\right ) \) at 5 years \(p\left ( t\right ) \) at 10 years



\(1\) \(49.3909\ \left ( 65.85\%\right ) \) \(66.1129\ \left ( 88.15\%\right ) \)



\(0.5\) \(49.39135\ \left ( 65.85\%\right ) \) \(66.11343\ \left ( 88.15\%\right ) \)



pict