Sequence of Bisect implementations
Loading...
Searching...
No Matches
Bisect3.cpp File Reference
#include <cmath>
#include <functional>
#include <iostream>
Include dependency graph for Bisect3.cpp:

Go to the source code of this file.

Functions

double f (const double x)
 Calculates function \( f(x) = \sin(x) - \frac{x}{2} \).
 
double g (const double x)
 Calculates function \( f(x) = -(x-1.234567)*(x+0.987654) \).
 
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] \).
 
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 81 of file Bisect3.cpp.

Here is the call graph for this function:
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 18 of file Bisect3.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 29 of file Bisect3.cpp.

Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 52 of file Bisect3.cpp.

Here is the call graph for this function: