false_position¶
- kgpy.optimization.root_finding.scalar.false_position(func, bracket_min, bracket_max, max_abs_error=1e-09, max_iterations=100)¶
The false position method (often known by its latin name, regula falsi) is a bracketed root-finding method that uses linear interpolation to iteratively approximate the root of a nonlinear function. This implementation is based on the wikipedia page.
- Parameters:
func (
typing.Callable[[typing.Union[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]],numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]]],bool,int,float,complex,str,bytes,numpy._typing._nested_sequence._NestedSequence[typing.Union[bool,int,float,complex,str,bytes]]]],typing.Union[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]],numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]]],bool,int,float,complex,str,bytes,numpy._typing._nested_sequence._NestedSequence[typing.Union[bool,int,float,complex,str,bytes]]]]) – Scalar function to be minimized.bracket_min (
typing.Union[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]],numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]]],bool,int,float,complex,str,bytes,numpy._typing._nested_sequence._NestedSequence[typing.Union[bool,int,float,complex,str,bytes]]]) – Minimum value of the range to search for the root.bracket_max (
typing.Union[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]],numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]]],bool,int,float,complex,str,bytes,numpy._typing._nested_sequence._NestedSequence[typing.Union[bool,int,float,complex,str,bytes]]]) – Maximum value of the range to search for the root.max_abs_error (
float) – Maximum absolute error of the objective function at the root.max_iterations (
int) – Maximum iterations to try before declaring non-convergence.
- Returns:
Root of the function
- Return type:
- Raises:
ValueError – If the number of iterations is exceeded and ::max_abs_error has not been reached.