Average Error: 7.6 → 0.2
Time: 2.5s
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(\left(x.im \cdot x.re\right) \cdot x.re\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(\left(x.im \cdot x.re\right) \cdot x.re\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r334114 = x_re;
        double r334115 = r334114 * r334114;
        double r334116 = x_im;
        double r334117 = r334116 * r334116;
        double r334118 = r334115 - r334117;
        double r334119 = r334118 * r334116;
        double r334120 = r334114 * r334116;
        double r334121 = r334116 * r334114;
        double r334122 = r334120 + r334121;
        double r334123 = r334122 * r334114;
        double r334124 = r334119 + r334123;
        return r334124;
}

double f(double x_re, double x_im) {
        double r334125 = 3.0;
        double r334126 = x_im;
        double r334127 = x_re;
        double r334128 = r334126 * r334127;
        double r334129 = r334128 * r334127;
        double r334130 = r334125 * r334129;
        double r334131 = pow(r334126, r334125);
        double r334132 = r334130 - r334131;
        return r334132;
}

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

    \[\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.6

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

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

Reproduce

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