Average Error: 6.6 → 0.2
Time: 22.0s
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 x.im\right) \cdot 3\right) \cdot x.re - {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 x.im\right) \cdot 3\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r9926457 = x_re;
        double r9926458 = r9926457 * r9926457;
        double r9926459 = x_im;
        double r9926460 = r9926459 * r9926459;
        double r9926461 = r9926458 - r9926460;
        double r9926462 = r9926461 * r9926459;
        double r9926463 = r9926457 * r9926459;
        double r9926464 = r9926459 * r9926457;
        double r9926465 = r9926463 + r9926464;
        double r9926466 = r9926465 * r9926457;
        double r9926467 = r9926462 + r9926466;
        return r9926467;
}

double f(double x_re, double x_im) {
        double r9926468 = x_re;
        double r9926469 = x_im;
        double r9926470 = r9926468 * r9926469;
        double r9926471 = 3.0;
        double r9926472 = r9926470 * r9926471;
        double r9926473 = r9926472 * r9926468;
        double r9926474 = pow(r9926469, r9926471);
        double r9926475 = r9926473 - r9926474;
        return r9926475;
}

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

Original6.6
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 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 0 6.5

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

    \[\leadsto \color{blue}{\left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - \left(x.im \cdot x.im\right) \cdot x.im}\]
  4. Using strategy rm
  5. Applied pow10.2

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

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

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

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

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

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

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

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

Reproduce

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