I have this equation to solve (e.g. f(x,y) = 0):
library(nleqslv)
target <- function(x)
{
z = x[1]/(x[1]+x[2])
y = numeric(2)
y[1] <- z*exp(-x[2]*(x[2]+z*(1-exp(-x[1]/z))))-0.00680
y[2] <- z/x[2]*(1-exp(-x[2]))-exp(-x[2])*z/x[1]*(1-exp(-x[1]))-3.43164
y
}
# Usage
xstart <- c(1,1)
target(xstart)
nleqslv(xstart, target, control=list(ftol=.0001, allowSingular=TRUE),jacobian=TRUE,method="Newton")
using R with nleqslv or another you have others :)
Thanks
I have been experimenting with your function. Rewrite the
target
function to use thea;b
constants in your comment as in your second comment as follows:The default values for
a
andb
are what you initially specified. Using them you'll get an ill-conditioned jacobiam.However if we give some other values to
a
andb
for example like soor
then for the first expression the full return value of
nleqslv
isI am inclined to conclude that either your function is incorrect or that you have specified impossible values for
a
andb
. MethodBroyden
also seems to work nicely.