<< moc_flipud Matlab/Octave Compatibility toolbox moc_gaussian >>

Matlab/Octave Compatibility toolbox >> Matlab/Octave Compatibility toolbox > moc_fzero

moc_fzero

solves the scalar nonlinear equation such that F(X) == 0

Calling Sequence

[X, FX, INFO] = moc_fzero (FCN, APPROX, OPTIONS)

Parameters

FCN :

function name as string

OPTIONS is a structure, with the following fields:

'abstol' :

absolute (error for Brent's or residual for fsolve) tolerance. Default = 1e-6.

'reltol' :

relative error tolerance (only Brent's method). Default = 1e-6.

'prl' :

print level, how much diagnostics to print. Default = 0, no diagnostics output

Description

Given Func, the name of a function of the form `F (X)', and an initial approximation APPROX, `fzero' solves the scalar nonlinear equation such that `F(X) == 0'. Depending on APPROX, `fzero' uses different algorithms to solve the problem: either the Brent's method or the Powell's method of `fsolve'. The computed approximation to the zero of FCN is returned in X. FX is then equal to FCN(X). If the iteration converged, INFO == 1. If Brent's method is used, and the function seems discontinuous, INFO is set to -5. If fsolve is used, INFO is determined by its convergence.

Examples

moc_fzero('sin',[-2 1])
[x, fx, info] = moc_fzero('sin',-2)
options.abstol = 1e-2; moc_fzero('sin',-2, options)

Authors


Report an issue
<< moc_flipud Matlab/Octave Compatibility toolbox moc_gaussian >>