User:Egm6341.s11.team4.BM/HW7

=Problem 7.1: Integrating the Logistic Equation Using Hermite-Simpson, Forward Euler, and Backward Euler=

This problem is given on Lecture Slide 40-1 with references to lecture slides 39-1 and lecture slides 40-1 and lecture slides 40-2.

Given
The logistic equation

$$ \frac{dx}{dt}=rx(1-\frac{x}{x_{max}}) $$

With the following conditions

$$ x_{max}=15 $$; $$ r=1.4 $$; $$ t=[0,20] $$

And the two initial conditions

$$ x_0=3< \frac{1}{2}x_{max} $$; $$ x_0=9 > \frac{1}{2}x_{max} $$

Find
1. The Integral over the time span using Hermite-Simpson and the step size $$h=2^{k} \hat{h} $$ for varying values of k.

2. The Integral over the time span using Forward Euler and the step size $$h=2^{k} \hat{h} $$ for varying values of k.

3. The Integral over the time span using Backward Euler and the step size $$h=2^{k} \hat{h} $$ for varying values of k.

Solution
All Code is included at the end of this problem. The Newton-Raphson method was used to solve the nonlinear problem in Hermite-Simpson. First, we will look at the case where the initial condition is $$ x_0=3 $$ then the case where $$ x_0=9 $$. Now, we we are to develop the forward and backward Euler integration schemes using the $$ x_{bar} $$ scheme introduced in class. It should be noted that we expect the explicit forward Euler scheme to produce unstable results and the implicit backward Euler scheme to be stable.

Forward Euler Development
Starting with the general forward Euler equation we will use the bar notation introduced in class.

$$ \bar{x}:=\frac{x}{x_{max}} $$

General Forward Euler Equation

$$ x_{i+1}=x_i (1+\frac{dx_i}{dt}h) $$

Which, for our equation, becomes

$$ \bar{x}_{i+1}=x_i(1+(r\bar{x}_i(1-\bar{x}_i))h) $$

Rearranging this, the equation becomes

$$ \bar{x}_{i+1}=hr\bar{x}_i(1-\bar{x}_i) +\bar{x}_i$$

Now our x vector can be obtained from this $$ \bar{x} $$ vector simply by multiplying through by the maximum value of x.

Backward Euler Development
Starting from the general Backward Euler equation.

$$ x_{i+1} = x_i + \frac{dx_{i+1}}{dt}h $$

$$ \bar{x}_{i+1}=\bar{x}_i + hr\bar{x}_{i+1}(1-\bar{x}_{i+1}) $$

Rearranging into a form that is second order in $$ \bar{x}_{i+1} $$.

$$ hr\bar{x}_{i+1}^{2}+(1-hr)\bar{x}_{i+1}-\bar{x}_i=0 $$

Now, employing the quadratic equation.

$$ \bar{x}_{i+1} = \frac{-(1-hr) \pm \sqrt{(1-hr)^2+4hr}} {2hr}$$

Once again, the true x vector can be found by multiplying the $$ \bar{x} $$ vector by the maximum value of x.

Both of these equations will be used when employing the Forward and Backward Euler integration.

Initial Condition X=3
Looking at figure 1 in the set of plots below, we see that the Hermite-Simpson integration method produces highly accurate results when plotted against the analytic solution. This accuracy maintains even as we increase the step size in accordance with the $$ h=2^k \hat{h} $$ rule. Similarly, as expected, the Forward Euler Integration scheme blows up as we increase the step size, ultimately providing results that are useless. The Backward Euler Integration scheme appears to be stable and provides results that rival the Hermite-Simpson integration scheme.

Initial Condition X=9
Looking at figure 2 in the set of plots below, we see similar results as obtained when the initial condition X=3 was used. First, we see that the Hermite-Simpson integration method once again produces highly accurate results when plotted against the analytic solution. This accuracy maintains even as we increase the step size in accordance with the $$ h=2^k \hat{h} $$ rule. Similarly the Forward Euler Integration scheme blows up as we increase the step size. Lastly, the Backward Euler Integration scheme is stable and provides results that rival the Hermite-Simpson integration scheme.

MATLAB Code
This problem was solved by Brendan Mahon