Average Error: 7.5 → 0.2
Time: 16.1s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
\[\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right) + \left(-{x.im}^{3}\right)\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right) + \left(-{x.im}^{3}\right)
double f(double x_re, double x_im) {
        double r114007 = x_re;
        double r114008 = r114007 * r114007;
        double r114009 = x_im;
        double r114010 = r114009 * r114009;
        double r114011 = r114008 - r114010;
        double r114012 = r114011 * r114009;
        double r114013 = r114007 * r114009;
        double r114014 = r114009 * r114007;
        double r114015 = r114013 + r114014;
        double r114016 = r114015 * r114007;
        double r114017 = r114012 + r114016;
        return r114017;
}

double f(double x_re, double x_im) {
        double r114018 = x_re;
        double r114019 = 3.0;
        double r114020 = r114018 * r114019;
        double r114021 = x_im;
        double r114022 = r114021 * r114018;
        double r114023 = r114020 * r114022;
        double r114024 = pow(r114021, r114019);
        double r114025 = -r114024;
        double r114026 = r114023 + r114025;
        return r114026;
}

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.5
Target0.2
Herbie0.2
\[\left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\]

Derivation

  1. Initial program 7.5

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.im \cdot \left(3 \cdot x.re\right), -{x.im}^{3}\right)}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity0.2

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

    \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{1 \cdot \left(x.im \cdot \left(3 \cdot x.re\right)\right)}, -{x.im}^{3}\right)\]
  6. Simplified0.2

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

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

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

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

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

Reproduce

herbie shell --seed 2019208 +o rules:numerics
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.im) (* 2 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im)))

  (+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re)))