>> 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

 採用された回答

Paul
Paul 2014 年 3 月 5 日

1 投票

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.

4 件のコメント

Ricardo
Ricardo 2014 年 3 月 5 日
編集済み: Ricardo 2014 年 3 月 5 日
I got the 1/2 integrating on my notebook, following my integration formulas i got: (-1/2)*cos(2x) "but when I saw it was different from matlab´s answer i tried to fit on it by (-1/2)*cos(2x)=(-1/2)*(cos^2(x)-sin^2(x)) =(-1/2)*(1-sin^2(x)-sin^2(x)) =(-1/2)+sin^2(x)
Paul
Paul 2014 年 3 月 5 日
編集済み: Paul 2014 年 3 月 5 日
Yes, (-1/2)*cos(2x) is also correct. The constant just doesn't matter in the integral because it could be anything, see http://en.wikipedia.org/wiki/Constant_of_integration. Because if you use the integral to calculate the area under the graph of f you will get the same result with any constant. In this case you will get the same result using sin(x)^2 or (-1/2)*cos(2x).
Ricardo
Ricardo 2014 年 3 月 5 日
編集済み: Ricardo 2014 年 3 月 5 日
All right, Thanks!!
Gustavo Leal
Gustavo Leal 2017 年 10 月 9 日
sin(pi)^2 != -cos (2pi)/2 ,for example, something its wrong with this function at MATLab

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2014 年 3 月 5 日

コメント済み:

2017 年 10 月 9 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by