Average Error: 7.2 → 0.2
Time: 25.1s
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} - \left(x.im \cdot 3\right) \cdot \left(x.re \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} - \left(x.im \cdot 3\right) \cdot \left(x.re \cdot x.im\right)
double f(double x_re, double x_im) {
        double r168675 = x_re;
        double r168676 = r168675 * r168675;
        double r168677 = x_im;
        double r168678 = r168677 * r168677;
        double r168679 = r168676 - r168678;
        double r168680 = r168679 * r168675;
        double r168681 = r168675 * r168677;
        double r168682 = r168677 * r168675;
        double r168683 = r168681 + r168682;
        double r168684 = r168683 * r168677;
        double r168685 = r168680 - r168684;
        return r168685;
}

double f(double x_re, double x_im) {
        double r168686 = x_re;
        double r168687 = 3.0;
        double r168688 = pow(r168686, r168687);
        double r168689 = x_im;
        double r168690 = r168689 * r168687;
        double r168691 = r168686 * r168689;
        double r168692 = r168690 * r168691;
        double r168693 = r168688 - r168692;
        return r168693;
}

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

    \[\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(\left(x.im \cdot x.re\right) \cdot x.im\right)}\]
  3. Using strategy rm
  4. Applied associate-*r*0.2

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

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

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

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

Reproduce

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