Secant

class Secant(*args)

Secant algorithm solver for 1D non linear equations.

Available constructor:

Secant()

Secant(absError, relError, resError, maximumFunctionEvaluation)

Parameters:

absError : positive float

Absolute error: distance between two successive iterates at the end point. Default is 10^{-5}.

relError : positive float

Relative error: distance between the two last successive iterates with regards to the last iterate. Default is 10^{-5}.

resError : positive float

Residual error: difference between the last iterate value and the expected value. Default is 10^{-8}.

maximumFunctionEvaluation : int

The maximum number of evaluations of the function. Default is 100.

See also

Solver, Bisection, Brent

Notes

The Secant solver is based on the evaluation of a segment between the two last iterated points.

Methods

getAbsoluteError() Accessor to the absolute error.
getClassName() Accessor to the object’s name.
getId() Accessor to the object’s id.
getMaximumFunctionEvaluation() Accessor to the maximum number of evaluations of the function.
getName() Accessor to the object’s name.
getRelativeError() Accessor to the relative error.
getResidualError() Accessor to the residual error.
getShadowedId() Accessor to the object’s shadowed id.
getUsedFunctionEvaluation() Accessor to the number of evaluations of the function.
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
setAbsoluteError(absoluteError) Accessor to the absolute error.
setMaximumFunctionEvaluation(...) Accessor to the maximum number of evaluations of the function.
setName(name) Accessor to the object’s name.
setRelativeError(relativeError) Accessor to the relative error.
setResidualError(residualError) Accessor to the residual error.
setShadowedId(id) Accessor to the object’s shadowed id.
setVisibility(visible) Accessor to the object’s visibility state.
solve(*args) Solve an equation.
__init__(*args)
getAbsoluteError()

Accessor to the absolute error.

Returns:

absError : float

The absolute error: distance between two successive iterates at the end point.

getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getMaximumFunctionEvaluation()

Accessor to the maximum number of evaluations of the function.

Returns:

maxEval : int

The maximum number of evaluations of the function.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getRelativeError()

Accessor to the relative error.

Returns:

relError : float

The relative error: distance between the two last successive iterates with regards to the last iterate.

getResidualError()

Accessor to the residual error.

Returns:

resError : float

The residual errors: difference between the last iterate value and the expected value.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getUsedFunctionEvaluation()

Accessor to the number of evaluations of the function.

Returns:

nEval : int

The number of evaluations of the function.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

setAbsoluteError(absoluteError)

Accessor to the absolute error.

Parameters:

absError : float

The absolute error: distance between two successive iterates at the end point.

setMaximumFunctionEvaluation(maximumFunctionEvaluation)

Accessor to the maximum number of evaluations of the function.

Parameters:

maxEval : int

The maximum number of evaluations of the function.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setRelativeError(relativeError)

Accessor to the relative error.

Parameters:

relError : float

The relative error: distance between the two last successive iterates with regards to the last iterate.

setResidualError(residualError)

Accessor to the residual error.

Parameters:

resError : float

The residual errors: difference between the last iterate value and the expected value.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.

solve(*args)

Solve an equation.

Available usages:

solve(function, value, infPoint, supPoint)

solve(function, value, infPoint, supPoint, infValue, supValue)

Parameters:

function : NumericalMathFunction

The function of the equation function(x) = value to be solved in the interval [infPoint, supPoint].

value : float

The value of which the function must be equal.

infPoint : float

Lower bound of the interval definition of the variable x.

supPoint : float

Upper bound of the interval definition of the variable x.

infValue : float

The value such that infValue = function(infPoint). It must be of opposite sign of supValue.

supValue : float

The value such that supValue = function(supPoint). It must be of opposite sign of infValue.

Returns:

result : float

The result of the root research.

Notes

The Secant solver is based on the evaluation of a segment between the two last iterated points. Secant might fail and not converge.