ECON 715, Optimization
Unconstrained Optimization
Multiproduct competitive firm
Consider a firm sells 2 different products, taking the market prices as given. The quantities of these products are and prices . The revenue is therefore: The cost function is . Declaring variables, and defining the revenue, cost and profit functions.
syms Q1 Q2 P1 P2 %Declaring symbolic variables
R = P1*Q1 + P2*Q2; %Revenue
C = 2*Q1^2 + Q1*Q2 + 2*Q2^2; %Cost function
Solving for optimal quantities:
[Q1_opt, Q2_opt] = solve(gradient(Pai,[Q1,Q2])==0, [Q1,Q2]);
display([Q1_opt;Q2_opt])
ans =
Substituting market prices:
Supply = subs([Q1_opt, Q2_opt], [P1,P2], [12,18])
Supply = You can change the market prices, and see how quantities change:
Supply = subs([Q1_opt, Q2_opt], [P1,P2], [15,15])
Supply = Multiproduct Monopoly
Consider a monopoly that sells 2 different products to two markets, with demands:
Defining the demand, revenue, cost and profit functions:
P1(Q1,Q2) = 55 - Q1 - Q2; %Demand in market 1
P2(Q1,Q2) = 70 - Q1 - 2*Q2; %Demand in market 2
R = P1*Q1 + P2*Q2; %Revenue
C = Q1^2 + Q1*Q2 + Q2^2; %Cost function
Pai = simplify(R - C); %Profit
Solving for optimal quantiies, equilibrium prices and maximal profit:
[Q1_opt, Q2_opt] = solve(gradient(Pai)==0);
P1_opt = double(P1(Q1_opt, Q2_opt));
P2_opt = double(P2(Q1_opt, Q2_opt));
Pai_opt = double(Pai(Q1_opt, Q2_opt));
Plotting the profit function:
% fsurf(Pai, [0 15 0 20] )
plot3(Q1_opt, Q2_opt, Pai_opt,'.r','MarkerSize',25) %Point of tangency - stationary point
Constrained Optimization
Utility function visualization
Plotting the graph of , a strictly concave function. syms x y %Declaring symbolic variables
u(x,y) = x^a*y^b; %Cobb-Douglas utility function
fmesh(u, [0 10 0 10], 'ShowContours','on')
Slicing the utility function, to illustrate indifference curves.
view([56.40 23.40]) %Rotate angle
Plotting the graph of , not concave, but strictly quisiconcave function. syms x y %Declaring symbolic variables
u(x,y) = x^a*y^b; %Cobb-Douglas utility function
fmesh(u, [0 10 0 10], 'ShowContours','on')
Slicing the utility function, to illustrate indifference curves.
view([56.40 23.40]) %Rotate angle
Notice that the level curves (indifference curves) of a strictly quisiconcave utility function have the same shape as the level curves of a strictly concave utility function, and upper contour sets are strictly convex in bot cases. Thus, strict concavity of utility fucntions is not necessary for the "right shape" of indifference curves.
Consumer's demand
Setting up the lagrange:
syms x y p_x p_y I k a %Declaring symbolic variables
u(x,y) = a*log(x) + (1-a)*log(y); %Utility function defined
L(x,y,k) = u(x,y) - k*(p_x*x + p_y*y - I); %Lagrange function defined
% k is the Lagrange multiplier
Solving for consumer demand:
[x,y,k] = solve(gradient(L,[x,y,k])==0, [x,y,k])
Substituting values of : demand = subs([x,y],[a,p_x,p_y,I],[0.5,3,0.75,100])
demand =