Average Error: 7.1 → 0.2
Time: 2.9s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
\[{x.re}^{3} - \left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.im\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
{x.re}^{3} - \left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.im
double f(double x_re, double x_im) {
        double r235708 = x_re;
        double r235709 = r235708 * r235708;
        double r235710 = x_im;
        double r235711 = r235710 * r235710;
        double r235712 = r235709 - r235711;
        double r235713 = r235712 * r235708;
        double r235714 = r235708 * r235710;
        double r235715 = r235710 * r235708;
        double r235716 = r235714 + r235715;
        double r235717 = r235716 * r235710;
        double r235718 = r235713 - r235717;
        return r235718;
}

double f(double x_re, double x_im) {
        double r235719 = x_re;
        double r235720 = 3.0;
        double r235721 = pow(r235719, r235720);
        double r235722 = x_im;
        double r235723 = r235722 * r235719;
        double r235724 = r235720 * r235723;
        double r235725 = r235724 * r235722;
        double r235726 = r235721 - r235725;
        return r235726;
}

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

Derivation

  1. Initial program 7.1

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  2. Simplified0.2

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

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

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

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

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

Reproduce

herbie shell --seed 2019354 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))