Bisection
bisect.cpp File Reference
#include "bisect.h"
#include <cassert>
#include <cmath>
#include <functional>
Include dependency graph for bisect.cpp:

Go to the source code of this file.

Functions

double Bisect (const std::function< double(double)> &func, const double a, const double b, const double eps)
 Returns one solution for the equation \( func(x) = 0 \) with \( x \in [a,b] \). More...
 

Function Documentation

◆ Bisect()

double Bisect ( const std::function< double(double)> &  func,
const double  a,
const double  b,
const double  eps 
)

Returns one solution for the equation \( func(x) = 0 \) with \( x \in [a,b] \).

The requirement \( func(a) > 0 > func(b) \) has to be fulfilled.

The solution is determined by bisection.

The input function func t has to be declared: double pp(double x); i.e., pp could be used as first argument in the parameter list when calling Bisect.

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
The function values \( func(a) \) and \( func(b) \) musst have different signs.

Definition at line 6 of file bisect.cpp.

Here is the caller graph for this function: