Average Error: 7.3 → 0.2
Time: 2.6s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
\[\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im + {x.re}^{3}\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im + {x.re}^{3}
double f(double x_re, double x_im) {
        double r235347 = x_re;
        double r235348 = r235347 * r235347;
        double r235349 = x_im;
        double r235350 = r235349 * r235349;
        double r235351 = r235348 - r235350;
        double r235352 = r235351 * r235347;
        double r235353 = r235347 * r235349;
        double r235354 = r235349 * r235347;
        double r235355 = r235353 + r235354;
        double r235356 = r235355 * r235349;
        double r235357 = r235352 - r235356;
        return r235357;
}

double f(double x_re, double x_im) {
        double r235358 = -3.0;
        double r235359 = x_re;
        double r235360 = x_im;
        double r235361 = r235359 * r235360;
        double r235362 = r235358 * r235361;
        double r235363 = r235362 * r235360;
        double r235364 = 3.0;
        double r235365 = pow(r235359, r235364);
        double r235366 = r235363 + r235365;
        return r235366;
}

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.3
Target0.2
Herbie0.2
\[\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)\]

Derivation

  1. Initial program 7.3

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  2. Simplified7.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, x.re \cdot \left(-x.im \cdot x.im\right), {x.re}^{3}\right)}\]
  3. Using strategy rm
  4. Applied distribute-lft-neg-in7.2

    \[\leadsto \mathsf{fma}\left(3, x.re \cdot \color{blue}{\left(\left(-x.im\right) \cdot x.im\right)}, {x.re}^{3}\right)\]
  5. Applied associate-*r*0.2

    \[\leadsto \mathsf{fma}\left(3, \color{blue}{\left(x.re \cdot \left(-x.im\right)\right) \cdot x.im}, {x.re}^{3}\right)\]
  6. Using strategy rm
  7. Applied fma-udef0.2

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

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

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

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

Reproduce

herbie shell --seed 2020002 +o rules:numerics
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))