Test equality of two symbolic expressions
    12 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Vinicius Lopes Simoes
 il 11 Mag 2020
  
    
    
    
    
    Risposto: Steven Lord
    
      
 il 11 Mag 2020
            Suppose, for the sake of simplicity, that I need to compare two equivalent symbolic expressions in Matlab.
syms a b
x = sin(a + b);
y = sin(a)*cos(b) + sin(b)*cos(a);
And, obviously, we know that  . Now if I use the Matlab functions isequal (or isequaln), I don't get the expected result, which is a logical 1, because this is an equality:
. Now if I use the Matlab functions isequal (or isequaln), I don't get the expected result, which is a logical 1, because this is an equality:
 . Now if I use the Matlab functions isequal (or isequaln), I don't get the expected result, which is a logical 1, because this is an equality:
. Now if I use the Matlab functions isequal (or isequaln), I don't get the expected result, which is a logical 1, because this is an equality:>> isequal(x,y)
ans =
    logical
    0
Why does it happen? Is there any function that does what I am trying to do?
Thanks!
0 Commenti
Risposta accettata
  Steven Lord
    
      
 il 11 Mag 2020
        Ask MATLAB if those two symbolic expressions isAlways equal.
>> syms a b
>> x = sin(a + b);
>> y = sin(a)*cos(b) + sin(b)*cos(a);
>> isAlways(x==y)
ans =
  logical
   1
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Assumptions in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

