How to calculate indefinite integral?
Show older comments
Hello, I hope you den help me. I am doing my math homework and I want to check the answer in Matlab. However, I checked that the answer, that is given by Matlab, is wrong. Here is an example of what I wrote:
>> syms x >> int(sin(2*x-3), x) >> ans = sin(x-3/2)^2
But the correct answer is -cos(3-2x)/2 + C So maybe you can tell me what I do wrong because I am new in Matlab so it is quite hard. Thank you very much for your help!
Best regards, Don
Answers (2)
Brendan Hamm
on 3 Mar 2015
Edited: Brendan Hamm
on 4 Mar 2015
1 vote
First off the answer is -cos(2*x-3)/2 + C. The two statements are equivalent up to a constant. Using the half angle identity:
sin(u)^2 = 1/2 - 1/2*cos(2*u)
let u = x -3/2
sin(x-3/2)^2 + C = 1/2 - 1/2*cos(2*(x-3/2)) + C
sin(x-3/2)^2 + C = -1/2*cos(2*x-3) + D
Sean de Wolski
on 4 Mar 2015
Both answers are right, just simplified differently:
syms x
mupad_answer = int(sin(2*x-3), x)
your_answer = -cos(3-2*x)/2;
isequal(simplify(diff(your_answer)),simplify(diff(mupad_answer)))
Categories
Find more on Code Performance 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!