Derivative of a real function becomes complex
Afficher commentaires plus anciens
Look at these expressions:

Even if every function and variable is real, the result is a complex number. Each step seems valid, but the sequence gives unexpected results. It seems to arise from the particular way it expresses the denominator of cos(atan2(y,x)).
Is the result valid? If not, how can I avoid this transformation?
sqrt(x^2 + y^2) = abs(x + i*y)
All this appears inside a symbolic expression (x and y are expressions too), so I can't manually rewrite them.
1 commentaire
Walter Roberson
le 2 Mai 2018
When I test in Maple, I do not see the same difficulty by default, provided that I have put the assumption of 'real' in place like you did. However, in Maple if I hold off the assumption of real until after the diff() then I am able to replicate the problem.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Code Performance dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!