Average Error: 7.6 → 0.2
Time: 2.1s
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 r119196 = x_re;
        double r119197 = r119196 * r119196;
        double r119198 = x_im;
        double r119199 = r119198 * r119198;
        double r119200 = r119197 - r119199;
        double r119201 = r119200 * r119196;
        double r119202 = r119196 * r119198;
        double r119203 = r119198 * r119196;
        double r119204 = r119202 + r119203;
        double r119205 = r119204 * r119198;
        double r119206 = r119201 - r119205;
        return r119206;
}

double f(double x_re, double x_im) {
        double r119207 = x_re;
        double r119208 = 3.0;
        double r119209 = pow(r119207, r119208);
        double r119210 = x_im;
        double r119211 = r119208 * r119210;
        double r119212 = r119211 * r119207;
        double r119213 = r119212 * r119210;
        double r119214 = r119209 - r119213;
        return r119214;
}

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

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