| Alternative 1 | |
|---|---|
| Accuracy | 80.9% |
| Cost | 130884 |

(FPCore (x.re x.im y.re y.im)
:precision binary64
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(cos
(+
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)
(* (atan2 x.im x.re) y.re)))))(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (- x.im)))
(t_1 (fma y.re (atan2 x.im x.re) (* y.im t_0)))
(t_2
(exp (- (* (log (hypot x.re x.im)) y.re) (* (atan2 x.im x.re) y.im))))
(t_3 (fma y.im t_0 (* y.im (log (/ -1.0 x.im))))))
(if (<= x.im -1.1e-40)
(* t_2 (- (* (cos t_1) (cos t_3)) (* (sin t_1) (sin t_3))))
(if (<= x.im 2.5e+141)
(*
t_2
(cos
(fma
(* (log (hypot x.im x.re)) (pow (cbrt y.im) 2.0))
(cbrt y.im)
(* y.re (atan2 x.im x.re)))))
t_2))))double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(-x_46_im);
double t_1 = fma(y_46_re, atan2(x_46_im, x_46_re), (y_46_im * t_0));
double t_2 = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_3 = fma(y_46_im, t_0, (y_46_im * log((-1.0 / x_46_im))));
double tmp;
if (x_46_im <= -1.1e-40) {
tmp = t_2 * ((cos(t_1) * cos(t_3)) - (sin(t_1) * sin(t_3)));
} else if (x_46_im <= 2.5e+141) {
tmp = t_2 * cos(fma((log(hypot(x_46_im, x_46_re)) * pow(cbrt(y_46_im), 2.0)), cbrt(y_46_im), (y_46_re * atan2(x_46_im, x_46_re))));
} else {
tmp = t_2;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(Float64(-x_46_im)) t_1 = fma(y_46_re, atan(x_46_im, x_46_re), Float64(y_46_im * t_0)) t_2 = exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_3 = fma(y_46_im, t_0, Float64(y_46_im * log(Float64(-1.0 / x_46_im)))) tmp = 0.0 if (x_46_im <= -1.1e-40) tmp = Float64(t_2 * Float64(Float64(cos(t_1) * cos(t_3)) - Float64(sin(t_1) * sin(t_3)))); elseif (x_46_im <= 2.5e+141) tmp = Float64(t_2 * cos(fma(Float64(log(hypot(x_46_im, x_46_re)) * (cbrt(y_46_im) ^ 2.0)), cbrt(y_46_im), Float64(y_46_re * atan(x_46_im, x_46_re))))); else tmp = t_2; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[(-x$46$im)], $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision] + N[(y$46$im * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(y$46$im * t$95$0 + N[(y$46$im * N[Log[N[(-1.0 / x$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -1.1e-40], N[(t$95$2 * N[(N[(N[Cos[t$95$1], $MachinePrecision] * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[t$95$1], $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 2.5e+141], N[(t$95$2 * N[Cos[N[(N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * N[Power[N[Power[y$46$im, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[y$46$im, 1/3], $MachinePrecision] + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\begin{array}{l}
t_0 := \log \left(-x.im\right)\\
t_1 := \mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot t_0\right)\\
t_2 := e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_3 := \mathsf{fma}\left(y.im, t_0, y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\\
\mathbf{if}\;x.im \leq -1.1 \cdot 10^{-40}:\\
\;\;\;\;t_2 \cdot \left(\cos t_1 \cdot \cos t_3 - \sin t_1 \cdot \sin t_3\right)\\
\mathbf{elif}\;x.im \leq 2.5 \cdot 10^{+141}:\\
\;\;\;\;t_2 \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot {\left(\sqrt[3]{y.im}\right)}^{2}, \sqrt[3]{y.im}, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
if x.im < -1.10000000000000004e-40Initial program 32.4%
Simplified78.8%
[Start]32.4% | \[ e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\] |
|---|
Taylor expanded in x.im around -inf 81.3%
Simplified81.3%
[Start]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(-1 \cdot \left(\log \left(\frac{-1}{x.im}\right) \cdot y.im\right) + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
|---|---|
+-commutative [=>]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + -1 \cdot \left(\log \left(\frac{-1}{x.im}\right) \cdot y.im\right)\right)}
\] |
mul-1-neg [=>]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + \color{blue}{\left(-\log \left(\frac{-1}{x.im}\right) \cdot y.im\right)}\right)
\] |
unsub-neg [=>]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} - \log \left(\frac{-1}{x.im}\right) \cdot y.im\right)}
\] |
*-commutative [=>]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} - \color{blue}{y.im \cdot \log \left(\frac{-1}{x.im}\right)}\right)
\] |
Applied egg-rr84.1%
[Start]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} - y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)
\] |
|---|---|
prod-diff [=>]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, -\log \left(\frac{-1}{x.im}\right) \cdot y.im\right) + \mathsf{fma}\left(-\log \left(\frac{-1}{x.im}\right), y.im, \log \left(\frac{-1}{x.im}\right) \cdot y.im\right)\right)}
\] |
*-commutative [<=]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, -\color{blue}{y.im \cdot \log \left(\frac{-1}{x.im}\right)}\right) + \mathsf{fma}\left(-\log \left(\frac{-1}{x.im}\right), y.im, \log \left(\frac{-1}{x.im}\right) \cdot y.im\right)\right)
\] |
fma-neg [<=]81.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\color{blue}{\left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} - y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)} + \mathsf{fma}\left(-\log \left(\frac{-1}{x.im}\right), y.im, \log \left(\frac{-1}{x.im}\right) \cdot y.im\right)\right)
\] |
cos-sum [=>]84.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \color{blue}{\left(\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} - y.im \cdot \log \left(\frac{-1}{x.im}\right)\right) \cdot \cos \left(\mathsf{fma}\left(-\log \left(\frac{-1}{x.im}\right), y.im, \log \left(\frac{-1}{x.im}\right) \cdot y.im\right)\right) - \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} - y.im \cdot \log \left(\frac{-1}{x.im}\right)\right) \cdot \sin \left(\mathsf{fma}\left(-\log \left(\frac{-1}{x.im}\right), y.im, \log \left(\frac{-1}{x.im}\right) \cdot y.im\right)\right)\right)}
\] |
Simplified84.1%
[Start]84.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(x.im \cdot -1\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right) - \sin \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(x.im \cdot -1\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right)\right)
\] |
|---|---|
*-commutative [=>]84.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \color{blue}{\left(-1 \cdot x.im\right)}\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right) - \sin \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(x.im \cdot -1\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right)\right)
\] |
mul-1-neg [=>]84.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \color{blue}{\left(-x.im\right)}\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right) - \sin \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(x.im \cdot -1\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right)\right)
\] |
*-commutative [=>]84.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(-x.im\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \color{blue}{\left(-1 \cdot x.im\right)}, y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right) - \sin \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(x.im \cdot -1\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right)\right)
\] |
mul-1-neg [=>]84.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(-x.im\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \color{blue}{\left(-x.im\right)}, y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right) - \sin \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(x.im \cdot -1\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right)\right)
\] |
*-commutative [=>]84.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(-x.im\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(-x.im\right), \color{blue}{\log \left(\frac{-1}{x.im}\right) \cdot y.im}\right)\right) - \sin \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(x.im \cdot -1\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(y.im, \log \left(x.im \cdot -1\right), y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\right)\right)
\] |
if -1.10000000000000004e-40 < x.im < 2.50000000000000013e141Initial program 59.8%
Simplified80.4%
[Start]59.8% | \[ e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\] |
|---|
Applied egg-rr77.3%
[Start]80.4% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
\] |
|---|---|
*-commutative [<=]80.4% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right)\right)
\] |
hypot-udef [=>]59.8% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}, y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)
\] |
fma-def [<=]59.8% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}
\] |
add-cube-cbrt [=>]60.7% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(\left(\sqrt[3]{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re} \cdot \sqrt[3]{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right) \cdot \sqrt[3]{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right)}
\] |
pow3 [=>]57.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left({\left(\sqrt[3]{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right)}^{3}\right)}
\] |
*-commutative [=>]57.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left({\left(\sqrt[3]{\color{blue}{y.im \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right)}^{3}\right)
\] |
hypot-udef [<=]77.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right)}^{3}\right)
\] |
fma-def [=>]77.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left({\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}}\right)}^{3}\right)
\] |
Applied egg-rr83.0%
[Start]77.3% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\right)}^{3}\right)
\] |
|---|---|
unpow3 [=>]80.1% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(\left(\sqrt[3]{\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\right)}
\] |
add-cube-cbrt [<=]80.4% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}
\] |
fma-udef [=>]80.4% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}
\] |
*-commutative [=>]80.4% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) + \color{blue}{y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)
\] |
*-commutative [<=]80.4% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\color{blue}{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.im} + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
add-cube-cbrt [=>]80.9% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot \color{blue}{\left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \sqrt[3]{y.im}\right)} + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
associate-*r* [=>]83.0% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\color{blue}{\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right)\right) \cdot \sqrt[3]{y.im}} + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
fma-def [=>]83.0% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \color{blue}{\left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right), \sqrt[3]{y.im}, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}
\] |
hypot-udef [=>]61.6% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right), \sqrt[3]{y.im}, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
\] |
+-commutative [=>]61.6% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(\log \left(\sqrt{\color{blue}{x.im \cdot x.im + x.re \cdot x.re}}\right) \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right), \sqrt[3]{y.im}, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
\] |
hypot-def [=>]83.0% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(\log \color{blue}{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)} \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right), \sqrt[3]{y.im}, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
\] |
pow2 [=>]83.0% | \[ e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot \color{blue}{{\left(\sqrt[3]{y.im}\right)}^{2}}, \sqrt[3]{y.im}, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
\] |
if 2.50000000000000013e141 < x.im Initial program 0.0%
Simplified81.4%
[Start]0.0% | \[ e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\] |
|---|
Taylor expanded in y.im around 0 84.1%
Taylor expanded in y.re around 0 89.4%
Final simplification84.3%
| Alternative 1 | |
|---|---|
| Accuracy | 80.9% |
| Cost | 130884 |
| Alternative 2 | |
|---|---|
| Accuracy | 81.8% |
| Cost | 106180 |
| Alternative 3 | |
|---|---|
| Accuracy | 81.1% |
| Cost | 78212 |
| Alternative 4 | |
|---|---|
| Accuracy | 80.1% |
| Cost | 65348 |
| Alternative 5 | |
|---|---|
| Accuracy | 80.1% |
| Cost | 58820 |
| Alternative 6 | |
|---|---|
| Accuracy | 81.9% |
| Cost | 26176 |
| Alternative 7 | |
|---|---|
| Accuracy | 73.5% |
| Cost | 20753 |
| Alternative 8 | |
|---|---|
| Accuracy | 72.5% |
| Cost | 19908 |
| Alternative 9 | |
|---|---|
| Accuracy | 54.2% |
| Cost | 19844 |
| Alternative 10 | |
|---|---|
| Accuracy | 36.2% |
| Cost | 19712 |
herbie shell --seed 2023277
(FPCore (x.re x.im y.re y.im)
:name "powComplex, real part"
:precision binary64
(* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))