Posts

Showing posts from April, 2019

Gauss Jordon Forward Interpolation Formula Using C programming

Gauss Jordon Forward Interpolation Formula Using C programming : #include<stdio.h> #include<conio.h> int main() {     int n,i,j,k;     printf("Enter the Number of Equations");     scanf("%d",&n);     float a[n][2*n],c;     for(i=1;i<=n;i++)     {          for(j=1;j<=2*n;j++)          {              if(j<=n)              {                  printf("Enter the x[%d][%d] : ",i,j);                  scanf("%f",&a[i][j]);              }                  else if(j>n&&(j-n==i))                     a[i][j]=1;         ...
Lagrange's Interpolation Formula : #include<stdio.h> int main() {     int i,j,n,o;     printf("Enter the value of n");     scanf("%d",&n);     float x[n],y[n],u,d,w,r;     for(i=0;i<n;i++)         {     printf("Enter the value of x[%d]",i);          scanf("%f",&x[i]);         }         for(i=0;i<n;i++)         {     printf("Enter the value of y[%d]",i);          scanf("%f",&y[i]);         }     r=0;     printf("Enter the number whose approximate value you want");     scanf("%f",&w);     for(i=0;i<n;i++)     {         u=d=1;         for(j=0;j<n;j++)         {           ...

Newton Backward Interpolation Formula

Newton Backward Interpolation Formula : #include<stdio.h> int main() {     int n,i,j;     printf("Enter the value of Number of inputs");     scanf("%d",&n);     float x[n],y[n][n],a; for(i=1;i<=n;i++)      {         printf("Enter the value of x[%d] : ",i);         scanf("%f",&x[i]);      } for(i=1;i<=n;i++)     {         printf("Enter the value of y[%d] : ",i);         scanf("%f",&y[i][1]);     } printf("Enter the value of X whose approximate value you want");     scanf("%f",&a);       int pc;       pc=n; for(i=2;i<=pc;i++)       {     for(j=1;j<n;j++)           {               y[j][i]=y[j+1][i-1]-y[j][i-1];       ...

Newton Forward Interpolation Method

Newton Forward Interpolation Method : #include<stdio.h> int main() {     int n,i,j;     printf("Enter the value of Number of inputs");     scanf("%d",&n);     float x[n],y[n][n],a; for(i=1;i<=n;i++)      {         printf("Enter the value of x[%d] : ",i);         scanf("%f",&x[i]);      } for(i=1;i<=n;i++)     {         printf("Enter the value of y[%d] : ",i);         scanf("%f",&y[i][1]);     } printf("Enter the value of X whose approximate value you want");     scanf("%f",&a);       int pc;       pc=n; for(i=2;i<=pc;i++)       {     for(j=1;j<n;j++)           {               y[j][i]=y[j+1][i-1]-y[j][i-1];         ...

Newton Raphson Method usng C Programming

Newton Raphson Method usng C Programming: #include<stdio.h> #include<math.h> #define e 0.001 #define f(x)  (x*x*x*x-x-10) #define df(x) (4*x*x*x-1) int main() {     int i;     float x0,x1,f1;     i=0;     printf("Enter the value of x0");     scanf("%f",&x0);     do     {         x1=x0-((f(x0))/(df(x0)));         f1=f(x1);         x0=x1;         i++;         printf("The Number of Iteration is %d and Value of Function is %f and value of x is %f\n",i,f1,x0);     }     while(fabs(f1)>e);     return 0; }
Regular Falsi Method Using C Programming: #include<stdio.h> #include<math.h> #define f(x) (2*x-(log(x)/log(10))-7) int main() {     float a,b,xn,x;     int i,p;     printf("Enter the value of A and B");     scanf("%f %f",&a,&b);     printf("Enter the Number of Iteration");     scanf("%d",&p);     for(i=1;i<=p;i++)     {      xn=((a*f(b))-(b*f(a)))/(f(b)-f(a));     printf("\nOutput is : %f ",xn);     if(f(a)>0)     {        if(f(xn)>0)             {a=xn;             b=b;}        else             {b=xn;             a=a;}     }      if(f(a)<0)     {        if(f(xn)<0)     ...
Image
C Programming For Runge Kutta Method: #include<stdio.h> #define f(x,y) ((x)+(y*y)) int main() {     int n,i;     float x0,y0,h,k1,k2,k3,k4,k;     printf("Enter the value of x0,y0 and h");     scanf("%f",&x0);     scanf("%f",&y0);     scanf("%f",&h);     printf("Enter the Number of Iteration");     scanf("%d",&n);     for(i=0;i<n;i++)     {    {                k1=h*(f(x0,y0));                k2=h*(f(x0+h/2,y0+k1/2));                k3=h*(f(x0+h/2,y0+k2/2));                k4=h*(f(x0+h,y0+k3));                k=(k1+2*k2+2*k3+k4)/6;                printf("The Output is %f",y0+k);     }...
Image
The Simpson’s 3/8 th  rule was developed by a mathematician named Thomas Simpson. Integration is the process of measuring the area under a function plotted on a graph. The Simpson’s 3/8 th  rule is used in complex numerical integrations. This integration method uses parabolas to approximate each part of the curve. It is basically used to measure an area in a curve. The Simpson’s 3/8th method is used for uniformly sampled function integration purpose. The Simpson’s 3/8 th  integration method is primarily used for numerical approximation of definite integrals. Simpson’s Rule Formula C programming For simpson 3/8th rule : #include<stdio.h> int main() {     int n,i,j;     printf("Enter the total Number of Input You want");     scanf("%d",&n);     float x[n],y[n],h,sum3,sumr;     sum3=sumr=0;     for(i=0;i<n;i++)     {         printf("Enter the value of X[%d] : ...

Simpson 1/3rd Rule using C programming

Image
The Simpson’s 1/3 rd  integration method is primarily used for numerical approximation of definite integrals. This specifically means that Simpson’s integration rule is used in complex integration calculations. It is a method to approximately calculate the definite integral. The Simpson’s theorem is used to find the area under a given curve. The Simpson’s method corresponds to the  3-point Newton-Cotes quadrature  rule as well. The Simpson’s integration method is a little time consuming compared to other methods in numerical analysis and is also a little difficult to implement computationally. Simpson’s Rule Formula                   C Programming For Simpson 1/3rd Rule : #include<stdio.h> int main() {     int n,i,j;     printf("Enter the total Number of Input You want");     scanf("%d",&n);     float x[n],y[n],h,sume,sumo;...
Image
Trapezoidal Rule using C programming : In mathematics, the trapezoid rule is a numerical integration method, that is, a method to calculate approximately the value of the definite integral. The Formula is :                      = =h/2[(y0+yn)+2*(y1+y2+y3+y4+......+yn-1)] or  h/2[(X)+2*R]; Where X =y0+y1            R= y1+y2+y3+........................yn-1 Trapezoidal Rule using C programming : #include<stdio.h> int main() {     int n,i,j;     printf("Enter the total Number of Input You want");     scanf("%d",&n);     float x[n],y[n],h,sum;     sum=0;     for(i=0;i<n;i++)     {         printf("Enter the value of X[%d] : ",i);         scanf("%f",&x[i]);     }     for(i=0;i<n;i++)     {...