Average Error: 7.4 → 0.2
Time: 13.2s
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(x.im \cdot \left(x.im \cdot x.re\right)\right) \cdot -3 + {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(x.im \cdot \left(x.im \cdot x.re\right)\right) \cdot -3 + {x.re}^{3}
double f(double x_re, double x_im) {
        double r101698 = x_re;
        double r101699 = r101698 * r101698;
        double r101700 = x_im;
        double r101701 = r101700 * r101700;
        double r101702 = r101699 - r101701;
        double r101703 = r101702 * r101698;
        double r101704 = r101698 * r101700;
        double r101705 = r101700 * r101698;
        double r101706 = r101704 + r101705;
        double r101707 = r101706 * r101700;
        double r101708 = r101703 - r101707;
        return r101708;
}

double f(double x_re, double x_im) {
        double r101709 = x_im;
        double r101710 = x_re;
        double r101711 = r101709 * r101710;
        double r101712 = r101709 * r101711;
        double r101713 = -3.0;
        double r101714 = r101712 * r101713;
        double r101715 = 3.0;
        double r101716 = pow(r101710, r101715);
        double r101717 = r101714 + r101716;
        return r101717;
}

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.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.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. Final simplification0.2

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

Reproduce

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