Average Error: 7.4 → 0.2
Time: 18.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(x.re \cdot \left(x.re \cdot x.im\right)\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(x.re \cdot \left(x.re \cdot x.im\right)\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r317520 = x_re;
        double r317521 = r317520 * r317520;
        double r317522 = x_im;
        double r317523 = r317522 * r317522;
        double r317524 = r317521 - r317523;
        double r317525 = r317524 * r317522;
        double r317526 = r317520 * r317522;
        double r317527 = r317522 * r317520;
        double r317528 = r317526 + r317527;
        double r317529 = r317528 * r317520;
        double r317530 = r317525 + r317529;
        return r317530;
}

double f(double x_re, double x_im) {
        double r317531 = 3.0;
        double r317532 = x_re;
        double r317533 = x_im;
        double r317534 = r317532 * r317533;
        double r317535 = r317532 * r317534;
        double r317536 = r317531 * r317535;
        double r317537 = pow(r317533, r317531);
        double r317538 = r317536 - r317537;
        return r317538;
}

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

    \[\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(x.re \cdot \left(x.re \cdot x.im\right)\right) - {x.im}^{3}}\]
  3. Final simplification0.2

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

Reproduce

herbie shell --seed 2020043 +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)))