Average Error: 6.6 → 0.2
Time: 28.9s
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) - \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(\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 r12102844 = x_re;
        double r12102845 = r12102844 * r12102844;
        double r12102846 = x_im;
        double r12102847 = r12102846 * r12102846;
        double r12102848 = r12102845 - r12102847;
        double r12102849 = r12102848 * r12102844;
        double r12102850 = r12102844 * r12102846;
        double r12102851 = r12102846 * r12102844;
        double r12102852 = r12102850 + r12102851;
        double r12102853 = r12102852 * r12102846;
        double r12102854 = r12102849 - r12102853;
        return r12102854;
}

double f(double x_re, double x_im) {
        double r12102855 = x_re;
        double r12102856 = x_im;
        double r12102857 = r12102855 - r12102856;
        double r12102858 = r12102857 * r12102855;
        double r12102859 = r12102856 + r12102855;
        double r12102860 = r12102858 * r12102859;
        double r12102861 = r12102855 * r12102856;
        double r12102862 = r12102861 + r12102861;
        double r12102863 = r12102862 * r12102856;
        double r12102864 = r12102860 - r12102863;
        return r12102864;
}

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

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

    \[\leadsto \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 \color{blue}{{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1}} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  9. Applied pow10.7

    \[\leadsto \left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \color{blue}{{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1}}\right) \cdot {\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  10. Applied pow10.7

    \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1}} \cdot {\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1}\right) \cdot {\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  11. Applied pow-prod-up0.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)}\right)}^{\left(1 + 1\right)}} \cdot {\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{1} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  12. Applied pow-prod-up0.6

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

    \[\leadsto {\left(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)}^{\color{blue}{3}} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  14. Using strategy rm
  15. Applied cbrt-prod0.9

    \[\leadsto {\color{blue}{\left(\sqrt[3]{x.re + x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.re}\right)}}^{3} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  16. Applied unpow-prod-down0.9

    \[\leadsto \color{blue}{{\left(\sqrt[3]{x.re + x.im}\right)}^{3} \cdot {\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.re}\right)}^{3}} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  17. Simplified0.7

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

    \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\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\]
  19. Final simplification0.2

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