0

This is my code:

syms a1 b1 a2 b2 c d

ket_psi1 = [a1;b1];
ket_psi2 = [a2;b2];
ket_phi = [c;d];

lefthandside=kron((ket_psi1+ket_psi2),ket_phi)
righthandside=kron(ket_psi1,ket_phi)+kron(ket_psi2,ket_phi)

lefthandside-righthandside

This results in c*(a1 + a2) - a2*c - a1*c.

Description for syms is given as "syms var1 ... varN creates symbolic scalar variables var1 ... varN of type sym". So, if the symbols represent scalars, then why isn't MATLAB showing 0 instead of the given result above?

Cris Luengo
  • 49,445
  • 7
  • 57
  • 113
  • 3
    You need to explicitly ask MATLAB to simplify the expression. See [this documentation page](https://www.mathworks.com/help/symbolic/simplify-symbolic-expressions.html). – Cris Luengo Mar 10 '22 at 14:27

0 Answers0