Sequence of Bisect implementations
Bisect3_lambda.cpp File Reference
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>
Include dependency graph for Bisect3_lambda.cpp:

Go to the source code of this file.

Functions

double f (const double x)
 Calculates function \( f(x) = \sin(x) - \frac{x}{2} \). More...
 
double g (const double x)
 Calculates function \( f(x) = -(x-1.234567)*(x+0.987654) \). More...
 
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 \( func(x) = 0 \) with \( x \in [a,b] \). More...
 
double eval (vector< double > const &a, double x)
 Evaluates the polynom \( p(x) := a_n x^n + a_{n-1} x^{n-1} + \ldots a_1 x^1 + a_0 \) at point x. More...
 
int main ()
 

Function Documentation

◆ Bisect3()

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 \( func(x) = 0 \) with \( x \in [a,b] \).

The solution is determined by bisection.

Parameters
[in]funcfunction with one double input parameter that returns a double value
[in]ainterval begin
[in]binterval end
[in]epsaccuracy \( \varepsilon \)
Returns
solution \( x^\ast\) such that \( |func(x^\ast)| < \varepsilon \)
Warning
{ \( func(a) \) and \( func(b) \) musst have different signs}

Definition at line 105 of file Bisect3_lambda.cpp.

Here is the caller graph for this function:

◆ eval()

double eval ( vector< double > const &  a,
double  x 
)

Evaluates the polynom \( p(x) := a_n x^n + a_{n-1} x^{n-1} + \ldots a_1 x^1 + a_0 \) at point x.

Parameters
[in]acoefficients of polynom
[in]xevaluatuon point
Returns
\( p(x) \)

Definition at line 127 of file Bisect3_lambda.cpp.

Here is the caller graph for this function:

◆ f()

double f ( const double  x)

Calculates function \( f(x) = \sin(x) - \frac{x}{2} \).

Parameters
[in]xposition for funtion evaluation
Returns
function value

Definition at line 21 of file Bisect3_lambda.cpp.

◆ g()

double g ( const double  x)

Calculates function \( f(x) = -(x-1.234567)*(x+0.987654) \).

Parameters
[in]xposition for funtion evaluation
Returns
function value

Definition at line 32 of file Bisect3_lambda.cpp.

◆ main()

int main ( )

Definition at line 65 of file Bisect3_lambda.cpp.

Here is the call graph for this function: