Average Error: 7.5 → 0.2
Time: 15.4s
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\]
\[3 \cdot \left(\left(x.im \cdot x.re\right) \cdot x.re\right) - {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
3 \cdot \left(\left(x.im \cdot x.re\right) \cdot x.re\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r132381 = x_re;
        double r132382 = r132381 * r132381;
        double r132383 = x_im;
        double r132384 = r132383 * r132383;
        double r132385 = r132382 - r132384;
        double r132386 = r132385 * r132383;
        double r132387 = r132381 * r132383;
        double r132388 = r132383 * r132381;
        double r132389 = r132387 + r132388;
        double r132390 = r132389 * r132381;
        double r132391 = r132386 + r132390;
        return r132391;
}

double f(double x_re, double x_im) {
        double r132392 = 3.0;
        double r132393 = x_im;
        double r132394 = x_re;
        double r132395 = r132393 * r132394;
        double r132396 = r132395 * r132394;
        double r132397 = r132392 * r132396;
        double r132398 = pow(r132393, r132392);
        double r132399 = r132397 - r132398;
        return r132399;
}

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.5
Target0.3
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.5

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

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

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

Reproduce

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