|
Algorithms_in_C++
1.0.0
Set of algorithms implemented in C++.
|
Solve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions. More...
#include <cmath>#include <ctime>#include <iostream>#include <limits>Macros | |
| #define | EPSILON 1e-6 |
| #define | MAX_ITERATIONS 50000 |
| Maximum number of iterations to check. | |
Functions | |
| static double | eq (double i) |
| static double | eq_der (double i) |
| int | main () |
Solve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions.
The \((i+1)^\text{th}\) approximation is given by:
\[ x_{i+1} = x_i - \frac{f(x_i)}{f'(x_i)} \]
|
static |
define \(f(x)\) to find root for
|
static |
define the derivative function \(f'(x)\)
| int main | ( | ) |
Main function