Average Error: 7.7 → 0.2
Time: 8.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\]
\[\left(3 \cdot x.re\right) \cdot \left(x.im \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
\left(3 \cdot x.re\right) \cdot \left(x.im \cdot x.re\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r255354 = x_re;
        double r255355 = r255354 * r255354;
        double r255356 = x_im;
        double r255357 = r255356 * r255356;
        double r255358 = r255355 - r255357;
        double r255359 = r255358 * r255356;
        double r255360 = r255354 * r255356;
        double r255361 = r255356 * r255354;
        double r255362 = r255360 + r255361;
        double r255363 = r255362 * r255354;
        double r255364 = r255359 + r255363;
        return r255364;
}

double f(double x_re, double x_im) {
        double r255365 = 3.0;
        double r255366 = x_re;
        double r255367 = r255365 * r255366;
        double r255368 = x_im;
        double r255369 = r255368 * r255366;
        double r255370 = r255367 * r255369;
        double r255371 = pow(r255368, r255365);
        double r255372 = r255370 - r255371;
        return r255372;
}

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

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

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

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

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

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

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(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)))