sin(x)^2
22 次查看(过去 30 天)
显示 更早的评论
How to expand a function like sin(x)^2 to output 1/2*(1-cos(2*x))? I tried expand(sin(x)^2) but it returns the same.
0 个评论
采纳的回答
Star Strider
2019-4-8
Use the rewrite function:
syms x
ys = sin(x)^2;
ye = rewrite(ys, 'exp')
yc = rewrite(expand(ye), 'cos')
p[roducing:
yc =
1/2 - cos(2*x)/2
更多回答(2 个)
Carlos Guerrero García
2022-11-22
Perhaps the following lines will be useful:
syms x; % Establishing 'x' as a symbolic variable
combine(sin(x)^2,'sincos') % For the 1st (original) question
combine(sin(x)^3,'sincos') % For the last question
1 个评论
John D'Errico
2022-11-22
Note that combine is a useful tool, but one we see mentioned here rarely. So...
help sym/combine
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!