37 Differential Equations

Referring back to calculus again, recall implicit differentiation which involved attempting to differentiate an equation that contained more than one variable. Recall that we denote the first derivative for a differential equations as \frac{dV}{dt}=f(t,V). Where we are taking the derivative of V with respect to time t. We can apply this to any variable though, the main focus is that \frac{dV}{dt} illustrates the change in V over the change in t. To calculate this we need to find the limit of \frac{\bigtriangleup V}{\bigtriangleup t} as \bigtriangleup t approaches 0. Since we cannot directly substitute 0 for t we need to calculate the values for the change in t close to 0. This will allow us to approximate the limit of \frac{\bigtriangleup V}{\bigtriangleup t} [16]. We find the formula by first acknowledging that \frac{dV}{dt} \approx \frac{\bigtriangleup V}{\bigtriangleup t} where

    \begin{equation*} \bigtriangleup V = f(t,V)\cdot \bigtriangleup t \Rightarrow V(t+\bigtriangleup t)=V(t)+f(t,V)\cdot \bigtriangleup t. \end{equation*}

We define this formula as Euler’s method. Here we see that the formula is to calculate the value of the current step using the previous value, similar to the idea in the Newton-Raphson and Secant methods. We can use a different array of variables, as well, to fit the formula as we see done in our next example.

 

Example:

Consider the equation \frac{dz}{dx} = -z^{2}. Given z(0)=1 and \bigtriangleup x=0.25, compute z(0.25) and z(0.5) using the Euler’s method. Compare to the exact solution z=\frac{1}{1+x} [15].

First we need to write out the Euler’s formula as it fits for our problem with the information we have been provided thus far.

    \begin{equation*} z(t+\bigtriangleup t) =z(t) + 0.25(-z^{2}) \end{equation*}

We know that z(0)=1 thus we have the following calculations:

    \begin{equation*} \begin{split} z(0+0.25)=z(0.25)&=z(0)+0.25(-(z(0))^{2})\\ &=1+0.25(-1)=0.75\\ z(0.25+0.25)=z(0.5)&=z(0.25)+0.25(-(z(0.25))^{2})\\ &=0.75+0.25(-0.5625)=0.0609375 \end{split} \end{equation*}

Now that we have found the values for z(0.25) and z(0.5) we need to compare them to the exact solution z=\frac{1}{1+x}.

    \begin{equation*} \begin{split} z(0.25)&=\frac{1}{1+0.25}=0.8\\ z(0.5)&=\frac{1}{1+0.5}=0.666667 \end{split} \end{equation*}

Now to compare our calculations we find the true error for each.

    \begin{equation*} \begin{split} E_{T}&=\left| 0.8-0.75 \right| = 0.05\\ E_{T}&=\left| 0.666667-0.609375 \right| = 0.057292\\ \end{split} \end{equation*}

 

 

From this example we can see that although the approximations are close we will need several more iterations before we begin to see smaller and smaller errors which signify that the approximations are coming closer to the exact solutions.

There is a revised version of Euler’s method, called improved Euler’s method or Heun’s method.

31.1 Improved Euler’s Method

As mentioned previously, the improved Euler’s method is a revised verion of the original formula but with a two step process for every one calculation we performed for the original Euler’s method. We change the notation in order to better understand the iterations involved. Let V(t)=V_{n} be the previous known value and let V^{*}_{n+1} be the rough approximation for the current value used to approximate the the final value, V_{n+1}.  We define the two steps, using our same variables as for the Euler’s method, as follows.

    \begin{equation*} \begin{split} Step \ 1) \ & V^{*}_{n+1}=V_{n}+f(t_{n},V_{n}) \bigtriangleup t\\ Step \ 2) \ & V_{n+1}=V_{n}+\frac{\bigtriangleup t}{2} [f(t_{n},V_{n})+ f(t_{n+1}, V_{n+1})] \end{split} \end{equation*}

Using the previous example we used for Euler’s method lets us now apply the improved Euler’s method.

 

Example:

Consider the equation \frac{dz}{dx} = -z^{2}. Given z(0)=1 and \bigtriangleup x=0.25, compute z(0.25) and z(0.5) using the improved Euler’s method. Compare to the exact solution z=\frac{1}{1+x} [15].

We define our two steps for this problem as follows:

    \begin{equation*} \begin{split} Step \ 1) \ & z^{*}_{n+1}=z_{n}+0.25(-(z_{n})^{2})\\ Step \ 2) \ & z_{n+1}=z_{n}+\frac{0.25}{2}[(-(z_{n})^{2})+(-(z^{*}_{n+1})^{2})] \end{split} \end{equation*}

Where z(0)=z_{0}, we can calculate z(0.25)=z_{1} and z(0.5)=z_{2} beginning with z(0.25)=z_{1}.

    \begin{equation*} \begin{split} z^{*}_{0+1}&=z_{0}+0.25(-(z_{0})^{2})=1+0.25(-(1)^{2})\\ &=1-0.25=0.75\\ z_{1}&=z_{0}+0.125[(-(z_{0})^{2})+(-(z^{*}_{1})^{2})]=1+0.125[(-(1)^{2})+(-(0.75)^{2})]\\ &=1+0.125(-0.1953125)=0.8046875 \end{split} \end{equation*}

