<p>I have used <a href="https://www.mathcha.io" rel="nofollow noreferrer">https://www.mathcha.io</a> to plot this picture:</p>
<p><a href="https://i.sstatic.net/zKzZb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zKzZb.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2023-10-06T20:04:43.227Z
2023-10-06T20:04:43.227Z
Amit
<p>I wrote some silly program where you just fix endowment $e=(e_1,e_2)$ and utility functions $u=(u_1(x_1,y_1),u_2(x_2,y_2))$. The example provides an illustration for your utility functions and $x_1+x_2=1$ and $y_1+y_2=1$. I've drawn 100 indifference curves on an equally spaced grid of given utility levels $\bar u_1\in[u_1(0,0),u_1(1,1)]$ (blue) and $\bar u_2\in[u_2(0,0),u_2(1,1)]$ (red). The black line is the contract curve.</p>

<p>I added a second figure with some initial endowment $e_1 = (0.25, 0.75)$, $e_2 = (0.75, 0.25)$ and core.</p>

<p><a href="https://i.sstatic.net/o2OAf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/o2OAf.png" alt="enter image description here"></a>
<a href="https://i.sstatic.net/scZkI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/scZkI.png" alt="enter image description here"></a></p>

<pre><code>e1 = [0.25 0.75];
e2 = [0.75 0.25];

X = 0.0:0.01:(e1(1)+e2(1));
Y = 0.0:0.01:(e1(2)+e2(2));

syms x1 y1 x2 y2 u1_bar u2_bar

u1 = x1.^2*y1;
u2 = x2*y2.^2;

I1_fun = matlabFunction(solve(u1_bar == u1, y1, 'PrincipalValue', true));
I2_fun = matlabFunction(solve(u2_bar == u2, y2, 'PrincipalValue', true));

u1_x = diff(u1, x1);
u1_y = diff(u1, y1);

u2_x = diff(u2, x2);
u2_y = diff(u2, y2);

u2_x = subs(u2_x, [x2,y2], [X(end) - x1, Y(end) - y1]);
u2_y = subs(u2_y, [x2,y2], [X(end) - x1, Y(end) - y1]);

contract_curve = matlabFunction(solve(u1_y/u1_x == u2_y/u2_x, y1));

u1_min = double(subs(u1, [x1,y1], [X(1), Y(1)]));
u1_max = double(subs(u1, [x1,y1], [X(end), Y(end)]));
u1_Array = linspace(u1_min, u1_max, 100);
I1_Array = zeros(length(X), length(u1_Array));

for i = 1:length(u1_Array)
I1_Array(:,i) = I1_fun(u1_Array(i), X);
end

u2_min = double(subs(u2, [x2,y2], [X(1), Y(1)]));
u2_max = double(subs(u2, [x2,y2], [X(end), Y(end)]));
u2_Array = linspace(u2_min, u2_max, 100);
I2_Array = zeros(length(X), length(u2_Array));
for i = 1:length(u2_Array)
I2_Array(:,i) = I2_fun(u2_Array(i), X);
end

hold on
[AX, H1, H2] = plotyy(X, I1_Array, 1-X, I2_Array)
set(AX(:),'YLim',[0 1]);
set(AX(:),'YTick',[0:0.1:1])
set(H1(1:length(u1_Array)), 'Color', 'b'); 
set(H2(1:length(u2_Array)), 'Color', 'r');
set(AX(2),'YDir','reverse')
axis(AX,'square') 
%str1 = '\bullet e=(e_1,e_2)';
%text(e1(1),e1(2),str1)
plot(X, contract_curve(X), 'k', 'linewidth', 2)
hold off
</code></pre>

CC BY-SA 3.0
2015-11-26T09:01:50.133Z
Yes, it's Matlab.
clueless
CC BY-SA 3.0
2015-11-24T18:54:01.697Z
2015-11-24T22:06:08.573Z
2015-11-24T22:06:08.573Z
clueless
<p>I can do simple calculations in micro-economics, such as: given the utility function of a consumer, calculate his demand curves; given utility functions of two consumers and initial endowment, calculate the competitive equilibrium; etc. However, the calculations become tedious and I am looking for a software that can do them automatically. For example, I am looking for a software where I can:</p>

<ul>
<li>Define utility functions, e.g. $u_1(x,y) = x^2 y$, $u_2(x,y) = x y^2$;</li>
<li>Define initial endowments $(x_1,y_1)$ and $(x_2,y_2)$;</li>
<li>Find and plot all the Pareto-efficient allocations;</li>
<li>Find and plot all the envy-free allocations;</li>
<li>Find a competitive equilibrium.</li>
</ul>

<p>Is there a software that can do this? Or maybe a package for a general symbolic math software?</p>

