21 double f(
const double x)
23 return sin(x) - 0.5 * x ;
32 double g(
const double x)
34 return -(x - 1.234567) * (x + 0.987654) ;
52 double Bisect3(
const std::function<
double(
double)>& func,
53 const double a,
const double b,
const double eps = 1e-6);
63 double eval(vector<double>
const &
a,
double x);
68 const double EPS = 1e-6;
71 cout <<
" Determine point of zero in [a,b] by bisection " << endl;
74 cout <<
"f(a) > 0, a : ";
76 cout <<
"f(b) < 0, b : ";
88 vector<double> koeff{-6.0, 1.0 , 1.0};
90 double x0 =
Bisect3([&koeff](
const double x){
return eval(koeff,x);},
94 cout << endl <<
" point of zero = " << x0 << endl;
105 double Bisect3(
const std::function<
double(
double)>& func,
const double a,
const double b,
109 double c = (
a +
b) / 2;
112 if ( std::abs(fc) < eps ) {
115 else if ( fc > 0.0 ) {
127 double eval(vector<double>
const &
a,
double x)
131 for (
size_t k=1; k<
a.size(); ++k)
double Bisect3(const std::function< double(double)> &func, const double a, const double b, const double eps=1e-6)
Returns one solution for the equation with .
double f(const double x)
Calculates function .
double eval(vector< double > const &a, double x)
Evaluates the polynom at point x.
double g(const double x)
Calculates function .