Functions > Solving and Optimization > Differential Equation Solvers > Example: Augmented Jacobian for Stiffb and Stiffr
Example: Augmented Jacobian for Stiffb and Stiffr
Use the Jacob function to compute the augmented Jacobian matrix for an ordinary differential equation (ODE), and then provide it as input to solvers Stiffb and Stiffr.
1. Define a system of four unknowns:
 y y 0 y 1 y 2 y 3 x y x y 0 y 1 y 1 y 0 y 2 x 2 y 3 y 2 x x 3
 The yi variables are functions of x.
2. Define the constants in the system.
 kc 1.34 1 σ 10 9 10 3 10 7 k 1.6 8 8
3. Define the initial values.
4. Define a vector function D(x,y) corresponding to the right-hand side of the system.
5. Use the augment function to create the augmented Jacobian:
6. Call the Stiffb and Stiffr functions:
 r1 0 r2 20 npoints 150 Yb Stiffb yinit r1 r2 npoints D AJ Yr Stiffr yinit r1 r2 npoints D AJ
 The returned matrices contain 5 columns corresponding to the number of points and the solutions for the four unknowns.
7. Extract the solutions for the four unknowns from the returned Stiffb and Stiffr matrices:
 n Yb 0 yb0 Yb 1 yr0 Yr 1 yb1 Yb 2 yr1 Yr 2 yb2 Yb 3 yr2 Yr 3 yb3 Yb 4 yr3 Yr 4
8. Plot and compare the returned solutions for each unknown from the two functions:
The plots show that the two ODE solvers return identical solutions.