Average Error: 7.4 → 0.2
Time: 11.7s
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.im \cdot \left(\left(-3 \cdot x.re\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
x.im \cdot \left(\left(-3 \cdot x.re\right) \cdot x.im\right) + {x.re}^{3}
double f(double x_re, double x_im) {
        double r189260 = x_re;
        double r189261 = r189260 * r189260;
        double r189262 = x_im;
        double r189263 = r189262 * r189262;
        double r189264 = r189261 - r189263;
        double r189265 = r189264 * r189260;
        double r189266 = r189260 * r189262;
        double r189267 = r189262 * r189260;
        double r189268 = r189266 + r189267;
        double r189269 = r189268 * r189262;
        double r189270 = r189265 - r189269;
        return r189270;
}

double f(double x_re, double x_im) {
        double r189271 = x_im;
        double r189272 = -3.0;
        double r189273 = x_re;
        double r189274 = r189272 * r189273;
        double r189275 = r189274 * r189271;
        double r189276 = r189271 * r189275;
        double r189277 = 3.0;
        double r189278 = pow(r189273, r189277);
        double r189279 = r189276 + r189278;
        return r189279;
}

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.4
Target0.3
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.4

    \[\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}{\mathsf{fma}\left(-x.re \cdot x.im, 3 \cdot x.im, {x.re}^{3}\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.2

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

    \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re \cdot x.im\right)\right) \cdot -3} + {x.re}^{3}\]
  6. Taylor expanded around 0 7.3

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

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

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

Reproduce

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

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

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