halleysMethod
-
constexpr Complex halleysMethod(Complex (*f)(Complex), const Complex &z0, const double alpha, const int epochs) noexcept
Performs the Halley’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{2f(z_k)f'(z_k)}{2[f'(z_k)]^2 - f(x_k)f''(z_k)}\]
Example
auto fn = [](Complex z) { return sin(z); };
Complex z = halleysMethod(fn, 0.1, 1000);
std::cout << z << "\n";
std::cout << sin(z) << "\n";
Output:
0 + 0j
0 + 0j
References