Int gives wrong answer
Show older comments
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 Comments
Robin Merkle
on 2 Mar 2022
The answer is correct. d/dx sin^2(x)/2 = sin(x)cos(x).
Torsten
on 2 Mar 2022
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.
Ali M
on 5 Mar 2022
Answers (1)
Walter Roberson
on 2 Mar 2022
0 votes
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'
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!