Different answers when I do the same integration

2 次查看(过去 30 天)
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 个评论
David Hill
David Hill 2022-9-13
-2ab = -2*cos(n) and is not the same as -2*(1-cos(x))

请先登录,再进行评论。

回答(1 个)

David Hill
David Hill 2022-9-13
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)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by