Next we calculate z(0.5)=z_{2}.

    \begin{equation*} \begin{split} z^{*}_{1+1}&=z_{1}+0.25(-(z_{1})^{2})=0.8046875+0.25(-(0.8046875)^{2})\\ &=0.8046875-0.161881=0.642807\\ z_{2}&=z_{1}+0.125[(-(z_{1})^{2})+(-(z^{*}_{2})^{2})]\\ &=0.8046875+0.125[(-(0.8046875)^{2})+(-(0.642807)^{2})\\ &=0.8046875+0.125(-1.060723)=0.672097 \end{split} \end{equation*}

Now we calculate the true error between the exact values we already found in the previous example and the values, rounded to the 6th significant figure, found using the improved Euler’s method.

    \begin{equation*} \begin{split} E_{T}&=| 0.8-0.8046875 |=0.0046875\\ E_{T}&=| 0.666667-0.672097| =0.0054305 \end{split} \end{equation*}

 

These are much lower true errors than what we found using the Euler’s method. Seeing the comparison between errors we can tell that the improved Euler’s method does, in fact, improve upon the approximations in comparison to the true values.

Now there is a third method that builds upon the improved Euler’s method to produce approximations with even better accuracy. In the next subsection we will learn how to utilize the fourth-order Runge-Kutta method for approximating differential equations.

31.2 Runge-Kutta Method

We can draw from the name that the fourth-order Runge-Kutta method requires 4 steps to calculate one approximation. The Runge-Kutta method is considered the more advanced as the more it has the greatest order. The Euler’s method was a first-order, with only one calculation to make an approximation. The improved Euler’s method was a second-order, as it required 2 sub-calculation to make an approximation. The Runge-Kutta method is a fourth-order because it requires 4 calculations to make an approximation. We define the formula for the fourth-order Runge-Kutta method as follows [16].

    \begin{equation*} V(t+ \bigtriangleup t)=V(t)+\frac{\bigtriangleup t}{6} [k_{1}+2K_{2}+2k_{3}+k_{4}]. \end{equation*}

We define the calculations denoted by k_{n} as the following:

    \begin{equation*} \begin{split} k_{1}&=f(t_{n},V_{n})\\ k_{2}&=f\left( t_{n}+\frac{\bigtriangleup t,V_{n}+\frac{\bigtriangleup t} {2} k_{1}}{2}\right) \\ k_{3}&=f\left( t_{n}+\frac{\bigtriangleup t, V_{n}+\frac{\bigtriangleup t} {2} k_{2}}{2}\right) \\ k_{4}&=f\left( t_{n} +\bigtriangleup t,V_{n}+ \bigtriangleup t k_{3}\right) \end{split} \end{equation*}

Using the same example we have used thus for in this section let us observe if the fourth-order Runge-Kutta method actually does improve upon Euler’s and improve Euler’s approximation.

 

Example:

Consider the equation \frac{dz}{dx} = -z^{2}. Given z(0)=1 and \bigtriangleup x=0.25, compute z(0.25) using the fourth-order Runge-Kutta method. Compare to the exact solution z=\frac{1}{1+x} [15].

We start with z(0.25) by calculating k_{1}, k_{2}, k_{3}, k_{4}.

    \begin{equation*} \begin{split} k_{1}&=f(0,1)=-(1)^{2}\\ &=-1\\ k_{2}&=f\left( 0+\frac{0.25}{2}, 1+\frac{0.25}{2}(-1) \right)=-(0.875)^{2}\\ &=-0.765625 \\ k_{3}&=f\left( 0+\frac{0.25}{2}, 1+\frac{0.25}{2}(-0.765625) \right)=-(0.904297)^{2}\\ &=-0.817753\\ k_{4}&=f\left( 0 +0.25,1+ 0.25(-0.817753)\right)=-(0.795562)^{2}\\ &=-0.632919 \end{split} \end{equation*}

Now that we have found our values for k_{n} we can input our known values into our formula and solve for z(0.25).

    \begin{equation*} \begin{split} z(0.25)&=z(0)+\frac{0.25}{6} [-1+2(-0.765625)+2(-0.817753)+(-0.632919)]\\ &=1+\frac{0.25}{6}(-4.799674)=0.800014 \end{split} \end{equation*}

We calculate the true error of this approximation using the exact value we found previously.

    \begin{equation*} E_{T}=| 0.8-0.800014 |=0.000014 \end{equation*}

 

We don’t perform the calculation for z(0.5) in this example because just from calculating the true error of the fourth-order Runge-Kutta approximation for z(0.25) we see an extreme improvement. This new true error is even smaller than the one we found for our approximations using the improve Euler’s method. Just from comparing these examples we can see the progression of an approximation depending on the method you utilize to make the approximation.

 

License

Senior Seminar Online Portfolio Copyright © by Maggie M Schildt. All Rights Reserved.

Share This Book