newtonsMethod
-
constexpr Complex newtonsMethod(Complex (*f)(Complex), const Complex &z0, const double alpha, const int epochs) noexcept
Performs the Newton’s method algortihm on a complex function.
Parameters
Returns
- type Complex
A complex number.
This function root-finds the given complex function \(f\) using the following update rule:
\[z_{k+1} = z_k - \frac{f(z_k)}{f'(z_k)}\]
Example
auto fn = [](Complex z) { return sin(z); };
Complex z = newtonsMethod(fn, 0.1, 1000);
std::cout << z << "\n";
std::cout << sin(z) << "\n";
Output:
0 + 0j
0 + 0j
References