Average Error: 7.3 → 0.2
Time: 9.7s
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(\left(x.re \cdot x.im\right) \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
3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.re\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r207086 = x_re;
        double r207087 = r207086 * r207086;
        double r207088 = x_im;
        double r207089 = r207088 * r207088;
        double r207090 = r207087 - r207089;
        double r207091 = r207090 * r207088;
        double r207092 = r207086 * r207088;
        double r207093 = r207088 * r207086;
        double r207094 = r207092 + r207093;
        double r207095 = r207094 * r207086;
        double r207096 = r207091 + r207095;
        return r207096;
}

double f(double x_re, double x_im) {
        double r207097 = 3.0;
        double r207098 = x_re;
        double r207099 = x_im;
        double r207100 = r207098 * r207099;
        double r207101 = r207100 * r207098;
        double r207102 = r207097 * r207101;
        double r207103 = pow(r207099, r207097);
        double r207104 = r207102 - r207103;
        return r207104;
}

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

    \[\leadsto 3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.re\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)))