Hi,
thank you for your suggestions. The algorithms work, but are difficult to use it
as a textbook example for students :)
I have experimented with the Lagrangian method in Maxima. There are some
observations:
1) Maxima don?t handle with the nonlinear constraints. Of course, I can replace
Lagrange method by the substitution constrain into of the objective function.
Unfortunately, a part of the economic interpretation of the problem will be
lost (Example 1)
2) Maxima handle with nonlinear goal function and linear constrain. Only one
notice: it should be only symbolic computation without any numbers. Compare
Example 2 and 3.
Now, I am working on two issues:
* Computational General Equilibrium ? Newton method
* Game theory and Nikaido-Isoda algorithm
Is anyone create something in these fields? Help :)
Best,
Tomek
/*********** Example 1 **************/
kill(all);
assume(X1>0, X2>0,w1>0,w2>0,Y>0, a>1)$
alfa:0.1;
/* constrain - production = Y*/
eq1:Y=(X1^(alfa))*(X2^(1-alfa));
solve([eq1],[X2]);
X2:rhs(%[9]);
/* substitution */
C:w1*X1+w2*X2;
eq2:diff(C,X1,1)=0;
solve([eq2],[X1]);
X1:rhs(%[9]);
X2:''X2;
/* cost function */
C:w1*X1+w2*X2;
/* compare cost function Y=10 and Y= 100 */
kill(Y);
Y:10;C1:''C;
kill(Y);
Y:100;C2:''C;
plot3d([C1,C2 ,[w1, 1, 10], [w2, 1, 10]])$
/*********** Example 2 **************/
kill(all)$
assume(x1>0, x2>0,p1>0,p2>0,u>0,a>0,a<1,lambda>0, M>0)$
U:x1^a*x2^b;
L:(U)+lambda*(p1*x1 + p2*x2 - M);
eq1:diff(L,x1,1)=0;
eq2:diff(L,x2,1)=0;
eq3:diff(L,lambda,1)=0;
solve([eq1,eq2,eq3],[x1,x2,lambda]);
FOC:%[1];
x1:rhs(FOC[1]);
x2:rhs(FOC[2]);
lambda:rhs(FOC[3]);
disp(" Indirect utility function U(x1*,x2*)=g(p1,p2,M)")$
I_U:''U;
disp(" ==============================================")$
kill(p1,p2);
a:0.3;
b:0.7;
M:2000;
U1:''I_U;
M:10000;
U2:''I_U;
draw3d(xlabel = "p1", ylabel = "p2", zlabel = " Indirect utility function",
color = blue,explicit(U1,p1,1,5,p2,1,5),
color = red,explicit(U2,p1,1,5,p2,1,5))$
/*********** Example 3 **************/
kill(all)$
assume(x1>0, x2>0,p1>0,p2>0,u>0,a>0,a<1,lambda>0, M>0)$
/* decelerate parameters before computation - not working :( )*/
a:0.3;
b:0.7;
U:x1^a*x2^b;
L:(U)+lambda*(p1*x1 + p2*x2 - M);
eq1:diff(L,x1,1)=0;
eq2:diff(L,x2,1)=0;
eq3:diff(L,lambda,1)=0;
solve([eq1,eq2,eq3],[x1,x2,lambda]);
FOC:%[1];
x1:rhs(FOC[1]);
x2:rhs(FOC[2]);
lambda:rhs(FOC[3]);
disp(" Indirect utility function U(x1*,x2*)=g(p1,p2,M)")$
I_U:''U;
disp(" ==============================================")$
kill(p1,p2);
M:2000;
U1:''I_U;
M:10000;
U2:''I_U;
draw3d(xlabel = "p1", ylabel = "p2", zlabel = " Indirect utility function",
color = blue,explicit(U1,p1,1,5,p2,1,5),
color = red,explicit(U2,p1,1,5,p2,1,5))$