CC BY-SA 3.0
2015-11-24T14:14:40.413Z
Would you mind providing a specific example? In general: if you can do the algebra symbolically then it shouldn't be to hard to write a simple program in, say, matlab which handles symbolic expressions.
clueless
CC BY-SA 3.0
2015-11-24T15:21:32.843Z
@clueless yes, it is not difficult, but there are many details and I thought that someone must have done it before.
Erel Segal-Halevi
<microeconomics><software>
A graphic calculator for simple microeconomics problems
Erel Segal-Halevi
# A graphic calculator for simple microeconomics problems

(Asked by: username_0 on 2015-11-24)

I can do simple calculations in micro-economics, such as: given the utility function of a consumer, calculate his demand curves; given utility functions of two consumers and initial endowment, calculate the competitive equilibrium; etc. However, the calculations become tedious and I am looking for a software that can do them automatically. For example, I am looking for a software where I can:

* Define utility functions, e.g. $u\_1(x,y) = x^2 y$, $u\_2(x,y) = x y^2$;
* Define initial endowments $(x\_1,y\_1)$ and $(x\_2,y\_2)$;
* Find and plot all the Pareto-efficient allocations;
* Find and plot all the envy-free allocations;
* Find a competitive equilibrium.

Is there a software that can do this? Or maybe a package for a general symbolic math software?

**Tags:** microeconomics, software
> **Comments:**
> **username_1**: Would you mind providing a specific example? In general: if you can do the algebra symbolically then it shouldn't be to hard to write a simple program in, say, matlab which handles symbolic expressions.  
> **username_0**: @clueless yes, it is not difficult, but there are many details and I thought that someone must have done it before.  

---

## 2 answers

### Answer by username_1 on 2015-11-24. Score: 3 | Accepted answer

I wrote some silly program where you just fix endowment $e=(e_1,e_2)$ and utility functions $u=(u_1(x_1,y_1),u_2(x_2,y_2))$. The example provides an illustration for your utility functions and $x_1+x_2=1$ and $y_1+y_2=1$. I've drawn 100 indifference curves on an equally spaced grid of given utility levels $\bar u_1\in[u_1(0,0),u_1(1,1)]$ (blue) and $\bar u_2\in[u_2(0,0),u_2(1,1)]$ (red). The black line is the contract curve.
I added a second figure with some initial endowment $e_1 = (0.25, 0.75)$, $e_2 = (0.75, 0.25)$ and core.


e1 = [0.25 0.75];
e2 = [0.75 0.25];

X = 0.0:0.01:(e1(1)+e2(1));
Y = 0.0:0.01:(e1(2)+e2(2));

syms x1 y1 x2 y2 u1_bar u2_bar

u1 = x1.^2*y1;
u2 = x2*y2.^2;

I1_fun = matlabFunction(solve(u1_bar == u1, y1, 'PrincipalValue', true));
I2_fun = matlabFunction(solve(u2_bar == u2, y2, 'PrincipalValue', true));

u1_x = diff(u1, x1);
u1_y = diff(u1, y1);

u2_x = diff(u2, x2);
u2_y = diff(u2, y2);

u2_x = subs(u2_x, [x2,y2], [X(end) - x1, Y(end) - y1]);
u2_y = subs(u2_y, [x2,y2], [X(end) - x1, Y(end) - y1]);

contract_curve = matlabFunction(solve(u1_y/u1_x == u2_y/u2_x, y1));

u1_min = double(subs(u1, [x1,y1], [X(1), Y(1)]));
u1_max = double(subs(u1, [x1,y1], [X(end), Y(end)]));
u1_Array = linspace(u1_min, u1_max, 100);
I1_Array = zeros(length(X), length(u1_Array));

for i = 1:length(u1_Array)
I1_Array(:,i) = I1_fun(u1_Array(i), X);
end

u2_min = double(subs(u2, [x2,y2], [X(1), Y(1)]));
u2_max = double(subs(u2, [x2,y2], [X(end), Y(end)]));
u2_Array = linspace(u2_min, u2_max, 100);
I2_Array = zeros(length(X), length(u2_Array));
for i = 1:length(u2_Array)
I2_Array(:,i) = I2_fun(u2_Array(i), X);
end

hold on
[AX, H1, H2] = plotyy(X, I1_Array, 1-X, I2_Array)
set(AX(:),'YLim',[0 1]);
set(AX(:),'YTick',[0:0.1:1])
set(H1(1:length(u1_Array)), 'Color', 'b'); 
set(H2(1:length(u2_Array)), 'Color', 'r');
set(AX(2),'YDir','reverse')
axis(AX,'square') 
%str1 = '\bullet e=(e_1,e_2)';
%text(e1(1),e1(2),str1)
plot(X, contract_curve(X), 'k', 'linewidth', 2)
hold off

> **Comments:**
> **username_1**: Yes, it's Matlab.  

---

### Answer by username_2 on 2023-10-06. Score: 3

I have used <https://www.mathcha.io> to plot this picture:

[![enter image description here](https://i.sstatic.net/zKzZb.png)](https://i.sstatic.net/zKzZb.png)


---

