Substitute expressions with cos and sin
I'm trying to simplify a symbolic expression obtained from sage integration. It contains terms of cos(theta)^2sin(theta)^2 and many others. I wanted to collect the coefficients of cos(theta)^2sin(theta)^2 and used subs_expr for this purpose. Here's a simplified version of what I'm trying to do:
var('theta,x,Psi')
y(theta)=cos(theta)^2*sin(theta)^2*cos(Psi)
y.subs_expr(cos(theta)^2*sin(theta)^2==x)
The result I got was "theta |--> cos(Psi)cos(theta)^2sin(theta)^2", not the expected "x*cos(Psi)". How can I get my expected result?