Average Error: 7.3 → 0.2
Time: 3.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\]
\[-3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.im\right) + {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
-3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.im\right) + {x.re}^{3}
double f(double x_re, double x_im) {
        double r283880 = x_re;
        double r283881 = r283880 * r283880;
        double r283882 = x_im;
        double r283883 = r283882 * r283882;
        double r283884 = r283881 - r283883;
        double r283885 = r283884 * r283880;
        double r283886 = r283880 * r283882;
        double r283887 = r283882 * r283880;
        double r283888 = r283886 + r283887;
        double r283889 = r283888 * r283882;
        double r283890 = r283885 - r283889;
        return r283890;
}

double f(double x_re, double x_im) {
        double r283891 = -3.0;
        double r283892 = x_re;
        double r283893 = x_im;
        double r283894 = r283892 * r283893;
        double r283895 = r283894 * r283893;
        double r283896 = r283891 * r283895;
        double r283897 = 3.0;
        double r283898 = pow(r283892, r283897);
        double r283899 = r283896 + r283898;
        return r283899;
}

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

    \[\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-lft-neg-in7.3

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

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

    \[\leadsto \color{blue}{3 \cdot \left(\left(x.re \cdot \left(-x.im\right)\right) \cdot x.im\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 pow10.2

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

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

Reproduce

herbie shell --seed 2020089 +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)))