Average Error: 7.7 → 0.2
Time: 3.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(\left(x.im \cdot x.re\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.im \cdot x.re\right) \cdot x.re\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r247250 = x_re;
        double r247251 = r247250 * r247250;
        double r247252 = x_im;
        double r247253 = r247252 * r247252;
        double r247254 = r247251 - r247253;
        double r247255 = r247254 * r247252;
        double r247256 = r247250 * r247252;
        double r247257 = r247252 * r247250;
        double r247258 = r247256 + r247257;
        double r247259 = r247258 * r247250;
        double r247260 = r247255 + r247259;
        return r247260;
}

double f(double x_re, double x_im) {
        double r247261 = 3.0;
        double r247262 = x_im;
        double r247263 = x_re;
        double r247264 = r247262 * r247263;
        double r247265 = r247264 * r247263;
        double r247266 = r247261 * r247265;
        double r247267 = pow(r247262, r247261);
        double r247268 = r247266 - r247267;
        return r247268;
}

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

    \[\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. Simplified7.7

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

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

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

Reproduce

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