Showing posts with label newton raphson method in c. Show all posts
Showing posts with label newton raphson method in c. Show all posts

Saturday, May 18, 2013

Newton-Raphson Method in C with source codes

Newton-Raphson method is a method for finding successively better roots (zeros) of a real valued function
x: f(x) = 0.

The algorithm can be implemented in C as follows:


#include<stdio.h>
#include<math.h>
#include<conio.h>
#define h pow(10,-6)
#define error pow(10,-6)
double f(double x)
{
 return(x*x-4);
}
double df(double x)
{
 return 2*x;
}