Average Error: 7.7 → 0.2
Time: 14.5s
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(x.im \cdot 3\right) \cdot \left(x.re \cdot x.im\right)\]
\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(x.im \cdot 3\right) \cdot \left(x.re \cdot x.im\right)
double f(double x_re, double x_im) {
        double r296590 = x_re;
        double r296591 = r296590 * r296590;
        double r296592 = x_im;
        double r296593 = r296592 * r296592;
        double r296594 = r296591 - r296593;
        double r296595 = r296594 * r296590;
        double r296596 = r296590 * r296592;
        double r296597 = r296592 * r296590;
        double r296598 = r296596 + r296597;
        double r296599 = r296598 * r296592;
        double r296600 = r296595 - r296599;
        return r296600;
}

double f(double x_re, double x_im) {
        double r296601 = x_re;
        double r296602 = 3.0;
        double r296603 = pow(r296601, r296602);
        double r296604 = x_im;
        double r296605 = r296604 * r296602;
        double r296606 = r296601 * r296604;
        double r296607 = r296605 * r296606;
        double r296608 = r296603 - r296607;
        return r296608;
}

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

    \[\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(\left(x.im \cdot x.re\right) \cdot x.im\right)}\]
  3. Using strategy rm
  4. Applied associate-*r*0.2

    \[\leadsto {x.re}^{3} - \color{blue}{\left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.im}\]
  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. Simplified0.2

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

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

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

Reproduce

herbie shell --seed 2019351 
(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)))