1 | initial version |

I don't know of a method that will work for all expressions, but there is a way of doing it depending on the expression. I don't think this is what you are looking for, but may help you in finding the solution to your problem

```
from sympy import *
from sympy.abc import *
print cse([(a-b),factor(a^2-b^2)])
print cse([sin(x),cos(x),sin(y),cos(y),expand(cos(x+y),trig=True)])
```

The output is

```
([(x0, a - b)], [x0, x0*(a + b)])
([(x0, cos(x)), (x1, cos(y)), (x2, sin(x)), (x3, sin(y))], [x2, x0, x3,
x1, x0*x1 - x2*x3])
```

The first element are the substitutions and the second element is the original expression in terms of these substitutions. You still have to get the expression explicitly in terms of the subexpressions you want.

I know in Mathematica there is a function called "Eliminate", which does what you are trying to do, but I am not aware of an equivalent statement in sage.

Sorry for an incomplete answer.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.