Average Error: 7.7 → 0.2
Time: 16.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 r8226414 = x_re;
        double r8226415 = r8226414 * r8226414;
        double r8226416 = x_im;
        double r8226417 = r8226416 * r8226416;
        double r8226418 = r8226415 - r8226417;
        double r8226419 = r8226418 * r8226416;
        double r8226420 = r8226414 * r8226416;
        double r8226421 = r8226416 * r8226414;
        double r8226422 = r8226420 + r8226421;
        double r8226423 = r8226422 * r8226414;
        double r8226424 = r8226419 + r8226423;
        return r8226424;
}

double f(double x_re, double x_im) {
        double r8226425 = x_re;
        double r8226426 = x_im;
        double r8226427 = r8226425 * r8226426;
        double r8226428 = 3.0;
        double r8226429 = r8226427 * r8226428;
        double r8226430 = r8226429 * r8226425;
        double r8226431 = pow(r8226426, r8226428);
        double r8226432 = r8226430 - r8226431;
        return r8226432;
}

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.7
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.7

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

    \[\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. Taylor expanded around 0 0.2

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right) + \color{blue}{\left(2 \cdot \left(x.im \cdot x.re\right)\right)} \cdot x.re\]
  6. Taylor expanded around 0 7.6

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

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

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

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

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

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

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

    \[\leadsto x.re \cdot \left(\left(x.im \cdot x.re\right) \cdot 3\right) - {x.im}^{\color{blue}{3}}\]
  15. 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 2019171 
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"

  :herbie-target
  (+ (* (* x.re x.im) (* 2.0 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)))