
(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 9 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 (* y.re (atan2 x.im x.re)))
(t_2
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im))))
(t_3 (cos (pow (cbrt (fma y.im t_0 t_1)) 3.0))))
(if (<= y.re -0.96)
(* t_2 (cos t_1))
(if (<= y.re 1.8e-146)
(/ (pow (hypot x.re x.im) y.re) (pow (exp y.im) (atan2 x.im x.re)))
(if (<= y.re 9.2e+89)
(* (exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im)))) t_3)
(if (<= y.re 1e+238)
(* t_2 (fabs (cos (fma y.im (log (hypot x.im x.re)) t_1))))
(* t_3 (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 t_0 = log(hypot(x_46_re, x_46_im));
double t_1 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = exp(((y_46_re * log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_3 = cos(pow(cbrt(fma(y_46_im, t_0, t_1)), 3.0));
double tmp;
if (y_46_re <= -0.96) {
tmp = t_2 * cos(t_1);
} else if (y_46_re <= 1.8e-146) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / pow(exp(y_46_im), atan2(x_46_im, x_46_re));
} else if (y_46_re <= 9.2e+89) {
tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * t_3;
} else if (y_46_re <= 1e+238) {
tmp = t_2 * fabs(cos(fma(y_46_im, log(hypot(x_46_im, x_46_re)), t_1)));
} else {
tmp = t_3 * 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) t_0 = log(hypot(x_46_re, x_46_im)) t_1 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_2 = exp(Float64(Float64(y_46_re * log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_3 = cos((cbrt(fma(y_46_im, t_0, t_1)) ^ 3.0)) tmp = 0.0 if (y_46_re <= -0.96) tmp = Float64(t_2 * cos(t_1)); elseif (y_46_re <= 1.8e-146) tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan(x_46_im, x_46_re))); elseif (y_46_re <= 9.2e+89) tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * t_3); elseif (y_46_re <= 1e+238) tmp = Float64(t_2 * abs(cos(fma(y_46_im, log(hypot(x_46_im, x_46_re)), t_1)))); else tmp = Float64(t_3 * (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_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(y$46$re * N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[Power[N[Power[N[(y$46$im * t$95$0 + t$95$1), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -0.96], N[(t$95$2 * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.8e-146], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 9.2e+89], 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] * t$95$3), $MachinePrecision], If[LessEqual[y$46$re, 1e+238], N[(t$95$2 * N[Abs[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$3 * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_3 := \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(y.im, t_0, t_1\right)}\right)}^{3}\right)\\
\mathbf{if}\;y.re \leq -0.96:\\
\;\;\;\;t_2 \cdot \cos t_1\\
\mathbf{elif}\;y.re \leq 1.8 \cdot 10^{-146}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\mathbf{elif}\;y.re \leq 9.2 \cdot 10^{+89}:\\
\;\;\;\;e^{\mathsf{fma}\left(t_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot t_3\\
\mathbf{elif}\;y.re \leq 10^{+238}:\\
\;\;\;\;t_2 \cdot \left|\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right), t_1\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t_3 \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.re < -0.95999999999999996Initial program 53.0%
Taylor expanded in y.im around 0 86.4%
if -0.95999999999999996 < y.re < 1.79999999999999989e-146Initial program 42.0%
exp-diff42.0%
exp-to-pow42.0%
hypot-def42.0%
*-commutative42.0%
exp-prod41.8%
fma-def41.8%
hypot-def83.1%
*-commutative83.1%
Simplified83.1%
add-cube-cbrt80.2%
pow377.2%
fma-udef77.2%
*-commutative77.2%
*-commutative77.2%
fma-def77.2%
Applied egg-rr77.2%
Taylor expanded in y.im around inf 86.7%
if 1.79999999999999989e-146 < y.re < 9.1999999999999996e89Initial program 21.5%
fma-neg21.5%
hypot-def21.5%
distribute-rgt-neg-out21.5%
fma-def21.5%
hypot-def73.8%
*-commutative73.8%
Simplified73.8%
add-cube-cbrt69.1%
pow376.3%
fma-udef76.3%
*-commutative76.3%
*-commutative76.3%
fma-def76.3%
Applied egg-rr90.5%
if 9.1999999999999996e89 < y.re < 1e238Initial program 45.2%
fma-def45.2%
hypot-udef64.6%
*-commutative64.6%
add-sqr-sqrt48.4%
sqrt-unprod90.4%
pow290.4%
fma-udef90.4%
*-commutative90.4%
*-commutative90.4%
fma-def90.4%
Applied egg-rr90.4%
unpow290.4%
rem-sqrt-square90.4%
hypot-def48.4%
unpow248.4%
unpow248.4%
+-commutative48.4%
*-commutative48.4%
fma-def48.4%
fma-def48.4%
unpow248.4%
unpow248.4%
hypot-def90.4%
Simplified90.4%
if 1e238 < y.re Initial program 36.8%
exp-diff26.3%
exp-to-pow26.3%
hypot-def26.3%
*-commutative26.3%
exp-prod26.3%
fma-def26.3%
hypot-def47.4%
*-commutative47.4%
Simplified47.4%
Taylor expanded in y.im around 0 57.9%
unpow257.9%
unpow257.9%
hypot-def57.9%
Simplified57.9%
add-cube-cbrt73.7%
pow378.9%
fma-udef73.7%
*-commutative73.7%
*-commutative73.7%
fma-def78.9%
Applied egg-rr94.7%
Final simplification88.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_1 (exp (- (* y.re t_0) (* (atan2 x.im x.re) y.im))))
(t_2 (* y.re (atan2 x.im x.re))))
(if (<= (* t_1 (cos (+ t_2 (* t_0 y.im)))) INFINITY)
(* t_1 (cos t_2))
(/ (pow (hypot x.re x.im) y.re) (pow (exp y.im) (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(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_1 = exp(((y_46_re * t_0) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_2 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if ((t_1 * cos((t_2 + (t_0 * y_46_im)))) <= ((double) INFINITY)) {
tmp = t_1 * cos(t_2);
} else {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / pow(exp(y_46_im), atan2(x_46_im, x_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 t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_1 = Math.exp(((y_46_re * t_0) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
double t_2 = y_46_re * Math.atan2(x_46_im, x_46_re);
double tmp;
if ((t_1 * Math.cos((t_2 + (t_0 * y_46_im)))) <= Double.POSITIVE_INFINITY) {
tmp = t_1 * Math.cos(t_2);
} else {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / Math.pow(Math.exp(y_46_im), Math.atan2(x_46_im, x_46_re));
}
return tmp;
}
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)))) t_1 = math.exp(((y_46_re * t_0) - (math.atan2(x_46_im, x_46_re) * y_46_im))) t_2 = y_46_re * math.atan2(x_46_im, x_46_re) tmp = 0 if (t_1 * math.cos((t_2 + (t_0 * y_46_im)))) <= math.inf: tmp = t_1 * math.cos(t_2) else: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / math.pow(math.exp(y_46_im), math.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(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_1 = exp(Float64(Float64(y_46_re * t_0) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_2 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (Float64(t_1 * cos(Float64(t_2 + Float64(t_0 * y_46_im)))) <= Inf) tmp = Float64(t_1 * cos(t_2)); else tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan(x_46_im, x_46_re))); end return tmp end
function tmp_2 = 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)))); t_1 = exp(((y_46_re * t_0) - (atan2(x_46_im, x_46_re) * y_46_im))); t_2 = y_46_re * atan2(x_46_im, x_46_re); tmp = 0.0; if ((t_1 * cos((t_2 + (t_0 * y_46_im)))) <= Inf) tmp = t_1 * cos(t_2); else tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan2(x_46_im, x_46_re)); end tmp_2 = tmp; 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]}, Block[{t$95$1 = N[Exp[N[(N[(y$46$re * t$95$0), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[Cos[N[(t$95$2 + N[(t$95$0 * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$1 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $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)\\
t_1 := e^{y.re \cdot t_0 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;t_1 \cdot \cos \left(t_2 + t_0 \cdot y.im\right) \leq \infty:\\
\;\;\;\;t_1 \cdot \cos t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < +inf.0Initial program 79.9%
Taylor expanded in y.im around 0 84.2%
if +inf.0 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) Initial program 0.0%
exp-diff0.0%
exp-to-pow0.0%
hypot-def0.0%
*-commutative0.0%
exp-prod0.0%
fma-def0.0%
hypot-def69.5%
*-commutative69.5%
Simplified69.5%
add-cube-cbrt72.0%
pow373.7%
fma-udef72.9%
*-commutative72.9%
*-commutative72.9%
fma-def73.7%
Applied egg-rr73.7%
Taylor expanded in y.im around inf 76.1%
Final simplification80.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re)))
(t_1 (cos (pow (cbrt (fma y.im (log (hypot x.re x.im)) t_0)) 3.0)))
(t_2
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im))))
(t_3
(/ (pow (hypot x.re x.im) y.re) (pow (exp y.im) (atan2 x.im x.re)))))
(if (<= y.re -0.95)
(* t_2 (cos t_0))
(if (<= y.re 1e-153)
t_3
(if (<= y.re 1.46e+87)
(* t_3 t_1)
(if (<= y.re 1.6e+237)
(* t_2 (fabs (cos (fma y.im (log (hypot x.im x.re)) t_0))))
(* t_1 (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 t_0 = y_46_re * atan2(x_46_im, x_46_re);
double t_1 = cos(pow(cbrt(fma(y_46_im, log(hypot(x_46_re, x_46_im)), t_0)), 3.0));
double t_2 = exp(((y_46_re * log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_3 = pow(hypot(x_46_re, x_46_im), y_46_re) / pow(exp(y_46_im), atan2(x_46_im, x_46_re));
double tmp;
if (y_46_re <= -0.95) {
tmp = t_2 * cos(t_0);
} else if (y_46_re <= 1e-153) {
tmp = t_3;
} else if (y_46_re <= 1.46e+87) {
tmp = t_3 * t_1;
} else if (y_46_re <= 1.6e+237) {
tmp = t_2 * fabs(cos(fma(y_46_im, log(hypot(x_46_im, x_46_re)), t_0)));
} else {
tmp = t_1 * 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) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_1 = cos((cbrt(fma(y_46_im, log(hypot(x_46_re, x_46_im)), t_0)) ^ 3.0)) t_2 = exp(Float64(Float64(y_46_re * log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_3 = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan(x_46_im, x_46_re))) tmp = 0.0 if (y_46_re <= -0.95) tmp = Float64(t_2 * cos(t_0)); elseif (y_46_re <= 1e-153) tmp = t_3; elseif (y_46_re <= 1.46e+87) tmp = Float64(t_3 * t_1); elseif (y_46_re <= 1.6e+237) tmp = Float64(t_2 * abs(cos(fma(y_46_im, log(hypot(x_46_im, x_46_re)), t_0)))); else tmp = Float64(t_1 * (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_] := Block[{t$95$0 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[Power[N[Power[N[(y$46$im * N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(y$46$re * N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -0.95], N[(t$95$2 * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1e-153], t$95$3, If[LessEqual[y$46$re, 1.46e+87], N[(t$95$3 * t$95$1), $MachinePrecision], If[LessEqual[y$46$re, 1.6e+237], N[(t$95$2 * N[Abs[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), t_0\right)}\right)}^{3}\right)\\
t_2 := e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_3 := \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\mathbf{if}\;y.re \leq -0.95:\\
\;\;\;\;t_2 \cdot \cos t_0\\
\mathbf{elif}\;y.re \leq 10^{-153}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y.re \leq 1.46 \cdot 10^{+87}:\\
\;\;\;\;t_3 \cdot t_1\\
\mathbf{elif}\;y.re \leq 1.6 \cdot 10^{+237}:\\
\;\;\;\;t_2 \cdot \left|\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right), t_0\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.re < -0.94999999999999996Initial program 53.0%
Taylor expanded in y.im around 0 86.4%
if -0.94999999999999996 < y.re < 1.00000000000000004e-153Initial program 42.0%
exp-diff42.0%
exp-to-pow42.0%
hypot-def42.0%
*-commutative42.0%
exp-prod41.8%
fma-def41.8%
hypot-def83.1%
*-commutative83.1%
Simplified83.1%
add-cube-cbrt80.2%
pow377.2%
fma-udef77.2%
*-commutative77.2%
*-commutative77.2%
fma-def77.2%
Applied egg-rr77.2%
Taylor expanded in y.im around inf 86.7%
if 1.00000000000000004e-153 < y.re < 1.46e87Initial program 21.5%
exp-diff21.5%
exp-to-pow21.5%
hypot-def21.5%
*-commutative21.5%
exp-prod21.5%
fma-def21.5%
hypot-def64.4%
*-commutative64.4%
Simplified64.4%
add-cube-cbrt69.1%
pow376.3%
fma-udef76.3%
*-commutative76.3%
*-commutative76.3%
fma-def76.3%
Applied egg-rr76.3%
if 1.46e87 < y.re < 1.60000000000000009e237Initial program 45.2%
fma-def45.2%
hypot-udef64.6%
*-commutative64.6%
add-sqr-sqrt48.4%
sqrt-unprod90.4%
pow290.4%
fma-udef90.4%
*-commutative90.4%
*-commutative90.4%
fma-def90.4%
Applied egg-rr90.4%
unpow290.4%
rem-sqrt-square90.4%
hypot-def48.4%
unpow248.4%
unpow248.4%
+-commutative48.4%
*-commutative48.4%
fma-def48.4%
fma-def48.4%
unpow248.4%
unpow248.4%
hypot-def90.4%
Simplified90.4%
if 1.60000000000000009e237 < y.re Initial program 36.8%
exp-diff26.3%
exp-to-pow26.3%
hypot-def26.3%
*-commutative26.3%
exp-prod26.3%
fma-def26.3%
hypot-def47.4%
*-commutative47.4%
Simplified47.4%
Taylor expanded in y.im around 0 57.9%
unpow257.9%
unpow257.9%
hypot-def57.9%
Simplified57.9%
add-cube-cbrt73.7%
pow378.9%
fma-udef73.7%
*-commutative73.7%
*-commutative73.7%
fma-def78.9%
Applied egg-rr94.7%
Final simplification86.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (* y.re (atan2 x.im x.re)))
(t_2
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im)))))
(if (<= y.re -1.3)
(* t_2 (cos t_1))
(if (<= y.re -2.2e-107)
(/ (pow (hypot x.re x.im) y.re) (pow (exp y.im) (atan2 x.im x.re)))
(if (<= y.re 3.2e+65)
(*
(exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
(cos (fma t_0 y.im t_1)))
(if (<= y.re 7.5e+233)
(* t_2 (fabs (cos (fma y.im (log (hypot x.im x.re)) t_1))))
(*
(cos (pow (cbrt (fma y.im t_0 t_1)) 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 t_0 = log(hypot(x_46_re, x_46_im));
double t_1 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = exp(((y_46_re * log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (atan2(x_46_im, x_46_re) * y_46_im)));
double tmp;
if (y_46_re <= -1.3) {
tmp = t_2 * cos(t_1);
} else if (y_46_re <= -2.2e-107) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / pow(exp(y_46_im), atan2(x_46_im, x_46_re));
} else if (y_46_re <= 3.2e+65) {
tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos(fma(t_0, y_46_im, t_1));
} else if (y_46_re <= 7.5e+233) {
tmp = t_2 * fabs(cos(fma(y_46_im, log(hypot(x_46_im, x_46_re)), t_1)));
} else {
tmp = cos(pow(cbrt(fma(y_46_im, t_0, t_1)), 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) t_0 = log(hypot(x_46_re, x_46_im)) t_1 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_2 = exp(Float64(Float64(y_46_re * log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))) - Float64(atan(x_46_im, x_46_re) * y_46_im))) tmp = 0.0 if (y_46_re <= -1.3) tmp = Float64(t_2 * cos(t_1)); elseif (y_46_re <= -2.2e-107) tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan(x_46_im, x_46_re))); elseif (y_46_re <= 3.2e+65) tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos(fma(t_0, y_46_im, t_1))); elseif (y_46_re <= 7.5e+233) tmp = Float64(t_2 * abs(cos(fma(y_46_im, log(hypot(x_46_im, x_46_re)), t_1)))); else tmp = Float64(cos((cbrt(fma(y_46_im, t_0, t_1)) ^ 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_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(y$46$re * N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -1.3], N[(t$95$2 * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -2.2e-107], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 3.2e+65], 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[(t$95$0 * y$46$im + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 7.5e+233], N[(t$95$2 * N[Abs[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[Power[N[Power[N[(y$46$im * t$95$0 + t$95$1), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $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}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{if}\;y.re \leq -1.3:\\
\;\;\;\;t_2 \cdot \cos t_1\\
\mathbf{elif}\;y.re \leq -2.2 \cdot 10^{-107}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\mathbf{elif}\;y.re \leq 3.2 \cdot 10^{+65}:\\
\;\;\;\;e^{\mathsf{fma}\left(t_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, t_1\right)\right)\\
\mathbf{elif}\;y.re \leq 7.5 \cdot 10^{+233}:\\
\;\;\;\;t_2 \cdot \left|\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right), t_1\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\cos \left({\left(\sqrt[3]{\mathsf{fma}\left(y.im, t_0, t_1\right)}\right)}^{3}\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.re < -1.30000000000000004Initial program 53.0%
Taylor expanded in y.im around 0 86.4%
if -1.30000000000000004 < y.re < -2.20000000000000012e-107Initial program 36.0%
exp-diff36.0%
exp-to-pow36.0%
hypot-def36.0%
*-commutative36.0%
exp-prod36.0%
fma-def36.0%
hypot-def80.0%
*-commutative80.0%
Simplified80.0%
add-cube-cbrt80.0%
pow380.0%
fma-udef80.0%
*-commutative80.0%
*-commutative80.0%
fma-def80.0%
Applied egg-rr80.0%
Taylor expanded in y.im around inf 95.1%
if -2.20000000000000012e-107 < y.re < 3.20000000000000007e65Initial program 35.9%
fma-neg35.9%
hypot-def35.9%
distribute-rgt-neg-out35.9%
fma-def35.9%
hypot-def81.1%
*-commutative81.1%
Simplified81.1%
if 3.20000000000000007e65 < y.re < 7.4999999999999997e233Initial program 44.1%
fma-def44.1%
hypot-udef64.8%
*-commutative64.8%
add-sqr-sqrt47.1%
sqrt-unprod88.3%
pow288.3%
fma-udef88.3%
*-commutative88.3%
*-commutative88.3%
fma-def88.3%
Applied egg-rr88.3%
unpow288.3%
rem-sqrt-square88.3%
hypot-def47.1%
unpow247.1%
unpow247.1%
+-commutative47.1%
*-commutative47.1%
fma-def47.1%
fma-def47.1%
unpow247.1%
unpow247.1%
hypot-def88.3%
Simplified88.3%
if 7.4999999999999997e233 < y.re Initial program 36.8%
exp-diff26.3%
exp-to-pow26.3%
hypot-def26.3%
*-commutative26.3%
exp-prod26.3%
fma-def26.3%
hypot-def47.4%
*-commutative47.4%
Simplified47.4%
Taylor expanded in y.im around 0 57.9%
unpow257.9%
unpow257.9%
hypot-def57.9%
Simplified57.9%
add-cube-cbrt73.7%
pow378.9%
fma-udef73.7%
*-commutative73.7%
*-commutative73.7%
fma-def78.9%
Applied egg-rr94.7%
Final simplification85.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im))))
(if (<= x.im -5e+100)
(*
(exp (- (* y.re (log (- x.im))) (* (atan2 x.im x.re) y.im)))
(cos (pow (cbrt (* y.im (log (hypot x.im x.re)))) 3.0)))
(*
(exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
(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 tmp;
if (x_46_im <= -5e+100) {
tmp = exp(((y_46_re * log(-x_46_im)) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(pow(cbrt((y_46_im * log(hypot(x_46_im, x_46_re)))), 3.0));
} else {
tmp = exp(fma(t_0, y_46_re, (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))));
}
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 (x_46_im <= -5e+100) tmp = Float64(exp(Float64(Float64(y_46_re * log(Float64(-x_46_im))) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos((cbrt(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) ^ 3.0))); else tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * 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]}, If[LessEqual[x$46$im, -5e+100], N[(N[Exp[N[(N[(y$46$re * N[Log[(-x$46$im)], $MachinePrecision]), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[Power[N[Power[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $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[(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)\\
\mathbf{if}\;x.im \leq -5 \cdot 10^{+100}:\\
\;\;\;\;e^{y.re \cdot \log \left(-x.im\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}\right)}^{3}\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(\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 < -4.9999999999999999e100Initial program 13.6%
Taylor expanded in x.im around -inf 13.6%
mul-1-neg13.6%
Simplified13.6%
Taylor expanded in y.re around 0 13.6%
unpow213.6%
unpow213.6%
hypot-def81.8%
Simplified81.8%
add-cube-cbrt90.9%
pow393.2%
Applied egg-rr93.2%
if -4.9999999999999999e100 < x.im Initial program 47.3%
fma-neg47.3%
hypot-def47.3%
distribute-rgt-neg-out47.3%
fma-def47.3%
hypot-def79.6%
*-commutative79.6%
Simplified79.6%
Final simplification82.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* y.re (atan2 x.im x.re))))
(t_1 (pow (hypot x.im x.re) y.re)))
(if (<= y.re -1.75)
(* t_0 t_1)
(if (<= y.re 340000.0)
(/ (pow (hypot x.re x.im) y.re) (pow (exp y.im) (atan2 x.im x.re)))
(if (<= y.re 1.3e+56)
(* t_0 (exp (- (* y.re (log (- x.im))) (* (atan2 x.im x.re) y.im))))
t_1)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = cos((y_46_re * atan2(x_46_im, x_46_re)));
double t_1 = pow(hypot(x_46_im, x_46_re), y_46_re);
double tmp;
if (y_46_re <= -1.75) {
tmp = t_0 * t_1;
} else if (y_46_re <= 340000.0) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / pow(exp(y_46_im), atan2(x_46_im, x_46_re));
} else if (y_46_re <= 1.3e+56) {
tmp = t_0 * exp(((y_46_re * log(-x_46_im)) - (atan2(x_46_im, x_46_re) * y_46_im)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
double t_1 = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
double tmp;
if (y_46_re <= -1.75) {
tmp = t_0 * t_1;
} else if (y_46_re <= 340000.0) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / Math.pow(Math.exp(y_46_im), Math.atan2(x_46_im, x_46_re));
} else if (y_46_re <= 1.3e+56) {
tmp = t_0 * Math.exp(((y_46_re * Math.log(-x_46_im)) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) t_1 = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) tmp = 0 if y_46_re <= -1.75: tmp = t_0 * t_1 elif y_46_re <= 340000.0: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / math.pow(math.exp(y_46_im), math.atan2(x_46_im, x_46_re)) elif y_46_re <= 1.3e+56: tmp = t_0 * math.exp(((y_46_re * math.log(-x_46_im)) - (math.atan2(x_46_im, x_46_re) * y_46_im))) else: tmp = t_1 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(y_46_re * atan(x_46_im, x_46_re))) t_1 = hypot(x_46_im, x_46_re) ^ y_46_re tmp = 0.0 if (y_46_re <= -1.75) tmp = Float64(t_0 * t_1); elseif (y_46_re <= 340000.0) tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan(x_46_im, x_46_re))); elseif (y_46_re <= 1.3e+56) tmp = Float64(t_0 * exp(Float64(Float64(y_46_re * log(Float64(-x_46_im))) - Float64(atan(x_46_im, x_46_re) * y_46_im)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos((y_46_re * atan2(x_46_im, x_46_re))); t_1 = hypot(x_46_im, x_46_re) ^ y_46_re; tmp = 0.0; if (y_46_re <= -1.75) tmp = t_0 * t_1; elseif (y_46_re <= 340000.0) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan2(x_46_im, x_46_re)); elseif (y_46_re <= 1.3e+56) tmp = t_0 * exp(((y_46_re * log(-x_46_im)) - (atan2(x_46_im, x_46_re) * y_46_im))); else tmp = t_1; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[y$46$re, -1.75], N[(t$95$0 * t$95$1), $MachinePrecision], If[LessEqual[y$46$re, 340000.0], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.3e+56], N[(t$95$0 * N[Exp[N[(N[(y$46$re * N[Log[(-x$46$im)], $MachinePrecision]), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
t_1 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.75:\\
\;\;\;\;t_0 \cdot t_1\\
\mathbf{elif}\;y.re \leq 340000:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\mathbf{elif}\;y.re \leq 1.3 \cdot 10^{+56}:\\
\;\;\;\;t_0 \cdot e^{y.re \cdot \log \left(-x.im\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y.re < -1.75Initial program 53.0%
exp-diff43.9%
exp-to-pow43.9%
hypot-def43.9%
*-commutative43.9%
exp-prod43.9%
fma-def43.9%
hypot-def69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in y.im around 0 75.9%
unpow275.9%
unpow275.9%
hypot-def75.9%
Simplified75.9%
Taylor expanded in y.im around 0 80.5%
unpow280.5%
unpow280.5%
hypot-def80.5%
Simplified80.5%
if -1.75 < y.re < 3.4e5Initial program 38.2%
exp-diff38.1%
exp-to-pow38.1%
hypot-def38.1%
*-commutative38.1%
exp-prod38.0%
fma-def38.0%
hypot-def81.8%
*-commutative81.8%
Simplified81.8%
add-cube-cbrt80.3%
pow380.4%
fma-udef80.4%
*-commutative80.4%
*-commutative80.4%
fma-def80.4%
Applied egg-rr80.4%
Taylor expanded in y.im around inf 84.2%
if 3.4e5 < y.re < 1.30000000000000005e56Initial program 0.0%
Taylor expanded in x.im around -inf 0.0%
mul-1-neg0.0%
Simplified0.0%
Taylor expanded in y.im around 0 71.4%
if 1.30000000000000005e56 < y.re Initial program 40.7%
exp-diff33.3%
exp-to-pow33.3%
hypot-def33.3%
*-commutative33.3%
exp-prod33.3%
fma-def33.3%
hypot-def53.7%
*-commutative53.7%
Simplified53.7%
Taylor expanded in y.im around 0 57.5%
unpow257.5%
unpow257.5%
hypot-def57.5%
Simplified57.5%
Taylor expanded in y.im around 0 61.2%
unpow261.2%
unpow261.2%
hypot-def61.2%
Simplified61.2%
Taylor expanded in y.re around 0 74.2%
Final simplification80.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -11.0) (* (cos (* y.re (atan2 x.im x.re))) (pow (hypot x.im x.re) y.re)) (/ (pow (hypot x.re x.im) y.re) (pow (exp y.im) (atan2 x.im x.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 <= -11.0) {
tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * pow(hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / pow(exp(y_46_im), atan2(x_46_im, x_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 <= -11.0) {
tmp = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re))) * Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / Math.pow(Math.exp(y_46_im), Math.atan2(x_46_im, x_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if y_46_re <= -11.0: tmp = math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) * math.pow(math.hypot(x_46_im, x_46_re), y_46_re) else: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / math.pow(math.exp(y_46_im), math.atan2(x_46_im, x_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 <= -11.0) tmp = Float64(cos(Float64(y_46_re * atan(x_46_im, x_46_re))) * (hypot(x_46_im, x_46_re) ^ y_46_re)); else tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan(x_46_im, x_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 <= -11.0) tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * (hypot(x_46_im, x_46_re) ^ y_46_re); else tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan2(x_46_im, x_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, -11.0], N[(N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -11:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if y.re < -11Initial program 53.0%
exp-diff43.9%
exp-to-pow43.9%
hypot-def43.9%
*-commutative43.9%
exp-prod43.9%
fma-def43.9%
hypot-def69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in y.im around 0 75.9%
unpow275.9%
unpow275.9%
hypot-def75.9%
Simplified75.9%
Taylor expanded in y.im around 0 80.5%
unpow280.5%
unpow280.5%
hypot-def80.5%
Simplified80.5%
if -11 < y.re Initial program 37.5%
exp-diff35.4%
exp-to-pow35.4%
hypot-def35.4%
*-commutative35.4%
exp-prod35.3%
fma-def35.3%
hypot-def71.3%
*-commutative71.3%
Simplified71.3%
add-cube-cbrt73.0%
pow374.1%
fma-udef73.5%
*-commutative73.5%
*-commutative73.5%
fma-def74.1%
Applied egg-rr74.1%
Taylor expanded in y.im around inf 76.7%
Final simplification77.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (let* ((t_0 (pow (hypot x.im x.re) y.re))) (if (<= y.im 1e+84) t_0 (* (cos (* y.re (atan2 x.im x.re))) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = pow(hypot(x_46_im, x_46_re), y_46_re);
double tmp;
if (y_46_im <= 1e+84) {
tmp = t_0;
} else {
tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * t_0;
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
double tmp;
if (y_46_im <= 1e+84) {
tmp = t_0;
} else {
tmp = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re))) * t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) tmp = 0 if y_46_im <= 1e+84: tmp = t_0 else: tmp = math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) * t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = hypot(x_46_im, x_46_re) ^ y_46_re tmp = 0.0 if (y_46_im <= 1e+84) tmp = t_0; else tmp = Float64(cos(Float64(y_46_re * atan(x_46_im, x_46_re))) * t_0); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = hypot(x_46_im, x_46_re) ^ y_46_re; tmp = 0.0; if (y_46_im <= 1e+84) tmp = t_0; else tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[y$46$im, 1e+84], t$95$0, N[(N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;y.im \leq 10^{+84}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot t_0\\
\end{array}
\end{array}
if y.im < 1.00000000000000006e84Initial program 41.8%
exp-diff39.4%
exp-to-pow39.4%
hypot-def39.4%
*-commutative39.4%
exp-prod39.3%
fma-def39.3%
hypot-def76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in y.im around 0 52.3%
unpow252.3%
unpow252.3%
hypot-def63.6%
Simplified63.6%
Taylor expanded in y.im around 0 53.2%
unpow253.2%
unpow253.2%
hypot-def65.0%
Simplified65.0%
Taylor expanded in y.re around 0 69.4%
if 1.00000000000000006e84 < y.im Initial program 40.1%
exp-diff30.1%
exp-to-pow30.1%
hypot-def30.1%
*-commutative30.1%
exp-prod30.1%
fma-def30.1%
hypot-def48.5%
*-commutative48.5%
Simplified48.5%
Taylor expanded in y.im around 0 37.0%
unpow237.0%
unpow237.0%
hypot-def29.9%
Simplified29.9%
Taylor expanded in y.im around 0 41.0%
unpow241.0%
unpow241.0%
hypot-def33.4%
Simplified33.4%
Final simplification62.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 41.5%
exp-diff37.6%
exp-to-pow37.6%
hypot-def37.6%
*-commutative37.6%
exp-prod37.5%
fma-def37.5%
hypot-def70.9%
*-commutative70.9%
Simplified70.9%
Taylor expanded in y.im around 0 49.3%
unpow249.3%
unpow249.3%
hypot-def57.0%
Simplified57.0%
Taylor expanded in y.im around 0 50.8%
unpow250.8%
unpow250.8%
hypot-def58.8%
Simplified58.8%
Taylor expanded in y.re around 0 60.0%
Final simplification60.0%
herbie shell --seed 2023318
(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)))))