\[re \cdot re - im \cdot im\]
Test:
math.square on complex, real part
Bits:
128 bits
Bits error versus re
Bits error versus im
Time: 2.8 s
Input Error: 0.0
Output Error: 0.0
Log:
Profile: 🕒
\(\left(re + im\right) \cdot \left(re - im\right)\)
  1. Started with
    \[re \cdot re - im \cdot im\]
    0.0
  2. Applied simplify to get
    \[\color{red}{re \cdot re - im \cdot im} \leadsto \color{blue}{{re}^2 - im \cdot im}\]
    0.0
  3. Using strategy rm
    0.0
  4. Applied square-unmult to get
    \[{re}^2 - \color{red}{im \cdot im} \leadsto {re}^2 - \color{blue}{{im}^2}\]
    0.0
  5. Applied difference-of-squares to get
    \[\color{red}{{re}^2 - {im}^2} \leadsto \color{blue}{\left(re + im\right) \cdot \left(re - im\right)}\]
    0.0

Original test:


(lambda ((re default) (im default))
  #:name "math.square on complex, real part"
  (- (* re re) (* im im)))