Average Error: 7.2 → 0.7
Time: 23.1s
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\]
\[\sqrt[3]{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \left(\sqrt[3]{x.im + x.re} \cdot \left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.re} \cdot \sqrt[3]{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\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
\sqrt[3]{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \left(\sqrt[3]{x.im + x.re} \cdot \left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.re} \cdot \sqrt[3]{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)
double f(double x_re, double x_im) {
        double r8443843 = x_re;
        double r8443844 = r8443843 * r8443843;
        double r8443845 = x_im;
        double r8443846 = r8443845 * r8443845;
        double r8443847 = r8443844 - r8443846;
        double r8443848 = r8443847 * r8443843;
        double r8443849 = r8443843 * r8443845;
        double r8443850 = r8443845 * r8443843;
        double r8443851 = r8443849 + r8443850;
        double r8443852 = r8443851 * r8443845;
        double r8443853 = r8443848 - r8443852;
        return r8443853;
}

double f(double x_re, double x_im) {
        double r8443854 = x_im;
        double r8443855 = x_re;
        double r8443856 = r8443854 + r8443855;
        double r8443857 = r8443855 - r8443854;
        double r8443858 = r8443857 * r8443855;
        double r8443859 = r8443856 * r8443858;
        double r8443860 = cbrt(r8443859);
        double r8443861 = cbrt(r8443856);
        double r8443862 = cbrt(r8443858);
        double r8443863 = r8443862 * r8443860;
        double r8443864 = r8443861 * r8443863;
        double r8443865 = r8443860 * r8443864;
        double r8443866 = r8443855 * r8443854;
        double r8443867 = r8443866 + r8443866;
        double r8443868 = r8443854 * r8443867;
        double r8443869 = r8443865 - r8443868;
        return r8443869;
}

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.2
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 7.2

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

    \[\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.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 cbrt-prod0.7

    \[\leadsto \left(\color{blue}{\left(\sqrt[3]{x.re + x.im} \cdot \sqrt[3]{\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. Applied associate-*l*0.7

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

    \[\leadsto \sqrt[3]{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)} \cdot \left(\sqrt[3]{x.im + x.re} \cdot \left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.re} \cdot \sqrt[3]{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right)}\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\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 x.im))))

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