s-news
[Top] [All Lists]

Re: Solving NonLinear Equations

To: "'Bert Jacobs'" <b.jacobs@pandora.be>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Solving NonLinear Equations
From: "Alan Hochberg" <alan.hochberg@prosanos.com>
Date: Thu, 7 Sep 2006 15:26:59 -0400
In-reply-to: <20060907151609.6DA4D230115@adicia.telenet-ops.be>
Thread-index: AcbR3FSoW5wP5SsSTuSOV8m7EzIhuQAsx0+AAAjMQSA=
Bert,

Note that your equations are non-linear but not inherently multivariate.
They can be easily transformed to a univariate form that can be solved with
the uniroot() function.  The following is quick-and-dirty, with just a guess
providing me with an interval for X that contained a sign change:

solveEquations <- function() {
        f <- function(x) {
                y <- 0.320 * x
                c <- 3059738 - 0.62653 * x
                d <- 783717 - 0.53653 * y
                resid <- ((((5.52868E-08*x*c) + d - (2.04766E-07*d*x))/c) -
                        0.256138456)
                resid
        }

        solve <- uniroot(f, c(-9999.0, 9999.0))
        x <- solve$root
        cat ("x = ",x,"\n")
                y <- 0.320 * x
                c <- 3059738 - 0.62653 * x
                d <- 783717 - 0.53653 * y
                resid <- ((((5.52868E-08*x*c) + d - (2.04766E-07*d*x))/c)
                        0.256138456)
        cat ("y = ",y,"\n")
        cat ("c = ",c,"\n")     
        cat ("d = ",d,"\n")
        cat ("residual = ",resid,"\n")
}

I got:

x =  171.346006636828 
y =  54.8307221237849 
c =  3059630.64658646 
d =  783687.581672659 
residual =  1.31006316905768e-014

Hope this helps,

Alan

Alan Hochberg
Vice President, Research
ProSanos Corp.
225 Market Street
Suite 502
Harrisburg, PA 17101
Tel. 717-635-2124
Fax 717-635-2575
alan.hochberg@prosanos.com
www.prosanos.com



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