Average Error: 7.2 → 0.2
Time: 3.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\]
\[\left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re - {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
\left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r370675 = x_re;
        double r370676 = r370675 * r370675;
        double r370677 = x_im;
        double r370678 = r370677 * r370677;
        double r370679 = r370676 - r370678;
        double r370680 = r370679 * r370677;
        double r370681 = r370675 * r370677;
        double r370682 = r370677 * r370675;
        double r370683 = r370681 + r370682;
        double r370684 = r370683 * r370675;
        double r370685 = r370680 + r370684;
        return r370685;
}

double f(double x_re, double x_im) {
        double r370686 = 3.0;
        double r370687 = x_im;
        double r370688 = x_re;
        double r370689 = r370687 * r370688;
        double r370690 = r370686 * r370689;
        double r370691 = r370690 * r370688;
        double r370692 = pow(r370687, r370686);
        double r370693 = r370691 - r370692;
        return r370693;
}

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

    \[\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. Simplified7.1

    \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right) - {x.im}^{3}}\]
  3. Using strategy rm
  4. Applied associate-*r*0.2

    \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} - {x.im}^{3}\]
  5. Using strategy rm
  6. Applied associate-*r*0.2

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

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

Reproduce

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