pms file doc

Post on 29-Sep-2015

226 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

PMS

TRANSCRIPT

Experiment No. 1

Solving differential equation by Runge-Kutta method

Objective:

To simulate a program for solving differential equations by using Runge-Kutta method.

dy/dx=x+y at y(0)=1

Find y at x=1 with h=0.1

Theory:

Runge-Kutta method does not require calculation of higher order derivatives & give greater accuracy. It possess the advantage of requiring only the function values at some selected points

Formula used:

Working rules for finding the increment k of y corresponding to an increment h of x by Runge-Kutta method from

dy/dx=f(x,y), y(x0)=y0 then

k1=hf(x0,y0)

k2=hf(x0+(0.5*h),y0+(0.5*k1))

k3=hf(x0+(0.5*h),y0+(0.5*k2))

k4=hf(x0+h,y0+k3)

Final compute k=(k1+(2*k2)+(2*k3)+k4)/6

which gives required approximate value as y1=y0+k;

Equation used:

We have dy/dx=x+y

Condition:

Initial condition is x=0 and y=0 & final condition is that we have to find the value of y at x=1.

Program

/*Runge Kutta Method*/

#include

#include

float f(float x, float y)

{

return x+y*y;

}

Int main()

{

float x0, y0,h,xn,x,y,k1,k2,k3,k4,k;

cout > y0 >>h >> xn;

x=x0; y=y0;

cout delta;

clrscr();

cout k >> tau >> delta;

clrscr();

cout

top related