
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im))))
(if (<= y.re -2.35e+69)
(*
(/ (pow (hypot x.re x.im) y.re) (+ 1.0 (* (atan2 x.im x.re) y.im)))
(cos (fma t_0 y.im (* y.re (atan2 x.im x.re)))))
(*
(exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
(cos (* y.im (log (hypot x.im x.re))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(hypot(x_46_re, x_46_im));
double tmp;
if (y_46_re <= -2.35e+69) {
tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (atan2(x_46_im, x_46_re) * y_46_im))) * cos(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re))));
} else {
tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos((y_46_im * log(hypot(x_46_im, x_46_re))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) tmp = 0.0 if (y_46_re <= -2.35e+69) tmp = Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / Float64(1.0 + Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re))))); else tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -2.35e+69], N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[(1.0 + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(t$95$0 * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;y.re \leq -2.35 \cdot 10^{+69}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(t\_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\
\end{array}
\end{array}
if y.re < -2.34999999999999998e69Initial program 29.3%
exp-diff22.0%
exp-to-pow22.0%
hypot-def22.0%
*-commutative22.0%
exp-prod22.0%
fma-def22.0%
hypot-def56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in y.im around 0 83.0%
if -2.34999999999999998e69 < y.re Initial program 37.4%
cancel-sign-sub-inv37.4%
fma-def37.4%
hypot-def37.4%
distribute-lft-neg-in37.4%
distribute-rgt-neg-out37.4%
fma-def37.4%
hypot-def76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in y.im around inf 40.2%
unpow240.2%
unpow240.2%
hypot-def80.6%
Simplified80.6%
Final simplification80.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (expm1 (cos (* y.im (log (hypot x.im x.re))))))
(t_1 (log (cbrt (exp (pow t_0 2.0))))))
(*
(exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))
(log1p (* (cbrt t_0) (cbrt (+ t_1 (* 2.0 t_1))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = expm1(cos((y_46_im * log(hypot(x_46_im, x_46_re)))));
double t_1 = log(cbrt(exp(pow(t_0, 2.0))));
return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * log1p((cbrt(t_0) * cbrt((t_1 + (2.0 * t_1)))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = expm1(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))) t_1 = log(cbrt(exp((t_0 ^ 2.0)))) return Float64(exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * log1p(Float64(cbrt(t_0) * cbrt(Float64(t_1 + Float64(2.0 * t_1)))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(Exp[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[Power[N[Exp[N[Power[t$95$0, 2.0], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[1 + N[(N[Power[t$95$0, 1/3], $MachinePrecision] * N[Power[N[(t$95$1 + N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{expm1}\left(\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\\
t_1 := \log \left(\sqrt[3]{e^{{t\_0}^{2}}}\right)\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \mathsf{log1p}\left(\sqrt[3]{t\_0} \cdot \sqrt[3]{t\_1 + 2 \cdot t\_1}\right)
\end{array}
\end{array}
Initial program 36.1%
cancel-sign-sub-inv36.1%
fma-def36.1%
hypot-def36.1%
distribute-lft-neg-in36.1%
distribute-rgt-neg-out36.1%
fma-def36.1%
hypot-def75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in y.im around inf 38.8%
unpow238.8%
unpow238.8%
hypot-def79.4%
Simplified79.4%
log1p-expm1-u79.4%
Applied egg-rr79.4%
add-cube-cbrt78.7%
associate-*l*78.7%
Applied egg-rr45.3%
log-pow45.3%
log-pow79.4%
Simplified79.4%
add-log-exp79.4%
add-cube-cbrt79.4%
log-prod79.4%
Applied egg-rr45.3%
log-prod45.3%
count-245.3%
log-pow45.3%
Simplified79.4%
Final simplification79.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (expm1 (cos (* y.im (log (hypot x.im x.re)))))))
(*
(exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))
(log1p (* (cbrt t_0) (cbrt (pow t_0 2.0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = expm1(cos((y_46_im * log(hypot(x_46_im, x_46_re)))));
return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * log1p((cbrt(t_0) * cbrt(pow(t_0, 2.0))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = expm1(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))) return Float64(exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * log1p(Float64(cbrt(t_0) * cbrt((t_0 ^ 2.0))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(Exp[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]}, N[(N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[1 + N[(N[Power[t$95$0, 1/3], $MachinePrecision] * N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{expm1}\left(\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \mathsf{log1p}\left(\sqrt[3]{t\_0} \cdot \sqrt[3]{{t\_0}^{2}}\right)
\end{array}
\end{array}
Initial program 36.1%
cancel-sign-sub-inv36.1%
fma-def36.1%
hypot-def36.1%
distribute-lft-neg-in36.1%
distribute-rgt-neg-out36.1%
fma-def36.1%
hypot-def75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in y.im around inf 38.8%
unpow238.8%
unpow238.8%
hypot-def79.4%
Simplified79.4%
log1p-expm1-u79.4%
Applied egg-rr79.4%
add-cube-cbrt78.7%
associate-*l*78.7%
Applied egg-rr45.3%
log-pow45.3%
log-pow79.4%
Simplified79.4%
Final simplification79.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* y.im (log (hypot x.im x.re))))))
(*
(exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))
(* (cbrt (pow t_0 2.0)) (cbrt t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = cos((y_46_im * log(hypot(x_46_im, x_46_re))));
return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * (cbrt(pow(t_0, 2.0)) * cbrt(t_0));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) return Float64(exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * Float64(cbrt((t_0 ^ 2.0)) * cbrt(t_0))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], 1/3], $MachinePrecision] * N[Power[t$95$0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \left(\sqrt[3]{{t\_0}^{2}} \cdot \sqrt[3]{t\_0}\right)
\end{array}
\end{array}
Initial program 36.1%
cancel-sign-sub-inv36.1%
fma-def36.1%
hypot-def36.1%
distribute-lft-neg-in36.1%
distribute-rgt-neg-out36.1%
fma-def36.1%
hypot-def75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in y.im around inf 38.8%
unpow238.8%
unpow238.8%
hypot-def79.4%
Simplified79.4%
add-cube-cbrt79.4%
cbrt-unprod79.4%
pow279.4%
Applied egg-rr79.4%
Final simplification79.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im)))) (log1p (expm1 (cos (* y.im (log (hypot x.im x.re))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * log1p(expm1(cos((y_46_im * log(hypot(x_46_im, x_46_re))))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * log1p(expm1(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right)
\end{array}
Initial program 36.1%
cancel-sign-sub-inv36.1%
fma-def36.1%
hypot-def36.1%
distribute-lft-neg-in36.1%
distribute-rgt-neg-out36.1%
fma-def36.1%
hypot-def75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in y.im around inf 38.8%
unpow238.8%
unpow238.8%
hypot-def79.4%
Simplified79.4%
log1p-expm1-u79.4%
Applied egg-rr79.4%
Final simplification79.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im)))) (cos (* y.im (log (hypot x.im x.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos((y_46_im * log(hypot(x_46_im, x_46_re))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)
\end{array}
Initial program 36.1%
cancel-sign-sub-inv36.1%
fma-def36.1%
hypot-def36.1%
distribute-lft-neg-in36.1%
distribute-rgt-neg-out36.1%
fma-def36.1%
hypot-def75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in y.im around inf 38.8%
unpow238.8%
unpow238.8%
hypot-def79.4%
Simplified79.4%
Final simplification79.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) (- y.im))))
(if (<= x.im -2.6e-41)
(*
(cos (* y.im (log (hypot x.im x.re))))
(exp (- t_0 (* y.re (log (/ -1.0 x.im))))))
(exp (fma (log (hypot x.re x.im)) y.re t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = atan2(x_46_im, x_46_re) * -y_46_im;
double tmp;
if (x_46_im <= -2.6e-41) {
tmp = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * exp((t_0 - (y_46_re * log((-1.0 / x_46_im)))));
} else {
tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, t_0));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)) tmp = 0.0 if (x_46_im <= -2.6e-41) tmp = Float64(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) * exp(Float64(t_0 - Float64(y_46_re * log(Float64(-1.0 / x_46_im)))))); else tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, t_0)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]}, If[LessEqual[x$46$im, -2.6e-41], N[(N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(y$46$re * N[Log[N[(-1.0 / x$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\\
\mathbf{if}\;x.im \leq -2.6 \cdot 10^{-41}:\\
\;\;\;\;\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot e^{t\_0 - y.re \cdot \log \left(\frac{-1}{x.im}\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, t\_0\right)}\\
\end{array}
\end{array}
if x.im < -2.5999999999999999e-41Initial program 32.9%
cancel-sign-sub-inv32.9%
fma-def32.9%
hypot-def32.9%
distribute-lft-neg-in32.9%
distribute-rgt-neg-out32.9%
fma-def32.9%
hypot-def78.8%
*-commutative78.8%
Simplified78.8%
Taylor expanded in y.im around inf 38.0%
unpow238.0%
unpow238.0%
hypot-def85.6%
Simplified85.6%
Taylor expanded in x.im around -inf 85.1%
distribute-lft-out85.1%
Simplified85.1%
if -2.5999999999999999e-41 < x.im Initial program 37.5%
cancel-sign-sub-inv37.5%
fma-def37.5%
hypot-def37.5%
distribute-lft-neg-in37.5%
distribute-rgt-neg-out37.5%
fma-def37.5%
hypot-def74.5%
*-commutative74.5%
Simplified74.5%
Taylor expanded in y.im around inf 39.2%
unpow239.2%
unpow239.2%
hypot-def76.6%
Simplified76.6%
Taylor expanded in y.im around 0 76.5%
Final simplification79.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re 1.12e+266)
(exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))
(*
(pow (hypot x.re x.im) y.re)
(+ 1.0 (* -0.5 (pow (* y.im (log (hypot x.im x.re))) 2.0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= 1.12e+266) {
tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
} else {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) * (1.0 + (-0.5 * pow((y_46_im * log(hypot(x_46_im, x_46_re))), 2.0)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= 1.12e+266) tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))); else tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) * Float64(1.0 + Float64(-0.5 * (Float64(y_46_im * log(hypot(x_46_im, x_46_re))) ^ 2.0)))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 1.12e+266], N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[Power[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 1.12 \cdot 10^{+266}:\\
\;\;\;\;e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \left(1 + -0.5 \cdot {\left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}^{2}\right)\\
\end{array}
\end{array}
if y.re < 1.11999999999999996e266Initial program 36.4%
cancel-sign-sub-inv36.4%
fma-def36.4%
hypot-def36.4%
distribute-lft-neg-in36.4%
distribute-rgt-neg-out36.4%
fma-def36.4%
hypot-def76.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in y.im around inf 39.2%
unpow239.2%
unpow239.2%
hypot-def80.2%
Simplified80.2%
Taylor expanded in y.im around 0 78.8%
if 1.11999999999999996e266 < y.re Initial program 20.0%
exp-diff20.0%
exp-to-pow20.0%
hypot-def20.0%
*-commutative20.0%
exp-prod20.0%
fma-def20.0%
hypot-def20.0%
*-commutative20.0%
Simplified20.0%
Taylor expanded in y.im around 0 20.0%
Taylor expanded in y.re around 0 20.0%
unpow220.0%
unpow220.0%
hypot-def40.0%
Simplified40.0%
Taylor expanded in y.im around 0 100.0%
unpow2100.0%
unpow2100.0%
unswap-sqr100.0%
Simplified100.0%
Final simplification79.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)}
\end{array}
Initial program 36.1%
cancel-sign-sub-inv36.1%
fma-def36.1%
hypot-def36.1%
distribute-lft-neg-in36.1%
distribute-rgt-neg-out36.1%
fma-def36.1%
hypot-def75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in y.im around inf 38.8%
unpow238.8%
unpow238.8%
hypot-def79.4%
Simplified79.4%
Taylor expanded in y.im around 0 77.2%
Final simplification77.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -600000.0) (not (<= y.re 2.5e-13))) (pow (hypot x.im x.re) y.re) (exp (* (atan2 x.im x.re) (- y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -600000.0) || !(y_46_re <= 2.5e-13)) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -600000.0) || !(y_46_re <= 2.5e-13)) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -600000.0) or not (y_46_re <= 2.5e-13): tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) else: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -600000.0) || !(y_46_re <= 2.5e-13)) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -600000.0) || ~((y_46_re <= 2.5e-13))) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -600000.0], N[Not[LessEqual[y$46$re, 2.5e-13]], $MachinePrecision]], N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -600000 \lor \neg \left(y.re \leq 2.5 \cdot 10^{-13}\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\end{array}
\end{array}
if y.re < -6e5 or 2.49999999999999995e-13 < y.re Initial program 28.9%
cancel-sign-sub-inv28.9%
fma-def28.9%
hypot-def28.9%
distribute-lft-neg-in28.9%
distribute-rgt-neg-out28.9%
fma-def28.9%
hypot-def66.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in y.im around inf 34.7%
unpow234.7%
unpow234.7%
hypot-def73.8%
Simplified73.8%
Taylor expanded in y.im around 0 72.1%
Taylor expanded in y.im around 0 68.8%
unpow268.8%
unpow268.8%
hypot-def70.6%
Simplified70.6%
if -6e5 < y.re < 2.49999999999999995e-13Initial program 42.6%
cancel-sign-sub-inv42.6%
fma-def42.6%
hypot-def42.6%
distribute-lft-neg-in42.6%
distribute-rgt-neg-out42.6%
fma-def42.6%
hypot-def84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in y.im around inf 42.6%
unpow242.6%
unpow242.6%
hypot-def84.4%
Simplified84.4%
Taylor expanded in y.im around 0 81.8%
Taylor expanded in y.re around 0 81.3%
neg-mul-181.3%
distribute-lft-neg-in81.3%
Simplified81.3%
Final simplification76.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (pow (hypot x.im x.re) y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return pow(hypot(x_46_im, x_46_re), y_46_re);
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow(math.hypot(x_46_im, x_46_re), y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return hypot(x_46_im, x_46_re) ^ y_46_re end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}
\end{array}
Initial program 36.1%
cancel-sign-sub-inv36.1%
fma-def36.1%
hypot-def36.1%
distribute-lft-neg-in36.1%
distribute-rgt-neg-out36.1%
fma-def36.1%
hypot-def75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in y.im around inf 38.8%
unpow238.8%
unpow238.8%
hypot-def79.4%
Simplified79.4%
Taylor expanded in y.im around 0 77.2%
Taylor expanded in y.im around 0 51.3%
unpow251.3%
unpow251.3%
hypot-def58.6%
Simplified58.6%
Final simplification58.6%
herbie shell --seed 2024040
(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)))))