Average Error: 6.7 → 0.7
Time: 21.7s
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\]
\[\left(\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right)} \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right)}\right) \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right)} - \left(x.re \cdot x.im + x.re \cdot x.im\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
\left(\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right)} \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right)}\right) \cdot \sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right)} - \left(x.re \cdot x.im + x.re \cdot x.im\right) \cdot x.im
double f(double x_re, double x_im) {
        double r10873337 = x_re;
        double r10873338 = r10873337 * r10873337;
        double r10873339 = x_im;
        double r10873340 = r10873339 * r10873339;
        double r10873341 = r10873338 - r10873340;
        double r10873342 = r10873341 * r10873337;
        double r10873343 = r10873337 * r10873339;
        double r10873344 = r10873339 * r10873337;
        double r10873345 = r10873343 + r10873344;
        double r10873346 = r10873345 * r10873339;
        double r10873347 = r10873342 - r10873346;
        return r10873347;
}

double f(double x_re, double x_im) {
        double r10873348 = x_re;
        double r10873349 = x_im;
        double r10873350 = r10873348 - r10873349;
        double r10873351 = r10873350 * r10873348;
        double r10873352 = r10873349 + r10873348;
        double r10873353 = r10873351 * r10873352;
        double r10873354 = cbrt(r10873353);
        double r10873355 = r10873354 * r10873354;
        double r10873356 = r10873355 * r10873354;
        double r10873357 = r10873348 * r10873349;
        double r10873358 = r10873357 + r10873357;
        double r10873359 = r10873358 * r10873349;
        double r10873360 = r10873356 - r10873359;
        return r10873360;
}

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

Original6.7
Target0.3
Herbie0.7
\[\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 6.7

    \[\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. Using strategy rm
  3. Applied difference-of-squares6.7

    \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  4. Applied associate-*l*0.2

    \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.7

    \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right) \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  7. Using strategy rm
  8. Applied *-commutative0.7

    \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)} \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  9. Final simplification0.7

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

Reproduce

herbie shell --seed 2019135 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"

  :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)))