Average Error: 7.2 → 0.2
Time: 24.8s
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 r155622 = x_re;
        double r155623 = r155622 * r155622;
        double r155624 = x_im;
        double r155625 = r155624 * r155624;
        double r155626 = r155623 - r155625;
        double r155627 = r155626 * r155622;
        double r155628 = r155622 * r155624;
        double r155629 = r155624 * r155622;
        double r155630 = r155628 + r155629;
        double r155631 = r155630 * r155624;
        double r155632 = r155627 - r155631;
        return r155632;
}

double f(double x_re, double x_im) {
        double r155633 = x_re;
        double r155634 = 3.0;
        double r155635 = pow(r155633, r155634);
        double r155636 = x_im;
        double r155637 = r155636 * r155634;
        double r155638 = r155633 * r155636;
        double r155639 = r155637 * r155638;
        double r155640 = r155635 - r155639;
        return r155640;
}

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

    \[\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 2019303 
(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)))