0% found this document useful (0 votes)
0 views

Runga Kutta Method of Order 4 Ks

This document contains a C program that implements the fourth-order Runge-Kutta method for solving ordinary differential equations. It prompts the user for initial values and computes the solution iteratively, displaying the results for each step. The program defines a function F(x, y) and uses it to calculate intermediate values k1, k2, k3, and k4 to update the solution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Runga Kutta Method of Order 4 Ks

This document contains a C program that implements the fourth-order Runge-Kutta method for solving ordinary differential equations. It prompts the user for initial values and computes the solution iteratively, displaying the results for each step. The program defines a function F(x, y) and uses it to calculate intermediate values k1, k2, k3, and k4 to update the solution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

//RUNGA KUTTA METHOD OF ORDER 4

#include<stdio.h>
#include<math.h>
#define F(x,y) (y-x)
main()
{
int i,n;
float x0,y0,k1,k2,k3,k4,h,xn,x,y,k;
printf("give the values of x0,y0,xn and n");
scanf("%f,%f,%f,%d",&x0,&y0,&xn,&n);
h=(xn-x0)/n;
x=x0;
y=y0;
for(i=0;i<=n;i++)
{
k1=h*F(x,y);
k2=h*F(x+(h/2.0),y+(k1/2.0));
k3=h*F(x+(h/2.0),y+(k2/2.0));
k4=h*F(x+h,y+k3);
k=(1/6.0)*(k1+2*k2+2*k3+k4);
printf("\n x=%f \t y=%f",x,y);
x=x+h;
y=y+k;
}
}

KALPATARU SAHOO
PHYS24-025

You might also like