Average Error: 7.4 → 0.2
Time: 12.0s
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 r246355 = x_re;
        double r246356 = r246355 * r246355;
        double r246357 = x_im;
        double r246358 = r246357 * r246357;
        double r246359 = r246356 - r246358;
        double r246360 = r246359 * r246355;
        double r246361 = r246355 * r246357;
        double r246362 = r246357 * r246355;
        double r246363 = r246361 + r246362;
        double r246364 = r246363 * r246357;
        double r246365 = r246360 - r246364;
        return r246365;
}

double f(double x_re, double x_im) {
        double r246366 = x_re;
        double r246367 = 3.0;
        double r246368 = pow(r246366, r246367);
        double r246369 = x_im;
        double r246370 = r246369 * r246366;
        double r246371 = r246367 * r246370;
        double r246372 = r246371 * r246369;
        double r246373 = r246368 - r246372;
        return r246373;
}

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

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