
(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 (exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im)))))
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, (atan2(x_46_im, x_46_re) * -y_46_im)));
}
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(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) 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[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)}
\end{array}
Initial program 40.4%
cancel-sign-sub-inv40.4%
fma-define40.4%
hypot-define40.4%
distribute-lft-neg-in40.4%
distribute-rgt-neg-out40.4%
fma-define40.4%
hypot-define80.3%
*-commutative80.3%
Simplified80.3%
Taylor expanded in y.re around inf 36.7%
+-commutative36.7%
associate-/l*35.6%
unpow235.6%
unpow235.6%
hypot-undefine72.7%
Simplified72.7%
Taylor expanded in y.im around 0 81.8%
Taylor expanded in y.re around 0 86.1%
Final simplification86.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* y.im (log (hypot x.im x.re))))))
(if (or (<= y.re -2.1e+25) (not (<= y.re 4.5e-15)))
(* (pow (hypot x.im x.re) y.re) t_0)
(* t_0 (exp (* (atan2 x.im x.re) (- y.im)))))))
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))));
double tmp;
if ((y_46_re <= -2.1e+25) || !(y_46_re <= 4.5e-15)) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * t_0;
} else {
tmp = t_0 * exp((atan2(x_46_im, x_46_re) * -y_46_im));
}
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))));
double tmp;
if ((y_46_re <= -2.1e+25) || !(y_46_re <= 4.5e-15)) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re) * t_0;
} else {
tmp = t_0 * Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
}
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)))) tmp = 0 if (y_46_re <= -2.1e+25) or not (y_46_re <= 4.5e-15): tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) * t_0 else: tmp = t_0 * math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) tmp = 0.0 if ((y_46_re <= -2.1e+25) || !(y_46_re <= 4.5e-15)) tmp = Float64((hypot(x_46_im, x_46_re) ^ y_46_re) * t_0); else tmp = Float64(t_0 * exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))); 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)))); tmp = 0.0; if ((y_46_re <= -2.1e+25) || ~((y_46_re <= 4.5e-15))) tmp = (hypot(x_46_im, x_46_re) ^ y_46_re) * t_0; else tmp = t_0 * exp((atan2(x_46_im, x_46_re) * -y_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[y$46$re, -2.1e+25], N[Not[LessEqual[y$46$re, 4.5e-15]], $MachinePrecision]], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $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)\\
\mathbf{if}\;y.re \leq -2.1 \cdot 10^{+25} \lor \neg \left(y.re \leq 4.5 \cdot 10^{-15}\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\end{array}
\end{array}
if y.re < -2.0999999999999999e25 or 4.4999999999999998e-15 < y.re Initial program 27.9%
exp-diff23.4%
exp-to-pow23.4%
hypot-define23.4%
*-commutative23.4%
exp-prod20.7%
fma-define20.7%
hypot-define58.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in y.im around 0 67.7%
unpow267.7%
unpow267.7%
hypot-undefine68.6%
Simplified68.6%
Taylor expanded in y.im around inf 31.6%
unpow231.6%
unpow231.6%
hypot-undefine82.9%
Simplified82.9%
if -2.0999999999999999e25 < y.re < 4.4999999999999998e-15Initial program 50.0%
cancel-sign-sub-inv50.0%
fma-define50.0%
hypot-define50.0%
distribute-lft-neg-in50.0%
distribute-rgt-neg-out50.0%
fma-define50.0%
hypot-define85.9%
*-commutative85.9%
Simplified85.9%
Taylor expanded in y.re around 0 85.1%
neg-mul-185.1%
*-commutative85.1%
distribute-rgt-neg-in85.1%
Simplified85.1%
Taylor expanded in y.im around inf 49.9%
unpow232.6%
unpow232.6%
hypot-undefine54.5%
Simplified85.1%
Final simplification84.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -2.1e+25) (not (<= y.re 5.8e-15))) (* (pow (hypot x.im x.re) y.re) (cos (* y.im (log (hypot x.im x.re))))) (* (exp (* (atan2 x.im x.re) (- y.im))) (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 tmp;
if ((y_46_re <= -2.1e+25) || !(y_46_re <= 5.8e-15)) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * cos((y_46_im * log(hypot(x_46_im, x_46_re))));
} else {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)) * 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 tmp;
if ((y_46_re <= -2.1e+25) || !(y_46_re <= 5.8e-15)) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re) * Math.cos((y_46_im * Math.log(Math.hypot(x_46_im, x_46_re))));
} else {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im)) * 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): tmp = 0 if (y_46_re <= -2.1e+25) or not (y_46_re <= 5.8e-15): tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) * math.cos((y_46_im * math.log(math.hypot(x_46_im, x_46_re)))) else: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) * 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) tmp = 0.0 if ((y_46_re <= -2.1e+25) || !(y_46_re <= 5.8e-15)) tmp = Float64((hypot(x_46_im, x_46_re) ^ y_46_re) * cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))); else tmp = Float64(exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))) * 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) tmp = 0.0; if ((y_46_re <= -2.1e+25) || ~((y_46_re <= 5.8e-15))) tmp = (hypot(x_46_im, x_46_re) ^ y_46_re) * cos((y_46_im * log(hypot(x_46_im, x_46_re)))); else tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)) * 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_] := If[Or[LessEqual[y$46$re, -2.1e+25], N[Not[LessEqual[y$46$re, 5.8e-15]], $MachinePrecision]], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $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}
\mathbf{if}\;y.re \leq -2.1 \cdot 10^{+25} \lor \neg \left(y.re \leq 5.8 \cdot 10^{-15}\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\end{array}
\end{array}
if y.re < -2.0999999999999999e25 or 5.80000000000000037e-15 < y.re Initial program 27.9%
exp-diff23.4%
exp-to-pow23.4%
hypot-define23.4%
*-commutative23.4%
exp-prod20.7%
fma-define20.7%
hypot-define58.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in y.im around 0 67.7%
unpow267.7%
unpow267.7%
hypot-undefine68.6%
Simplified68.6%
Taylor expanded in y.im around inf 31.6%
unpow231.6%
unpow231.6%
hypot-undefine82.9%
Simplified82.9%
if -2.0999999999999999e25 < y.re < 5.80000000000000037e-15Initial program 50.0%
cancel-sign-sub-inv50.0%
fma-define50.0%
hypot-define50.0%
distribute-lft-neg-in50.0%
distribute-rgt-neg-out50.0%
fma-define50.0%
hypot-define85.9%
*-commutative85.9%
Simplified85.9%
Taylor expanded in y.re around inf 42.8%
+-commutative42.8%
associate-/l*41.4%
unpow241.4%
unpow241.4%
hypot-undefine73.1%
Simplified73.1%
Taylor expanded in y.im around 0 85.8%
Taylor expanded in y.re around 0 85.0%
neg-mul-185.1%
*-commutative85.1%
distribute-rgt-neg-in85.1%
Simplified85.0%
Final simplification84.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* y.re (atan2 x.im x.re)))))
(if (or (<= y.re -3.9e+27) (not (<= y.re 5.8e-15)))
(* (pow (hypot x.im x.re) y.re) t_0)
(* (exp (* (atan2 x.im x.re) (- y.im))) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = cos((y_46_re * atan2(x_46_im, x_46_re)));
double tmp;
if ((y_46_re <= -3.9e+27) || !(y_46_re <= 5.8e-15)) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * t_0;
} else {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)) * 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.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
double tmp;
if ((y_46_re <= -3.9e+27) || !(y_46_re <= 5.8e-15)) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re) * t_0;
} else {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im)) * t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) tmp = 0 if (y_46_re <= -3.9e+27) or not (y_46_re <= 5.8e-15): tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) * t_0 else: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) * t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(y_46_re * atan(x_46_im, x_46_re))) tmp = 0.0 if ((y_46_re <= -3.9e+27) || !(y_46_re <= 5.8e-15)) tmp = Float64((hypot(x_46_im, x_46_re) ^ y_46_re) * t_0); else tmp = Float64(exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_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 = cos((y_46_re * atan2(x_46_im, x_46_re))); tmp = 0.0; if ((y_46_re <= -3.9e+27) || ~((y_46_re <= 5.8e-15))) tmp = (hypot(x_46_im, x_46_re) ^ y_46_re) * t_0; else tmp = exp((atan2(x_46_im, x_46_re) * -y_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[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[y$46$re, -3.9e+27], N[Not[LessEqual[y$46$re, 5.8e-15]], $MachinePrecision]], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{if}\;y.re \leq -3.9 \cdot 10^{+27} \lor \neg \left(y.re \leq 5.8 \cdot 10^{-15}\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \cdot t\_0\\
\end{array}
\end{array}
if y.re < -3.8999999999999999e27 or 5.80000000000000037e-15 < y.re Initial program 28.2%
exp-diff23.6%
exp-to-pow23.6%
hypot-define23.6%
*-commutative23.6%
exp-prod20.9%
fma-define20.9%
hypot-define59.1%
*-commutative59.1%
Simplified59.1%
Taylor expanded in y.im around 0 68.3%
unpow268.3%
unpow268.3%
hypot-undefine69.2%
Simplified69.2%
hypot-define26.4%
*-commutative26.4%
fma-define26.4%
add-exp-log14.6%
*-commutative14.6%
hypot-define36.6%
fma-define36.6%
Applied egg-rr36.6%
Taylor expanded in y.im around 0 71.9%
if -3.8999999999999999e27 < y.re < 5.80000000000000037e-15Initial program 49.7%
cancel-sign-sub-inv49.7%
fma-define49.7%
hypot-define49.7%
distribute-lft-neg-in49.7%
distribute-rgt-neg-out49.7%
fma-define49.7%
hypot-define85.3%
*-commutative85.3%
Simplified85.3%
Taylor expanded in y.re around inf 42.5%
+-commutative42.5%
associate-/l*41.1%
unpow241.1%
unpow241.1%
hypot-undefine72.6%
Simplified72.6%
Taylor expanded in y.im around 0 85.2%
Taylor expanded in y.re around 0 84.4%
neg-mul-184.5%
*-commutative84.5%
distribute-rgt-neg-in84.5%
Simplified84.4%
Final simplification79.1%
(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 -1e-308)
(* t_0 (cos (* y.im (log (/ -1.0 x.im)))))
(* t_0 (cos (* y.im (log x.im)))))))
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 <= -1e-308) {
tmp = t_0 * cos((y_46_im * log((-1.0 / x_46_im))));
} else {
tmp = t_0 * cos((y_46_im * log(x_46_im)));
}
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 <= -1e-308) {
tmp = t_0 * Math.cos((y_46_im * Math.log((-1.0 / x_46_im))));
} else {
tmp = t_0 * Math.cos((y_46_im * Math.log(x_46_im)));
}
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 <= -1e-308: tmp = t_0 * math.cos((y_46_im * math.log((-1.0 / x_46_im)))) else: tmp = t_0 * math.cos((y_46_im * math.log(x_46_im))) 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 <= -1e-308) tmp = Float64(t_0 * cos(Float64(y_46_im * log(Float64(-1.0 / x_46_im))))); else tmp = Float64(t_0 * cos(Float64(y_46_im * log(x_46_im)))); 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 <= -1e-308) tmp = t_0 * cos((y_46_im * log((-1.0 / x_46_im)))); else tmp = t_0 * cos((y_46_im * log(x_46_im))); 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, -1e-308], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[N[(-1.0 / x$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\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 -1 \cdot 10^{-308}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log \left(\frac{-1}{x.im}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log x.im\right)\\
\end{array}
\end{array}
if x.im < -9.9999999999999991e-309Initial program 44.1%
exp-diff42.0%
exp-to-pow42.0%
hypot-define42.0%
*-commutative42.0%
exp-prod40.6%
fma-define40.6%
hypot-define73.4%
*-commutative73.4%
Simplified73.4%
Taylor expanded in y.im around 0 56.4%
unpow256.4%
unpow256.4%
hypot-undefine64.4%
Simplified64.4%
Taylor expanded in y.im around inf 37.4%
unpow237.4%
unpow237.4%
hypot-undefine68.5%
Simplified68.5%
Taylor expanded in x.im around -inf 71.4%
mul-1-neg71.4%
cos-neg71.4%
Simplified71.4%
if -9.9999999999999991e-309 < x.im Initial program 35.6%
exp-diff32.9%
exp-to-pow32.9%
hypot-define32.9%
*-commutative32.9%
exp-prod31.9%
fma-define31.9%
hypot-define72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in y.im around 0 45.7%
unpow245.7%
unpow245.7%
hypot-undefine55.5%
Simplified55.5%
Taylor expanded in y.im around inf 25.2%
unpow225.2%
unpow225.2%
hypot-undefine64.5%
Simplified64.5%
Taylor expanded in x.re around 0 64.7%
(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 3.3e-308)
(* t_0 (cos (* y.re (atan2 x.im x.re))))
(* t_0 (cos (* y.im (log x.im)))))))
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 <= 3.3e-308) {
tmp = t_0 * cos((y_46_re * atan2(x_46_im, x_46_re)));
} else {
tmp = t_0 * cos((y_46_im * log(x_46_im)));
}
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 <= 3.3e-308) {
tmp = t_0 * Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
} else {
tmp = t_0 * Math.cos((y_46_im * Math.log(x_46_im)));
}
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 <= 3.3e-308: tmp = t_0 * math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) else: tmp = t_0 * math.cos((y_46_im * math.log(x_46_im))) 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 <= 3.3e-308) tmp = Float64(t_0 * cos(Float64(y_46_re * atan(x_46_im, x_46_re)))); else tmp = Float64(t_0 * cos(Float64(y_46_im * log(x_46_im)))); 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 <= 3.3e-308) tmp = t_0 * cos((y_46_re * atan2(x_46_im, x_46_re))); else tmp = t_0 * cos((y_46_im * log(x_46_im))); 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, 3.3e-308], N[(t$95$0 * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\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 3.3 \cdot 10^{-308}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log x.im\right)\\
\end{array}
\end{array}
if x.im < 3.2999999999999998e-308Initial program 44.1%
exp-diff42.0%
exp-to-pow42.0%
hypot-define42.0%
*-commutative42.0%
exp-prod40.6%
fma-define40.6%
hypot-define73.4%
*-commutative73.4%
Simplified73.4%
Taylor expanded in y.im around 0 56.4%
unpow256.4%
unpow256.4%
hypot-undefine64.4%
Simplified64.4%
hypot-define36.1%
*-commutative36.1%
fma-define36.1%
add-exp-log23.4%
*-commutative23.4%
hypot-define37.4%
fma-define37.4%
Applied egg-rr37.4%
Taylor expanded in y.im around 0 65.7%
if 3.2999999999999998e-308 < x.im Initial program 35.6%
exp-diff32.9%
exp-to-pow32.9%
hypot-define32.9%
*-commutative32.9%
exp-prod31.9%
fma-define31.9%
hypot-define72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in y.im around 0 45.7%
unpow245.7%
unpow245.7%
hypot-undefine55.5%
Simplified55.5%
Taylor expanded in y.im around inf 25.2%
unpow225.2%
unpow225.2%
hypot-undefine64.5%
Simplified64.5%
Taylor expanded in x.re around 0 64.7%
(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 -1.1e-307)
(* t_0 (cos (* y.im (log x.re))))
(* t_0 (cos (* y.im (log x.im)))))))
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 <= -1.1e-307) {
tmp = t_0 * cos((y_46_im * log(x_46_re)));
} else {
tmp = t_0 * cos((y_46_im * log(x_46_im)));
}
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 <= -1.1e-307) {
tmp = t_0 * Math.cos((y_46_im * Math.log(x_46_re)));
} else {
tmp = t_0 * Math.cos((y_46_im * Math.log(x_46_im)));
}
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 <= -1.1e-307: tmp = t_0 * math.cos((y_46_im * math.log(x_46_re))) else: tmp = t_0 * math.cos((y_46_im * math.log(x_46_im))) 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 <= -1.1e-307) tmp = Float64(t_0 * cos(Float64(y_46_im * log(x_46_re)))); else tmp = Float64(t_0 * cos(Float64(y_46_im * log(x_46_im)))); 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 <= -1.1e-307) tmp = t_0 * cos((y_46_im * log(x_46_re))); else tmp = t_0 * cos((y_46_im * log(x_46_im))); 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, -1.1e-307], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\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 -1.1 \cdot 10^{-307}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log x.re\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log x.im\right)\\
\end{array}
\end{array}
if x.im < -1.1e-307Initial program 44.4%
exp-diff42.3%
exp-to-pow42.3%
hypot-define42.3%
*-commutative42.3%
exp-prod40.8%
fma-define40.8%
hypot-define73.9%
*-commutative73.9%
Simplified73.9%
Taylor expanded in y.im around 0 56.8%
unpow256.8%
unpow256.8%
hypot-undefine64.9%
Simplified64.9%
Taylor expanded in y.im around inf 37.0%
unpow237.0%
unpow237.0%
hypot-undefine68.3%
Simplified68.3%
Taylor expanded in x.im around 0 31.5%
if -1.1e-307 < x.im Initial program 35.3%
exp-diff32.6%
exp-to-pow32.6%
hypot-define32.6%
*-commutative32.6%
exp-prod31.6%
fma-define31.6%
hypot-define72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in y.im around 0 45.3%
unpow245.3%
unpow245.3%
hypot-undefine55.0%
Simplified55.0%
Taylor expanded in y.im around inf 25.9%
unpow225.9%
unpow225.9%
hypot-undefine64.8%
Simplified64.8%
Taylor expanded in x.re around 0 64.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (pow (hypot x.im x.re) y.re) (cos (* y.im (log x.im)))))
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) * cos((y_46_im * log(x_46_im)));
}
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) * Math.cos((y_46_im * Math.log(x_46_im)));
}
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) * math.cos((y_46_im * math.log(x_46_im)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64((hypot(x_46_im, x_46_re) ^ y_46_re) * cos(Float64(y_46_im * log(x_46_im)))) 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) * cos((y_46_im * log(x_46_im))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(y.im \cdot \log x.im\right)
\end{array}
Initial program 40.4%
exp-diff38.1%
exp-to-pow38.1%
hypot-define38.1%
*-commutative38.1%
exp-prod36.8%
fma-define36.8%
hypot-define73.2%
*-commutative73.2%
Simplified73.2%
Taylor expanded in y.im around 0 51.8%
unpow251.8%
unpow251.8%
hypot-undefine60.6%
Simplified60.6%
Taylor expanded in y.im around inf 32.2%
unpow232.2%
unpow232.2%
hypot-undefine66.8%
Simplified66.8%
Taylor expanded in x.re around 0 27.8%
herbie shell --seed 2024083
(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)))))