
(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 8 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)))
(t_1 (exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))))
(if (<= x.im 2e+59)
t_1
(* t_1 (cos (fma t_0 y.im (* y.re (atan2 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 t_1 = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
double tmp;
if (x_46_im <= 2e+59) {
tmp = t_1;
} else {
tmp = t_1 * cos(fma(t_0, y_46_im, (y_46_re * atan2(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)) t_1 = exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) tmp = 0.0 if (x_46_im <= 2e+59) tmp = t_1; else tmp = Float64(t_1 * cos(fma(t_0, y_46_im, Float64(y_46_re * atan(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]}, Block[{t$95$1 = 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]}, If[LessEqual[x$46$im, 2e+59], t$95$1, N[(t$95$1 * 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)}\\
\mathbf{if}\;x.im \leq 2 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos \left(\mathsf{fma}\left(t\_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\
\end{array}
\end{array}
if x.im < 1.99999999999999994e59Initial program 44.6%
cancel-sign-sub-inv44.6%
fma-define44.6%
hypot-define44.6%
distribute-lft-neg-in44.6%
distribute-rgt-neg-out44.6%
fma-define44.6%
hypot-define82.8%
*-commutative82.8%
Simplified82.8%
Taylor expanded in y.im around inf 45.4%
unpow245.4%
unpow245.4%
hypot-undefine84.1%
Simplified84.1%
Taylor expanded in y.im around 0 86.5%
if 1.99999999999999994e59 < x.im Initial program 21.3%
cancel-sign-sub-inv21.3%
fma-define21.3%
hypot-define21.3%
distribute-lft-neg-in21.3%
distribute-rgt-neg-out21.3%
fma-define21.3%
hypot-define89.4%
*-commutative89.4%
Simplified89.4%
Final simplification87.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(exp
(fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))))
(if (<= y.re 5e+49)
t_0
(* t_0 (cbrt (pow (cos (* y.im (log (hypot x.im x.re)))) 3.0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
double tmp;
if (y_46_re <= 5e+49) {
tmp = t_0;
} else {
tmp = t_0 * cbrt(pow(cos((y_46_im * log(hypot(x_46_im, x_46_re)))), 3.0));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = 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)))) tmp = 0.0 if (y_46_re <= 5e+49) tmp = t_0; else tmp = Float64(t_0 * cbrt((cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) ^ 3.0))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = 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]}, If[LessEqual[y$46$re, 5e+49], t$95$0, N[(t$95$0 * N[Power[N[Power[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 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{if}\;y.re \leq 5 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt[3]{{\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}^{3}}\\
\end{array}
\end{array}
if y.re < 5.0000000000000004e49Initial program 42.1%
cancel-sign-sub-inv42.1%
fma-define42.1%
hypot-define42.1%
distribute-lft-neg-in42.1%
distribute-rgt-neg-out42.1%
fma-define42.1%
hypot-define84.5%
*-commutative84.5%
Simplified84.5%
Taylor expanded in y.im around inf 41.5%
unpow241.5%
unpow241.5%
hypot-undefine83.4%
Simplified83.4%
Taylor expanded in y.im around 0 86.6%
if 5.0000000000000004e49 < y.re Initial program 31.8%
cancel-sign-sub-inv31.8%
fma-define31.8%
hypot-define31.8%
distribute-lft-neg-in31.8%
distribute-rgt-neg-out31.8%
fma-define31.8%
hypot-define81.8%
*-commutative81.8%
Simplified81.8%
Taylor expanded in y.im around inf 34.1%
unpow234.1%
unpow234.1%
hypot-undefine84.1%
Simplified84.1%
add-cbrt-cube84.1%
pow384.1%
Applied egg-rr84.1%
Final simplification86.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re 5e+232)
(exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))
(*
(pow (cbrt (cos (* y.im (log (hypot x.im x.re))))) 3.0)
(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) {
double tmp;
if (y_46_re <= 5e+232) {
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(cbrt(cos((y_46_im * log(hypot(x_46_im, x_46_re))))), 3.0) * pow(hypot(x_46_im, x_46_re), y_46_re);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= 5e+232) 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((cbrt(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))) ^ 3.0) * (hypot(x_46_im, x_46_re) ^ y_46_re)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 5e+232], 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[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 5 \cdot 10^{+232}:\\
\;\;\;\;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(\sqrt[3]{\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}\right)}^{3} \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.re < 4.99999999999999987e232Initial program 40.8%
cancel-sign-sub-inv40.8%
fma-define40.8%
hypot-define40.8%
distribute-lft-neg-in40.8%
distribute-rgt-neg-out40.8%
fma-define40.8%
hypot-define84.3%
*-commutative84.3%
Simplified84.3%
Taylor expanded in y.im around inf 40.7%
unpow240.7%
unpow240.7%
hypot-undefine83.7%
Simplified83.7%
Taylor expanded in y.im around 0 86.6%
if 4.99999999999999987e232 < y.re Initial program 33.3%
exp-diff6.7%
exp-to-pow6.7%
hypot-define6.7%
*-commutative6.7%
exp-prod6.7%
fma-define6.7%
hypot-define33.3%
*-commutative33.3%
Simplified33.3%
Taylor expanded in y.im around inf 13.3%
unpow233.3%
unpow233.3%
hypot-undefine80.0%
Simplified40.0%
add-cube-cbrt40.0%
pow340.0%
Applied egg-rr40.0%
Taylor expanded in y.im around 0 80.0%
unpow246.7%
unpow246.7%
hypot-undefine46.7%
Simplified80.0%
Final simplification86.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -8.5e-11)
(/ (pow (hypot x.re x.im) y.re) (+ 1.0 (* (atan2 x.im x.re) y.im)))
(if (<= y.re 4.4e+49)
(exp (* (atan2 x.im x.re) (- y.im)))
(* (cos (* y.im (log (hypot x.im x.re)))) (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) {
double tmp;
if (y_46_re <= -8.5e-11) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (atan2(x_46_im, x_46_re) * y_46_im));
} else if (y_46_re <= 4.4e+49) {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * pow(hypot(x_46_im, x_46_re), y_46_re);
}
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 <= -8.5e-11) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (Math.atan2(x_46_im, x_46_re) * y_46_im));
} else if (y_46_re <= 4.4e+49) {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = Math.cos((y_46_im * Math.log(Math.hypot(x_46_im, x_46_re)))) * Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if y_46_re <= -8.5e-11: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (math.atan2(x_46_im, x_46_re) * y_46_im)) elif y_46_re <= 4.4e+49: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) else: tmp = math.cos((y_46_im * math.log(math.hypot(x_46_im, x_46_re)))) * math.pow(math.hypot(x_46_im, x_46_re), y_46_re) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -8.5e-11) tmp = 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))); elseif (y_46_re <= 4.4e+49) tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))); else tmp = Float64(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) * (hypot(x_46_im, x_46_re) ^ y_46_re)); 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 <= -8.5e-11) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / (1.0 + (atan2(x_46_im, x_46_re) * y_46_im)); elseif (y_46_re <= 4.4e+49) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); else tmp = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * (hypot(x_46_im, x_46_re) ^ y_46_re); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -8.5e-11], 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], If[LessEqual[y$46$re, 4.4e+49], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -8.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{elif}\;y.re \leq 4.4 \cdot 10^{+49}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.re < -8.50000000000000037e-11Initial program 37.7%
exp-diff34.8%
exp-to-pow34.8%
hypot-define34.8%
*-commutative34.8%
exp-prod34.8%
fma-define34.8%
hypot-define72.5%
*-commutative72.5%
Simplified72.5%
Taylor expanded in y.im around inf 34.8%
unpow237.7%
unpow237.7%
hypot-undefine84.1%
Simplified71.0%
Taylor expanded in y.im around 0 81.3%
Taylor expanded in y.im around 0 81.3%
if -8.50000000000000037e-11 < y.re < 4.4000000000000001e49Initial program 44.2%
exp-diff44.2%
exp-to-pow44.2%
hypot-define44.2%
*-commutative44.2%
exp-prod44.1%
fma-define44.1%
hypot-define82.8%
*-commutative82.8%
Simplified82.8%
Taylor expanded in y.im around inf 43.2%
unpow243.3%
unpow243.3%
hypot-undefine83.1%
Simplified81.9%
Taylor expanded in y.im around 0 84.0%
Taylor expanded in y.re around 0 84.2%
rec-exp84.2%
*-commutative84.2%
distribute-rgt-neg-in84.2%
Simplified84.2%
if 4.4000000000000001e49 < y.re Initial program 31.8%
exp-diff11.4%
exp-to-pow11.4%
hypot-define11.4%
*-commutative11.4%
exp-prod11.4%
fma-define11.4%
hypot-define50.0%
*-commutative50.0%
Simplified50.0%
Taylor expanded in y.im around inf 15.9%
unpow234.1%
unpow234.1%
hypot-undefine84.1%
Simplified52.3%
Taylor expanded in y.im around 0 75.1%
unpow263.8%
unpow263.8%
hypot-undefine63.8%
Simplified75.1%
Final simplification81.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re 8.8e+232) (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)))) (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) {
double tmp;
if (y_46_re <= 8.8e+232) {
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 = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * pow(hypot(x_46_im, x_46_re), y_46_re);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= 8.8e+232) 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(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) * (hypot(x_46_im, x_46_re) ^ y_46_re)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 8.8e+232], 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[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 8.8 \cdot 10^{+232}:\\
\;\;\;\;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}:\\
\;\;\;\;\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.re < 8.7999999999999999e232Initial program 40.8%
cancel-sign-sub-inv40.8%
fma-define40.8%
hypot-define40.8%
distribute-lft-neg-in40.8%
distribute-rgt-neg-out40.8%
fma-define40.8%
hypot-define84.3%
*-commutative84.3%
Simplified84.3%
Taylor expanded in y.im around inf 40.7%
unpow240.7%
unpow240.7%
hypot-undefine83.7%
Simplified83.7%
Taylor expanded in y.im around 0 86.6%
if 8.7999999999999999e232 < y.re Initial program 33.3%
exp-diff6.7%
exp-to-pow6.7%
hypot-define6.7%
*-commutative6.7%
exp-prod6.7%
fma-define6.7%
hypot-define33.3%
*-commutative33.3%
Simplified33.3%
Taylor expanded in y.im around inf 13.3%
unpow233.3%
unpow233.3%
hypot-undefine80.0%
Simplified40.0%
Taylor expanded in y.im around 0 80.0%
unpow246.7%
unpow246.7%
hypot-undefine46.7%
Simplified80.0%
Final simplification86.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -8.5e-11) (not (<= y.re 5.8e+14))) (/ (pow (hypot x.re x.im) y.re) (+ 1.0 (* (atan2 x.im x.re) y.im))) (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 <= -8.5e-11) || !(y_46_re <= 5.8e+14)) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (atan2(x_46_im, x_46_re) * y_46_im));
} 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 <= -8.5e-11) || !(y_46_re <= 5.8e+14)) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (Math.atan2(x_46_im, x_46_re) * y_46_im));
} 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 <= -8.5e-11) or not (y_46_re <= 5.8e+14): tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (math.atan2(x_46_im, x_46_re) * y_46_im)) 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 <= -8.5e-11) || !(y_46_re <= 5.8e+14)) tmp = 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))); 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 <= -8.5e-11) || ~((y_46_re <= 5.8e+14))) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / (1.0 + (atan2(x_46_im, x_46_re) * y_46_im)); 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, -8.5e-11], N[Not[LessEqual[y$46$re, 5.8e+14]], $MachinePrecision]], 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[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 -8.5 \cdot 10^{-11} \lor \neg \left(y.re \leq 5.8 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\end{array}
\end{array}
if y.re < -8.50000000000000037e-11 or 5.8e14 < y.re Initial program 34.2%
exp-diff25.0%
exp-to-pow25.0%
hypot-define25.0%
*-commutative25.0%
exp-prod25.0%
fma-define25.0%
hypot-define60.8%
*-commutative60.8%
Simplified60.8%
Taylor expanded in y.im around inf 26.7%
unpow235.0%
unpow235.0%
hypot-undefine80.8%
Simplified60.8%
Taylor expanded in y.im around 0 75.2%
Taylor expanded in y.im around 0 76.0%
if -8.50000000000000037e-11 < y.re < 5.8e14Initial program 45.8%
exp-diff45.8%
exp-to-pow45.8%
hypot-define45.8%
*-commutative45.8%
exp-prod45.6%
fma-define45.6%
hypot-define86.3%
*-commutative86.3%
Simplified86.3%
Taylor expanded in y.im around inf 44.7%
unpow244.8%
unpow244.8%
hypot-undefine85.9%
Simplified85.4%
Taylor expanded in y.im around 0 86.8%
Taylor expanded in y.re around 0 87.0%
rec-exp87.0%
*-commutative87.0%
distribute-rgt-neg-in87.0%
Simplified87.0%
Final simplification81.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -3.2e-11) (not (<= y.re 5.3e+17))) (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 <= -3.2e-11) || !(y_46_re <= 5.3e+17)) {
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 <= -3.2e-11) || !(y_46_re <= 5.3e+17)) {
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 <= -3.2e-11) or not (y_46_re <= 5.3e+17): 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 <= -3.2e-11) || !(y_46_re <= 5.3e+17)) 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 <= -3.2e-11) || ~((y_46_re <= 5.3e+17))) 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, -3.2e-11], N[Not[LessEqual[y$46$re, 5.3e+17]], $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 -3.2 \cdot 10^{-11} \lor \neg \left(y.re \leq 5.3 \cdot 10^{+17}\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 < -3.19999999999999994e-11 or 5.3e17 < y.re Initial program 34.7%
exp-diff25.4%
exp-to-pow25.4%
hypot-define25.4%
*-commutative25.4%
exp-prod25.4%
fma-define25.4%
hypot-define61.9%
*-commutative61.9%
Simplified61.9%
Taylor expanded in y.im around inf 27.1%
unpow235.6%
unpow235.6%
hypot-undefine81.4%
Simplified61.9%
Taylor expanded in y.im around 0 61.0%
Taylor expanded in y.im around 0 73.1%
unpow273.1%
unpow273.1%
hypot-undefine73.0%
Simplified73.0%
if -3.19999999999999994e-11 < y.re < 5.3e17Initial program 45.1%
exp-diff45.1%
exp-to-pow45.1%
hypot-define45.1%
*-commutative45.1%
exp-prod45.0%
fma-define45.0%
hypot-define85.1%
*-commutative85.1%
Simplified85.1%
Taylor expanded in y.im around inf 44.0%
unpow244.2%
unpow244.2%
hypot-undefine85.3%
Simplified84.1%
Taylor expanded in y.im around 0 85.6%
Taylor expanded in y.re around 0 86.5%
rec-exp86.5%
*-commutative86.5%
distribute-rgt-neg-in86.5%
Simplified86.5%
Final simplification80.3%
(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 40.3%
exp-diff36.0%
exp-to-pow36.0%
hypot-define36.0%
*-commutative36.0%
exp-prod36.0%
fma-define36.0%
hypot-define74.4%
*-commutative74.4%
Simplified74.4%
Taylor expanded in y.im around inf 36.2%
unpow240.2%
unpow240.2%
hypot-undefine83.5%
Simplified73.9%
Taylor expanded in y.im around 0 74.3%
Taylor expanded in y.im around 0 52.0%
unpow252.0%
unpow252.0%
hypot-undefine63.9%
Simplified63.9%
Final simplification63.9%
herbie shell --seed 2024084
(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)))))