The Computable Differential Equation Lecture ... - Bruce E. Shapiro
The Computable Differential Equation Lecture ... - Bruce E. Shapiro
The Computable Differential Equation Lecture ... - Bruce E. Shapiro
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
CHAPTER 9. DIFFERENTIAL ALGEBRAIC EQUATIONS 181<br />
to do this using Newon’s method we must compute the Jacobian matrix is<br />
⎛<br />
⎞<br />
∂F 1 /∂A n ∂F 1 /∂B n ∂F 1 /∂X n ∂F 1 /∂E n<br />
J = ⎜∂F 2 /∂A n ∂F 2 /∂B n ∂F 2 /∂X n ∂F 2 /∂E n<br />
⎟<br />
⎝∂F 3 /∂A n ∂F 3 /∂B n ∂F 3 /∂X n ∂F 3 /∂E n<br />
⎠<br />
∂F 4 /∂A n ∂F 4 /∂B n ∂F 4 /∂X n ∂F 4 /∂E n<br />
⎛<br />
⎞<br />
1/h + αE n 0 −β αA n<br />
(9.162)<br />
= ⎜ 0 1/h −γ 0<br />
⎟<br />
⎝ −αE n 0 1/h + (γ + β) −αA n<br />
⎠ (9.163)<br />
0 0 1 1<br />
We can implement the Jacobian calculation in Mathematica as follows<br />
jac[f , vars ] := Module[dF,<br />
If[Length[f] ≠ Length[vars], Return[$Failed]];<br />
dF[func ] := Map[D[func, #] &, vars];<br />
Return[Map[dF, f]]<br />
]<br />
and then we can calculate the Jacobian with<br />
F={ (A n -A n−1 )/h + (α*A n *e n -β*X n ),<br />
(B n -B n−1 )/h - γ*X n ,<br />
(X n -X n−1 )/h - (α*A n *e n - (β + γ)*X n ),<br />
e n +X n -1 };<br />
jac[F, {A n , B n , X n , e n }]<br />
Note that because the symbol E is reserved in Mathematica for the exponential e,<br />
we have replaced the symbol for the enzyme with a lower case e.<br />
At each time step we need to apply the iteration formula and invert it using<br />
Newton’s formula, e.g.,<br />
nextStep[h , {ALast , BLast , XLast , eLast }] :=<br />
Module[F,J,A,X,e,B,∆,IJ,IJF,ɛ=10 −12 ,A n ,X n ,e n ,B n ,<br />
F={ (A n -ALast)/h + (α*A n *e n -β*X n ),<br />
(B n -BLast)/h - γ*X n ,<br />
(X n -XLast)/h - (α*A n *e n - (β + γ)*X n ),<br />
e n +X n -1 };<br />
J= jac[F, {A n , B n , X n , e n }];<br />
IJ = Inverse[J];<br />
IJF = IJ.F;<br />
{A, B, X,e} = ALast, BLast, XLast, eLast;<br />
For [i = 0, i 5, i++,<br />
∆ = -IJF /. {A n -> A, B n -> B, X n -> X, e n ->e};<br />
{A, B, X, e} += ∆;<br />
If[Abs[∆] < ɛ, Break[]];<br />
];<br />
Return[A, B, X, e]<br />
]<br />
c○2007, B.E.<strong>Shapiro</strong><br />
Last revised: May 23, 2007<br />
Math 582B, Spring 2007<br />
California State University Northridge