Average Error: 7.2 → 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(3 \cdot \left(x.im \cdot x.re\right)\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(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r251307 = x_re;
        double r251308 = r251307 * r251307;
        double r251309 = x_im;
        double r251310 = r251309 * r251309;
        double r251311 = r251308 - r251310;
        double r251312 = r251311 * r251309;
        double r251313 = r251307 * r251309;
        double r251314 = r251309 * r251307;
        double r251315 = r251313 + r251314;
        double r251316 = r251315 * r251307;
        double r251317 = r251312 + r251316;
        return r251317;
}

double f(double x_re, double x_im) {
        double r251318 = 3.0;
        double r251319 = x_im;
        double r251320 = x_re;
        double r251321 = r251319 * r251320;
        double r251322 = r251318 * r251321;
        double r251323 = r251322 * r251320;
        double r251324 = pow(r251319, r251318);
        double r251325 = r251323 - r251324;
        return r251325;
}

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

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

    \[\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. Final simplification0.2

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

Reproduce

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