TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Solve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions. More...
#include <cmath>
#include <cstdint>
#include <ctime>
#include <iostream>
#include <limits>
Go to the source code of this file.
Functions | |
static double | eq (double i) |
static double | eq_der (double i) |
int | main () |
Variables | |
constexpr double | EPSILON = 1e-10 |
system accuracy limit | |
constexpr int16_t | MAX_ITERATIONS = INT16_MAX |
Maximum number of iterations. | |
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)} \]
Definition in file newton_raphson_method.cpp.
|
static |
define \(f(x)\) to find root for. Currently defined as:
\[ f(x) = x^3 - 4x - 9 \]
Definition at line 30 of file newton_raphson_method.cpp.
|
static |
define the derivative function \(f'(x)\) For the current problem, it is:
\[ f'(x) = 3x^2 - 4 \]
Definition at line 40 of file newton_raphson_method.cpp.
int main | ( | void | ) |
Main function
Definition at line 45 of file newton_raphson_method.cpp.
|
constexpr |
system accuracy limit
Definition at line 21 of file newton_raphson_method.cpp.
|
constexpr |
Maximum number of iterations.
Definition at line 22 of file newton_raphson_method.cpp.