
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (cbrt (* y.im t_0)))
(t_2 (exp (fma t_0 y.re (* y.im (- (atan2 x.im x.re)))))))
(if (<= y.im -2.8e+156)
(* t_2 (cos (* t_1 (pow (pow (cbrt t_1) 2.0) 3.0))))
(if (<= y.im 1.05e-144)
(* t_2 (cos (pow (* (cbrt t_0) (cbrt y.im)) 3.0)))
(* t_2 (cos (pow (cbrt (* 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 = cbrt((y_46_im * t_0));
double t_2 = exp(fma(t_0, y_46_re, (y_46_im * -atan2(x_46_im, x_46_re))));
double tmp;
if (y_46_im <= -2.8e+156) {
tmp = t_2 * cos((t_1 * pow(pow(cbrt(t_1), 2.0), 3.0)));
} else if (y_46_im <= 1.05e-144) {
tmp = t_2 * cos(pow((cbrt(t_0) * cbrt(y_46_im)), 3.0));
} else {
tmp = t_2 * cos(pow(cbrt((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 = cbrt(Float64(y_46_im * t_0)) t_2 = exp(fma(t_0, y_46_re, Float64(y_46_im * Float64(-atan(x_46_im, x_46_re))))) tmp = 0.0 if (y_46_im <= -2.8e+156) tmp = Float64(t_2 * cos(Float64(t_1 * ((cbrt(t_1) ^ 2.0) ^ 3.0)))); elseif (y_46_im <= 1.05e-144) tmp = Float64(t_2 * cos((Float64(cbrt(t_0) * cbrt(y_46_im)) ^ 3.0))); else tmp = Float64(t_2 * cos((cbrt(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[Power[N[(y$46$im * t$95$0), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(t$95$0 * y$46$re + N[(y$46$im * (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$im, -2.8e+156], N[(t$95$2 * N[Cos[N[(t$95$1 * N[Power[N[Power[N[Power[t$95$1, 1/3], $MachinePrecision], 2.0], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 1.05e-144], N[(t$95$2 * N[Cos[N[Power[N[(N[Power[t$95$0, 1/3], $MachinePrecision] * N[Power[y$46$im, 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[Cos[N[Power[N[Power[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $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 := \sqrt[3]{y.im \cdot t\_0}\\
t_2 := e^{\mathsf{fma}\left(t\_0, y.re, y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\\
\mathbf{if}\;y.im \leq -2.8 \cdot 10^{+156}:\\
\;\;\;\;t\_2 \cdot \cos \left(t\_1 \cdot {\left({\left(\sqrt[3]{t\_1}\right)}^{2}\right)}^{3}\right)\\
\mathbf{elif}\;y.im \leq 1.05 \cdot 10^{-144}:\\
\;\;\;\;t\_2 \cdot \cos \left({\left(\sqrt[3]{t\_0} \cdot \sqrt[3]{y.im}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot \cos \left({\left(\sqrt[3]{y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)}^{3}\right)\\
\end{array}
\end{array}
if y.im < -2.79999999999999988e156Initial program 40.7%
fma-neg40.7%
hypot-define40.7%
distribute-rgt-neg-out40.7%
fma-define40.7%
hypot-define74.1%
*-commutative74.1%
Simplified74.1%
fma-undefine74.1%
hypot-define40.7%
*-commutative40.7%
add-cube-cbrt40.7%
pow344.4%
fma-define44.4%
hypot-define74.1%
Applied egg-rr74.1%
Taylor expanded in y.im around inf 44.4%
+-commutative44.4%
unpow244.4%
unpow244.4%
hypot-undefine74.1%
Simplified74.1%
add-cube-cbrt74.1%
unpow-prod-down78.4%
pow278.4%
pow374.7%
add-cube-cbrt85.9%
Applied egg-rr85.9%
if -2.79999999999999988e156 < y.im < 1.0500000000000001e-144Initial program 30.7%
fma-neg30.7%
hypot-define30.7%
distribute-rgt-neg-out30.7%
fma-define30.7%
hypot-define82.5%
*-commutative82.5%
Simplified82.5%
fma-undefine82.5%
hypot-define30.7%
*-commutative30.7%
add-cube-cbrt32.4%
pow332.4%
fma-define32.4%
hypot-define84.8%
Applied egg-rr84.8%
Taylor expanded in y.im around inf 33.5%
+-commutative33.5%
unpow233.5%
unpow233.5%
hypot-undefine90.0%
Simplified90.0%
*-commutative90.0%
cbrt-prod91.6%
Applied egg-rr91.6%
if 1.0500000000000001e-144 < y.im Initial program 38.4%
fma-neg38.4%
hypot-define38.4%
distribute-rgt-neg-out38.4%
fma-define38.4%
hypot-define81.6%
*-commutative81.6%
Simplified81.6%
fma-undefine81.6%
hypot-define38.4%
*-commutative38.4%
add-cube-cbrt36.2%
pow337.4%
fma-define37.4%
hypot-define82.7%
Applied egg-rr82.7%
Taylor expanded in y.im around 0 83.0%
Final simplification88.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (exp (fma t_0 y.re (* y.im (- (atan2 x.im x.re)))))))
(if (or (<= x.re -2e-91) (not (<= x.re 1e-257)))
(* t_1 (fabs (cos (* y.im (log (hypot x.im x.re))))))
(*
t_1
(cos (pow (cbrt (fma t_0 y.im (* 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(fma(t_0, y_46_re, (y_46_im * -atan2(x_46_im, x_46_re))));
double tmp;
if ((x_46_re <= -2e-91) || !(x_46_re <= 1e-257)) {
tmp = t_1 * fabs(cos((y_46_im * log(hypot(x_46_im, x_46_re)))));
} else {
tmp = t_1 * cos(pow(cbrt(fma(t_0, y_46_im, (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(fma(t_0, y_46_re, Float64(y_46_im * Float64(-atan(x_46_im, x_46_re))))) tmp = 0.0 if ((x_46_re <= -2e-91) || !(x_46_re <= 1e-257)) tmp = Float64(t_1 * abs(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))))); else tmp = Float64(t_1 * cos((cbrt(fma(t_0, y_46_im, 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[(t$95$0 * y$46$re + N[(y$46$im * (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[x$46$re, -2e-91], N[Not[LessEqual[x$46$re, 1e-257]], $MachinePrecision]], N[(t$95$1 * N[Abs[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[N[Power[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], 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^{\mathsf{fma}\left(t\_0, y.re, y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\\
\mathbf{if}\;x.re \leq -2 \cdot 10^{-91} \lor \neg \left(x.re \leq 10^{-257}\right):\\
\;\;\;\;t\_1 \cdot \left|\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(t\_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\right)}^{3}\right)\\
\end{array}
\end{array}
if x.re < -2.00000000000000004e-91 or 9.9999999999999998e-258 < x.re Initial program 34.8%
fma-neg34.8%
hypot-define34.8%
distribute-rgt-neg-out34.8%
fma-define34.8%
hypot-define80.7%
*-commutative80.7%
Simplified80.7%
fma-undefine80.7%
hypot-define34.8%
*-commutative34.8%
add-cube-cbrt33.9%
pow333.9%
fma-define33.9%
hypot-define79.3%
Applied egg-rr79.3%
Taylor expanded in y.im around inf 34.3%
+-commutative34.3%
unpow234.3%
unpow234.3%
hypot-undefine81.1%
Simplified81.1%
rem-square-sqrt67.4%
sqrt-unprod85.9%
pow285.9%
rem-cube-cbrt85.9%
Applied egg-rr85.9%
unpow285.9%
rem-sqrt-square85.9%
hypot-undefine36.2%
unpow236.2%
unpow236.2%
+-commutative36.2%
unpow236.2%
unpow236.2%
hypot-define85.9%
Simplified85.9%
if -2.00000000000000004e-91 < x.re < 9.9999999999999998e-258Initial program 33.3%
fma-neg33.3%
hypot-define33.3%
distribute-rgt-neg-out33.3%
fma-define33.3%
hypot-define83.3%
*-commutative83.3%
Simplified83.3%
fma-undefine83.3%
hypot-define33.3%
*-commutative33.3%
add-cube-cbrt36.7%
pow340.0%
fma-define40.0%
hypot-define95.0%
Applied egg-rr95.0%
Final simplification88.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (exp (fma t_0 y.re (* y.im (- (atan2 x.im x.re)))))))
(if (<= y.im 5e-145)
(* t_1 (cos (pow (pow (cbrt (cbrt (* y.im t_0))) 3.0) 3.0)))
(* t_1 (cos (pow (cbrt (* 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(fma(t_0, y_46_re, (y_46_im * -atan2(x_46_im, x_46_re))));
double tmp;
if (y_46_im <= 5e-145) {
tmp = t_1 * cos(pow(pow(cbrt(cbrt((y_46_im * t_0))), 3.0), 3.0));
} else {
tmp = t_1 * cos(pow(cbrt((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(fma(t_0, y_46_re, Float64(y_46_im * Float64(-atan(x_46_im, x_46_re))))) tmp = 0.0 if (y_46_im <= 5e-145) tmp = Float64(t_1 * cos(((cbrt(cbrt(Float64(y_46_im * t_0))) ^ 3.0) ^ 3.0))); else tmp = Float64(t_1 * cos((cbrt(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[(t$95$0 * y$46$re + N[(y$46$im * (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$im, 5e-145], N[(t$95$1 * N[Cos[N[Power[N[Power[N[Power[N[Power[N[(y$46$im * t$95$0), $MachinePrecision], 1/3], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[N[Power[N[Power[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $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^{\mathsf{fma}\left(t\_0, y.re, y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\\
\mathbf{if}\;y.im \leq 5 \cdot 10^{-145}:\\
\;\;\;\;t\_1 \cdot \cos \left({\left({\left(\sqrt[3]{\sqrt[3]{y.im \cdot t\_0}}\right)}^{3}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos \left({\left(\sqrt[3]{y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)}^{3}\right)\\
\end{array}
\end{array}
if y.im < 4.9999999999999998e-145Initial program 32.3%
fma-neg32.3%
hypot-define32.3%
distribute-rgt-neg-out32.3%
fma-define32.3%
hypot-define81.1%
*-commutative81.1%
Simplified81.1%
fma-undefine81.1%
hypot-define32.3%
*-commutative32.3%
add-cube-cbrt33.7%
pow334.3%
fma-define34.3%
hypot-define83.1%
Applied egg-rr83.1%
Taylor expanded in y.im around inf 35.3%
+-commutative35.3%
unpow235.3%
unpow235.3%
hypot-undefine87.4%
Simplified87.4%
add-cube-cbrt88.0%
pow388.1%
Applied egg-rr88.1%
if 4.9999999999999998e-145 < y.im Initial program 38.4%
fma-neg38.4%
hypot-define38.4%
distribute-rgt-neg-out38.4%
fma-define38.4%
hypot-define81.6%
*-commutative81.6%
Simplified81.6%
fma-undefine81.6%
hypot-define38.4%
*-commutative38.4%
add-cube-cbrt36.2%
pow337.4%
fma-define37.4%
hypot-define82.7%
Applied egg-rr82.7%
Taylor expanded in y.im around 0 83.0%
Final simplification86.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(exp
(fma (log (hypot x.re x.im)) y.re (* y.im (- (atan2 x.im x.re)))))))
(if (or (<= y.im -7.2e+96) (not (<= y.im 4e-146)))
(* t_0 (cos (pow (cbrt (* y.re (atan2 x.im x.re))) 3.0)))
(* t_0 (+ 1.0 (* -0.5 (pow (* y.im (log (hypot x.im x.re))) 2.0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (y_46_im * -atan2(x_46_im, x_46_re))));
double tmp;
if ((y_46_im <= -7.2e+96) || !(y_46_im <= 4e-146)) {
tmp = t_0 * cos(pow(cbrt((y_46_re * atan2(x_46_im, x_46_re))), 3.0));
} else {
tmp = t_0 * (1.0 + (-0.5 * pow((y_46_im * log(hypot(x_46_im, x_46_re))), 2.0)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(y_46_im * Float64(-atan(x_46_im, x_46_re))))) tmp = 0.0 if ((y_46_im <= -7.2e+96) || !(y_46_im <= 4e-146)) tmp = Float64(t_0 * cos((cbrt(Float64(y_46_re * atan(x_46_im, x_46_re))) ^ 3.0))); else tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * (Float64(y_46_im * log(hypot(x_46_im, x_46_re))) ^ 2.0)))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(y$46$im * (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[y$46$im, -7.2e+96], N[Not[LessEqual[y$46$im, 4e-146]], $MachinePrecision]], N[(t$95$0 * N[Cos[N[Power[N[Power[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[Power[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\\
\mathbf{if}\;y.im \leq -7.2 \cdot 10^{+96} \lor \neg \left(y.im \leq 4 \cdot 10^{-146}\right):\\
\;\;\;\;t\_0 \cdot \cos \left({\left(\sqrt[3]{y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 + -0.5 \cdot {\left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}^{2}\right)\\
\end{array}
\end{array}
if y.im < -7.20000000000000026e96 or 4.0000000000000001e-146 < y.im Initial program 38.2%
fma-neg38.2%
hypot-define38.2%
distribute-rgt-neg-out38.2%
fma-define38.2%
hypot-define78.3%
*-commutative78.3%
Simplified78.3%
fma-undefine78.3%
hypot-define38.2%
*-commutative38.2%
add-cube-cbrt39.0%
pow339.7%
fma-define39.7%
hypot-define80.5%
Applied egg-rr80.5%
Taylor expanded in y.im around 0 83.5%
if -7.20000000000000026e96 < y.im < 4.0000000000000001e-146Initial program 30.3%
fma-neg30.3%
hypot-define30.3%
distribute-rgt-neg-out30.3%
fma-define30.3%
hypot-define84.6%
*-commutative84.6%
Simplified84.6%
fma-undefine84.6%
hypot-define30.3%
*-commutative30.3%
add-cube-cbrt29.7%
pow330.6%
fma-define30.6%
hypot-define85.7%
Applied egg-rr85.7%
Taylor expanded in y.im around inf 31.9%
+-commutative31.9%
unpow231.9%
unpow231.9%
hypot-undefine91.6%
Simplified91.6%
Taylor expanded in y.im around 0 36.7%
unpow236.7%
+-commutative36.7%
unpow236.7%
unpow236.7%
hypot-undefine92.1%
unpow292.1%
swap-sqr92.1%
unpow292.1%
Simplified92.1%
Final simplification87.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (exp (fma (log (hypot x.re x.im)) y.re (* y.im (- (atan2 x.im x.re))))) (fabs (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(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (y_46_im * -atan2(x_46_im, x_46_re)))) * fabs(cos((y_46_im * log(hypot(x_46_im, x_46_re)))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(y_46_im * Float64(-atan(x_46_im, x_46_re))))) * abs(cos(Float64(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[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(y$46$im * (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Abs[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)\right)} \cdot \left|\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right|
\end{array}
Initial program 34.5%
fma-neg34.5%
hypot-define34.5%
distribute-rgt-neg-out34.5%
fma-define34.5%
hypot-define81.3%
*-commutative81.3%
Simplified81.3%
fma-undefine81.3%
hypot-define34.5%
*-commutative34.5%
add-cube-cbrt34.6%
pow335.4%
fma-define35.4%
hypot-define82.9%
Applied egg-rr82.9%
Taylor expanded in y.im around inf 34.8%
+-commutative34.8%
unpow234.8%
unpow234.8%
hypot-undefine82.7%
Simplified82.7%
rem-square-sqrt65.9%
sqrt-unprod83.6%
pow283.6%
rem-cube-cbrt83.6%
Applied egg-rr83.6%
unpow283.6%
rem-sqrt-square83.6%
hypot-undefine34.8%
unpow234.8%
unpow234.8%
+-commutative34.8%
unpow234.8%
unpow234.8%
hypot-define83.6%
Simplified83.6%
Final simplification83.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (fma (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(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (y_46_im * -atan2(x_46_im, x_46_re))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(y_46_im * Float64(-atan(x_46_im, x_46_re))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(y$46$im * (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)\right)}
\end{array}
Initial program 34.5%
fma-neg34.5%
hypot-define34.5%
distribute-rgt-neg-out34.5%
fma-define34.5%
hypot-define81.3%
*-commutative81.3%
Simplified81.3%
fma-undefine81.3%
hypot-define34.5%
*-commutative34.5%
add-cube-cbrt34.6%
pow335.4%
fma-define35.4%
hypot-define82.9%
Applied egg-rr82.9%
Taylor expanded in y.im around inf 34.8%
+-commutative34.8%
unpow234.8%
unpow234.8%
hypot-undefine82.7%
Simplified82.7%
Taylor expanded in y.im around 0 83.3%
Final simplification83.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))))
(if (or (<= x.im 5e-251) (and (not (<= x.im 6e-150)) (<= x.im 2.5e-77)))
(exp (- (* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im))))) t_0))
(exp (- (* y.re (log x.im)) 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 tmp;
if ((x_46_im <= 5e-251) || (!(x_46_im <= 6e-150) && (x_46_im <= 2.5e-77))) {
tmp = exp(((y_46_re * log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - t_0));
} else {
tmp = exp(((y_46_re * log(x_46_im)) - t_0));
}
return tmp;
}
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
real(8) :: tmp
t_0 = y_46im * atan2(x_46im, x_46re)
if ((x_46im <= 5d-251) .or. (.not. (x_46im <= 6d-150)) .and. (x_46im <= 2.5d-77)) then
tmp = exp(((y_46re * log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))) - t_0))
else
tmp = exp(((y_46re * log(x_46im)) - t_0))
end if
code = tmp
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 = y_46_im * Math.atan2(x_46_im, x_46_re);
double tmp;
if ((x_46_im <= 5e-251) || (!(x_46_im <= 6e-150) && (x_46_im <= 2.5e-77))) {
tmp = Math.exp(((y_46_re * Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - t_0));
} else {
tmp = Math.exp(((y_46_re * Math.log(x_46_im)) - 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) tmp = 0 if (x_46_im <= 5e-251) or (not (x_46_im <= 6e-150) and (x_46_im <= 2.5e-77)): tmp = math.exp(((y_46_re * math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - t_0)) else: tmp = math.exp(((y_46_re * math.log(x_46_im)) - 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)) tmp = 0.0 if ((x_46_im <= 5e-251) || (!(x_46_im <= 6e-150) && (x_46_im <= 2.5e-77))) tmp = exp(Float64(Float64(y_46_re * log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))) - t_0)); else tmp = exp(Float64(Float64(y_46_re * log(x_46_im)) - 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); tmp = 0.0; if ((x_46_im <= 5e-251) || (~((x_46_im <= 6e-150)) && (x_46_im <= 2.5e-77))) tmp = exp(((y_46_re * log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))) - t_0)); else tmp = exp(((y_46_re * log(x_46_im)) - 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]}, If[Or[LessEqual[x$46$im, 5e-251], And[N[Not[LessEqual[x$46$im, 6e-150]], $MachinePrecision], LessEqual[x$46$im, 2.5e-77]]], 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] - t$95$0), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq 5 \cdot 10^{-251} \lor \neg \left(x.im \leq 6 \cdot 10^{-150}\right) \land x.im \leq 2.5 \cdot 10^{-77}:\\
\;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.im - t\_0}\\
\end{array}
\end{array}
if x.im < 5.0000000000000003e-251 or 6.0000000000000003e-150 < x.im < 2.49999999999999982e-77Initial program 39.7%
Taylor expanded in y.im around 0 67.4%
Taylor expanded in y.re around 0 69.9%
if 5.0000000000000003e-251 < x.im < 6.0000000000000003e-150 or 2.49999999999999982e-77 < x.im Initial program 27.1%
Taylor expanded in y.im around 0 56.0%
Taylor expanded in x.re around 0 78.8%
Taylor expanded in y.re around 0 79.7%
Final simplification74.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (- (* y.re (log x.im)) (* 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(((y_46_re * log(x_46_im)) - (y_46_im * atan2(x_46_im, x_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
code = exp(((y_46re * log(x_46im)) - (y_46im * atan2(x_46im, x_46re))))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.exp(((y_46_re * Math.log(x_46_im)) - (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(((y_46_re * math.log(x_46_im)) - (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(y_46_re * log(x_46_im)) - 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(((y_46_re * log(x_46_im)) - (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[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}
\end{array}
Initial program 34.5%
Taylor expanded in y.im around 0 62.6%
Taylor expanded in x.re around 0 38.9%
Taylor expanded in y.re around 0 39.6%
Final simplification39.6%
herbie shell --seed 2024102
(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)))))