Average Error: 7.0 → 0.6
Time: 24.1s
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\]
\[x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(\frac{\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.im\right) \cdot \left(x.im + x.re\right)}}{\sqrt[3]{x.im + x.re}} \cdot \left(\left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.re - x.im}\right) \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right)\right) \cdot \left(x.im + x.re\right)\]
\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
x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(\frac{\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.im\right) \cdot \left(x.im + x.re\right)}}{\sqrt[3]{x.im + x.re}} \cdot \left(\left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.re - x.im}\right) \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right)\right) \cdot \left(x.im + x.re\right)
double f(double x_re, double x_im) {
        double r8091086 = x_re;
        double r8091087 = r8091086 * r8091086;
        double r8091088 = x_im;
        double r8091089 = r8091088 * r8091088;
        double r8091090 = r8091087 - r8091089;
        double r8091091 = r8091090 * r8091088;
        double r8091092 = r8091086 * r8091088;
        double r8091093 = r8091088 * r8091086;
        double r8091094 = r8091092 + r8091093;
        double r8091095 = r8091094 * r8091086;
        double r8091096 = r8091091 + r8091095;
        return r8091096;
}

double f(double x_re, double x_im) {
        double r8091097 = x_re;
        double r8091098 = x_im;
        double r8091099 = r8091097 * r8091098;
        double r8091100 = r8091099 + r8091099;
        double r8091101 = r8091097 * r8091100;
        double r8091102 = r8091097 - r8091098;
        double r8091103 = r8091102 * r8091098;
        double r8091104 = r8091098 + r8091097;
        double r8091105 = r8091103 * r8091104;
        double r8091106 = cbrt(r8091105);
        double r8091107 = cbrt(r8091104);
        double r8091108 = r8091106 / r8091107;
        double r8091109 = cbrt(r8091098);
        double r8091110 = cbrt(r8091102);
        double r8091111 = r8091109 * r8091110;
        double r8091112 = cbrt(r8091103);
        double r8091113 = r8091111 * r8091112;
        double r8091114 = r8091108 * r8091113;
        double r8091115 = r8091114 * r8091104;
        double r8091116 = r8091101 + r8091115;
        return r8091116;
}

Error

Bits error versus x.re

Bits error versus x.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.0
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 7.0

    \[\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. 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.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  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.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.7

    \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \sqrt[3]{\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\]
  7. Using strategy rm
  8. Applied flip--7.5

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

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \sqrt[3]{\color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}{x.re + x.im}}}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  10. Applied cbrt-div7.4

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \color{blue}{\frac{\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}}{\sqrt[3]{x.re + x.im}}}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  11. Simplified0.7

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \frac{\color{blue}{\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.im\right) \cdot \left(x.im + x.re\right)}}}{\sqrt[3]{x.re + x.im}}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  12. Using strategy rm
  13. Applied cbrt-prod0.6

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

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

Reproduce

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