#1 FindRoot and protected variables? #2 Am I using the wrong method?
- To: mathgroup at smc.vnet.net
- Subject: [mg21968] #1 FindRoot and protected variables? #2 Am I using the wrong method?
- From: "Christian vonPein" <vonpein at mobilixnet.dk>
- Date: Mon, 7 Feb 2000 03:02:36 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hello all.
I'm working with some optimal control theory in economics and I'm having
some problems with the solutions of simultanious
equations. The program, which isn't very long and is intuitivelly for
non-economists, is reported after these questions. I hope some of you
can help me!!!!
In a much smaller setup every thing works fine, but in the real setup
with some 8x8 matrices the FindRoot[] writes
that some of the elements in the matrices is Protected. I used the
?v[2,5] (v[2,5] is the element wich it claims to be protected) but with
no result. It does not recognize the parameter.
I have also tried to do a Unprotect[v[2,5]], but with no luck. I tried
with some different names for the matrices, but still with no luck.
I have also tried the ordinary NSolve[] command, but the system is too
big and the computer takes a lot of time working on this problem. I'm
working on a Penthium I 200mmx so it should not be a computer problem
but instead because the resulting equations is highly non-linear. The
ConstrainedMax[] command is not working eather, since it will not accept
equalities as constraints.
I have to solve the system like 300 times with different parameters
within 1.st of april. So I only want Mathematica to find the one of the
solution which I'm searching for. Or find a algorithm that works faster.
My quistions is:
# 1:What does it (Mathematica) mean by this :
FindRoot::"write": "Tag Times in (a[2, 5] a[2, 6] is Protected.
Is it protected by default or have I done it in my program (not meaning
to)
# 2 Am I using a wrong method or command - FindRoot[]. Is the Global
Optimum package better for this kind of problems. And isn't there a more
simple way to write the the FindRoot[] than I have done (it was the only
iterating process which worked for me - see buttom of page).
#3 I have looked at the list of quistions to the Mathgroup on the
internet. Some economists dealing with optimal control problems has
asked the quistion if mathematica is usuable for these problems or some
other programs is better (like Gauss). But I have not seen any answers
on these quistions.
I hope some of you will react on my quistions. Regards Christian von
Pein - Den Danske Bank/Copenhagen University
This reads a list of 54 caracters. Parameters from som regressions
(unequal - no. 1,3,5 etc) and standard diviations of parameters (egual -
2,4,6 etc.)
m = ReadList["c:\var7999.prn",Number]
k = 1;
Sets up the model parameters : Matrices A and B
A =
{{m[[k]],m[[k+2]],m[[k+4]],m[[k+6]],m[[k+8]],m[[k+10]],m[[k+14]],m[[k+16]
]},{1,0,0,0,0,0,0,0},{0,1,0,0,0,0,0,0},{m[[k+18]],m[[k+20]],m[[k+22]],m[[
k+24]],m[[k+26]],m[[k+28]],m[[k+32]],m[[k+34]]},{0,0,0,1,0,0,0,0},{0,0,0,
0,1,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,1,0}};
B = {{m[[k+12]]},{0},{0},{m[[k+30]]},{0},{0},{1},{0}};
Defines some variance-matrices
{m[[k+1]]^2,m[[k+3]]^2,m[[k+5]]^2,m[[k+7]]^2,m[[k+9]]^2,m[[k+11]]^2,m[[k+
15]]^2,m[[k+17]]^2};
SA11 = DiagonalMatrix[%];
{m[[k+19]]^2,m[[k+21]]^2,m[[k+23]]^2,m[[k+25]]^2,m[[k+27]]^2,m[[k+29]]^2,
m[[k+33]]^2,m[[k+35]]^2};
SA22 = DiagonalMatrix[%];
Discount factor:
d = 0.987;
Defining two matrices
Q = DiagonalMatrix[{1,0,0,1,0,0,0,0}];
V = Array[a,{8,8}];
This is the equations I am interested in: e is the main attraction
e = - Inverse[Transpose[B] . (V + Transpose[V]) . B + 2 v[1,1]
(m[[k+13]]^2) + 2 v[4,4] (m[[k+31]]^2)] . (Transpose[B] . (V +
Transpose[V]) . A );
and e can be found numerically by iterating on the Ricatti-equation were
H = V
H = Q + d Transpose[A + B . e] . V . (A + B . e) + d v[1,1] (SA11 +
(Transpose[e] ( m[[k+13]]^2)) . e) + d v[4,4] (SA22 + (Transpose[e]
(m[[k+31]]^2)) . e);
To get solutions I could make NSolve[] but this takes a couple of days
(at least three), so I try to find the relevant solution by giving some
start values:
(Go to buttom to find how Mathematica is reacting)
FindRoot[{V[[1,1]] == H[[1,1]], V[[1,2]] == H[[1,2]],V[[1,3]]
== H[[1,3]],
V[[1,4]] == H[[1,4]],V[[1,5]] == H[[1,5]]
,V[[1,6]] == H[[1,6]],V[[1,7]] == H[[1,7]],V[[1,8]] ==
H[[1,8]],
V[[2,1]] == H[[2,1]],V[[2,2]] == H[[2,2]],V[[2,3]] ==
H[[2,3]]
,V[[2,4]] == H[[2,4]],V[[2,5]] == H[[2,5]],V[[2,6]] ==
H[[2,6]],
V[[2,7]] == H[[2,7]],V[[2,8]] == H[[2,8]],V[[3,1]] ==
H[[3,1]]
,V[[3,2]] == H[[3,2]],V[[3,3]] == H[[3,3]],V[[3,4]] ==
H[[3,4]],
V[[3,5]] == H[[3,5]],V[[3,6]] == H[[3,6]],V[[3,7]] ==
H[[3,7]],
V[[3,8]] == H[[3,8]],V[[4,1]] == H[[4,1]],V[[4,2]] ==
H[[4,2]],
V[[4,3]] == H[[4,3]],V[[4,4]] == H[[4,4]],V[[4,5]] ==
H[[4,5]],
V[[4,6]] == H[[4,6]],V[[4,7]] == H[[4,7]],V[[4,8]] ==
H[[4,8]],
V[[5,1]] == H[[5,1]],V[[5,2]] == H[[5,2]],V[[5,3]] ==
H[[5,3]],
V[[5,4]] == H[[5,4]],V[[5,5]] == H[[5,5]],V[[5,6]] ==
H[[5,6]],
V[[5,7]] == H[[5,7]],V[[5,8]] == H[[5,8]],V[[6,1]] ==
H[[6,1]],
V[[6,2]] == H[[6,2]],V[[6,3]] == H[[6,3]],V[[6,4]] ==
H[[6,4]],
V[[6,5]] == H[[6,5]],V[[6,6]] == H[[6,6]],V[[6,7]] ==
H[[6,7]],
V[[6,8]] = H[[6,8]],V[[7,1]] == H[[7,1]],V[[8,2]] ==
H[[7,2]],
V[[7,3]] == H[[7,3]],V[[7,4]] == H[[7,4]],V[[7,5]] ==
H[[7,5]],
V[[7,6]] == H[[7,6]],V[[7,7]] == H[[7,7]],V[[7,8]] ==
H[[7,8]],
V[[8,1]] == H[[8,1]],V[[8,2]] == H[[8,2]],V[[8,3]] ==
H[[8,3]],
V[[8,4]] == H[[8,4]],V[[8,5]] == H[[8,5]],V[[8,6]] ==
H[[8,6]],
V[[8,7]] == H[[8,7]],V[[8,8]] ==
H[[8,8]]},{a[1,1],0.5},{a[1,2],0.6},{
a[1,3],0.5},{a[1,4],0.65},{a[1,5],0.5},{a[1,6],0.85},{a[1,7],0.5},{a[1,8]
,
0.5},{a[2,1],0.35},{a[2,2],0.15},{a[2,3],0.55},{a[2,4],
0.85},{a[2,5],0.95}
{a[2,6],0.55},{a[2,7],0.5},{a[2,8],0.5},{a[3,1],0.5},{a[3,2],0.5},{a[3,3]
,
0.5},{a[3,4],0.5},{a[3,5],0.5},{a[3,6],0.5},{a[3,7],0.5},{a[3,8],0.5},{
a[4,1],0.5},{a[4,2],0.5},{a[4,3],0.5},{a[4,4],0.5},
{a[4,5],0.5},{a[4,6],0.5},{a[4,7],0.5},{a[4,8],0.5},{a[5,1],0.5},{a[5,2],
0.5},{a[5,3],0.5},{a[5,4],0.5},{a[5,5],0.5},{a[5,6],0.5},{a[5,7],0.5},{
a[5,8],0.5},{a[6,1],0.5},{a[6,2],0.5},{a[6,3],0.5},{a[6,4],0.5},{a[6,5],
0.5},{a[6,6],0.5},{a[6,7],0.5},{a[6,8],0.5},{a[7,1],0.5},{a[7,2],0.5},{
a[7,3],0.5},{a[7,4],0.5},{a[7,5],0.5},{a[7,6],0.5},{a[7,7],0.5},{a[7,8],
0.5},{a[8,1],0.5},{a[8,2],0.5},{a[8,3],0.5},{a[8,4],0.5},{a[8,5],0.5},{
a[8,6],0.5},{a[8,7],0.5},{a[8,8],0.5}];
FindRoot::"write": "Tag Times in (a[2, 5] a[2, 6] is Protected.
e/.%