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

Error

Bits error versus x.re

Bits error versus x.im

Target

Original7.0
Target0.2
Herbie0.6
\[\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. Using strategy rm
  3. Applied difference-of-squares7.0

    \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  4. Applied associate-*l*0.2

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

    \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right) \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  7. Using strategy rm
  8. Applied pow10.7

    \[\leadsto \left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right) \cdot \color{blue}{{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1}} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  9. Applied pow20.7

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{2}} \cdot {\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  10. Applied pow-prod-up0.6

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

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

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

Reproduce

herbie shell --seed 2019089 +o rules:numerics
(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)))