Why is MATLAB giving false output for A and B being equal?

  • Context: MATLAB 
  • Thread starter Thread starter stihl29
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
stihl29
Messages
24
Reaction score
0
i have this code

A = [2 -2;-2 -1];
A=orth(A);
B=inv(A);
if A==B
disp('match');
else
disp('no match');
end

they are the same, but i always get the output 'no match'

any ideas?
 
Physics news on Phys.org
Technically A is not equal to B because the inverse algorithm gives only an approximation.

To see this,

Code:
>> orth([2 -2;-2 -1]) - inv(orth([2 -2;-2 -1]))
ans =
  1.0e-015 *
   0.888178419700125  -0.444089209850063
  -0.388578058618805  -0.777156117237609

So your expression is being analysed as false.