Average Error: 7.4 → 0.2
Time: 3.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\]
\[{\left(\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\right)}^{1} - {x.im}^{3}\]
\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 \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\right)}^{1} - {x.im}^{3}
double f(double x_re, double x_im) {
        double r167393 = x_re;
        double r167394 = r167393 * r167393;
        double r167395 = x_im;
        double r167396 = r167395 * r167395;
        double r167397 = r167394 - r167396;
        double r167398 = r167397 * r167395;
        double r167399 = r167393 * r167395;
        double r167400 = r167395 * r167393;
        double r167401 = r167399 + r167400;
        double r167402 = r167401 * r167393;
        double r167403 = r167398 + r167402;
        return r167403;
}

double f(double x_re, double x_im) {
        double r167404 = x_re;
        double r167405 = 3.0;
        double r167406 = r167404 * r167405;
        double r167407 = x_im;
        double r167408 = r167407 * r167404;
        double r167409 = r167406 * r167408;
        double r167410 = 1.0;
        double r167411 = pow(r167409, r167410);
        double r167412 = pow(r167407, r167405);
        double r167413 = r167411 - r167412;
        return r167413;
}

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

    \[\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. Simplified7.4

    \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right) - {x.im}^{3}}\]
  3. Using strategy rm
  4. Applied associate-*r*0.2

    \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} - {x.im}^{3}\]
  5. Using strategy rm
  6. Applied associate-*r*0.2

    \[\leadsto \color{blue}{\left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re} - {x.im}^{3}\]
  7. Using strategy rm
  8. Applied add-cube-cbrt0.2

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

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

    \[\leadsto \left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \left(x.im \cdot x.re\right)\right)\right) \cdot \color{blue}{{x.re}^{1}} - {x.im}^{3}\]
  12. Applied pow10.3

    \[\leadsto \left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \left(x.im \cdot \color{blue}{{x.re}^{1}}\right)\right)\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  13. Applied pow10.3

    \[\leadsto \left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \left(\color{blue}{{x.im}^{1}} \cdot {x.re}^{1}\right)\right)\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  14. Applied pow-prod-down0.3

    \[\leadsto \left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \color{blue}{{\left(x.im \cdot x.re\right)}^{1}}\right)\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  15. Applied pow10.3

    \[\leadsto \left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\color{blue}{{\left(\sqrt[3]{3}\right)}^{1}} \cdot {\left(x.im \cdot x.re\right)}^{1}\right)\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  16. Applied pow-prod-down0.3

    \[\leadsto \left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \color{blue}{{\left(\sqrt[3]{3} \cdot \left(x.im \cdot x.re\right)\right)}^{1}}\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  17. Applied pow10.3

    \[\leadsto \left(\left(\sqrt[3]{3} \cdot \color{blue}{{\left(\sqrt[3]{3}\right)}^{1}}\right) \cdot {\left(\sqrt[3]{3} \cdot \left(x.im \cdot x.re\right)\right)}^{1}\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  18. Applied pow10.3

    \[\leadsto \left(\left(\color{blue}{{\left(\sqrt[3]{3}\right)}^{1}} \cdot {\left(\sqrt[3]{3}\right)}^{1}\right) \cdot {\left(\sqrt[3]{3} \cdot \left(x.im \cdot x.re\right)\right)}^{1}\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  19. Applied pow-prod-down0.3

    \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right)}^{1}} \cdot {\left(\sqrt[3]{3} \cdot \left(x.im \cdot x.re\right)\right)}^{1}\right) \cdot {x.re}^{1} - {x.im}^{3}\]
  20. Applied pow-prod-down0.3

    \[\leadsto \color{blue}{{\left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \left(x.im \cdot x.re\right)\right)\right)}^{1}} \cdot {x.re}^{1} - {x.im}^{3}\]
  21. Applied pow-prod-down0.3

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

    \[\leadsto {\color{blue}{\left(\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\right)}}^{1} - {x.im}^{3}\]
  23. Final simplification0.2

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

Reproduce

herbie shell --seed 2020060 
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"
  :precision binary64

  :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)))