s-news
[Top] [All Lists]

Re: Solving NonLinear Equations

To: "Bert Jacobs" <b.jacobs@pandora.be>
Subject: Re: Solving NonLinear Equations
From: Tim Hesterberg <timh@insightful.com>
Date: 7 Sep 2006 12:39:35 -0700
Cc: <s-news@lists.biostat.wustl.edu>
In-reply-to: <20060907151609.6DA4D230115@adicia.telenet-ops.be> (b.jacobs@pandora.be)
References: <20060907151609.6DA4D230115@adicia.telenet-ops.be>
Express your equations in vector form, e.g.

f <- function(xycd){
  x <- xycd[1]
  y <- xycd[2]
  cc <- xycd[3]  # don't use the name "c"
  d <- xycd[4]
  # Return difference between two sides of equation; solution will be
  # when this is rep(0,4):
  c(3059738     - 0.62653*x + cc
    783717      - 0.53653*y + d
    y           - 0.320*x
    0.256138456 - ((5.52868E-08*x*cc) + d - (2.04766E-07*d*x))/cc)
}

Then you could use e.g. solveNonlinear (in help(nlmin)).

Tim Hesterberg

>I was wondering if S-Plus could help me solve the equations in the example
>below. Normally I use the function solve to get results for a linear
>equation system but now I have to deal with nonlineair equations.
>
>3,059,738   = 0.62653*x + c
>783,717     = 0.53653*y + d
>y            = 0.320*x
>0.256138456    = ((5.52868E-08*x*c) + d - (2.04766E-07*d*x))/c
>
>Anybody an idea?  Is this possible in S-Plus?
>Normally the equation above should give a unique solution, can I check this
>in a way?
>
>Thx a lot for helping me out,
>Bert


<Prev in Thread] Current Thread [Next in Thread>