Average Error: 7.5 → 0.2
Time: 15.7s
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(3 \cdot x.re\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(3 \cdot x.re\right) \cdot \left(x.im \cdot x.re\right) + \left(-{x.im}^{3}\right)
double f(double x_re, double x_im) {
        double r110213 = x_re;
        double r110214 = r110213 * r110213;
        double r110215 = x_im;
        double r110216 = r110215 * r110215;
        double r110217 = r110214 - r110216;
        double r110218 = r110217 * r110215;
        double r110219 = r110213 * r110215;
        double r110220 = r110215 * r110213;
        double r110221 = r110219 + r110220;
        double r110222 = r110221 * r110213;
        double r110223 = r110218 + r110222;
        return r110223;
}

double f(double x_re, double x_im) {
        double r110224 = 3.0;
        double r110225 = x_re;
        double r110226 = r110224 * r110225;
        double r110227 = x_im;
        double r110228 = r110227 * r110225;
        double r110229 = r110226 * r110228;
        double r110230 = pow(r110227, r110224);
        double r110231 = -r110230;
        double r110232 = r110229 + r110231;
        return r110232;
}

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

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

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

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

Reproduce

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

  :herbie-target
  (+ (* (* x.re x.im) (* 2.0 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)))