mentat-collective / emmy

The Emmy Computer Algebra System.
https://emmy.mentat.org
GNU General Public License v3.0
405 stars 24 forks source link

simplifier doesn't detect exp(i x) * exp(- i x) = 1 #188

Open light-matters opened 2 months ago

light-matters commented 2 months ago

Without I, the simplifier does as expected:

(e/simplify (* (e/exp (* -1 (c/complex 'k)))
               (e/exp (* 1 (c/complex 'k)))))  ;=>1

With I, it does something very different:

(e/simplify (* (e/exp (* -1 I (complex 'k)))
               (e/exp (* 1 I (complex 'k)))))
;=> #emmy/complex [(- (* (cos (* -1 k)) (cos k)) (* (sin (* -1 k)) (sin k))) (+ (* (cos (* -1 k)) (sin k)) (* (sin (* -1 k)) (cos k)))]

This is a problem because multiplying by the conjugate is a very common operation.