
(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 (log (hypot x.re x.im)))
(t_1 (cbrt (fma t_0 y.im (* y.re (atan2 x.im x.re)))))
(t_2 (exp (- (* t_0 y.re) (* y.im (atan2 x.im x.re))))))
(if (<= y.im -2e-77)
(* t_2 (cos (* t_1 (pow t_1 2.0))))
(* t_2 (cbrt (pow (cos (* y.im (log (hypot x.im x.re)))) 3.0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(hypot(x_46_re, x_46_im));
double t_1 = cbrt(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re))));
double t_2 = exp(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
double tmp;
if (y_46_im <= -2e-77) {
tmp = t_2 * cos((t_1 * pow(t_1, 2.0)));
} else {
tmp = t_2 * cbrt(pow(cos((y_46_im * log(hypot(x_46_im, x_46_re)))), 3.0));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) t_1 = cbrt(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re)))) t_2 = 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-77) tmp = Float64(t_2 * cos(Float64(t_1 * (t_1 ^ 2.0)))); else tmp = Float64(t_2 * cbrt((cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) ^ 3.0))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$2 = 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-77], N[(t$95$2 * N[Cos[N[(t$95$1 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[Power[N[Power[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := \sqrt[3]{\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\
t_2 := e^{t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;y.im \leq -2 \cdot 10^{-77}:\\
\;\;\;\;t_2 \cdot \cos \left(t_1 \cdot {t_1}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \sqrt[3]{{\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}^{3}}\\
\end{array}
\end{array}
if y.im < -1.9999999999999999e-77Initial program 37.3%
Simplified77.7%
add-cube-cbrt82.7%
Applied egg-rr82.7%
if -1.9999999999999999e-77 < y.im Initial program 43.9%
Simplified86.2%
*-commutative86.2%
add-cube-cbrt82.9%
pow382.9%
Applied egg-rr82.9%
add-cbrt-cube82.9%
pow382.9%
unpow382.9%
add-cube-cbrt86.2%
Applied egg-rr86.2%
Taylor expanded in y.re around 0 46.1%
+-commutative46.1%
unpow246.1%
unpow246.1%
hypot-def88.4%
*-commutative88.4%
*-commutative88.4%
hypot-def46.1%
unpow246.1%
unpow246.1%
+-commutative46.1%
unpow246.1%
unpow246.1%
hypot-def88.4%
Simplified88.4%
Final simplification86.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 (<= y.re 6e+217)
(* t_0 (cbrt (pow (cos (* y.im (log (hypot x.im x.re)))) 3.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 = 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 (y_46_re <= 6e+217) {
tmp = t_0 * cbrt(pow(cos((y_46_im * log(hypot(x_46_im, x_46_re)))), 3.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.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 (y_46_re <= 6e+217) {
tmp = t_0 * Math.cbrt(Math.pow(Math.cos((y_46_im * Math.log(Math.hypot(x_46_im, x_46_re)))), 3.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 = 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 (y_46_re <= 6e+217) tmp = Float64(t_0 * cbrt((cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) ^ 3.0))); else tmp = Float64(t_0 * cos(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[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[y$46$re, 6e+217], N[(t$95$0 * N[Power[N[Power[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 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 := 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}\;y.re \leq 6 \cdot 10^{+217}:\\
\;\;\;\;t_0 \cdot \sqrt[3]{{\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}^{3}}\\
\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.99999999999999952e217Initial program 41.4%
Simplified83.1%
*-commutative83.1%
add-cube-cbrt82.2%
pow381.8%
Applied egg-rr81.8%
add-cbrt-cube81.8%
pow381.8%
unpow382.2%
add-cube-cbrt83.1%
Applied egg-rr83.1%
Taylor expanded in y.re around 0 42.7%
+-commutative42.7%
unpow242.7%
unpow242.7%
hypot-def85.6%
*-commutative85.6%
*-commutative85.6%
hypot-def42.7%
unpow242.7%
unpow242.7%
+-commutative42.7%
unpow242.7%
unpow242.7%
hypot-def85.6%
Simplified85.6%
if 5.99999999999999952e217 < y.re Initial program 47.6%
Simplified90.5%
Taylor expanded in y.im around 0 95.2%
Final simplification86.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (/ -1.0 x.im))) (t_1 (* y.im (atan2 x.im x.re))))
(if (<= x.im -2e+67)
(/
(cos (- (* y.re (atan2 x.im x.re)) (* y.im t_0)))
(exp (+ t_1 (* y.re t_0))))
(exp (- (* (log (hypot x.re x.im)) y.re) t_1)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log((-1.0 / x_46_im));
double t_1 = y_46_im * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= -2e+67) {
tmp = cos(((y_46_re * atan2(x_46_im, x_46_re)) - (y_46_im * t_0))) / exp((t_1 + (y_46_re * t_0)));
} else {
tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - 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.log((-1.0 / x_46_im));
double t_1 = y_46_im * Math.atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= -2e+67) {
tmp = Math.cos(((y_46_re * Math.atan2(x_46_im, x_46_re)) - (y_46_im * t_0))) / Math.exp((t_1 + (y_46_re * t_0)));
} else {
tmp = Math.exp(((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re) - t_1));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log((-1.0 / x_46_im)) t_1 = y_46_im * math.atan2(x_46_im, x_46_re) tmp = 0 if x_46_im <= -2e+67: tmp = math.cos(((y_46_re * math.atan2(x_46_im, x_46_re)) - (y_46_im * t_0))) / math.exp((t_1 + (y_46_re * t_0))) else: tmp = math.exp(((math.log(math.hypot(x_46_re, x_46_im)) * y_46_re) - t_1)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(Float64(-1.0 / x_46_im)) t_1 = Float64(y_46_im * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_im <= -2e+67) tmp = Float64(cos(Float64(Float64(y_46_re * atan(x_46_im, x_46_re)) - Float64(y_46_im * t_0))) / exp(Float64(t_1 + Float64(y_46_re * t_0)))); else tmp = exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - t_1)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log((-1.0 / x_46_im)); t_1 = y_46_im * atan2(x_46_im, x_46_re); tmp = 0.0; if (x_46_im <= -2e+67) tmp = cos(((y_46_re * atan2(x_46_im, x_46_re)) - (y_46_im * t_0))) / exp((t_1 + (y_46_re * t_0))); else tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - 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[Log[N[(-1.0 / x$46$im), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -2e+67], N[(N[Cos[N[(N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision] - N[(y$46$im * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(t$95$1 + N[(y$46$re * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{-1}{x.im}\right)\\
t_1 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq -2 \cdot 10^{+67}:\\
\;\;\;\;\frac{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} - y.im \cdot t_0\right)}{e^{t_1 + y.re \cdot t_0}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t_1}\\
\end{array}
\end{array}
if x.im < -1.99999999999999997e67Initial program 20.4%
exp-diff18.4%
exp-to-pow18.4%
hypot-def18.4%
*-commutative18.4%
exp-prod18.4%
fma-def18.4%
hypot-def73.3%
*-commutative73.3%
Simplified73.3%
Taylor expanded in x.im around -inf 73.3%
associate-/l*73.3%
+-commutative73.3%
mul-1-neg73.3%
unsub-neg73.3%
*-commutative73.3%
*-commutative73.3%
*-commutative73.3%
div-exp89.6%
*-commutative89.6%
mul-1-neg89.6%
distribute-rgt-neg-in89.6%
Simplified89.6%
if -1.99999999999999997e67 < x.im Initial program 47.1%
Simplified82.2%
Taylor expanded in y.im around 0 79.3%
Taylor expanded in y.re around 0 83.5%
Final simplification84.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))) (t_1 (log (/ -1.0 x.im))))
(if (<= x.im -4.9e+70)
(/ (cos (* y.im t_1)) (exp (+ t_0 (* y.re t_1))))
(exp (- (* (log (hypot x.re x.im)) y.re) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * atan2(x_46_im, x_46_re);
double t_1 = log((-1.0 / x_46_im));
double tmp;
if (x_46_im <= -4.9e+70) {
tmp = cos((y_46_im * t_1)) / exp((t_0 + (y_46_re * t_1)));
} else {
tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_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 = y_46_im * Math.atan2(x_46_im, x_46_re);
double t_1 = Math.log((-1.0 / x_46_im));
double tmp;
if (x_46_im <= -4.9e+70) {
tmp = Math.cos((y_46_im * t_1)) / Math.exp((t_0 + (y_46_re * t_1)));
} else {
tmp = Math.exp(((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = y_46_im * math.atan2(x_46_im, x_46_re) t_1 = math.log((-1.0 / x_46_im)) tmp = 0 if x_46_im <= -4.9e+70: tmp = math.cos((y_46_im * t_1)) / math.exp((t_0 + (y_46_re * t_1))) else: tmp = math.exp(((math.log(math.hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) t_1 = log(Float64(-1.0 / x_46_im)) tmp = 0.0 if (x_46_im <= -4.9e+70) tmp = Float64(cos(Float64(y_46_im * t_1)) / exp(Float64(t_0 + Float64(y_46_re * t_1)))); else tmp = exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_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 = y_46_im * atan2(x_46_im, x_46_re); t_1 = log((-1.0 / x_46_im)); tmp = 0.0; if (x_46_im <= -4.9e+70) tmp = cos((y_46_im * t_1)) / exp((t_0 + (y_46_re * t_1))); else tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_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[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[(-1.0 / x$46$im), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, -4.9e+70], N[(N[Cos[N[(y$46$im * t$95$1), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(t$95$0 + N[(y$46$re * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \log \left(\frac{-1}{x.im}\right)\\
\mathbf{if}\;x.im \leq -4.9 \cdot 10^{+70}:\\
\;\;\;\;\frac{\cos \left(y.im \cdot t_1\right)}{e^{t_0 + y.re \cdot t_1}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t_0}\\
\end{array}
\end{array}
if x.im < -4.90000000000000028e70Initial program 20.4%
exp-diff18.4%
exp-to-pow18.4%
hypot-def18.4%
*-commutative18.4%
exp-prod18.4%
fma-def18.4%
hypot-def73.3%
*-commutative73.3%
Simplified73.3%
Taylor expanded in x.im around -inf 73.3%
associate-/l*73.3%
+-commutative73.3%
mul-1-neg73.3%
unsub-neg73.3%
*-commutative73.3%
*-commutative73.3%
*-commutative73.3%
div-exp89.6%
*-commutative89.6%
mul-1-neg89.6%
distribute-rgt-neg-in89.6%
Simplified89.6%
Taylor expanded in y.re around 0 85.5%
cos-neg85.5%
*-commutative85.5%
Simplified85.5%
if -4.90000000000000028e70 < x.im Initial program 47.1%
Simplified82.2%
Taylor expanded in y.im around 0 79.3%
Taylor expanded in y.re around 0 83.5%
Final simplification83.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (let* ((t_0 (pow (hypot x.im x.re) y.re))) (if (<= x.im -5e-119) (* (cos (* y.re (atan2 x.im x.re))) t_0) 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 (x_46_im <= -5e-119) {
tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * t_0;
} 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.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
double tmp;
if (x_46_im <= -5e-119) {
tmp = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re))) * t_0;
} else {
tmp = 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 x_46_im <= -5e-119: tmp = math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) * t_0 else: tmp = 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 (x_46_im <= -5e-119) tmp = Float64(cos(Float64(y_46_re * atan(x_46_im, x_46_re))) * t_0); 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 = hypot(x_46_im, x_46_re) ^ y_46_re; tmp = 0.0; if (x_46_im <= -5e-119) tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * t_0; 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[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[x$46$im, -5e-119], N[(N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;x.im \leq -5 \cdot 10^{-119}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x.im < -4.99999999999999993e-119Initial program 33.7%
exp-diff29.2%
exp-to-pow29.2%
hypot-def29.2%
*-commutative29.2%
exp-prod29.2%
fma-def29.2%
hypot-def70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in y.im around 0 57.0%
*-commutative57.0%
unpow257.0%
unpow257.0%
hypot-def65.5%
Simplified65.5%
if -4.99999999999999993e-119 < x.im Initial program 46.3%
exp-diff41.6%
exp-to-pow41.6%
hypot-def41.6%
*-commutative41.6%
exp-prod41.4%
fma-def41.4%
hypot-def73.6%
*-commutative73.6%
Simplified73.6%
Taylor expanded in y.im around 0 56.7%
*-commutative56.7%
unpow256.7%
unpow256.7%
hypot-def62.1%
Simplified62.1%
Taylor expanded in y.re around 0 66.8%
Final simplification66.3%
(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 42.0%
Simplified83.7%
Taylor expanded in y.im around 0 79.6%
Taylor expanded in y.re around 0 81.9%
Final simplification81.9%
(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 42.0%
exp-diff37.3%
exp-to-pow37.3%
hypot-def37.3%
*-commutative37.3%
exp-prod37.2%
fma-def37.2%
hypot-def72.6%
*-commutative72.6%
Simplified72.6%
Taylor expanded in y.im around 0 56.8%
*-commutative56.8%
unpow256.8%
unpow256.8%
hypot-def63.3%
Simplified63.3%
Taylor expanded in y.re around 0 64.4%
Final simplification64.4%
herbie shell --seed 2023240
(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)))))