Average Error: 7.7 → 0.6
Time: 40.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(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right) - \sqrt[3]{x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)} \cdot \left(\left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right) \cdot \left(\sqrt[3]{x.re \cdot x.im} \cdot \sqrt[3]{2}\right)\right)\]
\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(\left(x.re - x.im\right) \cdot x.re\right) \cdot \left(x.im + x.re\right) - \sqrt[3]{x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)} \cdot \left(\left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right) \cdot \left(\sqrt[3]{x.re \cdot x.im} \cdot \sqrt[3]{2}\right)\right)
double f(double x_re, double x_im) {
        double r9125481 = x_re;
        double r9125482 = r9125481 * r9125481;
        double r9125483 = x_im;
        double r9125484 = r9125483 * r9125483;
        double r9125485 = r9125482 - r9125484;
        double r9125486 = r9125485 * r9125481;
        double r9125487 = r9125481 * r9125483;
        double r9125488 = r9125483 * r9125481;
        double r9125489 = r9125487 + r9125488;
        double r9125490 = r9125489 * r9125483;
        double r9125491 = r9125486 - r9125490;
        return r9125491;
}

double f(double x_re, double x_im) {
        double r9125492 = x_re;
        double r9125493 = x_im;
        double r9125494 = r9125492 - r9125493;
        double r9125495 = r9125494 * r9125492;
        double r9125496 = r9125493 + r9125492;
        double r9125497 = r9125495 * r9125496;
        double r9125498 = r9125492 * r9125493;
        double r9125499 = r9125498 + r9125498;
        double r9125500 = r9125493 * r9125499;
        double r9125501 = cbrt(r9125500);
        double r9125502 = cbrt(r9125493);
        double r9125503 = r9125502 * r9125501;
        double r9125504 = cbrt(r9125498);
        double r9125505 = 2.0;
        double r9125506 = cbrt(r9125505);
        double r9125507 = r9125504 * r9125506;
        double r9125508 = r9125503 * r9125507;
        double r9125509 = r9125501 * r9125508;
        double r9125510 = r9125497 - r9125509;
        return r9125510;
}

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.7
Target0.3
Herbie0.6
\[\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.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-squares7.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.3

    \[\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.6

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

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) - \left(\color{blue}{\left(\sqrt[3]{x.re \cdot x.im + x.im \cdot x.re} \cdot \sqrt[3]{x.im}\right)} \cdot \sqrt[3]{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\right) \cdot \sqrt[3]{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\]
  9. Applied associate-*l*0.6

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) - \color{blue}{\left(\sqrt[3]{x.re \cdot x.im + x.im \cdot x.re} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\right)\right)} \cdot \sqrt[3]{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\]
  10. Taylor expanded around 0 48.8

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) - \left(\color{blue}{\left(e^{\frac{1}{3} \cdot \left(\log x.im + \log x.re\right)} \cdot \sqrt[3]{2}\right)} \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\right)\right) \cdot \sqrt[3]{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\]
  11. Simplified0.6

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

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

Reproduce

herbie shell --seed 2019168 
(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.0 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))