0% found this document useful (0 votes)
94 views37 pages

6.7. Ordinary Differential Equation (Ode) and PDE

This document provides an introduction to ordinary differential equations (ODEs) and partial differential equations (PDEs). It discusses various methods for solving ODEs, including Euler's method, Runge-Kutta methods, and boundary value problems. It also covers classifications of PDEs as elliptic, parabolic, or hyperbolic based on the coefficients. Examples are given to illustrate the different solution methods and PDE classifications.

Uploaded by

Eyu Kaleb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views37 pages

6.7. Ordinary Differential Equation (Ode) and PDE

This document provides an introduction to ordinary differential equations (ODEs) and partial differential equations (PDEs). It discusses various methods for solving ODEs, including Euler's method, Runge-Kutta methods, and boundary value problems. It also covers classifications of PDEs as elliptic, parabolic, or hyperbolic based on the coefficients. Examples are given to illustrate the different solution methods and PDE classifications.

Uploaded by

Eyu Kaleb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Introduction to Numerical

Ordinary Differential Equation and


partial differential equations

Compiled by:
Habtamu G.
Ordinary Differential Equation
(ODE)
Ordinary Differential Equations can be
solved using:
- Euler s Method
- Improvements of Euler's Method
- Runge-Kutta Methods
- General Methods for Boundary-Value Problems
and Derivative Boundary Conditions.
This chapter is developed
to solve ODE on the form:

dy
= g(x, y)
dx
A. Euler’s Methods
It is based on the low-order Taylor series:
y

y i+1 = y i + f (x i , y i )h
h

where f (x i , y i ) =  = y'(x i , y i ) = slope
x
xi x i+1
h = xi+1 − xi = stepsize

Euler’s (or Euler-Cauchy or point-slope) Method

A new value of y is predicted using the slope to extrapolate linearly over h


Example: Solve the following initial-value problem
analytically and numerically using Euler’s method
over the interval from x=0 to 2 with step size of
h=0.5, given the initial condition y(0)=1.
dy
− yx 2 + 1.1y = 0
dx
Solution:
Analytically:

 y =  (x 2 − 1.1)dx
dy dy dy
dy
− yx + 1.1y = 0
2 = yx 2
− 1.1y = x 2
− 1.1
dx dx y
x3 x3
− 1.1x+c
x3
Ln(y) = − 1.1x + c y=e3 = c 1e 3
−1.1x
3
From the initial condition y(0)=1 c1 = 1
Numerically:
y i+1 = y i + f (x i , y i )h
dy
= yx 2 − 1.1y
dx
Initial condition y(0)=1 0 0.5 1.5

y(0.5) = y(0) + f (0,1)(0.5) = 1 + (−1.1)(0.5) = 0.45


f (0,1) = 1(0) 2 − 1.1(1) = −1.1
y(1) = y(0.5) + f (0.5,0.45)(0.5) = 0.45 + (−0.3825)(0.5) = 0.25875
f (0.5,0.45) = 0.45(0.5)2 − 1.1(0.45) = −0.3825
y(1.5) = y(1) + f (1,0.25875)(0.5) = 0.25875 + (−0.02588)(0.5) = 0.245813

f (1,0.25875) = 0.25875(1) 2 − 1.1(0.25875) = −0.02588


y(2) = y(1.5) + f (1.5,0.245813)(0.5) = 0.25875 + (0.282684)(0.5) = 0.387155
f (1.5,0.245813) = 0.245813(1.5)2 − 1.1(0.245813) = 0.282684
x y f(xi,yi)=dy/dx
0 1 ‐1.1
0.5 0.45 ‐0.3825
1 0.25875 ‐0.02588
1.5 0.245813 0.282684
2 0.387155 1.122749
Exercise: Use Euler’s method to solve the
following equation from t=0 to 4 using h=0.1
d2y
− 0.5t + y = 0 y(0) = 2 y'(0) = 0
2
dt
Solution:
Needed to change to a System of
dy y(0) = 2
=z Equations and need initial
dt
condition for each equation
dz dy
= 0.5t − y z(0) = (0) = 0
dt dt
Single: y i+1 = y i + f (x i , y i )h
Euler’s method
for single can be
y i+1 = y i + f1 (t i , y i , z i )h
extended to the
system: z i+1 = z i + f 2 (t i , y i , z i )h
y(0.1) = y(0) + f1 (0,2,0)0.1 = 2 + 0(0.1) = 2
z(0.1) = z(0) + f 2 (0,2,0)0.1 = 0 + (−2)(0.1) = −0.2
y(0.2) = y(0.1) + f1 (0.1,2,−0.2)0.1 = 2 + (−0.2)(0.1) = 1.98

