#include<stdio.h>
#include<math.h>
main()
{
float f0,g0,h0,p0,t0,ti,gi,xn,pr,k1f,k2f,k3f,k4f; // declaration of the variables
float k1g,k2g,k3g,k4g,k1h,k2h,k3h,k4h,k1t,k2t,k3t,k4t;
float k1p,k2p,k3p,k4p,fnew,gnew,hnew,tnew,pnew,f,g,h,p,t,disp,i;
f0=0.0;g0=0.0;gi=1.0;
xn=8.0;disp=0.1;pr=1.0; //initialization, these are intial conditions, disp is the step size
// xn is the point at which values of f,g,h,t,p are to be found, it shud be 8
t0=1.0;ti=0.0;
h0=0.6421;p0=-0.5671;
printf("eta f g h t p \n"); // sequence of printing..
f=f0;g=g0;h=h0;t=t0;p=p0;
for(i=0;i<xn;i=i+disp)
{
k1f=disp*g;
k1g=disp*h; // runge kutta 4th order method is used
k1t=disp*p;
k1p=disp*(0.75*f*p);
k1h=disp*((t)-(g*g/2.0*pr)+(3.0*f*h/4.0*pr));
k2f=disp*(g+k1g/2.0);
k2g=disp*(h+k1h/2.0);
k2t=disp*(p+k1p/2.0);
k2p=disp*(0.75*(f+k1f/2.0)*(p+k1p/2.0));
k2h=disp*((t+k1t/2.0)-((g+k1g/2.0)*(g+k1g/2.0)/2.0*pr)+(3.0*(f+k1f/2.0)*(h+k1h/2.0)/4.0*pr));
k3f=disp*(g+k2g/2.0);
k3g=disp*(h+k2h/2.0);
k3t=disp*(p+k2p/2.0);
k3p=disp*(0.75*(f+k2f/2.0)*(p+k2p/2.0));
k3h=disp*((t+k2t/2.0)-((g+k2g/2.0)*(g+k2g/2.0)/2.0*pr)+(3.0*(f+k2f/2.0)*(h+k2h/2.0)/4.0*pr));
k4f=disp*(g+k3g);
k4g=disp*(h+k3h);
k4t=disp*(p+k3p);
k4p=disp*(0.75*(f+k3f)*(p+k3p));
k4h=disp*((t+k3t)-((g+k3g)*(g+k3g)/2.0*pr)+(3.0*(f+k3f)*(h+k3h)/4.0*pr));
fnew=f+(k1f+(2.0*k2f)+(2.0*k3f)+k4f)/6.0;
gnew=g+(k1g+(2.0*k2g)+(2.0*k3g)+k4g)/6.0;
tnew=t+(k1t+(2.0*k2t)+(2.0*k3t)+k4t)/6.0; // finding value at next disp point..so this formula is to be used
pnew=p+(k1p+(2.0*k2p)+(2.0*k3p)+k4p)/6.0;
hnew=h+(k1h+(2.0*k2h)+(2.0*k3h)+k4h)/6.0;
printf("%f %f %f %f %f %f \n",i+disp,fnew,gnew,hnew,tnew,pnew);
f=fnew;g=gnew;h=hnew,t=tnew;p=pnew; // assigning the new value so tat it is used for integration in next step
}
}