Professional Documents
Culture Documents
Envi-Modeling-Lecture-Finals-1
Envi-Modeling-Lecture-Finals-1
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.
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
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
Solution:
Using Euler’s Method, we start with the initial condition y(0) = 1 and iteratively calculate the next
approximation using the formula:
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
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
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
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:
Runge-Kutta Method
MATLAB
Example:
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
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!