Average Error: 7.1 → 0.2
Time: 9.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\]
\[\left(x.im \cdot \left(3 \cdot x.re\right)\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(x.im \cdot \left(3 \cdot x.re\right)\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r186399 = x_re;
        double r186400 = r186399 * r186399;
        double r186401 = x_im;
        double r186402 = r186401 * r186401;
        double r186403 = r186400 - r186402;
        double r186404 = r186403 * r186401;
        double r186405 = r186399 * r186401;
        double r186406 = r186401 * r186399;
        double r186407 = r186405 + r186406;
        double r186408 = r186407 * r186399;
        double r186409 = r186404 + r186408;
        return r186409;
}

double f(double x_re, double x_im) {
        double r186410 = x_im;
        double r186411 = 3.0;
        double r186412 = x_re;
        double r186413 = r186411 * r186412;
        double r186414 = r186410 * r186413;
        double r186415 = r186414 * r186412;
        double r186416 = pow(r186410, r186411);
        double r186417 = r186415 - r186416;
        return r186417;
}

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

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

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

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

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

Reproduce

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