Different answers when I do the same integration

Hey,
I'm getting different answers when I perform the same integration but by just expanding the squared term.
How is this possible?
As I procced further, I'm getting 2 completely different answers as my result.
Which one is correct?
PS: I'm getting the same answer even after using 'IgnoreAnalyticConstraints',true.
Thanks

4 件のコメント

Stephen23
Stephen23 2022 年 9 月 13 日
They don't look very similar:
X = linspace(0,pi,1e3);
Y1 = (1-cos(X)).^2;
Y2 = 1+cos(X).^2-2*(1-cos(X));
plot(X,Y1,X,Y2)
Nishanth Pradyumna
Nishanth Pradyumna 2022 年 9 月 13 日
編集済み: Nishanth Pradyumna 2022 年 9 月 13 日
I have just used the identity (a-b)^2 = (a^2 + b^2 - 2ab). Technically, I should get the same results.
David Hill
David Hill 2022 年 9 月 13 日
-2ab = -2*cos(n) and is not the same as -2*(1-cos(x))
Nishanth Pradyumna
Nishanth Pradyumna 2022 年 9 月 13 日
My bad. That was a dumb typo. Thanks.

サインインしてコメントする。

回答 (1 件)

David Hill
David Hill 2022 年 9 月 13 日

0 投票

They are not the same expressions.
syms x
int((1+cos(x))^2,0,pi)
ans = 
int(1+2*cos(x)+cos(x)^2,0,pi)
ans = 
int(1+cos(x)^2-2*(1-cos(x)),0,pi)%this is not the same expression
ans = 

2 件のコメント

Nishanth Pradyumna
Nishanth Pradyumna 2022 年 9 月 13 日
編集済み: Nishanth Pradyumna 2022 年 9 月 13 日
My bad, added the wrong screenshot. please try int((1-cos(x))^2,0,pi).
I did not get the same answer with that. (please check the updated screenshot)
Torsten
Torsten 2022 年 9 月 13 日
Look up the binomial formula:
(a-b)^2 = a^2 - 2*a*b + b^2

サインインしてコメントする。

カテゴリ

製品

リリース

R2022a

質問済み:

2022 年 9 月 13 日

コメント済み:

2022 年 9 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by