Average Error: 7.6 → 0.2
Time: 2.8s
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 r280367 = x_re;
        double r280368 = r280367 * r280367;
        double r280369 = x_im;
        double r280370 = r280369 * r280369;
        double r280371 = r280368 - r280370;
        double r280372 = r280371 * r280369;
        double r280373 = r280367 * r280369;
        double r280374 = r280369 * r280367;
        double r280375 = r280373 + r280374;
        double r280376 = r280375 * r280367;
        double r280377 = r280372 + r280376;
        return r280377;
}

double f(double x_re, double x_im) {
        double r280378 = 3.0;
        double r280379 = x_im;
        double r280380 = x_re;
        double r280381 = r280379 * r280380;
        double r280382 = r280381 * r280380;
        double r280383 = r280378 * r280382;
        double r280384 = pow(r280379, r280378);
        double r280385 = r280383 - r280384;
        return r280385;
}

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.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 7.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. 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 2020062 
(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)))