Wednesday 23 April 2014

Program to find the solution of the equation using Runge-Kutta fourth order Method

#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
float x1,y1,x2,y2,xf,h,s,s1,s2,s3,s4;
//clrscr();
printf("enter the initial points :\n");
scanf("%f%f",&x1,&y1);
printf("enter the final points :\n");
scanf("%f",&xf);
printf("enter the step size :\n");
scanf("%f",&h);
//printline();
printf("X\t\tY\n");
//printline();
printf("%.2f\t\t%.2f\n",x1,y1);
while(x1<=xf)
{
  s1=1-(x1*x1*x1);
  x2=x1+(h/2);
  y2=y1+(s1*(h/2));
  s2=1-(x1*x1*x1);
  y2=y1+(s2*(h/2));
  s3=1-(x1*x1*x1);
  x2=x1+h;
  y2=y1+(s3*h);
  s4=1-(x1*x1*x1);
  s=(s1+2*s2+2*s3+s4)/6;
  y2=y1+h*s;
  x1=x2;
  y1=y2;
  printf("%.2f\t\t%.2f\n",x1,y1);
}


getch();}

No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2022