PENG9570 — Lecture 5 (March 3rd)
Euler’s Method for ODEs
The slope of the solution is .
Linearising on an interval ,
This is the basis for Euler’s method

Numerical methods: -notation : Time step Error at time :
Then the method is said to be Larger means higher precision
Numerical Methods for ODEs
Integrating from to , we get the integral form of the IVP: Integral form of IVP:
In general, the integral is evaluated numerically.
Numerical Integration Methods: Riemann Sums
- [?] Left / right Riemann?

Local error ⇒ Euler’s method
Euler’s method : Time step Method is (first order)
Numerical Integration Methods: Midpoint Rule

Mid-point Method
Local error ⇒ Mid-point method
Estimate using Euler’s method
Method is (second order)
Numerical Integration Methods: Trapezoidal Rule

Local error ⇒ Heun’s method/ Runge-Kutta’s 2. order method
RK2/Heun’s Method
Method is (second order)
Numerical Integration Methods: Simpson’s Rule
Local error
⇒ Runge-Kutta’s 4. order method
Runge-Kutta 4th order Method
Method is (fourth order)
Demonstration of Convergence Properties for the Four Methods
: Numerical error
(Linear in with slope )

Problem
Consider the IVP
- Show that .
- Compute numerical solutions on for a range of values for number of subintervals using (i) Euler’s method, (ii) RK2 (Heun’s method), (iii) the midpoint method and (iv) Runge-Kutta’s fourth order method. |stimate
- Compute the error for all methods for all values for and use these quantities to estimate the convergence rates.
1. Analytical Solution
Show that .
Assuming: Then:
Fill in the transformation from the LHS of the first part of this to its RHS. I'm having some difficulty understanding
ROBOT GENERATED – gemini-3.5-flash
To understand this verification, it helps to first point out a few typographical/OCR errors in your notes that make the math look confusing:
- First line: has an extra at the end. It should be .
- Second line: is a typo for . Additionally, the exponents in the last two terms should be negative: and .
- Fourth line: is a typo for .
Step-by-Step Derivation
Given the analytical solution:
1. Compute the components
Using the chain rule, find the derivative :
The powers of are:
2. Substitute into the LHS of the ODE ()
3. Factor out the common term
This is the step that usually causes confusion. To simplify the last two terms, factor out :
(This works because .)
4. Simplify inside the brackets
5. Combine and resolve
Now, substitute this simplified expression back into the full equation:
This confirms that the LHS simplifies to , proving that is indeed the correct analytical solution.
Programming: Compute Numerical Solutions
- Programming: Compute numerical solutions on for a range of values for number of subintervals using (i) Euler’s method, (ii) RK2 (Heun’s method), (iii) the mid-point method and (iv) Runge-Kutta’s fourth order method.

Exact (curve) Euler (dots) Midpoint (dots) RK2 (dots) RK4 (dots)
- Programming: Compute the error for all methods for all values for and use these quantities to estimate the convergence rates.
Figure 4

Euler, slope=1.0016 RK2, slope=2.0287 Midpoint, slope=2.0276 RK4, slope=4.1342
Example – Model of prey–predator interactions.
Model of prey–predator interactions.
- : prey population,
- : predator population. .
a) Nullclines:
i.e where:
The case : predator death rate is high
(predator death rate is high)

The case : Equilibrium-ish

