Average Error: 6.6 → 0.2
Time: 22.7s
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(x.re \cdot x.im\right) \cdot 3\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(x.re \cdot x.im\right) \cdot 3\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r9150972 = x_re;
        double r9150973 = r9150972 * r9150972;
        double r9150974 = x_im;
        double r9150975 = r9150974 * r9150974;
        double r9150976 = r9150973 - r9150975;
        double r9150977 = r9150976 * r9150974;
        double r9150978 = r9150972 * r9150974;
        double r9150979 = r9150974 * r9150972;
        double r9150980 = r9150978 + r9150979;
        double r9150981 = r9150980 * r9150972;
        double r9150982 = r9150977 + r9150981;
        return r9150982;
}

double f(double x_re, double x_im) {
        double r9150983 = x_re;
        double r9150984 = x_im;
        double r9150985 = r9150983 * r9150984;
        double r9150986 = 3.0;
        double r9150987 = r9150985 * r9150986;
        double r9150988 = r9150987 * r9150983;
        double r9150989 = pow(r9150984, r9150986);
        double r9150990 = r9150988 - r9150989;
        return r9150990;
}

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

Original6.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 6.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. Taylor expanded around 0 6.5

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

    \[\leadsto \color{blue}{\left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - \left(x.im \cdot x.im\right) \cdot x.im}\]
  4. Using strategy rm
  5. Applied pow10.2

    \[\leadsto \left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - \left(x.im \cdot x.im\right) \cdot \color{blue}{{x.im}^{1}}\]
  6. Applied pow10.2

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

    \[\leadsto \left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - \left(\color{blue}{{x.im}^{1}} \cdot {x.im}^{1}\right) \cdot {x.im}^{1}\]
  8. Applied pow-prod-up0.2

    \[\leadsto \left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.re - \color{blue}{{x.im}^{\left(1 + 1\right)}} \cdot {x.im}^{1}\]
  9. Applied pow-prod-up0.2

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

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

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

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

Reproduce

herbie shell --seed 2019162 
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"

  :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)))