User:Egm6341.s11.team2.franklin/hwk7

= Problem 7.3: Solving the Logistic Equation Using Inconsistent Trap-Simpson's rule & Newton-Raphson =

Given
Refer to lecture slide 41-1 for problem statement

The logistic equation for population dynamics is given in S10 lecture slide 38-3,


 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:95%" |
 * style="width:95%" |

\dot{x}(t) = f(x) = rx \left(1-\frac{x}{x_{max}}\right). $$     (7.3.1)
 * 
 * }

For S11, $$\displaystyle x_{max}=15;\ r = 1.4,\ $$ and $$\displaystyle t \in [0,20] $$

The analytical solution, found by the Hermite-Simpson method, is given in S10 lecture slide 39-1,


 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:95%" |
 * style="width:95%" |

x(t) = \frac{x_0x_{max}e^{rt}}{x_{max} + x_0(e^{rt}-1)}. $$     (7.3.2)
 * 
 * }

Find
To solve logistic equation defined by Eq 7.8.1 for two initial conditions, $$\displaystyle x_0=3\ and\ x_0 = 9,\ $$ using Inconsistent Trap-Simpson's rule given by (1) in lecture slide 38-3,


 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:95%" |
 * style="width:95%" |

z_{i+1} = z_{i} + \frac{h/2}{3} \left[f_i + 4f_{(i+1/2)} +f_{i+1}\right]. $$     (7.3.4)
 * 
 * }

The Inconsistent Trap rule is given by,


 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:95%" |
 * style="width:95%" |

z_{i+1/2} = \frac{1}{2} [z_{i} + z_{i+1}]. $$     (7.3.5)
 * 
 * }

Solution
Consider Eq 7.3.1 in which $$\displaystyle f_{(i+1/2)}$$ is a function of $$\displaystyle z_{i}$$ and $$\displaystyle z_{i+1}$$, where $$\displaystyle z_i, z_{i+1} $$ goes to values of $$\displaystyle x$$ at $$\displaystyle t = t_i$$ and $$\displaystyle t = t_{i+1}$$.

Because this is an initial value problem, $$\displaystyle z_i$$ is known. So, Eq 7.3.4 becomes a function of $$\displaystyle z_{i+1}$$ given by,


 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:95%" |
 * style="width:95%" |

F(z_{i+1}) = 0 $$     (7.3.6)
 * 
 * }

We find the root $$\displaystyle z_{i+1}$$ of Eq 7.3.6 using Newton-Raphson method in lecture 26-2,


 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:95%" |
 * style="width:95%" |

z_{i+1}^{(k+1)} = z_{i+1}^{(k)} - \left[\frac{dF(z_{i+1}^{(k)})}{dz}\right]^{-1} F(z_{i+1}^{(k)}) $$     (7.3.6)
 * 
 * }

The Newton-Raphson iteration, starting with an initial guess as $$\displaystyle z_{i+1}^{0} = z_{i}$$, is stopped once the absolute tolerance


 * {| style="width:100%" border="0"

$$\displaystyle p = \frac{-1}{(C  (A-BK)^{-1} \times B)} $$     (7.3.7)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

is satisfied.

Below are the plots of the solution of the Verhulst Function and the error, initial population of 3, h=0.125.

Below are the plots of the solution of the Verhulst Function and the error, initial population of 9.

The code for the case with initial population of 9 is very similar to the code post above. The only difference is that "x0=9" instead of "x0=9."


 * {| style="width:100%" border="0"

$$\displaystyle Fitted\; T.F.\, = \frac{150.1 s^2 + 598.3 s + 1.354\times10^5}{s^4 + 4.551 s^3 + 6506 s^2 + 3636 s + 6.408\times10^5} $$     (7.3.7)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }