You are on page 1of 2

Date : 21/06/2021

<<< Double Root by NEWTON RAPHSON Method >>>


Roll Number : SH-157
• Statement of the problem :
Write a C program to compute a real double root of the following equation
correct up to five decimal places, by modified Newton Raphson method.
𝑥 3 − 5𝑥 2 + 8𝑥 − 4 = 0
• Solution:
#include<stdio.h>
#include<math.h>
#define m 2
float f(float x);
float f1(float x);
main()
{
float x,h,error=1e-7;
printf("Enter the initial value\n");
scanf("%f",&x);
h=-m*f(x)/f1(x);
while(fabs(h)>error)
{
x=x+h;
h=-m*f(x)/f1(x);
}
printf("Root=%.5f(correct up to five decimal places)",x);
}
float f(float x)
{
float y;
y=pow(x,3)-5*pow(x,2)+8*x-4;
return(y);
}
float f1(float x)
{
float y;
y=3*pow(x,2)-10*x+8;
return(y);
}

OUTPUT:

You might also like