Jacobian
How did we get this Jacobian? (oh lol it was already defined, just in reverse order)
ROBOT GENERATED – gemini-3.5-flash
To find the Jacobian matrix , we use the system of differential equations describing the prey-predator interactions given in the note:
The Jacobian matrix is defined as the matrix of first-order partial derivatives of these functions:
Step-by-step Differentiation
- Top-left entry (): Differentiate with respect to (treating as a constant):
- Top-right entry (): Differentiate with respect to (treating as a constant):
- Bottom-left entry (): Differentiate with respect to (treating as a constant):
- Bottom-right entry (): Differentiate with respect to (treating as a constant):
Final Matrix
Placing these partial derivatives into the Jacobian structure yields the highlighted matrix:
Jacobian:
where, and ,
At :
Upper triangular: eigenvalues are on the diagonal, . ; stable node. ; saddle (unstable).
Why are these x,y values selected?
ROBOT GENERATED – gemini-3.5-flash
The values are selected because they represent an equilibrium point (or fixed point) of the prey-predator system.
Equilibrium points occur where the system’s rates of change are zero ( and ). We find these by finding the intersections of the system’s nullclines:
- Prey nullclines ():
- Predator nullclines ():
By intersecting the prey nullcline with the predator nullcline , we get:
This yields two equilibrium points: and .
Evaluating the Jacobian matrix at allows us to perform linear stability analysis to determine the behavior of the populations near this steady state (e.g., whether it is a stable node or an unstable saddle point depending on the parameter ).
At :
(there, )
Eigenvalues:
Define "Characteristic Equation" here
ROBOT GENERATED – gemini-3.5-flash
Based on the provided notes and the highlighted snippet, the characteristic equation is the algebraic equation solved to find the eigenvalues () of a matrix.
It is defined by setting the determinant of the matrix to zero:
In the specific context of the prey-predator model evaluated at the equilibrium point , expanding this determinant yields the quadratic characteristic equation:
where:
- is the Jacobian matrix.
- is the identity matrix.
- represents the eigenvalues.
Result:
- Stable node: For , we have two real eigenvalues, both negative.
- Stable spiral (sink): For , we have complex conjugate eigenvalues with negative real part.
- Unstable spiral (source): For , we have complex conjugate eigenvalues with positive real part.
Where is the bound on the a values coming from? Is it from solving for a with the eigenvalues?
ROBOT GENERATED – gemini-3.5-flash
Yes, the bounds on the values come directly from solving for and analyzing the eigenvalues ().
From the characteristic equation in the note:
By simplifying the discriminant (the term inside the square root), we get:
1. Real vs. Complex Eigenvalues (The bound)
- Real eigenvalues occur when the discriminant is positive ():
- Complex conjugate eigenvalues occur when the discriminant is negative ():
2. Stable vs. Unstable Spirals (The bound)
When the eigenvalues are complex (), their real part is determined by the term outside the square root:
Since , the sign of the real part depends entirely on the term :
- Negative real part (Stable spiral / Sink):
- Positive real part (Unstable spiral / Source):
Combining these conditions yields the exact bounds presented in the results.
Result Illustrations



Hopf Bifurcation Diagram
So if given:
Then, Hopf bifurcation at (he writes 0.5 in slide). Equilibrium becomes unstable and a limit cycle emerges.

Phase Portrait
Blue:
Yellow:
Green:
Red:
Time-Series Plots

Phase plots using different methods
Euler’s method predicts wrong closed curve solution.
Partial Differential Equations (PDES)

Partial Derivatives
: slope of tangent of at
- : slope of tangent in the -direction at ( fixed)
- : slope of tangent in the -direction at ( fixed)
Notation for second order derivatives:
Example 1 – Heat equation
Heat equation. : heat conductivity
Example 2 – Fisher’s equation
Fisher’s equation. : diffusion constant
Example 3 – Solve:
Solve:
We write the PDE as
We introduce :
We have
What does the bar over c(t) signify? Why do we add arbitrary functions?
ROBOT GENERATED – gemini-3.5-flash
Based on the provided notes and highlighted mathematical steps, here are the answers to your questions:
1. What does the bar over signify?
The bar over , written as , signifies the antiderivative (or integral) of the arbitrary function with respect to .
As shown in the snippet:
Because is an arbitrary function of , its integral is also just another arbitrary function of . The bar notation is used to simplify and clean up the final expression of the general solution.
2. Why do we add arbitrary functions?
In partial differential equations (PDEs), when you integrate with respect to one variable, you must treat all other independent variables as constants:
Integrating with respect to : Since is treated as a constant, the “constant of integration” does not have to be a single number; it can be any function that depends only on , denoted as . This is because its partial derivative with respect to is zero:
Integrating with respect to : Since is treated as a constant, the constant of integration can be any arbitrary function of , denoted as , because:
Adding these arbitrary functions is necessary to capture the complete, general solution of the PDE.
Example 4 – Solve :
Possible to solve, but tedious.
Introduce :
Then:
- [?] How does it go from step 1 to 2? We derive wrt to but then where does the whole RHS come from?
Continuing:
General solution:
Arbitrary functions:
Conservation laws
Note
I’m not exactly sure what is being asked for here

I. Amount of substance in at time
II. Net rate of substance flowing into
III. Rate of production of substance in
IV. Change of amount of substance per time unit
Conservation Law:
Net rate of substance into + rate of production inside = change of amount in
Mathematically:
The interval is chosen arbitrarily ⇒ the integrand must be Zero!
Fick’s law:
Note
I think I have a topics Fick’s law
- Fix this section!
Fick’s law is as follows:

Insertion:
- [?] I’m not certain what is happening here
Boundary and Initial Conditions:
The initial boundary Value problem (IBVP) Consider:
To determine the solution Uniquely we need:
- an initial function
- boundary conditions

Dirichlet Conditions:
and are prescribed functions (as we have here).
Insulated boundary conditions: Neumann boundary conditions:
An explicit scheme for the heat / diffusion PDE / IBVP
IBVP:
IC: .
BC:
is separated into subintervals of width .
number of interior points for one value of .
Approximations of and
If is small:
We introduce as an approximation to j
Three-point approximation for :
Thus,
Since :
Discretized Version of

Derivation of a matrixvector formulation
Let
The explicit scheme For (application of )
For (application of
General case:
The equations read, structurally:
Linear system of equations:
Define The explicit scheme: