\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
Test:
math.cube on complex, real part
Bits:
128 bits
Bits error versus x.re
Bits error versus x.im
Time: 26.1 s
Input Error: 6.2
Output Error: 0.3
Log:
Profile: 🕒
\({x.re}^2 \cdot \left(x.re + x.im\right) + \left(\left(-\left(x.re + x.im\right)\right) - \left(x.im + x.im\right)\right) \cdot \left(x.im \cdot x.re\right)\)
  1. Started with
    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
    6.2
  2. Applied simplify to get
    \[\color{red}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im} \leadsto \color{blue}{x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}\]
    6.3
  3. Using strategy rm
    6.3
  4. Applied sub-neg to get
    \[x.re \cdot \left(\left(x.re + x.im\right) \cdot \color{red}{\left(x.re - x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \leadsto x.re \cdot \left(\left(x.re + x.im\right) \cdot \color{blue}{\left(x.re + \left(-x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right)\]
    6.3
  5. Applied distribute-lft-in to get
    \[x.re \cdot \left(\color{red}{\left(x.re + x.im\right) \cdot \left(x.re + \left(-x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \leadsto x.re \cdot \left(\color{blue}{\left(\left(x.re + x.im\right) \cdot x.re + \left(x.re + x.im\right) \cdot \left(-x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right)\]
    6.3
  6. Applied associate--l+ to get
    \[x.re \cdot \color{red}{\left(\left(\left(x.re + x.im\right) \cdot x.re + \left(x.re + x.im\right) \cdot \left(-x.im\right)\right) - \left(x.im + x.im\right) \cdot x.im\right)} \leadsto x.re \cdot \color{blue}{\left(\left(x.re + x.im\right) \cdot x.re + \left(\left(x.re + x.im\right) \cdot \left(-x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)}\]
    6.3
  7. Applied distribute-lft-in to get
    \[\color{red}{x.re \cdot \left(\left(x.re + x.im\right) \cdot x.re + \left(\left(x.re + x.im\right) \cdot \left(-x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \leadsto \color{blue}{x.re \cdot \left(\left(x.re + x.im\right) \cdot x.re\right) + x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(-x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}\]
    6.3
  8. Applied simplify to get
    \[\color{red}{x.re \cdot \left(\left(x.re + x.im\right) \cdot x.re\right)} + x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(-x.im\right) - \left(x.im + x.im\right) \cdot x.im\right) \leadsto \color{blue}{{x.re}^2 \cdot \left(x.re + x.im\right)} + x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(-x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\]
    6.3
  9. Applied simplify to get
    \[{x.re}^2 \cdot \left(x.re + x.im\right) + \color{red}{x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(-x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \leadsto {x.re}^2 \cdot \left(x.re + x.im\right) + \color{blue}{\left(\left(-\left(x.re + x.im\right)\right) - \left(x.im + x.im\right)\right) \cdot \left(x.im \cdot x.re\right)}\]
    0.3

Original test:


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