0% found this document useful (0 votes)
39 views2 pages

Komputasi Ryan Agatha

This document contains source code implementing the Newton-Raphson method to find the root of a polynomial equation. It prompts the user to input the polynomial order and coefficients, an initial guess, and iterates using the Newton-Raphson formula until convergence within 0.0001 is reached. It outputs the iteration count, estimates, function values, derivatives and errors at each step before concluding with the final root.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Komputasi Ryan Agatha

This document contains source code implementing the Newton-Raphson method to find the root of a polynomial equation. It prompts the user to input the polynomial order and coefficients, an initial guess, and iterates using the Newton-Raphson formula until convergence within 0.0001 is reached. It outputs the iteration count, estimates, function values, derivatives and errors at each step before concluding with the final root.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Komputasi

Newton-Raphson Methods
Nama: Ryan Agatha
NIM:37903
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int n,i=0,cnt=0,flag=0,d[10]={0};
float x1=0,x2=0,t=0,fx1=0,fdx1=0;
int main()
{
printf("===========PROGRAM NEWTON_RAPHSON METHOD============\n");
printf("\n\n\npolinom pangkat: ");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
printf("\n\t x^%d::",i);
scanf("%d",&d[i]);
}
printf("\n");
printf("\nPolinom:");
for(i=n;i>=0;i--)
{
printf(" %dx^%d",d[i],i);
}
printf("\n\tNilai terkaan=");
scanf("%f",&x1);
printf("\n perulangan X1 FX1
do
{
cnt++;
fx1=fdx1=0;
for(i=n;i>=1;i--)
{
fx1+=d[i] * (pow(x1,i)) ;
}

F'X1

ERROR");

fx1+=d[0];
for(i=n;i>=0;i--)
{
fdx1+=d[i]* (i*pow(x1,(i-1)));
}
t=x2;
x2=(x1-(fx1/fdx1));
x1=x2;
printf("\n %d

%.3f %.3f %.3f %.3f",cnt,x2,fx1,fdx1, fabs(t - x1));

}while((fabs(t - x1))>=0.0001);
printf("\n\t Akar persamaan = %f",x2);
getch();
}

You might also like