# Deriving a contract curve in sage

Im trying to solve for the set of pareto efficent allocations using sage. So far i'm on the right track with my code of a two by two economy with consumer A and consumer B with resource constraints given by R1 and R2 for the total amount of good 1 and good 2.

```
xa1, xa2, xb1, xb2, a, b, R1, R2 = var('xa1, xa2, xb1, xb2, a, b, R1, R2')
Ua = xa1^a * xa2^b;
Ub = xb1^a*xb2^b;
R1=xa1+xb1;
R2=xa2+xb2;
MUa1=Ua.diff(xa1)
MUa2=Ua.diff(xa2)
MUb1=Ub.diff(xb1)
MUb2=Ub.diff(xb2)
MRSA=MUa1/MUa2
MRSB=MUb1/MUb2
solve([MRSA==MRSB],xa1)
```

The solution this code gives us is:

```
[xa1 == xa2*xb1/xb2]
```

I want to reduce `xa1`

to be a function of `R1`

,`R2`

and `xb1`

.

on paper this could be found by using the definitions of `R1`

and `R2`

.

I've tried this before by including these variables in the square brackets of the solution but with no luck. Any help is appreciated.