MATLAB: Problem Integrating sin(2*x)

integrationproblem

>> syms x >> f=sin(2*x)
f =
sin(2*x)
>> int(f)
ans =
sin(x)^2
>>
I am sure it is wrong because it should be -1/2+sin(x)^2

Best Answer

The integral is:
sin(x)^2 + C
but Matlab just doesn't show the constant. How do you get the -1/2? Because if you differentiate the integral (sin(x)^2 + C) you get:
2*sin(x)*cos(x) = sin(2*x)
And the constant differentiated gives 0 since it doesnt depend on x.