Average Error: 7.5 → 0.2
Time: 16.9s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
\[\mathsf{fma}\left(x.re, \left(\sqrt[3]{3} \cdot {\left(\sqrt{\sqrt[3]{3}}\right)}^{3}\right) \cdot \left(\sqrt{\sqrt[3]{3}} \cdot \left(x.im \cdot x.re\right)\right), -{x.im}^{3}\right)\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\mathsf{fma}\left(x.re, \left(\sqrt[3]{3} \cdot {\left(\sqrt{\sqrt[3]{3}}\right)}^{3}\right) \cdot \left(\sqrt{\sqrt[3]{3}} \cdot \left(x.im \cdot x.re\right)\right), -{x.im}^{3}\right)
double f(double x_re, double x_im) {
        double r272115 = x_re;
        double r272116 = r272115 * r272115;
        double r272117 = x_im;
        double r272118 = r272117 * r272117;
        double r272119 = r272116 - r272118;
        double r272120 = r272119 * r272117;
        double r272121 = r272115 * r272117;
        double r272122 = r272117 * r272115;
        double r272123 = r272121 + r272122;
        double r272124 = r272123 * r272115;
        double r272125 = r272120 + r272124;
        return r272125;
}

double f(double x_re, double x_im) {
        double r272126 = x_re;
        double r272127 = 3.0;
        double r272128 = cbrt(r272127);
        double r272129 = sqrt(r272128);
        double r272130 = pow(r272129, r272127);
        double r272131 = r272128 * r272130;
        double r272132 = x_im;
        double r272133 = r272132 * r272126;
        double r272134 = r272129 * r272133;
        double r272135 = r272131 * r272134;
        double r272136 = pow(r272132, r272127);
        double r272137 = -r272136;
        double r272138 = fma(r272126, r272135, r272137);
        return r272138;
}

Error

Bits error versus x.re

Bits error versus x.im

Target

Original7.5
Target0.2
Herbie0.2
\[\left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\]

Derivation

  1. Initial program 7.5

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, 3 \cdot \left(x.im \cdot x.re\right), -{x.im}^{3}\right)}\]
  3. Using strategy rm
  4. Applied add-cube-cbrt0.2

    \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}\right)} \cdot \left(x.im \cdot x.re\right), -{x.im}^{3}\right)\]
  5. Applied associate-*l*0.2

    \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \left(x.im \cdot x.re\right)\right)}, -{x.im}^{3}\right)\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt0.3

    \[\leadsto \mathsf{fma}\left(x.re, \left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\color{blue}{\left(\sqrt{\sqrt[3]{3}} \cdot \sqrt{\sqrt[3]{3}}\right)} \cdot \left(x.im \cdot x.re\right)\right), -{x.im}^{3}\right)\]
  8. Applied associate-*l*0.2

    \[\leadsto \mathsf{fma}\left(x.re, \left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \color{blue}{\left(\sqrt{\sqrt[3]{3}} \cdot \left(\sqrt{\sqrt[3]{3}} \cdot \left(x.im \cdot x.re\right)\right)\right)}, -{x.im}^{3}\right)\]
  9. Using strategy rm
  10. Applied associate-*r*0.2

    \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt{\sqrt[3]{3}}\right) \cdot \left(\sqrt{\sqrt[3]{3}} \cdot \left(x.im \cdot x.re\right)\right)}, -{x.im}^{3}\right)\]
  11. Simplified0.2

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

    \[\leadsto \mathsf{fma}\left(x.re, \left(\sqrt[3]{3} \cdot {\left(\sqrt{\sqrt[3]{3}}\right)}^{3}\right) \cdot \left(\sqrt{\sqrt[3]{3}} \cdot \left(x.im \cdot x.re\right)\right), -{x.im}^{3}\right)\]

Reproduce

herbie shell --seed 2019351 +o rules:numerics
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.im) (* 2 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im)))

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