
(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 7 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
(*
(cos (* y.im (log (hypot x.im x.re))))
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im))))))
(if (<= y.re -1.3e-11)
t_0
(if (<= y.re 2.1e+18)
(/
(cos (* (log (hypot x.re x.im)) y.im))
(pow (exp y.im) (atan2 x.im x.re)))
(if (<= y.re 3e+182)
t_0
(* (pow (hypot x.re x.im) y.re) (cos (* 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 = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * 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.3e-11) {
tmp = t_0;
} else if (y_46_re <= 2.1e+18) {
tmp = cos((log(hypot(x_46_re, x_46_im)) * y_46_im)) / pow(exp(y_46_im), atan2(x_46_im, x_46_re));
} else if (y_46_re <= 3e+182) {
tmp = t_0;
} else {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) * cos((y_46_re * 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.cos((y_46_im * Math.log(Math.hypot(x_46_im, x_46_re)))) * Math.exp(((y_46_re * Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
double tmp;
if (y_46_re <= -1.3e-11) {
tmp = t_0;
} else if (y_46_re <= 2.1e+18) {
tmp = Math.cos((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_im)) / Math.pow(Math.exp(y_46_im), Math.atan2(x_46_im, x_46_re));
} else if (y_46_re <= 3e+182) {
tmp = t_0;
} else {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) * Math.cos((y_46_re * 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.cos((y_46_im * math.log(math.hypot(x_46_im, x_46_re)))) * math.exp(((y_46_re * math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (math.atan2(x_46_im, x_46_re) * y_46_im))) tmp = 0 if y_46_re <= -1.3e-11: tmp = t_0 elif y_46_re <= 2.1e+18: tmp = math.cos((math.log(math.hypot(x_46_re, x_46_im)) * y_46_im)) / math.pow(math.exp(y_46_im), math.atan2(x_46_im, x_46_re)) elif y_46_re <= 3e+182: tmp = t_0 else: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) * math.cos((y_46_re * 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 = Float64(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) * 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.3e-11) tmp = t_0; elseif (y_46_re <= 2.1e+18) tmp = Float64(cos(Float64(log(hypot(x_46_re, x_46_im)) * y_46_im)) / (exp(y_46_im) ^ atan(x_46_im, x_46_re))); elseif (y_46_re <= 3e+182) tmp = t_0; else tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) * cos(Float64(y_46_re * 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 = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * 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))); tmp = 0.0; if (y_46_re <= -1.3e-11) tmp = t_0; elseif (y_46_re <= 2.1e+18) tmp = cos((log(hypot(x_46_re, x_46_im)) * y_46_im)) / (exp(y_46_im) ^ atan2(x_46_im, x_46_re)); elseif (y_46_re <= 3e+182) tmp = t_0; else tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) * cos((y_46_re * 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[(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[(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]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.3e-11], t$95$0, If[LessEqual[y$46$re, 2.1e+18], N[(N[Cos[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $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, 3e+182], t$95$0, N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $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) \cdot 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 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 2.1 \cdot 10^{+18}:\\
\;\;\;\;\frac{\cos \left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.im\right)}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\mathbf{elif}\;y.re \leq 3 \cdot 10^{+182}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\end{array}
\end{array}
if y.re < -1.3e-11 or 2.1e18 < y.re < 3.0000000000000002e182Initial program 52.4%
Taylor expanded in y.re around 0 53.0%
unpow253.0%
unpow253.0%
hypot-undefine83.6%
Simplified83.6%
if -1.3e-11 < y.re < 2.1e18Initial program 44.6%
exp-diff43.8%
exp-to-pow43.8%
hypot-define43.8%
*-commutative43.8%
exp-prod43.4%
fma-define43.4%
hypot-define80.5%
*-commutative80.5%
Simplified80.5%
*-commutative80.5%
add-cube-cbrt80.5%
pow380.5%
Applied egg-rr80.5%
Taylor expanded in y.re around 0 44.6%
+-commutative44.6%
unpow244.6%
unpow244.6%
hypot-undefine82.3%
exp-prod81.8%
Simplified81.8%
if 3.0000000000000002e182 < y.re Initial program 38.1%
exp-diff28.6%
exp-to-pow28.6%
hypot-define28.6%
*-commutative28.6%
exp-prod28.6%
fma-define28.6%
hypot-define52.4%
*-commutative52.4%
Simplified52.4%
*-commutative52.4%
add-cube-cbrt47.6%
pow347.6%
Applied egg-rr47.6%
Taylor expanded in y.im around 0 81.0%
+-commutative81.0%
unpow281.0%
unpow281.0%
hypot-undefine81.0%
Simplified81.0%
Final simplification82.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im))))
(*
(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));
return 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))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) return 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
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]}, 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)\\
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}
Initial program 47.2%
cancel-sign-sub-inv47.2%
fma-define47.2%
hypot-define47.2%
distribute-lft-neg-in47.2%
distribute-rgt-neg-out47.2%
fma-define47.2%
hypot-define82.5%
*-commutative82.5%
Simplified82.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.re x.im) y.re))
(t_1 (cos (* y.im (log (hypot x.im x.re))))))
(if (<= y.re -5e-6)
(*
t_1
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im))))
(if (<= y.re 4.7e+95)
(/ 1.0 (/ (pow (exp y.im) (atan2 x.im x.re)) (* t_1 t_0)))
(* t_0 (cos (* 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 = pow(hypot(x_46_re, x_46_im), y_46_re);
double t_1 = cos((y_46_im * log(hypot(x_46_im, x_46_re))));
double tmp;
if (y_46_re <= -5e-6) {
tmp = t_1 * 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)));
} else if (y_46_re <= 4.7e+95) {
tmp = 1.0 / (pow(exp(y_46_im), atan2(x_46_im, x_46_re)) / (t_1 * t_0));
} else {
tmp = t_0 * cos((y_46_re * 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.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
double t_1 = Math.cos((y_46_im * Math.log(Math.hypot(x_46_im, x_46_re))));
double tmp;
if (y_46_re <= -5e-6) {
tmp = t_1 * Math.exp(((y_46_re * Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
} else if (y_46_re <= 4.7e+95) {
tmp = 1.0 / (Math.pow(Math.exp(y_46_im), Math.atan2(x_46_im, x_46_re)) / (t_1 * t_0));
} else {
tmp = t_0 * Math.cos((y_46_re * 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.pow(math.hypot(x_46_re, x_46_im), y_46_re) t_1 = math.cos((y_46_im * math.log(math.hypot(x_46_im, x_46_re)))) tmp = 0 if y_46_re <= -5e-6: tmp = t_1 * math.exp(((y_46_re * math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (math.atan2(x_46_im, x_46_re) * y_46_im))) elif y_46_re <= 4.7e+95: tmp = 1.0 / (math.pow(math.exp(y_46_im), math.atan2(x_46_im, x_46_re)) / (t_1 * t_0)) else: tmp = t_0 * math.cos((y_46_re * 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 = hypot(x_46_re, x_46_im) ^ y_46_re t_1 = cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) tmp = 0.0 if (y_46_re <= -5e-6) tmp = Float64(t_1 * 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)))); elseif (y_46_re <= 4.7e+95) tmp = Float64(1.0 / Float64((exp(y_46_im) ^ atan(x_46_im, x_46_re)) / Float64(t_1 * t_0))); else tmp = Float64(t_0 * cos(Float64(y_46_re * 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 = hypot(x_46_re, x_46_im) ^ y_46_re; t_1 = cos((y_46_im * log(hypot(x_46_im, x_46_re)))); tmp = 0.0; if (y_46_re <= -5e-6) tmp = t_1 * 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))); elseif (y_46_re <= 4.7e+95) tmp = 1.0 / ((exp(y_46_im) ^ atan2(x_46_im, x_46_re)) / (t_1 * t_0)); else tmp = t_0 * cos((y_46_re * 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[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -5e-6], N[(t$95$1 * 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]), $MachinePrecision], If[LessEqual[y$46$re, 4.7e+95], N[(1.0 / N[(N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision] / N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
t_1 := \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\
\mathbf{if}\;y.re \leq -5 \cdot 10^{-6}:\\
\;\;\;\;t\_1 \cdot 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{elif}\;y.re \leq 4.7 \cdot 10^{+95}:\\
\;\;\;\;\frac{1}{\frac{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}{t\_1 \cdot t\_0}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\end{array}
\end{array}
if y.re < -5.00000000000000041e-6Initial program 56.8%
Taylor expanded in y.re around 0 56.3%
unpow256.3%
unpow256.3%
hypot-undefine83.5%
Simplified83.5%
if -5.00000000000000041e-6 < y.re < 4.69999999999999972e95Initial program 42.9%
exp-diff42.2%
exp-to-pow42.2%
hypot-define42.2%
*-commutative42.2%
exp-prod41.8%
fma-define41.8%
hypot-define78.6%
*-commutative78.6%
Simplified78.6%
*-commutative78.6%
add-cube-cbrt80.0%
pow379.3%
Applied egg-rr79.3%
log1p-expm1-u79.3%
rem-cube-cbrt78.6%
Applied egg-rr78.6%
associate-*l/78.6%
clear-num78.6%
log1p-expm1-u78.6%
fma-undefine78.6%
rem-cbrt-cube26.3%
unpow1/326.3%
*-commutative26.3%
unpow1/326.3%
rem-cbrt-cube78.6%
fma-define78.6%
Applied egg-rr78.6%
Taylor expanded in y.re around 0 42.5%
unpow242.5%
unpow242.5%
hypot-undefine82.1%
Simplified82.1%
if 4.69999999999999972e95 < y.re Initial program 45.0%
exp-diff37.5%
exp-to-pow37.5%
hypot-define37.5%
*-commutative37.5%
exp-prod37.5%
fma-define37.5%
hypot-define57.5%
*-commutative57.5%
Simplified57.5%
*-commutative57.5%
add-cube-cbrt50.0%
pow347.5%
Applied egg-rr47.5%
Taylor expanded in y.im around 0 77.6%
+-commutative77.6%
unpow277.6%
unpow277.6%
hypot-undefine77.6%
Simplified77.6%
Final simplification81.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (or (<= y.re -2.9e+26) (not (<= y.re 8.2e+51)))
(* (pow (hypot x.re x.im) y.re) (cos (* y.re (atan2 x.im x.re))))
(/
(cos (* (log (hypot x.re x.im)) y.im))
(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 <= -2.9e+26) || !(y_46_re <= 8.2e+51)) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) * cos((y_46_re * atan2(x_46_im, x_46_re)));
} else {
tmp = cos((log(hypot(x_46_re, x_46_im)) * y_46_im)) / 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 <= -2.9e+26) || !(y_46_re <= 8.2e+51)) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) * Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
} else {
tmp = Math.cos((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_im)) / 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 <= -2.9e+26) or not (y_46_re <= 8.2e+51): tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) * math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) else: tmp = math.cos((math.log(math.hypot(x_46_re, x_46_im)) * y_46_im)) / 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 <= -2.9e+26) || !(y_46_re <= 8.2e+51)) tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) * cos(Float64(y_46_re * atan(x_46_im, x_46_re)))); else tmp = Float64(cos(Float64(log(hypot(x_46_re, x_46_im)) * y_46_im)) / (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 <= -2.9e+26) || ~((y_46_re <= 8.2e+51))) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) * cos((y_46_re * atan2(x_46_im, x_46_re))); else tmp = cos((log(hypot(x_46_re, x_46_im)) * y_46_im)) / (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[Or[LessEqual[y$46$re, -2.9e+26], N[Not[LessEqual[y$46$re, 8.2e+51]], $MachinePrecision]], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $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 -2.9 \cdot 10^{+26} \lor \neg \left(y.re \leq 8.2 \cdot 10^{+51}\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.im\right)}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if y.re < -2.9e26 or 8.20000000000000021e51 < y.re Initial program 50.5%
exp-diff44.1%
exp-to-pow44.1%
hypot-define44.1%
*-commutative44.1%
exp-prod43.2%
fma-define43.2%
hypot-define66.7%
*-commutative66.7%
Simplified66.7%
*-commutative66.7%
add-cube-cbrt67.6%
pow364.9%
Applied egg-rr64.9%
Taylor expanded in y.im around 0 79.4%
+-commutative79.4%
unpow279.4%
unpow279.4%
hypot-undefine79.4%
Simplified79.4%
if -2.9e26 < y.re < 8.20000000000000021e51Initial program 44.8%
exp-diff43.4%
exp-to-pow43.4%
hypot-define43.4%
*-commutative43.4%
exp-prod43.0%
fma-define43.0%
hypot-define79.1%
*-commutative79.1%
Simplified79.1%
*-commutative79.1%
add-cube-cbrt79.1%
pow379.1%
Applied egg-rr79.1%
Taylor expanded in y.re around 0 43.7%
+-commutative43.7%
unpow243.7%
unpow243.7%
hypot-undefine80.3%
exp-prod80.6%
Simplified80.6%
Final simplification80.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (or (<= y.im -49000000000.0) (not (<= y.im 7.5e-32)))
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im)))
(pow (hypot x.re x.im) 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_im <= -49000000000.0) || !(y_46_im <= 7.5e-32)) {
tmp = 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)));
} else {
tmp = pow(hypot(x_46_re, x_46_im), 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_im <= -49000000000.0) || !(y_46_im <= 7.5e-32)) {
tmp = Math.exp(((y_46_re * Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
} else {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_im <= -49000000000.0) or not (y_46_im <= 7.5e-32): tmp = math.exp(((y_46_re * math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - (math.atan2(x_46_im, x_46_re) * y_46_im))) else: tmp = math.pow(math.hypot(x_46_re, x_46_im), 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_im <= -49000000000.0) || !(y_46_im <= 7.5e-32)) tmp = 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))); else tmp = hypot(x_46_re, x_46_im) ^ 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_im <= -49000000000.0) || ~((y_46_im <= 7.5e-32))) tmp = 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))); else tmp = hypot(x_46_re, x_46_im) ^ y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -49000000000.0], N[Not[LessEqual[y$46$im, 7.5e-32]], $MachinePrecision]], 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], N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -49000000000 \lor \neg \left(y.im \leq 7.5 \cdot 10^{-32}\right):\\
\;\;\;\;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{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.im < -4.9e10 or 7.49999999999999953e-32 < y.im Initial program 39.8%
Taylor expanded in y.im around 0 60.2%
Taylor expanded in y.re around 0 58.7%
if -4.9e10 < y.im < 7.49999999999999953e-32Initial program 55.1%
exp-diff55.1%
exp-to-pow55.1%
hypot-define55.1%
*-commutative55.1%
exp-prod55.1%
fma-define55.1%
hypot-define93.8%
*-commutative93.8%
Simplified93.8%
*-commutative93.8%
add-cube-cbrt94.6%
pow393.0%
Applied egg-rr93.0%
Taylor expanded in y.im around 0 69.2%
+-commutative69.2%
unpow269.2%
unpow269.2%
hypot-undefine92.6%
Simplified92.6%
Taylor expanded in y.re around 0 93.2%
Final simplification75.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (pow (hypot x.re x.im) y.re) (cos (* 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) {
return pow(hypot(x_46_re, x_46_im), y_46_re) * cos((y_46_re * atan2(x_46_im, x_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_re, x_46_im), y_46_re) * Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow(math.hypot(x_46_re, x_46_im), y_46_re) * math.cos((y_46_re * math.atan2(x_46_im, x_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64((hypot(x_46_re, x_46_im) ^ y_46_re) * cos(Float64(y_46_re * atan(x_46_im, x_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) * cos((y_46_re * atan2(x_46_im, x_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\end{array}
Initial program 47.2%
exp-diff43.7%
exp-to-pow43.7%
hypot-define43.7%
*-commutative43.7%
exp-prod43.1%
fma-define43.1%
hypot-define73.7%
*-commutative73.7%
Simplified73.7%
*-commutative73.7%
add-cube-cbrt74.1%
pow372.9%
Applied egg-rr72.9%
Taylor expanded in y.im around 0 53.8%
+-commutative53.8%
unpow253.8%
unpow253.8%
hypot-undefine62.2%
Simplified62.2%
Final simplification62.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (pow (hypot x.re x.im) 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_re, x_46_im), 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_re, x_46_im), y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow(math.hypot(x_46_re, x_46_im), y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return hypot(x_46_re, x_46_im) ^ y_46_re end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = hypot(x_46_re, x_46_im) ^ y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}
\end{array}
Initial program 47.2%
exp-diff43.7%
exp-to-pow43.7%
hypot-define43.7%
*-commutative43.7%
exp-prod43.1%
fma-define43.1%
hypot-define73.7%
*-commutative73.7%
Simplified73.7%
*-commutative73.7%
add-cube-cbrt74.1%
pow372.9%
Applied egg-rr72.9%
Taylor expanded in y.im around 0 53.8%
+-commutative53.8%
unpow253.8%
unpow253.8%
hypot-undefine62.2%
Simplified62.2%
Taylor expanded in y.re around 0 61.3%
Final simplification61.3%
herbie shell --seed 2024111
(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)))))