Average Error: 7.1 → 0.2
Time: 21.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(\left(x.re + x.im\right) \cdot x.im\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
\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 + x.im\right) \cdot x.im\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
double f(double x_re, double x_im) {
        double r177280 = x_re;
        double r177281 = r177280 * r177280;
        double r177282 = x_im;
        double r177283 = r177282 * r177282;
        double r177284 = r177281 - r177283;
        double r177285 = r177284 * r177282;
        double r177286 = r177280 * r177282;
        double r177287 = r177282 * r177280;
        double r177288 = r177286 + r177287;
        double r177289 = r177288 * r177280;
        double r177290 = r177285 + r177289;
        return r177290;
}

double f(double x_re, double x_im) {
        double r177291 = x_re;
        double r177292 = x_im;
        double r177293 = r177291 + r177292;
        double r177294 = r177293 * r177292;
        double r177295 = r177291 - r177292;
        double r177296 = r177294 * r177295;
        double r177297 = r177291 * r177292;
        double r177298 = r177292 * r177291;
        double r177299 = r177297 + r177298;
        double r177300 = r177299 * r177291;
        double r177301 = r177296 + r177300;
        return r177301;
}

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

    \[\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. Using strategy rm
  3. Applied difference-of-squares7.1

    \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  4. Applied associate-*l*0.2

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

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

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

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

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

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

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

    \[\leadsto \left(\left(x.re + x.im\right) \cdot x.im\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]

Reproduce

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