Average Error: 7.7 → 0.2
Time: 10.1s
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 r209438 = x_re;
        double r209439 = r209438 * r209438;
        double r209440 = x_im;
        double r209441 = r209440 * r209440;
        double r209442 = r209439 - r209441;
        double r209443 = r209442 * r209440;
        double r209444 = r209438 * r209440;
        double r209445 = r209440 * r209438;
        double r209446 = r209444 + r209445;
        double r209447 = r209446 * r209438;
        double r209448 = r209443 + r209447;
        return r209448;
}

double f(double x_re, double x_im) {
        double r209449 = 3.0;
        double r209450 = x_im;
        double r209451 = x_re;
        double r209452 = r209450 * r209451;
        double r209453 = r209449 * r209452;
        double r209454 = r209453 * r209451;
        double r209455 = pow(r209450, r209449);
        double r209456 = r209454 - r209455;
        return r209456;
}

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

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

    \[\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. Using strategy rm
  10. Applied *-un-lft-identity0.2

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

    \[\leadsto \color{blue}{\left(\left(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot 1\right) \cdot x.re} - {x.im}^{3}\]
  12. Simplified0.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(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re - {x.im}^{3}\]

Reproduce

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