Average Error: 7.3 → 0.2
Time: 17.6s
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 r231554 = x_re;
        double r231555 = r231554 * r231554;
        double r231556 = x_im;
        double r231557 = r231556 * r231556;
        double r231558 = r231555 - r231557;
        double r231559 = r231558 * r231556;
        double r231560 = r231554 * r231556;
        double r231561 = r231556 * r231554;
        double r231562 = r231560 + r231561;
        double r231563 = r231562 * r231554;
        double r231564 = r231559 + r231563;
        return r231564;
}

double f(double x_re, double x_im) {
        double r231565 = 3.0;
        double r231566 = x_re;
        double r231567 = x_im;
        double r231568 = r231566 * r231567;
        double r231569 = r231566 * r231568;
        double r231570 = r231565 * r231569;
        double r231571 = pow(r231567, r231565);
        double r231572 = r231570 - r231571;
        return r231572;
}

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.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.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\]
  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 2020047 +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)))