z(0.2) = z(0.1) + f 2 (0.1,2,−0.2)0.1 = −0.2 + (−1.95)(0.1) = −0.395

And so on…
t y z f1 f2
0 2 0 0 ‐2
0.1 2 ‐0.2 ‐0.2 ‐1.95
0.2 1.98 ‐0.395 ‐0.395 ‐1.88
0.3 1.9405 ‐0.583 ‐0.583 ‐1.7905
0.4 1.8822 ‐0.76205 ‐0.76205 ‐1.6822
0.5 1.805995 ‐0.93027 ‐0.93027 ‐1.556
.
.
.
4
Improvements of Euler’s Methods

(1) Heun’s Method

(2) Midpoint (or improved polygon) Method


a. Heun’s Method
This is simple modification of Euler’s
method.
Technique: One slope at initial point and
the other at the end point, then the two
derivatives are then averaged for the
entire interval
Example: Solve the following equation using Heun’s
method for the interval from x=0 to x=4 with h=1. Initial
condition y(0)=2. 0.8x
y'= 4e − 0.5y
x yHuen
0 2
1 6.701082

2 16.31978

3 37.19924

4 83.3377
b. The Midpoint Method (or Improved Polygon
Method)
This is another simple modification of Euler’s
method.
Technique: use Euler’s method to predict a
value of y at the midpoint of the interval.
Example: Solve the following equation using the midpoint
method with a step size of 0.5 and x=[0 2].

Solution:
B. Runge-Kutta Methods (Reading
assignment)
Runge‐Kutta (RK) methods achieve the accuracy of a Taylor
series without requiring the calculation of higher derivatives
The general form: y i+1 = y i + (x i , y i ,h)h
(xi , y i , h) =increment function which represent the slope over the interval
The general form of :  = a1k 1 + a 2k 2 + ... + a n k n
k 1 = f (x i , y i )
k 2 = f (x i + p 1h, y i + q 11k 1h)
k 3 = f (x i + p 2h, y i + q 21k 1h + q 22k 2h)
.
.
.

k n = f (x i + p n−1h, y i + qn−1,1k1h + q n−1,2k 2h + ...qn−1,n−1kn−1h)

a’s, p’s, and q’s are constants


n: represents the order of the approach

n=1: 1st order RK, O(h)


n=2: 2nd order RK, O(h2)
n=3: 3rd order RK, O(h3)
n=4: 4th order RK, O(h4)
Introduction to Partial
Differential Equations
What is a Partial Differential
Equation ?
Ordinary Differential Equations have only one independent
variable
dy
3 + 5 y 2 = 3e − x , y (0) = 5
dx
Partial Differential Equations have more than one independent
variable
 u  u
2 2
3 2 + 2 =x +y
2 2

x y
subject to certain conditions: where u is the dependent variable,
and x and y are the independent variables.
Classification of 2nd Order Linear PDE’s

 u
2
 u 2
 u 2
A 2 +B +C 2 + D = 0
x xy y

can be:
• Elliptic B − 4 AC  0
2

• Parabolic B − 4 AC = 0
2

• Hyperbolic B − 4 AC  0
2
Classification of 2nd Order Linear PDE’s: Elliptic
 T  T
2 2
Example: + 2 =0
x 2
y
where, A = 1, B = 0, C = 1 giving B − 4 AC = 0 − 4(1)(1) = −4  0
2

therefore the equation is elliptic.


Classification of 2nd Order Linear PDE’s: Parabolic

T  T 2

Example: =k 2
t x
where, A = k , B = 0, C = 0 giving B 2 − 4 AC = 0 − 4(0)(k ) = 0

therefore the equation is parabolic.


Classification of 2nd Order Linear PDE’s: Hyperbolic

 2
y 1  2
y
Example: = 2 2
x 2
c t
−1 4
where, A = 1, B = 0, C = − 1 giving B − 4 AC = 0 − 4(1)( 2 ) = 2  0
2

c2 c c

therefore the equation is hyperbolic.

You might also like