Algorithms_in_C  1.0.0
Set of algorithms implemented in C.
newton_raphson_root.c File Reference

Find approximate solution for \(f(x) = 0\) using Newton-Raphson interpolation algorithm. More...

#include <complex.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Include dependency graph for newton_raphson_root.c:

Macros

#define ACCURACY   1e-10
 solution accuracy
 

Functions

double complex func (double complex x)
 Return value of the function to find the root for. More...
 
double complex d_func (double complex x)
 Return first order derivative of the function. More...
 
int main (int argc, char **argv)
 main function
 

Detailed Description

Find approximate solution for \(f(x) = 0\) using Newton-Raphson interpolation algorithm.

Author
Krishna Vedala

Function Documentation

◆ d_func()

double complex d_func ( double complex  x)

Return first order derivative of the function.

\(f'(x)\)

32 { return 2. * x; }

◆ func()

double complex func ( double complex  x)

Return value of the function to find the root for.

\(f(x)\)

23 {
24  return x * x - 3.; /* x^2 = 3 - solution is sqrt(3) */
25  // return x * x - 2.; /* x^2 = 2 - solution is sqrt(2) */
26 }