0

I want to determine the value of z = z1, ..., zn such that

z1 = g1(z1,..,zn)

...

zn = gn(z1,..,zn)

for some nonlinear gi(z1,..,zn), 1<=i<=n. And I declared the function:

vecfun <- function(z){
fun1 <- z1 - g1(z1,..,zn)
...
funn <- zn - gn(z1,..,zn)
return(c(fun1, ..., funn))
} 

Then, I will call:

sol <- nleqslv(cond0, vectfun)

And I get some output different from cond0 (I also had some times when the output/solution allegedly is the same as cond0, but in reality, it isn't). However when I do:

vecfun(sol$x)

The results aren't zero, nor something relatively close. In principle, nleqslv should return the z's that solve the system for vectfun to be the n-dimensional zero vector (right?). But why doesn't it hold when I try to confirm it?

Any help is highly appreciated as well as alternative methods to find roots of vector functions.

leplata
  • 123
  • 5
  • 1
    Try to edit your question so that we can recreate the problem, including working functions and sample data. You are likely to get faster, better help. – jpsmith Feb 16 '22 at 01:34
  • We need a working example to be able to help you. In addition you seem to be assuming that a solution has been found. You should always check the value `sol$termcd` for succes. See the manual. – Bhas Feb 18 '22 at 08:47

0 Answers0