Presentation is loading. Please wait.

Presentation is loading. Please wait.

Numerical Calculations Part 5: Solving differential equations

Similar presentations


Presentation on theme: "Numerical Calculations Part 5: Solving differential equations"— Presentation transcript:

1 Numerical Calculations Part 5: Solving differential equations
Dr.Entesar Ganash

2 First order differential equation
The general first order differential equation is Initial condition Is given Example:

3 Rung-Kutta fourth-order formulae
There are a variety of alogorithms, under the general name of Runge-Kutta. This can be used to integrate systems of ordinary differential equations In the first order differential equation: First, Let us see this The fourth- order Runge-Kutta estimate at is given by where

4 Second order differential equation
The general second order differential equation is Initial conditions are given Example:

5 Rung-Kutta fourth-order formulae
In the second order, we have where

6 Example Write a program to solve the following differential equation in when use n=30 Solving program RKM implicit none integer::n,i ! No of parts, counter real ::y,dy,x,xn,h,exact real ::k1,k2,k3,k4 n=30 x=0.0 y=0.0 dy=1.0 xn=1.0 h=(xn-x)/n Exact=sin(x) print*,' ' print*,' x', ' y', ' dy',' Exact' print*, x,y,dy,Exact

7 continue Solving DO I=1,n k1=h*f (x,y,dy)
k2=h*f(x+h/2,y+h*dy/2+h*k1/8,dy+k1/2) k3=h*f(x+h/2,y+h*dy/2+h*k1/8,dy+k2/2) k4=h*f(x+h, y+h*dy+h*k3/2, dy+k3) x=x+h Exact=sin(x) y=y+h*(dy+(k1+k2+k3)/6) dy=dy+(k1+2.0*k2+2.0*k3+k4)/6 print*, x,y,dy,exact End do print*,' ' CONTAINS REAL Function f(p,q,u) Real ::f, p,q,u f=-q End function f End program RKM continue Solving

8 The result:

9 References Hahn, B.D., 1994, Fortran 90 For Scientists and Engineers, Elsevier


Download ppt "Numerical Calculations Part 5: Solving differential equations"

Similar presentations


Ads by Google