Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Ordinary Differential

Equations
Prepared by
Louriejean L. Alfar
Instructor I
Differential Equations
 In environmental research, differential equations are essential
because it provides mathematical tools for comprehending
environmental processes and forecasting change.

 The application of differential equations enables scientists to


analyze environmental problems in depth and propose effective
solutions.
Differential Equations
Differential Equations
Differential Equations

Two Main Categories


1. Ordinary Differential Equations (ODEs)
- describe functions of one variable

2. Partial Differential Equations (PDEs)


- involve multivariable functions
Application of DE in Environmental Science Modeling

 Differential Equations are widely used in


environmental science to understand and
predict the behavior of complex systems. By separating and integrating the variables,

Example:
Consider the diffusion and degradation of
pollutants, which can be described using the showing that the concentration decreases
first-order differential equation. exponentially with time, where Co is the initial
pollutant concentration

where, C is the concentration of the pollutant, k


is a normal number representing the degradation
rate.
Ordinary Differential Equations

Initial Value Problem:


• Euler Method
• Runge-Kutta Method

Boundary Value Problem:


• Shooting Method
• Finite Difference Method
Ordinary Differential Equations

Initial Value Problem


Euler Method
Euler’s Method is a numerical approximation technique used to numerically
solve ordinary differential equations (ODEs). It is named after the Swiss
mathematician Leonhard Euler, who made significant contributions to the field of
mathematics.
Evaluating Euler Method

Start by having a given ODE in the form dy/dx = f(x, y), along with an
Formulate the
initial condition specifying the value of y at a given x-value (e.g., y(x₀)
ODE = y₀).

Choose the Step Determine the desired step size (h) to divide the interval of interest into
smaller intervals. A smaller step size generally yields more accurate results but
Size increases computational effort.

Set-up the Define a sequence of x-values starting from the initial x₀ and incrementing by the
step size h: x₀, x₁ = x₀ + h, x₂ = x₁ + h, and so on, until the desired endpoint is
Discretization reached.
Evaluating Euler Method

Initialize the Set the initial solution value to the given initial condition: y(x₀) = y₀.
Solution

Continue iterating the method by moving to the next x-value in the sequence and updating the
Repeat the solution using the computed derivative and step size. Repeat this process until reaching the
desired endpoint using the formula:
Iteration
yᵢ₊₁ = yᵢ + h * f(xᵢ, yᵢ).

Output the Once the iteration is complete, the final set of (x, y) pairs represents the
Solution numerical approximation of the solution to the ODE within the specified interval.
Euler Method

It is important to note that Euler’s Method provides an approximate


solution, and the accuracy depends on the chosen step size. Smaller step
sizes generally yield more accurate results but require more
computational effort.
Example:
1. Consider the differential equation dy/dx = y-2x, start at (x,y) = (0,1), 0 ≤ x ≤ 2 with subinterval h =
0.4 to approximate the solution at x = 2.

Solution:
Using Euler’s Method, we start with the initial condition y(0) = 1 and iteratively calculate the next
approximation using the formula:

y(i+1) = yi + h * g(xi, yi)

At x0 = 0, y0 = 1
At x1 = 0.4, y1 = 1 + 0.4 * [1-2(0)] = 1.4
At x2 = 0.8, y2 = 1.4 + 0.4 * [1.4-2(0.4)] = 1.64
At x3 = 1.2, y3 = 1.64 + 0.4 * [1.64-2(0.8)] = 1.656
At x4 = 1.6, y4 = 1.656 + 0.4 * [1.656-2(1.2)] = 1.3584
At x5 = 2.0, y5 = 1.3584 + 0.4 * [1.3584-2(1.6)] = 0.6218

Therefore, the approximation of the solution at x = 2 is y ≈ 0.6218


Example:

MATLAB Codes
Example:
2. Consider the differential equation dy/dx = x^2 with the initial condition y(0) = 1. Use Euler’s
Method with a step size of h = 0.1 to approximate the solution at x = 0.5.

Solution:
Using Euler’s Method, we start with the initial condition y(0) = 1 and iteratively calculate the next
approximation using the formula:
y(i+1) = yi + h * g(xi, yi)

Step 1: At x0 = 0, y0 = 1.
Step 2: At x1 = 0.1, y1 = 1 + 0.1 * (0^2) = 1.000
Step 3: At x2 = 0.2, y2 = 1.000 + 0.1 * (0.1^2) = 1.001
Step 4: At x3 = 0.3, y3 = 1.001 + 0.1 * (0.2^2) = 1.005
Step 5: At x4 = 0.4, y4 = 1.005 + 0.1 * (0.3^2) = 1.014
Step 6: At x5 = 0.5, y5 = 1.014 + 0.1 * (0.4^2) = 1.030

Therefore, the approximation of the solution at x = 0.5 is y ≈ 1.030


