Average Error: 7.5 → 0.2
Time: 2.6s
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(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.im\]
\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(\left(3 \cdot x.im\right) \cdot x.re\right) \cdot x.im
double f(double x_re, double x_im) {
        double r364700 = x_re;
        double r364701 = r364700 * r364700;
        double r364702 = x_im;
        double r364703 = r364702 * r364702;
        double r364704 = r364701 - r364703;
        double r364705 = r364704 * r364700;
        double r364706 = r364700 * r364702;
        double r364707 = r364702 * r364700;
        double r364708 = r364706 + r364707;
        double r364709 = r364708 * r364702;
        double r364710 = r364705 - r364709;
        return r364710;
}

double f(double x_re, double x_im) {
        double r364711 = x_re;
        double r364712 = 3.0;
        double r364713 = pow(r364711, r364712);
        double r364714 = x_im;
        double r364715 = r364712 * r364714;
        double r364716 = r364715 * r364711;
        double r364717 = r364716 * r364714;
        double r364718 = r364713 - r364717;
        return r364718;
}

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

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

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

Reproduce

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