Average Error: 6.6 → 0.3
Time: 54.9s
Precision: 64
\[\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(\left(x.im + x.re\right) \cdot x.im\right) \cdot (\left(-\sqrt[3]{x.im}\right) \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right) + \left(\sqrt[3]{x.im} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right)\right))_* + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right) + \left(\left(x.im + x.re\right) \cdot x.im\right) \cdot \left(x.re - x.im\right)\]
double f(double x_re, double x_im) {
        double r24059984 = x_re;
        double r24059985 = r24059984 * r24059984;
        double r24059986 = x_im;
        double r24059987 = r24059986 * r24059986;
        double r24059988 = r24059985 - r24059987;
        double r24059989 = r24059988 * r24059986;
        double r24059990 = r24059984 * r24059986;
        double r24059991 = r24059986 * r24059984;
        double r24059992 = r24059990 + r24059991;
        double r24059993 = r24059992 * r24059984;
        double r24059994 = r24059989 + r24059993;
        return r24059994;
}

double f(double x_re, double x_im) {
        double r24059995 = x_im;
        double r24059996 = x_re;
        double r24059997 = r24059995 + r24059996;
        double r24059998 = r24059997 * r24059995;
        double r24059999 = cbrt(r24059995);
        double r24060000 = -r24059999;
        double r24060001 = r24059999 * r24059999;
        double r24060002 = r24059999 * r24060001;
        double r24060003 = fma(r24060000, r24060001, r24060002);
        double r24060004 = r24059998 * r24060003;
        double r24060005 = r24059996 * r24059995;
        double r24060006 = r24060005 + r24060005;
        double r24060007 = r24059996 * r24060006;
        double r24060008 = r24060004 + r24060007;
        double r24060009 = r24059996 - r24059995;
        double r24060010 = r24059998 * r24060009;
        double r24060011 = r24060008 + r24060010;
        return r24060011;
}

\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(\left(x.im + x.re\right) \cdot x.im\right) \cdot (\left(-\sqrt[3]{x.im}\right) \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right) + \left(\sqrt[3]{x.im} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right)\right))_* + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right) + \left(\left(x.im + x.re\right) \cdot x.im\right) \cdot \left(x.re - x.im\right)

Error

Bits error versus x.re

Bits error versus x.im

Target

Original6.6
Target0.2
Herbie0.3
\[\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.6

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

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

    \[\leadsto \left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(\color{blue}{\left(\sqrt[3]{x.re} \cdot \sqrt[3]{x.re}\right) \cdot \sqrt[3]{x.re}} - \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right) \cdot \sqrt[3]{x.im}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  7. Applied prod-diff0.7

    \[\leadsto \left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \color{blue}{\left((\left(\sqrt[3]{x.re} \cdot \sqrt[3]{x.re}\right) \cdot \left(\sqrt[3]{x.re}\right) + \left(-\sqrt[3]{x.im} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right)\right))_* + (\left(-\sqrt[3]{x.im}\right) \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right) + \left(\sqrt[3]{x.im} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right)\right))_*\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  8. Applied distribute-lft-in0.7

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

    \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot (\left(\sqrt[3]{x.re} \cdot \sqrt[3]{x.re}\right) \cdot \left(\sqrt[3]{x.re}\right) + \left(-\sqrt[3]{x.im} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right)\right))_* + \left(\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot (\left(-\sqrt[3]{x.im}\right) \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right) + \left(\sqrt[3]{x.im} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right)\right))_* + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)}\]
  10. Simplified0.3

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

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

Reproduce

herbie shell --seed 2019102 +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)))