### replacing even powers of sin(x) by powers of (1-cos(x)^2)

Hi folks, I would like to force sage to take an expression like

f = cos(x)*(sin(x))^2+cos(x)^3*(sin(x))^5

and replace the even powers of sin(x) by powers of (1-cos(x)^2), so that the above would become

f=cos(x)*(1-cos(x)^2)+cos(x)^3*(1-cos(x)^2)^2*sin(x)

Any suggestions?