Average Error: 7.3 → 0.2
Time: 51.1s
Precision: 64
Internal Precision: 128
\[\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\]
\[\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.re + x.im\right) - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\]

Error

Bits error versus x.re

Bits error versus x.im

Target

Original7.3
Target0.3
Herbie0.2
\[\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)\]

Derivation

  1. Initial program 7.3

    \[\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\]
  2. Taylor expanded around 0 7.2

    \[\leadsto \color{blue}{\left({x.re}^{3} - {x.im}^{2} \cdot x.re\right)} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  3. Simplified0.2

    \[\leadsto \color{blue}{\left(x.im + x.re\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  4. Final simplification0.2

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

Reproduce

herbie shell --seed 2019091 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"

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

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