Average Error: 7.5 → 0.2
Time: 14.0s
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\]
\[3 \cdot \left(x.re \cdot \left(x.im \cdot x.re\right)\right) - {x.im}^{3}\]
\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
3 \cdot \left(x.re \cdot \left(x.im \cdot x.re\right)\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r165589 = x_re;
        double r165590 = r165589 * r165589;
        double r165591 = x_im;
        double r165592 = r165591 * r165591;
        double r165593 = r165590 - r165592;
        double r165594 = r165593 * r165591;
        double r165595 = r165589 * r165591;
        double r165596 = r165591 * r165589;
        double r165597 = r165595 + r165596;
        double r165598 = r165597 * r165589;
        double r165599 = r165594 + r165598;
        return r165599;
}

double f(double x_re, double x_im) {
        double r165600 = 3.0;
        double r165601 = x_re;
        double r165602 = x_im;
        double r165603 = r165602 * r165601;
        double r165604 = r165601 * r165603;
        double r165605 = r165600 * r165604;
        double r165606 = pow(r165602, r165600);
        double r165607 = r165605 - r165606;
        return r165607;
}

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}{\left(3 \cdot x.re\right) \cdot \left(x.im \cdot x.re\right) - {x.im}^{3}}\]
  3. Using strategy rm
  4. Applied associate-*l*0.2

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

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

Reproduce

herbie shell --seed 2019208 
(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)))