MATLAB: Int function gives strange integral

intintegral

I was experimenting with the int() function which gave me a strange integral.
syms x;
f2 = @(x) sin(x) + 2*cos(x);
integral = int(f2, x)
which gave me:
integral =
-2*cos(x/2)*(cos(x/2) - 2*sin(x/2))
Any idea why this is the case? I expected something along the lines of -cos(x) – 2*sin(x); is this the same expression written differently or is my code written incorrectly, or is something else going on?

Best Answer

Hi Abhishek,
I believe you meant -cos(x) + 2*sin(x) is expected. The answer you got is equal to -cos(x) + 2*sin(x) -1, so the answer included a constant of integration of -1. It might be strange, but it's not wrong. Disappointing, let's say.