
(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 5 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
(if (<= y.re 1.9e+212)
(*
(exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))
(log (exp (cos (* y.im (log (hypot x.im x.re)))))))
(* (cos (* y.re (atan2 x.im x.re))) (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) {
double tmp;
if (y_46_re <= 1.9e+212) {
tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * log(exp(cos((y_46_im * log(hypot(x_46_im, x_46_re))))));
} else {
tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * pow(hypot(x_46_im, x_46_re), y_46_re);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= 1.9e+212) tmp = Float64(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)))) * log(exp(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))))); else tmp = Float64(cos(Float64(y_46_re * atan(x_46_im, x_46_re))) * (hypot(x_46_im, x_46_re) ^ y_46_re)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 1.9e+212], N[(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] * N[Log[N[Exp[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 1.9 \cdot 10^{+212}:\\
\;\;\;\;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)} \cdot \log \left(e^{\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.re < 1.89999999999999994e212Initial program 43.2%
cancel-sign-sub-inv43.2%
fma-def43.2%
hypot-def43.2%
distribute-lft-neg-in43.2%
distribute-rgt-neg-out43.2%
fma-def43.2%
hypot-def84.6%
*-commutative84.6%
Simplified84.6%
add-cube-cbrt81.9%
pow382.3%
fma-udef82.3%
*-commutative82.3%
*-commutative82.3%
fma-def82.3%
Applied egg-rr82.3%
rem-cube-cbrt84.6%
add-log-exp84.6%
Applied egg-rr84.6%
Taylor expanded in y.re around 0 43.2%
unpow243.2%
unpow243.2%
hypot-def87.5%
Simplified87.5%
if 1.89999999999999994e212 < y.re Initial program 29.4%
exp-diff17.6%
exp-to-pow17.6%
hypot-def17.6%
*-commutative17.6%
exp-prod17.6%
fma-def17.6%
hypot-def41.2%
*-commutative41.2%
Simplified41.2%
Taylor expanded in y.im around 0 70.6%
Taylor expanded in y.im around 0 82.4%
unpow282.4%
unpow282.4%
hypot-def82.4%
Simplified82.4%
Final simplification87.2%
(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 42.3%
cancel-sign-sub-inv42.3%
fma-def42.3%
hypot-def42.3%
distribute-lft-neg-in42.3%
distribute-rgt-neg-out42.3%
fma-def42.3%
hypot-def83.7%
*-commutative83.7%
Simplified83.7%
add-cube-cbrt79.5%
pow381.1%
fma-udef81.1%
*-commutative81.1%
*-commutative81.1%
fma-def81.1%
Applied egg-rr81.1%
Taylor expanded in y.im around inf 83.4%
Final simplification83.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re))
(t_1 (* (cos (* y.re (atan2 x.im x.re))) t_0)))
(if (<= y.re -7800000000.0)
t_1
(if (<= y.re 1.7)
(exp (* (atan2 x.im x.re) (- y.im)))
(if (<= y.re 2e+184) t_0 t_1)))))
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 t_1 = cos((y_46_re * atan2(x_46_im, x_46_re))) * t_0;
double tmp;
if (y_46_re <= -7800000000.0) {
tmp = t_1;
} else if (y_46_re <= 1.7) {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
} else if (y_46_re <= 2e+184) {
tmp = t_0;
} else {
tmp = 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.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
double t_1 = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re))) * t_0;
double tmp;
if (y_46_re <= -7800000000.0) {
tmp = t_1;
} else if (y_46_re <= 1.7) {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
} else if (y_46_re <= 2e+184) {
tmp = t_0;
} else {
tmp = t_1;
}
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) t_1 = math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) * t_0 tmp = 0 if y_46_re <= -7800000000.0: tmp = t_1 elif y_46_re <= 1.7: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) elif y_46_re <= 2e+184: tmp = t_0 else: tmp = t_1 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 t_1 = Float64(cos(Float64(y_46_re * atan(x_46_im, x_46_re))) * t_0) tmp = 0.0 if (y_46_re <= -7800000000.0) tmp = t_1; elseif (y_46_re <= 1.7) tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))); elseif (y_46_re <= 2e+184) tmp = t_0; else tmp = t_1; 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; t_1 = cos((y_46_re * atan2(x_46_im, x_46_re))) * t_0; tmp = 0.0; if (y_46_re <= -7800000000.0) tmp = t_1; elseif (y_46_re <= 1.7) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); elseif (y_46_re <= 2e+184) tmp = t_0; else tmp = 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[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[y$46$re, -7800000000.0], t$95$1, If[LessEqual[y$46$re, 1.7], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision], If[LessEqual[y$46$re, 2e+184], t$95$0, t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
t_1 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot t_0\\
\mathbf{if}\;y.re \leq -7800000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y.re \leq 1.7:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\mathbf{elif}\;y.re \leq 2 \cdot 10^{+184}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y.re < -7.8e9 or 2.00000000000000003e184 < y.re Initial program 42.7%
exp-diff36.6%
exp-to-pow36.6%
hypot-def36.6%
*-commutative36.6%
exp-prod34.1%
fma-def34.1%
hypot-def67.1%
*-commutative67.1%
Simplified67.1%
Taylor expanded in y.im around 0 84.3%
Taylor expanded in y.im around 0 86.7%
unpow286.7%
unpow286.7%
hypot-def86.7%
Simplified86.7%
if -7.8e9 < y.re < 1.69999999999999996Initial program 44.5%
cancel-sign-sub-inv44.5%
fma-def44.5%
hypot-def44.5%
distribute-lft-neg-in44.5%
distribute-rgt-neg-out44.5%
fma-def44.5%
hypot-def86.2%
*-commutative86.2%
Simplified86.2%
add-cube-cbrt80.3%
pow382.7%
fma-udef82.7%
*-commutative82.7%
*-commutative82.7%
fma-def82.7%
Applied egg-rr82.7%
Taylor expanded in y.im around inf 85.0%
Taylor expanded in y.re around 0 84.7%
neg-mul-184.7%
distribute-rgt-neg-in84.7%
Simplified84.7%
if 1.69999999999999996 < y.re < 2.00000000000000003e184Initial program 35.6%
cancel-sign-sub-inv35.6%
fma-def35.6%
hypot-def35.6%
distribute-lft-neg-in35.6%
distribute-rgt-neg-out35.6%
fma-def35.6%
hypot-def68.9%
*-commutative68.9%
Simplified68.9%
add-cube-cbrt73.3%
pow364.4%
fma-udef64.4%
*-commutative64.4%
*-commutative64.4%
fma-def64.4%
Applied egg-rr64.4%
Taylor expanded in y.im around inf 80.0%
Taylor expanded in y.im around 0 77.8%
unpow277.8%
unpow277.8%
hypot-def77.8%
Simplified77.8%
Final simplification84.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -7800000000.0) (not (<= y.re 3900.0))) (pow (hypot x.im x.re) y.re) (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 tmp;
if ((y_46_re <= -7800000000.0) || !(y_46_re <= 3900.0)) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = 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 tmp;
if ((y_46_re <= -7800000000.0) || !(y_46_re <= 3900.0)) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = 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): tmp = 0 if (y_46_re <= -7800000000.0) or not (y_46_re <= 3900.0): tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) else: tmp = 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) tmp = 0.0 if ((y_46_re <= -7800000000.0) || !(y_46_re <= 3900.0)) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = 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) tmp = 0.0; if ((y_46_re <= -7800000000.0) || ~((y_46_re <= 3900.0))) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = 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_] := If[Or[LessEqual[y$46$re, -7800000000.0], N[Not[LessEqual[y$46$re, 3900.0]], $MachinePrecision]], N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -7800000000 \lor \neg \left(y.re \leq 3900\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\end{array}
\end{array}
if y.re < -7.8e9 or 3900 < y.re Initial program 40.2%
cancel-sign-sub-inv40.2%
fma-def40.2%
hypot-def40.2%
distribute-lft-neg-in40.2%
distribute-rgt-neg-out40.2%
fma-def40.2%
hypot-def81.1%
*-commutative81.1%
Simplified81.1%
add-cube-cbrt78.7%
pow379.5%
fma-udef79.5%
*-commutative79.5%
*-commutative79.5%
fma-def79.5%
Applied egg-rr79.5%
Taylor expanded in y.im around inf 81.9%
Taylor expanded in y.im around 0 78.0%
unpow278.0%
unpow278.0%
hypot-def78.0%
Simplified78.0%
if -7.8e9 < y.re < 3900Initial program 44.5%
cancel-sign-sub-inv44.5%
fma-def44.5%
hypot-def44.5%
distribute-lft-neg-in44.5%
distribute-rgt-neg-out44.5%
fma-def44.5%
hypot-def86.2%
*-commutative86.2%
Simplified86.2%
add-cube-cbrt80.3%
pow382.7%
fma-udef82.7%
*-commutative82.7%
*-commutative82.7%
fma-def82.7%
Applied egg-rr82.7%
Taylor expanded in y.im around inf 85.0%
Taylor expanded in y.re around 0 84.7%
neg-mul-184.7%
distribute-rgt-neg-in84.7%
Simplified84.7%
Final simplification81.4%
(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.3%
cancel-sign-sub-inv42.3%
fma-def42.3%
hypot-def42.3%
distribute-lft-neg-in42.3%
distribute-rgt-neg-out42.3%
fma-def42.3%
hypot-def83.7%
*-commutative83.7%
Simplified83.7%
add-cube-cbrt79.5%
pow381.1%
fma-udef81.1%
*-commutative81.1%
*-commutative81.1%
fma-def81.1%
Applied egg-rr81.1%
Taylor expanded in y.im around inf 83.4%
Taylor expanded in y.im around 0 56.5%
unpow256.5%
unpow256.5%
hypot-def62.4%
Simplified62.4%
Final simplification62.4%
herbie shell --seed 2024013
(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)))))