Ask Your Question
1

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

asked 2022-08-03 21:55:57 +0100

rhaynes74 gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2022-08-03 23:17:30 +0100

Max Alekseyev gravatar image

One can use wildcards for this purpose:

f = cos(x)*(sin(x))^2+cos(x)^3*(sin(x))^5
w = SR.wild(0)
f.subs({sin(x)^w:((1-cos(x)^2)^floor(w/2)*sin(x)^(w-2*floor(w/2)))})
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-08-03 21:55:57 +0100

Seen: 196 times

Last updated: Aug 03 '22