Average Error: 7.0 → 0.7
Time: 6.0m
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(\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.re + x.im\right)} \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.re + x.im\right)}\right) \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.re + x.im\right)} - \left(x.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im\]

Error

Bits error versus x.re

Bits error versus x.im

Target

Original7.0
Target0.2
Herbie0.7
\[\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.0

    \[\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 inf 6.9

    \[\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. Using strategy rm
  5. Applied add-cube-cbrt0.7

    \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.im + x.re\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)} \cdot \sqrt[3]{\left(x.im + x.re\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)}\right) \cdot \sqrt[3]{\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\]
  6. Final simplification0.7

    \[\leadsto \left(\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.re + x.im\right)} \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.re + x.im\right)}\right) \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.re + x.im\right)} - \left(x.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im\]

Reproduce

herbie shell --seed 2019089 
(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)))