Average Error: 7.4 → 0.2
Time: 19.0s
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(x.im \cdot \left(x.re \cdot -3\right)\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(x.im \cdot \left(x.re \cdot -3\right)\right) + {x.re}^{3}
double f(double x_re, double x_im) {
        double r104625 = x_re;
        double r104626 = r104625 * r104625;
        double r104627 = x_im;
        double r104628 = r104627 * r104627;
        double r104629 = r104626 - r104628;
        double r104630 = r104629 * r104625;
        double r104631 = r104625 * r104627;
        double r104632 = r104627 * r104625;
        double r104633 = r104631 + r104632;
        double r104634 = r104633 * r104627;
        double r104635 = r104630 - r104634;
        return r104635;
}

double f(double x_re, double x_im) {
        double r104636 = x_im;
        double r104637 = x_re;
        double r104638 = -3.0;
        double r104639 = r104637 * r104638;
        double r104640 = r104636 * r104639;
        double r104641 = r104636 * r104640;
        double r104642 = 3.0;
        double r104643 = pow(r104637, r104642);
        double r104644 = r104641 + r104643;
        return r104644;
}

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

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

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

    \[\leadsto x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right) + {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)))