Average Error: 7.5 → 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} - \left(3 \cdot \left(x.im \cdot x.re\right)\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(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.im
double f(double x_re, double x_im) {
        double r193476 = x_re;
        double r193477 = r193476 * r193476;
        double r193478 = x_im;
        double r193479 = r193478 * r193478;
        double r193480 = r193477 - r193479;
        double r193481 = r193480 * r193476;
        double r193482 = r193476 * r193478;
        double r193483 = r193478 * r193476;
        double r193484 = r193482 + r193483;
        double r193485 = r193484 * r193478;
        double r193486 = r193481 - r193485;
        return r193486;
}

double f(double x_re, double x_im) {
        double r193487 = x_re;
        double r193488 = 3.0;
        double r193489 = pow(r193487, r193488);
        double r193490 = x_im;
        double r193491 = r193490 * r193487;
        double r193492 = r193488 * r193491;
        double r193493 = r193492 * r193490;
        double r193494 = r193489 - r193493;
        return r193494;
}

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

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

Reproduce

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