Int gives wrong answer

5 visualizzazioni (ultimi 30 giorni)
Ali M
Ali M il 2 Mar 2022
Commentato: Ali M il 5 Mar 2022
syms x
f(x) = cos(x)*sin(x);
Fx = int(f,x)
Fx(x) = 
Fx(x) =
sin(x)^2/2
while the correct answer is -cos(x)^2/2
  3 Commenti
Torsten
Torsten il 2 Mar 2022
Since sin(x)^2/2 = -cos(x)^2/2 + 1/2, both answers are correct.
Note that both answers only differ by a constant, namely 1/2.
Ali M
Ali M il 5 Mar 2022
Thanks @Torsten & @Robin Merkle! @Torsten I would vote for you but I cant, your is a comment not an answer

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 2 Mar 2022
Remember that indefinite integration always has an implied "plus a constant". So any two results of int() that differ by a constant are the same integral result. And sin squared plus cos squared equals 1 so the two possibilities are the same up to the constant.
You can ask to rewrite() to 'cos'

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by