Why does the distributive property fail when comparing expressions?
Afficher commentaires plus anciens
As a simplified example, I'm trying to compare whether two expressions are equal, where they are simply written differently. But
syms a x y;
logical((x+y)*a == x*a + y*a)
returns false, and everything else that assumes distributivity of + and *. Is there some other function that will help me, or some explanation why this happens?
1 commentaire
Stephen Prunty
le 18 Avr 2018
Réponses (1)
Star Strider
le 18 Avr 2018
To get logical results with symbolic expressions, use the isAlways (link) function.
syms a x y; TF = isAlways((x+y)*a == x*a + y*a)
TF =
logical
1
Catégories
En savoir plus sur Assumptions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!