Average Error: 7.3 → 0.2
Time: 2.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\]
\[\left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - {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
\left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r202191 = x_re;
        double r202192 = r202191 * r202191;
        double r202193 = x_im;
        double r202194 = r202193 * r202193;
        double r202195 = r202192 - r202194;
        double r202196 = r202195 * r202193;
        double r202197 = r202191 * r202193;
        double r202198 = r202193 * r202191;
        double r202199 = r202197 + r202198;
        double r202200 = r202199 * r202191;
        double r202201 = r202196 + r202200;
        return r202201;
}

double f(double x_re, double x_im) {
        double r202202 = 3.0;
        double r202203 = x_im;
        double r202204 = r202202 * r202203;
        double r202205 = x_re;
        double r202206 = r202204 * r202205;
        double r202207 = r202206 * r202205;
        double r202208 = pow(r202203, r202202);
        double r202209 = r202207 - r202208;
        return r202209;
}

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

    \[\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. Using strategy rm
  6. Applied associate-*r*0.2

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

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

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

Reproduce

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