
(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 6 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 (- (* t_0 y.re) (* y.im (atan2 x.im x.re))))))
(if (<= y.im 2e-120)
(* t_1 (cos (* y.im (log (hypot x.im x.re)))))
(*
t_1
(cos (pow (cbrt (fma y.im t_0 (* y.re (atan2 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 = log(hypot(x_46_re, x_46_im));
double t_1 = exp(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
double tmp;
if (y_46_im <= 2e-120) {
tmp = t_1 * cos((y_46_im * log(hypot(x_46_im, x_46_re))));
} else {
tmp = t_1 * cos(pow(cbrt(fma(y_46_im, t_0, (y_46_re * atan2(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 = log(hypot(x_46_re, x_46_im)) t_1 = exp(Float64(Float64(t_0 * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) tmp = 0.0 if (y_46_im <= 2e-120) tmp = Float64(t_1 * cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))); else tmp = Float64(t_1 * cos((cbrt(fma(y_46_im, t_0, Float64(y_46_re * atan(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[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$im, 2e-120], N[(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]), $MachinePrecision], N[(t$95$1 * N[Cos[N[Power[N[Power[N[(y$46$im * t$95$0 + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $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^{t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;y.im \leq 2 \cdot 10^{-120}:\\
\;\;\;\;t_1 \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(y.im, t_0, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\right)}^{3}\right)\\
\end{array}
\end{array}
if y.im < 1.99999999999999996e-120Initial program 45.7%
Simplified85.4%
add-cube-cbrt80.7%
pow381.4%
fma-udef81.4%
*-commutative81.4%
*-commutative81.4%
fma-def81.4%
Applied egg-rr81.4%
Taylor expanded in y.re around 0 46.9%
pow-base-146.9%
*-lft-identity46.9%
*-commutative46.9%
+-commutative46.9%
unpow246.9%
unpow246.9%
hypot-def87.2%
hypot-def46.9%
unpow246.9%
unpow246.9%
+-commutative46.9%
unpow246.9%
unpow246.9%
hypot-def87.2%
Simplified87.2%
if 1.99999999999999996e-120 < y.im Initial program 43.9%
Simplified79.8%
add-cube-cbrt87.7%
pow385.4%
fma-udef85.4%
*-commutative85.4%
*-commutative85.4%
fma-def85.4%
Applied egg-rr85.4%
Final simplification86.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (exp (- (* t_0 y.re) (* y.im (atan2 x.im x.re))))))
(if (<= x.im 1.5e-253)
(* t_1 (cos (pow (cbrt (* y.im (log (hypot x.im x.re)))) 3.0)))
(* 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(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
double tmp;
if (x_46_im <= 1.5e-253) {
tmp = t_1 * cos(pow(cbrt((y_46_im * log(hypot(x_46_im, x_46_re)))), 3.0));
} 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(Float64(Float64(t_0 * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) tmp = 0.0 if (x_46_im <= 1.5e-253) tmp = Float64(t_1 * cos((cbrt(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) ^ 3.0))); 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[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, 1.5e-253], N[(t$95$1 * 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[(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^{t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;x.im \leq 1.5 \cdot 10^{-253}:\\
\;\;\;\;t_1 \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}:\\
\;\;\;\;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.5000000000000001e-253Initial program 43.1%
Simplified81.9%
add-cube-cbrt82.1%
pow382.9%
fma-udef82.9%
*-commutative82.9%
*-commutative82.9%
fma-def82.9%
Applied egg-rr82.9%
Taylor expanded in y.re around 0 20.6%
unpow1/345.5%
*-commutative45.5%
+-commutative45.5%
unpow245.5%
unpow245.5%
hypot-def85.7%
hypot-def45.5%
unpow245.5%
unpow245.5%
+-commutative45.5%
unpow245.5%
unpow245.5%
hypot-def85.7%
Simplified85.7%
if 1.5000000000000001e-253 < x.im Initial program 47.6%
Simplified85.5%
Final simplification85.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (log (hypot x.im x.re))))
(t_1
(exp
(- (* (log (hypot x.re x.im)) y.re) (* y.im (atan2 x.im x.re))))))
(if (<= x.im 1e-250) (* t_1 (cos (pow (cbrt t_0) 3.0))) (* t_1 (cos t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * log(hypot(x_46_im, x_46_re));
double t_1 = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
double tmp;
if (x_46_im <= 1e-250) {
tmp = t_1 * cos(pow(cbrt(t_0), 3.0));
} else {
tmp = t_1 * cos(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 = y_46_im * Math.log(Math.hypot(x_46_im, x_46_re));
double t_1 = Math.exp(((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * Math.atan2(x_46_im, x_46_re))));
double tmp;
if (x_46_im <= 1e-250) {
tmp = t_1 * Math.cos(Math.pow(Math.cbrt(t_0), 3.0));
} else {
tmp = t_1 * Math.cos(t_0);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * log(hypot(x_46_im, x_46_re))) t_1 = exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) tmp = 0.0 if (x_46_im <= 1e-250) tmp = Float64(t_1 * cos((cbrt(t_0) ^ 3.0))); else tmp = Float64(t_1 * cos(t_0)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, 1e-250], N[(t$95$1 * N[Cos[N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
t_1 := e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;x.im \leq 10^{-250}:\\
\;\;\;\;t_1 \cdot \cos \left({\left(\sqrt[3]{t_0}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \cos t_0\\
\end{array}
\end{array}
if x.im < 1.0000000000000001e-250Initial program 43.1%
Simplified81.9%
add-cube-cbrt82.1%
pow382.9%
fma-udef82.9%
*-commutative82.9%
*-commutative82.9%
fma-def82.9%
Applied egg-rr82.9%
Taylor expanded in y.re around 0 20.6%
unpow1/345.5%
*-commutative45.5%
+-commutative45.5%
unpow245.5%
unpow245.5%
hypot-def85.7%
hypot-def45.5%
unpow245.5%
unpow245.5%
+-commutative45.5%
unpow245.5%
unpow245.5%
hypot-def85.7%
Simplified85.7%
if 1.0000000000000001e-250 < x.im Initial program 47.6%
Simplified85.5%
add-cube-cbrt84.3%
pow382.7%
fma-udef82.7%
*-commutative82.7%
*-commutative82.7%
fma-def82.7%
Applied egg-rr82.7%
Taylor expanded in y.re around 0 46.7%
pow-base-146.7%
*-lft-identity46.7%
*-commutative46.7%
+-commutative46.7%
unpow246.7%
unpow246.7%
hypot-def85.0%
hypot-def46.7%
unpow246.7%
unpow246.7%
+-commutative46.7%
unpow246.7%
unpow246.7%
hypot-def85.0%
Simplified85.0%
Final simplification85.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (exp (- (* (log (hypot x.re x.im)) y.re) (* y.im (atan2 x.im x.re)))) (cos (* y.im (log (hypot x.im x.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re)))) * cos((y_46_im * log(hypot(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.exp(((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * Math.atan2(x_46_im, x_46_re)))) * Math.cos((y_46_im * Math.log(Math.hypot(x_46_im, x_46_re))));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp(((math.log(math.hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * math.atan2(x_46_im, x_46_re)))) * math.cos((y_46_im * math.log(math.hypot(x_46_im, x_46_re))))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) * cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re)))) * cos((y_46_im * log(hypot(x_46_im, x_46_re)))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)
\end{array}
Initial program 45.1%
Simplified83.5%
add-cube-cbrt83.1%
pow382.8%
fma-udef82.8%
*-commutative82.8%
*-commutative82.8%
fma-def82.8%
Applied egg-rr82.8%
Taylor expanded in y.re around 0 45.1%
pow-base-145.1%
*-lft-identity45.1%
*-commutative45.1%
+-commutative45.1%
unpow245.1%
unpow245.1%
hypot-def83.7%
hypot-def45.1%
unpow245.1%
unpow245.1%
+-commutative45.1%
unpow245.1%
unpow245.1%
hypot-def83.7%
Simplified83.7%
Final simplification83.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(exp
(- (* (log (hypot x.re x.im)) y.re) (* y.im (atan2 x.im x.re))))))
(if (<= x.re -2.6e-299) (* t_0 (cos (* y.im (log (/ -1.0 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 = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
double tmp;
if (x_46_re <= -2.6e-299) {
tmp = t_0 * cos((y_46_im * log((-1.0 / x_46_re))));
} else {
tmp = 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.exp(((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * Math.atan2(x_46_im, x_46_re))));
double tmp;
if (x_46_re <= -2.6e-299) {
tmp = t_0 * Math.cos((y_46_im * Math.log((-1.0 / x_46_re))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.exp(((math.log(math.hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * math.atan2(x_46_im, x_46_re)))) tmp = 0 if x_46_re <= -2.6e-299: tmp = t_0 * math.cos((y_46_im * math.log((-1.0 / x_46_re)))) else: tmp = t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) tmp = 0.0 if (x_46_re <= -2.6e-299) tmp = Float64(t_0 * cos(Float64(y_46_im * log(Float64(-1.0 / x_46_re))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re)))); tmp = 0.0; if (x_46_re <= -2.6e-299) tmp = t_0 * cos((y_46_im * log((-1.0 / x_46_re)))); else tmp = 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[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$re, -2.6e-299], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[N[(-1.0 / x$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;x.re \leq -2.6 \cdot 10^{-299}:\\
\;\;\;\;t_0 \cdot \cos \left(y.im \cdot \log \left(\frac{-1}{x.re}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x.re < -2.5999999999999999e-299Initial program 51.6%
Simplified85.6%
Taylor expanded in x.re around -inf 87.3%
Taylor expanded in y.re around 0 88.1%
mul-1-neg88.1%
*-commutative88.1%
cos-neg88.1%
Simplified88.1%
if -2.5999999999999999e-299 < x.re Initial program 38.8%
Simplified81.4%
add-cube-cbrt79.2%
pow382.4%
fma-udef82.4%
*-commutative82.4%
*-commutative82.4%
fma-def82.4%
Applied egg-rr82.4%
Taylor expanded in y.im around inf 75.8%
Final simplification81.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (- (* (log (hypot x.re x.im)) y.re) (* 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) {
return exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * 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.exp(((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * Math.atan2(x_46_im, x_46_re))));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp(((math.log(math.hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * math.atan2(x_46_im, x_46_re))))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re)))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}
\end{array}
Initial program 45.1%
Simplified83.5%
add-cube-cbrt83.1%
pow382.8%
fma-udef82.8%
*-commutative82.8%
*-commutative82.8%
fma-def82.8%
Applied egg-rr82.8%
Taylor expanded in y.im around inf 78.4%
Final simplification78.4%
herbie shell --seed 2023222
(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)))))