Average Error: 7.0 → 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\]
\[\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im + {x.re}^{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
\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im + {x.re}^{3}
double f(double x_re, double x_im) {
        double r258982 = x_re;
        double r258983 = r258982 * r258982;
        double r258984 = x_im;
        double r258985 = r258984 * r258984;
        double r258986 = r258983 - r258985;
        double r258987 = r258986 * r258982;
        double r258988 = r258982 * r258984;
        double r258989 = r258984 * r258982;
        double r258990 = r258988 + r258989;
        double r258991 = r258990 * r258984;
        double r258992 = r258987 - r258991;
        return r258992;
}

double f(double x_re, double x_im) {
        double r258993 = -3.0;
        double r258994 = x_re;
        double r258995 = x_im;
        double r258996 = r258994 * r258995;
        double r258997 = r258993 * r258996;
        double r258998 = r258997 * r258995;
        double r258999 = 3.0;
        double r259000 = pow(r258994, r258999);
        double r259001 = r258998 + r259000;
        return r259001;
}

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

    \[\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. Simplified6.9

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, x.re \cdot \left(-x.im \cdot x.im\right), {x.re}^{3}\right)}\]
  3. Using strategy rm
  4. Applied distribute-rgt-neg-in6.9

    \[\leadsto \mathsf{fma}\left(3, x.re \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)}, {x.re}^{3}\right)\]
  5. Applied associate-*r*0.2

    \[\leadsto \mathsf{fma}\left(3, \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(-x.im\right)}, {x.re}^{3}\right)\]
  6. Using strategy rm
  7. Applied fma-udef0.2

    \[\leadsto \color{blue}{3 \cdot \left(\left(x.re \cdot x.im\right) \cdot \left(-x.im\right)\right) + {x.re}^{3}}\]
  8. Simplified0.2

    \[\leadsto \color{blue}{-3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.im\right)} + {x.re}^{3}\]
  9. Using strategy rm
  10. Applied associate-*r*0.2

    \[\leadsto \color{blue}{\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im} + {x.re}^{3}\]
  11. Final simplification0.2

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

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(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)))