Int gives wrong answer
3 次查看(过去 30 天)
显示 更早的评论
syms x
f(x) = cos(x)*sin(x);
Fx = int(f,x)
Fx(x) =
sin(x)^2/2
while the correct answer is -cos(x)^2/2
3 个评论
Torsten
2022-3-2
Since sin(x)^2/2 = -cos(x)^2/2 + 1/2, both answers are correct.
Note that both answers only differ by a constant, namely 1/2.
回答(1 个)
Walter Roberson
2022-3-2
Remember that indefinite integration always has an implied "plus a constant". So any two results of int() that differ by a constant are the same integral result. And sin squared plus cos squared equals 1 so the two possibilities are the same up to the constant.
You can ask to rewrite() to 'cos'
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!