25 std::function<T(
const T&)> f;
27 T solve_iter(T a, T b, T f_a, T f_b, std::size_t n)
const;
28 T solve_eps(T a, T b, T f_a, T f_b, T eps)
const;
43 a_0(a), b_0(b), f(f) {
58 T solve_iter(std::size_t n)
const;
72 T solve_eps(T eps)
const;
80 throw std::logic_error(
81 " f(a_0) = " + std::to_string(f_a) +
82 " and f(b_0) " + std::to_string(f_b) +
83 " should be of opposite signs. (a_0=" +
84 std::to_string(a_0) +
", b_0=" + std::to_string(b_0) +
")"
86 return solve_iter(a_0, b_0, f_a, f_b, n);
93 T c = (a * f_b - b * f_a) / (f_b - f_a);
100 return solve_iter(a, c, f_a, f_c, n-1);
101 return solve_iter(c, b, f_c, f_b, n-1);
109 throw std::logic_error(
110 "f(a_0) = " + std::to_string(f_a) +
111 " and f(b_0) " + std::to_string(f_b) +
112 " should be of opposite signs. (a_0=" +
113 std::to_string(a_0) +
", b_0=" + std::to_string(b_0) +
")"
115 return solve_eps(a_0, b_0, f_a, f_b, eps);
122 T c = (a * f_b - b * f_a) / (f_b - f_a);
124 if(std::abs(f_c) < eps)
127 return solve_eps(a, c, f_a, f_c, eps);
128 return solve_eps(c, b, f_c, f_b, eps);
Definition regula_falsi.h:20
RegulaFalsi(T a, T b, std::function< T(const T &)> f)
Definition regula_falsi.h:42
Definition chemmisol.h:31