how to expand/rewrite/simplify (cos(a)+cos(b))^2?

조회 수: 3 (최근 30일)
cfy30
cfy30 2023년 7월 27일
댓글: Nathan Hardenberg 2023년 7월 27일
I have the code below. How to expand/rewrite/simplify the expression f^2 into cos(2a), cos(2b), cos(a+b), cos(2a), cos(2b), cos(a-b), cos(b-a)?
==========================================
syms a b;
f=cos(a)+cos(b);
combine(f^2)
ans = 
shows (cos(a) + cos(b))^2
rewrite(f^2, 'sincos')
ans = 
shows (cos(a) + cos(b))^2
simplify(f^2)
ans = 
shows (cos(a) + cos(b))^2
==========================================
  댓글 수: 3
cfy30
cfy30 2023년 7월 27일
The result I am looking for is without the square, the last expression below. Any way to do it?
(cos(a) + cos(b))^2
=cos(a)^2 + 2cos(a)cos(b) + cos(b)^2
=1/2*[1+cos(2a)] + cos(a+b)+cos(a-b) + 1/2*[1+cos(2b)]
Nathan Hardenberg
Nathan Hardenberg 2023년 7월 27일
I could be wrong, but I don't think this is possible. In the rewrite() documentation you can find a list of functions that can be replaced, but squares/powers are not (yet?) one of the options.
Still I want to mention that you can find multiple simplifications with the following Code:
syms a b
expr = cos(a) + cos(b);
simplify(expr,'Steps',15,'All',true)
ans = 

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by