Average Error: 6.9 → 7.0
Time: 26.0s
Precision: 64
Internal Precision: 128
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
\[x.im \cdot \left(\left(x.re + \left(x.re + x.re\right)\right) \cdot x.re - x.im \cdot x.im\right)\]

Error

Bits error versus x.re

Bits error versus x.im

Target

Original6.9
Target0.2
Herbie7.0
\[\left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\]

Derivation

  1. Initial program 6.9

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  2. Simplified7.0

    \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot \left(x.re + \left(x.re + x.re\right)\right) - x.im \cdot x.im\right)}\]
  3. Final simplification7.0

    \[\leadsto x.im \cdot \left(\left(x.re + \left(x.re + x.re\right)\right) \cdot x.re - x.im \cdot x.im\right)\]

Reproduce

herbie shell --seed 2019091 +o rules:numerics
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"

  :herbie-target
  (+ (* (* x.re x.im) (* 2 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im)))

  (+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re)))