Average Error: 7.1 → 0.3
Time: 18.7s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
\[x.im \cdot \left(\left(x.re + 3 \cdot x.im\right) \cdot \left(-x.re\right)\right) + \left(x.re \cdot \left(x.im + x.re\right)\right) \cdot x.re\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
x.im \cdot \left(\left(x.re + 3 \cdot x.im\right) \cdot \left(-x.re\right)\right) + \left(x.re \cdot \left(x.im + x.re\right)\right) \cdot x.re
double f(double x_re, double x_im) {
        double r7601442 = x_re;
        double r7601443 = r7601442 * r7601442;
        double r7601444 = x_im;
        double r7601445 = r7601444 * r7601444;
        double r7601446 = r7601443 - r7601445;
        double r7601447 = r7601446 * r7601442;
        double r7601448 = r7601442 * r7601444;
        double r7601449 = r7601444 * r7601442;
        double r7601450 = r7601448 + r7601449;
        double r7601451 = r7601450 * r7601444;
        double r7601452 = r7601447 - r7601451;
        return r7601452;
}

double f(double x_re, double x_im) {
        double r7601453 = x_im;
        double r7601454 = x_re;
        double r7601455 = 3.0;
        double r7601456 = r7601455 * r7601453;
        double r7601457 = r7601454 + r7601456;
        double r7601458 = -r7601454;
        double r7601459 = r7601457 * r7601458;
        double r7601460 = r7601453 * r7601459;
        double r7601461 = r7601453 + r7601454;
        double r7601462 = r7601454 * r7601461;
        double r7601463 = r7601462 * r7601454;
        double r7601464 = r7601460 + r7601463;
        return r7601464;
}

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.3
Herbie0.3
\[\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)\]

Derivation

  1. Initial program 7.1

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  2. Taylor expanded around 0 7.0

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

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

    \[\leadsto \left(x.re \cdot \left(x.re + x.im\right)\right) \cdot \color{blue}{\left(x.re + \left(-x.im\right)\right)} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  6. Applied distribute-rgt-in0.3

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

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

    \[\leadsto x.re \cdot \left(x.re \cdot \left(x.re + x.im\right)\right) + \color{blue}{\left(-x.im\right) \cdot \left(x.re \cdot \left(x.re + x.im\right) + x.im \cdot \left(x.re + x.re\right)\right)}\]
  9. Taylor expanded around 0 0.3

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

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

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

Reproduce

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

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))