27 template<
class function_t,
class derivative_function_t>
29 const function_t& func,
30 const derivative_function_t& derivativeFunc,
32 double fMaxError = 0.0001,
33 size_t nMaxIterations = 10000)
35 double x = fInitialGuess;
37 for (
size_t i = 0; i < nMaxIterations; i++)
39 const double y = func(x);
41 if (std::abs(y) < fMaxError)
44 x -= y / derivativeFunc(x);
double newtons_method(const function_t &func, const derivative_function_t &derivativeFunc, double fInitialGuess, double fMaxError=0.0001, size_t nMaxIterations=10000)
Find root of the equation using Newtons method.