Average Error: 7.1 → 0.2
Time: 25.2s
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 r194076 = x_re;
        double r194077 = r194076 * r194076;
        double r194078 = x_im;
        double r194079 = r194078 * r194078;
        double r194080 = r194077 - r194079;
        double r194081 = r194080 * r194076;
        double r194082 = r194076 * r194078;
        double r194083 = r194078 * r194076;
        double r194084 = r194082 + r194083;
        double r194085 = r194084 * r194078;
        double r194086 = r194081 - r194085;
        return r194086;
}

double f(double x_re, double x_im) {
        double r194087 = x_re;
        double r194088 = 3.0;
        double r194089 = pow(r194087, r194088);
        double r194090 = x_im;
        double r194091 = r194090 * r194088;
        double r194092 = r194087 * r194090;
        double r194093 = r194091 * r194092;
        double r194094 = r194089 - r194093;
        return r194094;
}

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.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.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(\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 2019304 
(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)))