Average Error: 7.3 → 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(\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 r180052 = x_re;
        double r180053 = r180052 * r180052;
        double r180054 = x_im;
        double r180055 = r180054 * r180054;
        double r180056 = r180053 - r180055;
        double r180057 = r180056 * r180052;
        double r180058 = r180052 * r180054;
        double r180059 = r180054 * r180052;
        double r180060 = r180058 + r180059;
        double r180061 = r180060 * r180054;
        double r180062 = r180057 - r180061;
        return r180062;
}

double f(double x_re, double x_im) {
        double r180063 = x_re;
        double r180064 = 3.0;
        double r180065 = pow(r180063, r180064);
        double r180066 = x_im;
        double r180067 = r180064 * r180066;
        double r180068 = r180067 * r180063;
        double r180069 = r180068 * r180066;
        double r180070 = r180065 - r180069;
        return r180070;
}

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

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