secantMethod
-
constexpr Complex secantMethod(Complex (*f)(Complex), const Complex &z0, const double alpha, const int epochs) noexcept
Performs the secant 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 - f(z_k)\frac{z_k - z_{k - 1}}{f(z_k) - f(z_{k - 1})}\]
Example
auto fn = [](Complex z) { return sin(z); };
Complex z = secantMethod(fn, 0.1, 0.05, 1000);
std::cout << z << "\n";
std::cout << sin(z) << "\n";
Output:
-4.94066e-323 + 0j
-4.94066e-323 + 0j
References