\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
\begin{array}{l}
\mathbf{if}\;x.re \leq -20274.627700358556:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{elif}\;x.re \leq 2.0298236451026524 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(x.re + x.im, x.re \cdot \left(x.re - x.im\right), x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x.re} \cdot \left(\sqrt{x.re} \cdot \mathsf{fma}\left(x.re, x.re, -3 \cdot \left(x.im \cdot x.im\right)\right)\right)\\
\end{array}
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
(FPCore (x.re x.im)
:precision binary64
(if (<= x.re -20274.627700358556)
(* x.re (fma x.re x.re (* x.im (* x.im -3.0))))
(if (<= x.re 2.0298236451026524e+47)
(fma (+ x.re x.im) (* x.re (- x.re x.im)) (* x.im (* (* x.re x.im) -2.0)))
(* (sqrt x.re) (* (sqrt x.re) (fma x.re x.re (* -3.0 (* x.im x.im))))))))double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= -20274.627700358556) {
tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
} else if (x_46_re <= 2.0298236451026524e+47) {
tmp = fma((x_46_re + x_46_im), (x_46_re * (x_46_re - x_46_im)), (x_46_im * ((x_46_re * x_46_im) * -2.0)));
} else {
tmp = sqrt(x_46_re) * (sqrt(x_46_re) * fma(x_46_re, x_46_re, (-3.0 * (x_46_im * x_46_im))));
}
return tmp;
}




Bits error versus x.re




Bits error versus x.im
| Original | 10.6 |
|---|---|
| Target | 8.1 |
| Herbie | 1.9 |
if x.re < -20274.627700358556Initial program 14.5
Simplified3.8
Applied associate-*l*_binary643.8
Simplified3.8
if -20274.627700358556 < x.re < 2.02982364510265238e47Initial program 6.8
Applied difference-of-squares_binary646.8
Applied associate-*l*_binary640.2
Applied fma-neg_binary640.2
Simplified0.2
if 2.02982364510265238e47 < x.re Initial program 15.9
Simplified4.1
Applied add-sqr-sqrt_binary644.1
Applied associate-*l*_binary644.1
Final simplification1.9
herbie shell --seed 2022088
(FPCore (x.re x.im)
:name "math.cube on complex, real part"
:precision binary64
: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)))