Consider Newton-Raphson's algorithm to calculate the roots of the equation f (x) = 0 with (0.5, 1, 2, 3.4556) for each initial x.
f (X) = X ^ 4-12X ^ 3 + 47x ^ 2-60X I made the code equal to the algorithm, but it is not finding the roots, can anyone help me?
#include <stdio.h>
float Abs( float x ){
return x>=0? x:-x;
};
int main(){
float xini = 0, xnovo , Fxnovo, Fdxnovo , E ;
int k = 0;
printf( "Digite o x inicial: " );
scanf( "%f", &xnovo );
printf( "Digite a precisao: " );
scanf( "%f", &E );
do{
xini = xnovo;
Fxnovo = ( xini * xini * xini * xini ) - 12 * (xini * xini * xini) + 47*(xini * xini) - 60 * xini; //inserir sua função principal aqui
Fdxnovo = 4. * ( xini * xini * xini) - 36. * (xini * xini ) + 94 * xini - 60; //inserir a derivada da função principal aqui
xnovo = xini - ( Fxnovo / Fdxnovo );
k += 1;
printf( "\niteracao = %d", k );
printf( "\nxini = %f\nxnovo = %f", xini, xnovo, Fxnovo, Fdxnovo );
} while(Abs(Fxnovo) > E);
printf( "\n\nxnovo - xini = %f\n", xnovo -(xini) );
printf( "A solucao final e: %f\n", xnovo );
return 0;
}