Average Error: 7.3 → 0.2
Time: 10.2s
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 r336633 = x_re;
        double r336634 = r336633 * r336633;
        double r336635 = x_im;
        double r336636 = r336635 * r336635;
        double r336637 = r336634 - r336636;
        double r336638 = r336637 * r336635;
        double r336639 = r336633 * r336635;
        double r336640 = r336635 * r336633;
        double r336641 = r336639 + r336640;
        double r336642 = r336641 * r336633;
        double r336643 = r336638 + r336642;
        return r336643;
}

double f(double x_re, double x_im) {
        double r336644 = 3.0;
        double r336645 = x_re;
        double r336646 = x_im;
        double r336647 = r336645 * r336646;
        double r336648 = r336645 * r336647;
        double r336649 = r336644 * r336648;
        double r336650 = pow(r336646, r336644);
        double r336651 = r336649 - r336650;
        return r336651;
}

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 2020042 +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)))