| 1 | initial version |
Sage's symbolic ring has "wildcards" for advanced substitutions.
For example, starting from the expression in the question:
sage: w0 = SR.wild(0)
sage: a.subs({sin(w0)/cos(w0): tan(w0)})
tan(x^2 + x + 1)
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.