Ordinary Differential Equations (ODEs)
Introduction
Let and consider an open rectangular neighborhood of
Let be a function defined on this plane. Then, for all , we have
This is an ordinary differential equation (ODE)!
Essentially, this creates a slope field, where the slope varies based on our position !
Suppose we want to solve this ODE, or in other words, find the satisfying the relation and initial condition.
Theorem: Uniqueness of Solutions
Assume that and are continuous on . Then, there exists a such that we have a unique solution on .
Example: Ordinary Differential Equations
We can solve this!
We can also show that
Are also solutions. Note that we do not have uniqueness, as the derivative of with respect to is not continuous!
Additionally, we have the following.
Theorem: Convergence of Solutions
Let and be the solutions of the ordinary differential equation with initial conditions and , respectively.
Assume for all and . Then,
This theorem implies the following:
- If , then , implying convergence of to exponentially. We call such ODEs stable, as solutions converge
- If , then may diverge away exponentially from . We call such ODEs unstable, as solutions diverge.
Example: Stability of ODEs
Because for all , our ODE is unstable! Thus, solutions will diverge.
Systems of Ordinary Differential Equations
First-Order ODEs
Suppose we have and want to find them satisfying
With initial conditions .
Note that our unknowns can be coupled together. If they aren’t, then we just have multiple independent ODEs that we can solve separately.
We can also write this in the compact form
Denote the Jacobian Matrix as
And define the open rectangle as
Then, we have the following.
Theorem: Unique Solutions
If and are continuous in , then there exists a unique solution to the system , where .
Higher Order ODEs
Suppose we have a higher order system of ordinary differential equations
With initial values
Then we can rewrite this as a first order system of ODEs! Define as the following.
Then, we can use this and solve our first order system of ODEs as normal. Note that for any , .
Solving Ordinary Differential Equations
Solving ODEs can be hard! Here, we discuss how to iteratively approximate solutions to our ordinary differential equations.
Forward Euler Method
Algorithm
Suppose we want to solve the system
Notice that with a forward difference, we can actually approximate as
So, it’s possible to approximate nearby values by taking small incremental steps in the direction we want!
So, our algorithm is as follows:
- First, divide into equal sized subintervals given by
- Then, let , our initial condition.
- Then, for all , we have
- Repeat this for all .
Error
Let’s find the error of this algorithm. At any step , we can find our error as
Where is our approximation, and is our true value. Using the Taylor expansion about , we can find
We also know that we can find as
Combining these equations, we find
By the Mean Value Theorem, we can guarantee the between and such that
So, we find our error as
where
Where amplification factor is the amount in which the previous error is amplified, and local truncation error is the additional error added from one step.
Let’s analyze what this error means for us in different cases.
In the general case, assume that
- for all ,
- for all
Then, we can find our error as
Using this iteratively, we get error bound
Additionally, because , we have
Some key takeaways:
- As , our error will increase exponentially!
- For a finite , our error grows linearly, and is bounded by . Thus, for finite , Forward Euler is a first order method.
In the special case, assume that our ordinary differential equation is stable. In other words,
- such that , for all and .
- for all .
This gives us
Notice how as becomes smaller, both bounds go to 1! As they’ll have to cross 0 to do this, we can choose such that
Then, we have
Let . Then, repeating the same process as the general case, we get
Giving us a first order that is always bounded by a factor of our timstep ! Thus, our method is 1st order in this case as well.
Note that for this to happen, we assumed stability condition . This must hold for us to get this error!
Forward Euler Takeaways
- 1 evaluation of per step
- Local truncation error of
- Global error of - first order.
Theorem: Local Truncation Error
Let’s take a closer look at the local truncation error. It not only represents the error from one time step of the algorithm, but also indicates the degree in which the true solution doesn’t satisfy the algorithm.
To find the order of some method, we have
- Local Truncation Error
- Global Error
So, for a second order method, we should try to get a local truncation error . How can we get such a method?
Runge Kutta-2 (Multi-Step Methods)
The Runge Kutta Method describes multi-step methods we can use to solve systems of ordinary differential equations. Here, we will discuss RK-2.
Consider the system
If we integrate our ordinary differential equation from , we’ll get
While we have as an initial condition, we can’t find ! But what if we could approximate our integral instead?
Let . Then, we can approximate our integral using a quadrature giving us a third order error.
Let be the trapezoidal rule. Then, we have approximation
Note that this gives us error
But we’re trying to solve for , so we don’t know ! So, let’s use Forward Euler to approximate in to get
Recall that the error of this would be
Our RK-2 scheme is given as
So, our algorithm is as follows:
- Divide into subintervals with size , where .
- Set . solve for the following.
- For ,
- We first perform Forward Euler.
Let’s find our error. Using MVT, we can find an between , such that
Using this, we find error
Assume that is bounded. Then, our RK-2 scheme will have local truncation error !
RK-2 Takeaways
- 2 evaluations of per step
- Local truncation error of
- Global error of - second order.
So RK-2 is far more accurate than Forward Euler, but this comes at a cost! We need to do more computations to get this higher order.
RK-4 Method
We can generalize this to obtain higher orders! One of the most popular ODE integration schemes is RK-4, which has the following properties:
- 4 evaluations of per step.
- Local truncation error of
- Global error of
We state the algorithm below without proof.
- Divide into equal intervals.
- Set .
- For ,
Stiff Ordinary Differential Equations
Consider the ordinary differential equation
Assume this ODE is stable. In other words, such that
Then, applying methods like Forward Euler, we get solutions that are nice and bounded close to our ODE, granted is small enough!
But what if the ODE is “too stable”? In other words what if are too negative? Then, needs to be extremely small for stability! This is known as a stiff ODE, where there are region in the solution where the solution can vary rapidly, and require very small for stability.
Example: Stiff ODEs
The exact solution to this is !
If , with large time steps, we have large oscillations which are not very reflective of our actual solution! We need to make our time step small enough to aviod this.
Because of this, the methods we know aren’t suited very well for Stiff ODEs! Here, we cover alternative methods built to solve these Stiff ODEs.
Backward Euler (Implicit Euler)
Suppose we have the Stiff ODE
That is very stable.
Recall that for Forward Euler, the ampliciation factor is given by
Where we approximate
For Backward Euler, we take the backward difference, finding
Giving us the scheme
Interestingly enough, with this scheme we have an that is given in terms of itself! If is linear, then we can solve the linear system of equations to isolate .
If is non-linear, we need to apply a few steps of Newton’s method to approximate .
We can use this scheme like all of our other methods to approximate our solution!
Let’s estimate our error. By Taylor expansion at , we get
Subtracting our estimation from this, we get
We get
By MVT, we can guarantee the existence of some between and such that
We can sub this back into our above equation to get
We can find our error as
So, we find that a local truncation error of , telling us that our method is first order!
Let’s check for what we need a stability condition. For a stable ODE where , we have
Assume . Then, we have
Where
To give us
Now, we have no condition on ! So, our error is always bounded, meaning our method is unconditionally stable for all .
Unlike Forward Euler, our stability holds for all !
Key Takeaways (Implicit Euler)
- Local truncation error of
- Global error of
- Stability of method for all