Cobb Douglas Utility Maximization
A Model with Two Goods
A consumer, with preference
and M dollars, chooses between two goods,
and
, that cost
and
per unit of good. Below, we will draw the utility surface, budget set, and indifference curves.
Model Parameters
% Number of grid points (points along x and y axis)
Preference
Consumers have preference over the two goods, and
represents the utility assigned to the goods bundle 
If households enjoy both goods as complements, we could use this Cobb-Douglas form with Constant Return to Scale to represent the utility function:
We can use matlab to graph the utility function as a "hill":
% This generates a vector between 0 and 10 with grid_points number of points
x1 = linspace(0,maxX1,grid_points);
% This generates another vector between 0 and 10 with grid_points number of points
x2 = linspace(0,maxX2,grid_points);
% This creates all possible combinations of the x1 and x2 vectors, fills up the grid
[x1mesh, x2mesh] = meshgrid(x1,x2);
% Evaluate the utility function at all x1 and x2 combination points
U = (x1mesh.^alpha).*(x2mesh.^beta);
% Graph "hill" using mesh
zlabel('Cobb Douglas Utility');
title('Utility Function Along Two Goods Dimensions')
Budget
The budget (choice) set facing the household could be written as:
where M is the total resource available for the household.
We can plot out the budget set graphically:
% Same as before, generating grid, and creating all possible combinations using meshgrid
x1 = linspace(0,maxX1,grid_points);
x2 = linspace(0,maxX2,grid_points);
[x1mesh_cost, x2mesh_cost] = meshgrid(x1,x2);
% Evaluate the cost of bundles of goods
bundle_cost = x1mesh_cost*p1 + x2mesh_cost*p2;
contour = contourf(x1mesh_cost, x2mesh_cost, bundle_cost, 10);
title('Contour Plot of Budget Set over two goods')
Budget and Preference: Indifference Curves
Budget and Utility together. Use contour plot for utility. These are the altitude graphs you have seen in your geography classes. Rather than graphing out the "hill" as earlier, we can represent the heights of the hill with contours, the show where the "hill" is higher and lower.
% Contour plot, the fourth parameter are at what utility values we want to see the contour lines.
% All consumption bundle along the same contour line gives the same utility, hence they are: Indifference Curves.
contour_u = contourf(x1mesh, x2mesh, U, [0.1, 0.6, 1.1, 2.1,3.1,4.1,5,1,6.1,7.1,8.1,9.1,20,30,40,50,60,70,80,90,100]);
zlabel('Cobb Douglas Utility');
title('Utility Function Along Two Goods Dimensions and Budget')
% From 0 to max x1 given budget and p1
x1_M = linspace(0, M/p1, grid_points);
% Given x1 bought, what are the X2s
plot(x1_M, x2_M, 'LineWidth', 3);