MATLAB: Integration showing wrong answer

integrationwrong answer

Best Answer

It is the correct result, although it may not be the one you were anticipaiting.
Try this:
syms x
f(x) = sin(x)+2*cos(x)
intf = int(f)
simplifiedResult = simplify(intf, 'Steps', 100)
producing:
f(x) =
2*cos(x) + sin(x)
intf(x) =
-2*cos(x/2)*(cos(x/2) - 2*sin(x/2))
simplifiedResult(x) =
2*sin(x) - cos(x) - 1