From: Berend Hasselman <bhh_at_xs4all.nl>

Date: Fri, 25 Apr 2008 05:55:14 -0700 (PDT)

Date: Fri, 25 Apr 2008 05:55:14 -0700 (PDT)

> x^2 - y^2 = 6

*> x – y = 3
**>
**>
*

You can also try this

# function

f <- function(x) {

y <- numeric(2)

y[1] <- x[1]^2-x[2]^2-6

y[2] <- x[1]-x[2]-3

y

}

# function values transformed to scalar
# minimising fnorm this way is not the best method of finding a solution for
f(x)=0

# there may be values for x which minimise fnorm but do not set f(x) = 0
# but you can always try

fnorm <- function(z) {p <- f(z);return(crossprod(p))}

#starting values

xstart <- c(0,0)

# You can use nlm or nlminb

nlm(fnorm,xstart)

nlminb(xstart,fnorm)

Sometimes minpack.lm can be used to find roots. Do

library(minpack.lm)

nls.lm(xstart,f)

and in this case you'll see that it doesn't work.

In this case stick to nlm and/or nlminb.

Berend

-- View this message in context: http://www.nabble.com/Non-linear-system-of-equations-tp16893056p16895541.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Fri 25 Apr 2008 - 13:06:12 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Fri 25 Apr 2008 - 13:30:31 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*