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

Error

Bits error versus x.re

Bits error versus x.im

Target

Original6.9
Target0.2
Herbie0.6
\[\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. Taylor expanded around 0 6.8

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

    \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  4. Using strategy rm
  5. Applied add-cube-cbrt0.6

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right) + \color{blue}{\left(\left(\sqrt[3]{x.re \cdot x.im + x.im \cdot x.re} \cdot \sqrt[3]{x.re \cdot x.im + x.im \cdot x.re}\right) \cdot \sqrt[3]{x.re \cdot x.im + x.im \cdot x.re}\right)} \cdot x.re\]
  6. Applied associate-*l*0.6

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

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

Reproduce

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