Birge–Vieta Method

Source Code:

Write a program in C to find one root of the polynomial x³ − 𝟔x² + 𝟏𝟏x − 𝟔 = 𝟎 using the Birge–Vieta Method.

#include <stdio.h>
#include <conio.h>
double f(double x){ return x*x*x - x - 2; }
double df(double x){ return 3*x*x - 1; }
int main(){
clrscr();
 double a[4]={1,-6,11,-6}, b[4], c[4], x=1.5, dx;
 for(int k=0;k<20;k++){
 b[0]=a[0];
 b[1]=a[1]+b[0]*x;
 b[2]=a[2]+b[1]*x;
 b[3]=a[3]+b[2]*x;
 c[0]=b[0];
 c[1]=b[1]+c[0]*x;
 c[2]=b[2]+c[1]*x;
 dx=b[3]/c[2];
 x=x-dx;
 if(dx<0? -dx: dx<1e-6) break;
 }
 printf("\n\n\tRoot : %.4f\n",x);
 getch();
 return 0;
}

Output