Average Error: 7.5 → 0.2
Time: 2.4s
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(\left(3 \cdot x.im\right) \cdot x.re\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(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.im
double f(double x_re, double x_im) {
        double r135796 = x_re;
        double r135797 = r135796 * r135796;
        double r135798 = x_im;
        double r135799 = r135798 * r135798;
        double r135800 = r135797 - r135799;
        double r135801 = r135800 * r135796;
        double r135802 = r135796 * r135798;
        double r135803 = r135798 * r135796;
        double r135804 = r135802 + r135803;
        double r135805 = r135804 * r135798;
        double r135806 = r135801 - r135805;
        return r135806;
}

double f(double x_re, double x_im) {
        double r135807 = x_re;
        double r135808 = 3.0;
        double r135809 = pow(r135807, r135808);
        double r135810 = x_im;
        double r135811 = r135808 * r135810;
        double r135812 = r135811 * r135807;
        double r135813 = r135812 * r135810;
        double r135814 = r135809 - r135813;
        return r135814;
}

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

    \[\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. Final simplification0.2

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

Reproduce

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