Average Error: 7.7 → 0.2
Time: 2.3s
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.re}^{3} - 3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.im\right)\]
\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.re}^{3} - 3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.im\right)
double f(double x_re, double x_im) {
        double r209493 = x_re;
        double r209494 = r209493 * r209493;
        double r209495 = x_im;
        double r209496 = r209495 * r209495;
        double r209497 = r209494 - r209496;
        double r209498 = r209497 * r209493;
        double r209499 = r209493 * r209495;
        double r209500 = r209495 * r209493;
        double r209501 = r209499 + r209500;
        double r209502 = r209501 * r209495;
        double r209503 = r209498 - r209502;
        return r209503;
}

double f(double x_re, double x_im) {
        double r209504 = x_re;
        double r209505 = 3.0;
        double r209506 = pow(r209504, r209505);
        double r209507 = x_im;
        double r209508 = r209504 * r209507;
        double r209509 = r209508 * r209507;
        double r209510 = r209505 * r209509;
        double r209511 = r209506 - r209510;
        return r209511;
}

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.3
Herbie0.2
\[\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.7

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

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

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

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

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

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

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

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

Reproduce

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

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

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