# RE: Nonlinear systems of equations

Essiam, Albert AK (Essiam.Albert.AK@bhp.com.au)
Tue, 13 Jan 1998 06:16:00 +1100

------------------------------------------------------------------------
---- ------------------------------------------
Has anyone written a function to solve a system of nonlinear
equations |
as below, using Newton Raphson or other technique?  
 |

Find x,y for      
 |

1.5 = [1/(1+x)^3 + 1/(1+y)^3]/2.1    
 |
0.18 = .5*ln(x/y)      
 |

If so, please send help to Mary.J.Nordstrom@chi.frb.org 
 |

------------------------------------------------------------------------
---- -----------------------------------------

Hello Mary,

here is one way to solve your problem using the Newton-Raphson method.

First you can write your first equation as a function of y by
substituting
x = ye^0.36 from equation 2. Hence equation 1 can be written as

f(y) = 1/(1+4.33329y)^3 + 1/(1+y)^3 - 3.15

the derivative of f(y) = -4.299987/(1+4.33329y)^4 - 3/(1+y)^4

You can now implement the Newton-Raphson method in S-plus as follows:

f1<-function(y){(1/(1+1.433329*y)^3 + 1/(1+y)^3)-3.15}
f2<-function(y){-4.299987/(1+1.433329*y)^4 - 3/(1+y)^4}
lasty<-1000
y<--.001
while(abs(y-lasty)>0.00000001){
lasty <- y
y<-y-f1(y)/f2(y)
}

> y
[1] -0.1143195
> x<-y*1.433329414
> x
[1] -0.1638576

Hope this helps.

Albert Essiam