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:
Click to copy this expression
Click to copy this expression
* 
The yi variables are functions of x.
2. Define the constants in the system.
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Define the initial values.
Click to copy this expression
4. Define a vector function D(x,y) corresponding to the right-hand side of the system.
Click to copy this expression
5. Use the augment function to create the augmented Jacobian:
Click to copy this expression
6. Call the Stiffb and Stiffr functions:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
* 
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:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
8. Plot and compare the returned solutions for each unknown from the two functions:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
The plots show that the two ODE solvers return identical solutions.
Was this helpful?