| testnslv | R Documentation |
nleqslvThe function tests different methods and global strategies for solving a system of nonlinear equations with nleqslv
testnslv(x, fn, jac=NULL, ...,
method = c("Newton", "Broyden"),
global = c("cline", "qline", "gline", "pwldog", "dbldog", "hook", "none"),
Nrep=0L, title=NULL
)
x |
A numeric vector with an initial guess of the root. |
fn |
A function of |
jac |
A function to return the Jacobian for the |
... |
Further arguments to be passed to |
method |
The methods to use for finding a solution. |
global |
The global strategies to test. The argument may consist of several possibly abbreviated items. |
Nrep |
Number of repetitions to apply. Default is no repetitions. |
title |
a description of this experiment. |
The function solves the function fn with nleqslv for the specified methods and global strategies.
When argument Nrep has been set to a number greater than or equal to 1,
repetitions of the solving process are performed and the used CPU time in seconds is recorded.
If checking a user supplied jacobian is enabled, then testnslv will stop immediately when a possibly
incorrect jacobian is detected.
testnslv returns an object of class "test.nleqslv" which is a list containing the following elements
callthe matched call
outa dataframe containing the results with the following columns
Methodmethod used.
Globalglobal strategy used.
termcdtermination code of nleqslv.
Fcntnumber of function evaluations used by the method and global strategy. This excludes function evaluations made when computing a numerical Jacobian.
Jcntnumber of Jacobian evaluations.
Iternumber of outer iterations used by the algorithm.
Messagea string describing the termination code in an abbreviated form.
Fnormsquare of the euclidean norm of the vector of function results divided by 2.
cpusecsCPU seconds used by the requested number of repetitions (only present when
argument Nrep is not 0).
titlethe description if specified
The abbreviated strings are
FcritConvergence of function values has been achieved.
XcritThis means that the relative distance between two
consecutive x-values is smaller than xtol.
StalledThe algorithm cannot find an acceptable new point.
MaxiterIteration limit maxit exceeded.
IllcondJacobian is too ill-conditioned.
SingularJacobian is singular.
BadJacJacobian is unusable.
ERRORnleqslv stopped because of a fatal error.
Any nleqslv error message will be displayed immediately and
an error for the particular combination of method and global strategy will be recorded in the final dataframe.
dslnex <- function(x) {
y <- numeric(2)
y[1] <- x[1]^2 + x[2]^2 - 2
y[2] <- exp(x[1]-1) + x[2]^3 - 2
y
}
xstart <- c(0.5,0.5)
fstart <- dslnex(xstart)
testnslv(xstart,dslnex)
# this will encounter an error
xstart <- c(2.0,0.5)
fstart <- dslnex(xstart)
testnslv(xstart,dslnex)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.