Example:
2. Consider the differential equation dy/dx = x^2 with the initial condition y(0) = 1. Use Euler’s
Method with a step size of h = 0.1 to approximate the solution at x = 0.5.

Solution:
Using Euler’s Method, we start with the initial condition y(0) = 1 and iteratively calculate the next
approximation using the formula:
y(i+1) = yi + h * g(xi, yi)

Step 1: At x0 = 0, y0 = 1.
Step 2: At x1 = 0.1, y1 = 1 + 0.1 * (0^2) = 1.000
Step 3: At x2 = 0.2, y2 = 1.000 + 0.1 * (0.1^2) = 1.001
Step 4: At x3 = 0.3, y3 = 1.001 + 0.1 * (0.2^2) = 1.005
Step 5: At x4 = 0.4, y4 = 1.005 + 0.1 * (0.3^2) = 1.014
Step 6: At x5 = 0.5, y5 = 1.014 + 0.1 * (0.4^2) = 1.030

Therefore, the approximation of the solution at x = 0.5 is y ≈ 1.030


Example:
MATLAB Codes
Runge-Kutta Method

Runge-Kutta is a method of numerically integrating ordinary differential


equations with single-step methods — however, with multiple stages per
step. They are motivated by the dependence of the Taylor methods on the
specific IVP. Runge-Kutta methods are among the most popular ODE
solvers. They were first studied by Carle Runge and Martin Kutta around
1900. Modern developments are mostly due to John Butcher in the 1960s.
Runge-Kutta Method

The most commonly used Runge Kutta method to find the


solution of a differential equation is the RK4 method, i.e., the fourth-order
Runge-Kutta method. The Runge-Kutta method provides the approximate
value of y for a given point x. Only the first order ODEs can be solved using
the Runge Kutta RK4 method.
Runge-Kutta Method
Runge-Kutta Method

Example:

Consider the differential equation dy/dx = with the initial conditions x(0)
= 1 and y(0) = 1.2. Find y(1.05) using the Runge-Kutta Method with a
step size of h = 0.05.
Runge-Kutta Method (Example)

Solution: Calculate the values of k1, k2, k3, k4


Runge-Kutta Method (Example)

Solution: Calculate the values of k1, k2, k3, k4


Runge-Kutta Method (Example)

Solution:
Runge-Kutta Method

MATLAB
Example:

Consider the differential equation dy/dx = with the initial conditions: 0 ≤ x ≤ 3,


y(0) = 1 and h = 0.1. Solve for the values of x and y using the Runge-Kutta
Method. Show the graph of the solution.
Runge-Kutta Method

MATLAB
Solution:
Runge-Kutta Method

MATLAB
Solution: x y 1.6000 9.6591
0 1.0000 1.7000 11.0218
0.1000 1.1155 1.8000 12.5489
0.2000 1.2642 1.9000 14.2577
0.3000 1.4496 2.0000 16.1671
0.4000 1.6755
2.1000 18.2985
0.5000 1.9462
0.6000 2.2664 2.2000 20.6750
0.7000 2.6413 2.3000 23.3225
0.8000 3.0766 2.4000 26.2695
0.9000 3.5788 2.5000 29.5474
1.0000 4.1548 2.6000 33.1911
1.1000 4.8125 2.7000 37.2391
1.2000 5.5603 2.8000 41.7338
1.3000 6.4079
1.4000 7.3656
2.9000 46.7223
1.5000 8.4451 3.0000 52.2565
Runge-Kutta Method

MATLAB

Example
Solve and plot
dy = sin x + cos y + sin z, y(0) = 0
dt

dz = cos x + sin z, z(0) = 0


dt
x ϵ [0, 20] with 100 intervals, and h = 0.2. Use a fourth-order Runge-Kutta method and
solve for x, y and z. Show the graph of the solution.
Runge-Kutta Method
MATLAB
Solution:
Runge-Kutta Method
MATLAB
Solution:
Ordinary Differential Equations

Boundary Value Problem


Finite Difference Method

The finite difference method is used to solve ordinary differential


equations that have conditions imposed on the boundary rather than at the
initial point. These problems are called boundary-value problems.
Finite Difference Method
In the finite difference method, the derivatives in the differential equation are
approximated using the finite difference formulas. We can divide the interval of
[a,b] into n equal subintervals of length h as shown in the following figure.
Finite Difference Method
Central difference formulas in the finite difference methods will be used due to the
fact that they yield better accuracy. The differential equation is enforced only at the
grid points, and the first and second derivatives are:
Shooting Method

The shooting method uses the same methods that were used in solving initial
value problems. This is done by assuming initial values that would have been
given if the ordinary differential equation were an initial value problem. The
boundary value obtained is then compared with the actual boundary value. Using
trial and error or some scientific approach, one tries to get as close to the boundary
value as possible.

General Procedure:
1. Convert a BVP into IVP
2. Solve the resulting problem iteratively
Shooting Method
Thank You!

You might also like