Skip to main content

Birge Vieta Method in C Programming

 Birge Vieta Method in C Programming

See & Learn 😉


#include <stdio.h>
#include <math.h>
float p[6], ply[6], q[6];

float synth(int mfloat r)
{
   int i;
   q[0] = p[0];
   for (i = 1i <= mi++)
   {
      q[i] = (q[i - 1] * r) + p[i];
   }

   return (q[m]);
}

void main()
{

   int miflag = 0;
   float rxx1fxfdx;

   printf("\n Enter the highest degree of the equation (max 5): ");
   scanf("%d", &m);
   for (i = 0i <= mi++)
   {
      printf("\n Coefficient x[%d] = "m - i);
      scanf("%f", &p[i]);
      ply[i] = p[i];
   }
   printf("\n Enter the initial value x0 : ");
   scanf("%f", &r);
   x = r;

   do
   {
      printf("\n%f\n"x);
      fx = synth(mx);
      for (i = 0i <= mi++)
      {
         p[i] = q[i];
      }
      fdx = synth(m - 1x);
      x1 = x - (fx / fdx);

      if (fabs(x1 - x) <= 0.0009)
      {
         flag = 1;
      }
      x = x1;

      for (i = 0i <= 5i++)
      {
         p[i] = ply[i];
      }

   } while (flag != 1);

   printf("\nApproximate root = %f"x1);
}

Comments