Help on solving simultaneous non-linear equations using FindRoot.
- To: mathgroup at smc.vnet.net
- Subject: [mg28505] Help on solving simultaneous non-linear equations using FindRoot.
- From: Youyan Li <youyanli at acsu.buffalo.edu>
- Date: Sun, 22 Apr 2001 21:03:21 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
I am trying to solve a 12-eqaution simultaneous non-linear equations using
FindRoot function in Mathematica. This system of equations has 9 given
parameter values and I need to solve for 12 unknown variables. But I have
the problem in getting the system converged. If I take one endogenous
variable out of the system and let it to be a given parameter, and also
reduce the system into 9 equations, I can get a solution that looks like
converged, but some of the variables have negative values, which are not
what I expected. I expect all the variables have non-negative values.
If I specify the range of the variables, usually I cannot get a solution
at all. I wonder how to solve this problem. Or how to get an acceptable
solution for this system? Is there any trick of solving large system of
simultaneous non-linear equations using FindRoot?
Below is my problem that I converted from another program, because I don't
know how to save a mathematica program into a text file correctly. If you
could help, would you please take a look at it? Sorry it may look long. I
am trying to solve functions f[1] to f[12] simultaneously.
> M:=3/5; L:=1.0; c[1]:=1.0; c[2]:=1.0; mu:=2/5; sigma:=5; F[1]:=1.0;
F[2]:=1.0; T:=3/2;
M := 3/5
L := 1.0
c[1] := 1.0
c[2] := 1.0
mu := 2/5
sigma := 5
F[1] := 1.0
F[2] := 1.0
T := 3/2
>
f[1]:=(mu*Y[1]-w[1]*c[1]/p[11])*p[11]^(1-sigma)/(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma))+(mu*Y[2]-w[1]*c[1]*T/p[12])*p[12]^(1-sigma)/(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma))=w[1]*F[1];
1.0 w[1] 1.500000000 w[1]
2/5 Y[1] - -------- 2/5 Y[2] - ----------------
p[11] p[12]
f[1] := ------------------------ + --------------------------- =
4 / n[1] n[2] \ 4 / n[1] n[2] \
p[11] |------ + ------| p[12] |------ + ------|
| 4 4| | 4 4|
\p[11] p[21] / \p[12] p[22] /
1.0 w[1]
>
>
f[2]:=(mu*Y[1]-w[2]*c[2]*T/p[21])*p[21]^(1-sigma)/(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma))+(mu*Y[2]-w[2]*c[2]/p[22])*p[22]^(1-sigma)/(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma))=w[2]*F[2];
1.500000000 w[2] 1.0 w[2]
2/5 Y[1] - ---------------- 2/5 Y[2] - --------
p[21] p[22]
f[2] := --------------------------- + ------------------------ =
4 / n[1] n[2] \ 4 / n[1] n[2] \
p[21] |------ + ------| p[22] |------ + ------|
| 4 4| | 4 4|
\p[11] p[21] / \p[12] p[22] /
1.0 w[2]
>
f[3]:=n[1]*(c[1]*mu*(Y[1]*p[11]^(-sigma)/(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma))+T*Y[2]*p[12]^(-sigma)/(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma)))+F[1])=M*lambda;
/ Y[1]
f[3] := n[1] |.4000000000 ------------------------
| 5 / n[1] n[2] \
| p[11] |------ + ------|
| | 4 4|
\ \p[11] p[21] /
.6000000000 Y[2] \
+ ------------------------ + 1.0| = 3/5 lambda
5 / n[1] n[2] \ |
p[12] |------ + ------| |
| 4 4| |
\p[12] p[22] / /
>
f[4]:=n[2]*(c[1]*mu*(T*Y[1]*p[21]^(-sigma)/(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma))+Y[2]*p[22]^(-sigma)/(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma)))+F[2])=M*(1-lambda);
/ Y[1]
f[4] := n[2] |.6000000000 ------------------------
| 5 / n[1] n[2] \
| p[21] |------ + ------|
| | 4 4|
\ \p[11] p[21] /
.4000000000 Y[2] \
+ ------------------------ + 1.0| = 3/5 - 3/5 lambda
5 / n[1] n[2] \ |
p[22] |------ + ------| |
| 4 4| |
\p[12] p[22] / /
>
f[5]:=(1+(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma))/((sigma-1)*(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma)-p[11]^(1-sigma))))*w[1]*c[1]=p[11];
/ / n[1] n[2] \ \
| 1/4 |------ + ------| |
| | 4 4| |
| \p[11] p[21] / |
f[5] := 1.0 |1 + ------------------------| w[1] = p[11]
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[11] p[21] p[11] /
>
f[6]:=(1+(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma))/((sigma-1)*(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma)-p[12]^(1-sigma))))*w[1]*c[1]*T=p[12];
/ / n[1] n[2] \ \
| 1/4 |------ + ------| |
| | 4 4| |
| \p[12] p[22] / |
f[6] := 1.500000000 |1 + ------------------------| w[1] = p[12]
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[12] p[22] p[12] /
>
f[7]:=(1+(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma))/((sigma-1)*(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma)-p[21]^(1-sigma))))*w[2]*c[2]*T=p[21];
/ / n[1] n[2] \ \
| 1/4 |------ + ------| |
| | 4 4| |
| \p[11] p[21] / |
f[7] := 1.500000000 |1 + ------------------------| w[2] = p[21]
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[11] p[21] p[21] /
>
f[8]:=(1+(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma))/((sigma-1)*(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma)-p[22]^(1-sigma))))*w[2]*c[2]=p[22];
/ / n[1] n[2] \ \
| 1/4 |------ + ------| |
| | 4 4| |
| \p[12] p[22] / |
f[8] := 1.0 |1 + ------------------------| w[2] = p[22]
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[12] p[22] p[22] /
> f[9]:=M*lambda*w[1]+(L-M)/2*p[A]=Y[1];
f[9] := 3/5 lambda w[1] + .2000000000 p[A] = Y[1]
> f[10]:=M*(1-lambda)*w[2]+(L-M)/2*p[A]=Y[2];
f[10] := 3/5 (1 - lambda) w[2] + .2000000000 p[A] = Y[2]
> f[11]:=(1-mu)*(Y[1]+Y[2])/p[A]=L-M;
Y[1] + Y[2]
f[11] := 3/5 ----------- = .4000000000
p[A]
>
f[12]:=w[1]/(n[1]*p[11]^(1-sigma)+n[2]*p[21]^(1-sigma))^(mu/(1-sigma))=w[2]/(n[1]*p[12]^(1-sigma)+n[2]*p[22]^(1-sigma))^(mu/(1-sigma));
f[12] :=
/ n[1] n[2] \(1/10) / n[1] n[2] \(1/10)
w[1] |------ + ------| = w[2] |------ + ------|
| 4 4| | 4 4|
\p[11] p[21] / \p[12] p[22] /
>
sol:=fsolve({f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10],f[11],f[12]},{p[A],p[11],p[12],p[21],p[22],n[1],n[2],w[1],w[2],Y[1],Y[2],lambda},{p[A]=0..1.5,p[11]=0.5..infinity,p[12]=0.5..infinity,p[21]=0.5..infinity,p[22]=0.5..infinity,n[1]=0..2,n[2]=0..2,w[1]=0..infinity,w[2]=0..infinity,Y[1]=0..infinity,Y[2]=0..infinity,lambda=0..1});
sol =FindRoot[{
/ Y[1] .4000000000 Y[2] \
n[2] |.6000000000 --------- + ---------------- + 1.0| =
| 5 5 |
\ p[21] %1 p[22] %2 /
3/5 - 3/5 lambda,
1.0 w[1] 1.50 w[1]
.4 Y[1] - -------- .4 Y[2] - ---------
p[11] p[12]
------------------ + ------------------- = 1.0 w[1],
4 4
p[11] %1 p[12] %2
1.500000000 w[2] 1.0 w[2]
2/5 Y[1] - ---------------- 2/5 Y[2] - --------
p[21] p[22]
--------------------------- + ------------------- = 1.0 w[2],
4 4
p[21] %1 p[22] %2
/ Y[1] .6000000000 Y[2] \
n[1] |.4000000000 --------- + ---------------- + 1.0| =
| 5 5 |
\ p[11] %1 p[12] %2 /
/ 1/4 %1 \
3/5 lambda, 1.0 |1 + ------------------------| w[1] = p[11],
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[11] p[21] p[11] /
/ 1/4 %2 \
1.500000000 |1 + ------------------------| w[1] = p[12],
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[12] p[22] p[12] /
/ 1/4 %1 \
1.500000000 |1 + ------------------------| w[2] = p[21],
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[11] p[21] p[21] /
/ 1/4 %2 \
1.0 |1 + ------------------------| w[2] = p[22],
| n[1] n[2] 1 |
| ------ + ------ - ------|
| 4 4 4|
\ p[12] p[22] p[22] /
3/5 lambda w[1] + .2000000000 p[A] = Y[1],
3/5 (1 - lambda) w[2] + .2000000000 p[A] = Y[2],
Y[1] + Y[2] (1/10) (1/10)
3/5 ----------- = .4000000000, w[1] %1 = w[2] %2 }
p[A]
, {Y[1], 1},{w[1],1} {p[11],1}, {n[1], 0.5},{n[2],0.5}, {p[21],1},
{Y[2],1}, {p[12],1},{p[22],1},
{w[2],1},{lambda,0.5}, {p[A],1}]
>