Average Error: 7.6 → 0.2
Time: 2.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(\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 r443683 = x_re;
        double r443684 = r443683 * r443683;
        double r443685 = x_im;
        double r443686 = r443685 * r443685;
        double r443687 = r443684 - r443686;
        double r443688 = r443687 * r443683;
        double r443689 = r443683 * r443685;
        double r443690 = r443685 * r443683;
        double r443691 = r443689 + r443690;
        double r443692 = r443691 * r443685;
        double r443693 = r443688 - r443692;
        return r443693;
}

double f(double x_re, double x_im) {
        double r443694 = x_re;
        double r443695 = 3.0;
        double r443696 = pow(r443694, r443695);
        double r443697 = x_im;
        double r443698 = r443695 * r443697;
        double r443699 = r443698 * r443694;
        double r443700 = r443699 * r443697;
        double r443701 = r443696 - r443700;
        return r443701;
}

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

    \[\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 2019362 
(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)))