Matlab ignores pi in a function

1 vue (au cours des 30 derniers jours)
Alex CB
Alex CB le 3 Jan 2016
When I try to use:
syms x; y=3*cos(pi-x^2); diff(y)
it gives
6*x*sin(x^2)
it ignores the pi, giving an incorrect solution and I don't know how to solve it.
It also says that "y=-3*cos(x^2)", ignoring the pi again.
Thanks in advance.

Réponse acceptée

Image Analyst
Image Analyst le 3 Jan 2016
Why do you incorrectly think that cos(pi-theta) is not equal to -cos(theta)? It is. Just try plotting some angles on the unit circle to prove it to yourself. So you can use either equation because they are equivalent.
  1 commentaire
Alex CB
Alex CB le 3 Jan 2016
...I see it now, it seems I'm just an idiot.
Thank you so much, I'm sorry for the troubles.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by