Average Error: 7.3 → 0.2
Time: 5.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\]
\[\left(\left(3 \cdot x.im\right) \cdot x.re\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(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r132994 = x_re;
        double r132995 = r132994 * r132994;
        double r132996 = x_im;
        double r132997 = r132996 * r132996;
        double r132998 = r132995 - r132997;
        double r132999 = r132998 * r132996;
        double r133000 = r132994 * r132996;
        double r133001 = r132996 * r132994;
        double r133002 = r133000 + r133001;
        double r133003 = r133002 * r132994;
        double r133004 = r132999 + r133003;
        return r133004;
}

double f(double x_re, double x_im) {
        double r133005 = 3.0;
        double r133006 = x_im;
        double r133007 = r133005 * r133006;
        double r133008 = x_re;
        double r133009 = r133007 * r133008;
        double r133010 = r133009 * r133008;
        double r133011 = pow(r133006, r133005);
        double r133012 = r133010 - r133011;
        return r133012;
}

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.3
Target0.3
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.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\]
  2. Simplified7.3

    \[\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. Using strategy rm
  8. Applied associate-*r*0.2

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

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

Reproduce

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