
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im))))
(t_2 (* y.re (atan2 x.im x.re))))
(if (<= x.im 5.2e-209)
t_1
(if (<= x.im 9e+99)
(* t_1 (cos (fma t_0 y.im t_2)))
(* t_1 (cos (pow (cbrt (fma y.im t_0 t_2)) 3.0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(hypot(x_46_re, x_46_im));
double t_1 = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_2 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= 5.2e-209) {
tmp = t_1;
} else if (x_46_im <= 9e+99) {
tmp = t_1 * cos(fma(t_0, y_46_im, t_2));
} else {
tmp = t_1 * cos(pow(cbrt(fma(y_46_im, t_0, t_2)), 3.0));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) t_1 = exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_2 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_im <= 5.2e-209) tmp = t_1; elseif (x_46_im <= 9e+99) tmp = Float64(t_1 * cos(fma(t_0, y_46_im, t_2))); else tmp = Float64(t_1 * cos((cbrt(fma(y_46_im, t_0, t_2)) ^ 3.0))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 5.2e-209], t$95$1, If[LessEqual[x$46$im, 9e+99], N[(t$95$1 * N[Cos[N[(t$95$0 * y$46$im + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[N[Power[N[Power[N[(y$46$im * t$95$0 + t$95$2), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq 5.2 \cdot 10^{-209}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x.im \leq 9 \cdot 10^{+99}:\\
\;\;\;\;t_1 \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, t_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(y.im, t_0, t_2\right)}\right)}^{3}\right)\\
\end{array}
\end{array}
if x.im < 5.19999999999999969e-209Initial program 37.1%
Simplified72.8%
Taylor expanded in y.im around inf 36.6%
unpow236.6%
unpow236.6%
hypot-def78.1%
Simplified78.1%
Taylor expanded in y.im around 0 82.5%
if 5.19999999999999969e-209 < x.im < 8.9999999999999999e99Initial program 65.2%
Simplified89.2%
if 8.9999999999999999e99 < x.im Initial program 10.0%
Simplified75.3%
add-cube-cbrt85.5%
pow387.5%
fma-udef87.5%
*-commutative87.5%
*-commutative87.5%
fma-def87.5%
Applied egg-rr87.5%
Final simplification85.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im))
(t_1 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_2 (* y.im t_1))
(t_3 (exp (- (* y.re t_1) t_0)))
(t_4 (* y.re (atan2 x.im x.re))))
(if (<= (* t_3 (cos (+ t_4 t_2))) 2.0)
(* t_3 (cos (+ t_2 (pow (cbrt t_4) 3.0))))
(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 = atan2(x_46_im, x_46_re) * y_46_im;
double t_1 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_2 = y_46_im * t_1;
double t_3 = exp(((y_46_re * t_1) - t_0));
double t_4 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if ((t_3 * cos((t_4 + t_2))) <= 2.0) {
tmp = t_3 * cos((t_2 + pow(cbrt(t_4), 3.0)));
} 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 = Math.atan2(x_46_im, x_46_re) * y_46_im;
double t_1 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_2 = y_46_im * t_1;
double t_3 = Math.exp(((y_46_re * t_1) - t_0));
double t_4 = y_46_re * Math.atan2(x_46_im, x_46_re);
double tmp;
if ((t_3 * Math.cos((t_4 + t_2))) <= 2.0) {
tmp = t_3 * Math.cos((t_2 + Math.pow(Math.cbrt(t_4), 3.0)));
} 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(atan(x_46_im, x_46_re) * y_46_im) t_1 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_2 = Float64(y_46_im * t_1) t_3 = exp(Float64(Float64(y_46_re * t_1) - t_0)) t_4 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (Float64(t_3 * cos(Float64(t_4 + t_2))) <= 2.0) tmp = Float64(t_3 * cos(Float64(t_2 + (cbrt(t_4) ^ 3.0)))); else tmp = exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(y$46$im * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(y$46$re * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$3 * N[Cos[N[(t$95$4 + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], N[(t$95$3 * N[Cos[N[(t$95$2 + N[Power[N[Power[t$95$4, 1/3], $MachinePrecision], 3.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$0), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_2 := y.im \cdot t_1\\
t_3 := e^{y.re \cdot t_1 - t_0}\\
t_4 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;t_3 \cdot \cos \left(t_4 + t_2\right) \leq 2:\\
\;\;\;\;t_3 \cdot \cos \left(t_2 + {\left(\sqrt[3]{t_4}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t_0}\\
\end{array}
\end{array}
if (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < 2Initial program 87.7%
add-cube-cbrt88.7%
pow388.7%
Applied egg-rr88.7%
if 2 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) Initial program 10.1%
Simplified71.6%
Taylor expanded in y.im around inf 7.5%
unpow27.5%
unpow27.5%
hypot-def76.3%
Simplified76.3%
Taylor expanded in y.im around 0 79.9%
Final simplification83.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(exp
(- (* (log (hypot x.re x.im)) y.re) (* (atan2 x.im x.re) y.im)))))
(if (<= x.im 5e-307) t_0 (* 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 = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
double tmp;
if (x_46_im <= 5e-307) {
tmp = t_0;
} 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.exp(((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
double tmp;
if (x_46_im <= 5e-307) {
tmp = t_0;
} 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.exp(((math.log(math.hypot(x_46_re, x_46_im)) * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) tmp = 0 if x_46_im <= 5e-307: tmp = t_0 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 = exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) tmp = 0.0 if (x_46_im <= 5e-307) tmp = t_0; 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 = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))); tmp = 0.0; if (x_46_im <= 5e-307) tmp = t_0; 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[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, 5e-307], t$95$0, 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 := e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{if}\;x.im \leq 5 \cdot 10^{-307}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \cos \left(y.im \cdot \log x.im\right)\\
\end{array}
\end{array}
if x.im < 5.00000000000000014e-307Initial program 38.8%
Simplified72.7%
Taylor expanded in y.im around inf 37.8%
unpow237.8%
unpow237.8%
hypot-def77.6%
Simplified77.6%
Taylor expanded in y.im around 0 81.8%
if 5.00000000000000014e-307 < x.im Initial program 40.1%
Simplified82.0%
Taylor expanded in y.im around inf 37.6%
unpow237.6%
unpow237.6%
hypot-def82.9%
Simplified82.9%
Taylor expanded in x.re around 0 84.3%
Final simplification83.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (- (* (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(((log(hypot(x_46_re, x_46_im)) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
}
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) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
}
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) - (math.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(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) 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) - (atan2(x_46_im, x_46_re) * y_46_im))); 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[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}
\end{array}
Initial program 39.5%
Simplified77.7%
Taylor expanded in y.im around inf 37.7%
unpow237.7%
unpow237.7%
hypot-def80.4%
Simplified80.4%
Taylor expanded in y.im around 0 81.5%
Final simplification81.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -2.1e+58)
(exp (* (atan2 x.im x.re) (- y.im)))
(if (<= y.im 700000000.0)
(pow (hypot x.im x.re) y.re)
(pow (exp 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) {
double tmp;
if (y_46_im <= -2.1e+58) {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
} else if (y_46_im <= 700000000.0) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = pow(exp(y_46_im), -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_im <= -2.1e+58) {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
} else if (y_46_im <= 700000000.0) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = Math.pow(Math.exp(y_46_im), -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_im <= -2.1e+58: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) elif y_46_im <= 700000000.0: tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) else: tmp = math.pow(math.exp(y_46_im), -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_im <= -2.1e+58) tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))); elseif (y_46_im <= 700000000.0) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = exp(y_46_im) ^ Float64(-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_im <= -2.1e+58) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); elseif (y_46_im <= 700000000.0) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = exp(y_46_im) ^ -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[LessEqual[y$46$im, -2.1e+58], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision], If[LessEqual[y$46$im, 700000000.0], N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision], N[Power[N[Exp[y$46$im], $MachinePrecision], (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -2.1 \cdot 10^{+58}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\mathbf{elif}\;y.im \leq 700000000:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{y.im}\right)}^{\left(-\tan^{-1}_* \frac{x.im}{x.re}\right)}\\
\end{array}
\end{array}
if y.im < -2.10000000000000012e58Initial program 31.0%
Taylor expanded in y.im around 0 51.6%
Taylor expanded in y.re around 0 45.4%
unpow245.4%
unpow245.4%
swap-sqr47.4%
unpow247.4%
Simplified47.4%
Taylor expanded in y.re around 0 61.6%
distribute-rgt-neg-in61.6%
Simplified61.6%
if -2.10000000000000012e58 < y.im < 7e8Initial program 42.3%
Simplified82.0%
Taylor expanded in y.im around inf 42.0%
unpow242.0%
unpow242.0%
hypot-def90.6%
Simplified90.6%
Taylor expanded in y.im around 0 90.0%
add-log-exp90.0%
exp-to-pow90.0%
Applied egg-rr90.0%
Taylor expanded in y.im around 0 71.5%
unpow271.5%
unpow271.5%
hypot-def89.0%
Simplified89.0%
if 7e8 < y.im Initial program 39.7%
Taylor expanded in y.im around 0 62.2%
Taylor expanded in y.re around 0 57.8%
unpow257.8%
unpow257.8%
swap-sqr57.8%
unpow257.8%
Simplified57.8%
Taylor expanded in y.re around 0 65.6%
distribute-rgt-neg-in65.6%
exp-prod66.8%
Simplified66.8%
Final simplification77.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -1.7e+58) (not (<= y.im 650000000.0))) (exp (* (atan2 x.im x.re) (- y.im))) (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_im <= -1.7e+58) || !(y_46_im <= 650000000.0)) {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = pow(hypot(x_46_im, x_46_re), y_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_im <= -1.7e+58) || !(y_46_im <= 650000000.0)) {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_im <= -1.7e+58) or not (y_46_im <= 650000000.0): tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) else: tmp = math.pow(math.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_im <= -1.7e+58) || !(y_46_im <= 650000000.0)) tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))); else tmp = hypot(x_46_im, x_46_re) ^ y_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_im <= -1.7e+58) || ~((y_46_im <= 650000000.0))) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); else tmp = hypot(x_46_im, x_46_re) ^ y_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$im, -1.7e+58], N[Not[LessEqual[y$46$im, 650000000.0]], $MachinePrecision]], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision], N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1.7 \cdot 10^{+58} \lor \neg \left(y.im \leq 650000000\right):\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\end{array}
\end{array}
if y.im < -1.7e58 or 6.5e8 < y.im Initial program 36.1%
Taylor expanded in y.im around 0 57.7%
Taylor expanded in y.re around 0 52.6%
unpow252.6%
unpow252.6%
swap-sqr53.4%
unpow253.4%
Simplified53.4%
Taylor expanded in y.re around 0 63.9%
distribute-rgt-neg-in63.9%
Simplified63.9%
if -1.7e58 < y.im < 6.5e8Initial program 42.3%
Simplified82.0%
Taylor expanded in y.im around inf 42.0%
unpow242.0%
unpow242.0%
hypot-def90.6%
Simplified90.6%
Taylor expanded in y.im around 0 90.0%
add-log-exp90.0%
exp-to-pow90.0%
Applied egg-rr90.0%
Taylor expanded in y.im around 0 71.5%
unpow271.5%
unpow271.5%
hypot-def89.0%
Simplified89.0%
Final simplification77.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (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) {
return exp((atan2(x_46_im, x_46_re) * -y_46_im));
}
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((atan2(x_46im, x_46re) * -y_46im))
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((Math.atan2(x_46_im, x_46_re) * -y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp((math.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(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}
\end{array}
Initial program 39.5%
Taylor expanded in y.im around 0 60.0%
Taylor expanded in y.re around 0 47.9%
unpow247.9%
unpow247.9%
swap-sqr49.9%
unpow249.9%
Simplified49.9%
Taylor expanded in y.re around 0 54.4%
distribute-rgt-neg-in54.4%
Simplified54.4%
Final simplification54.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (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) {
return exp((atan2(x_46_im, x_46_re) * y_46_im));
}
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((atan2(x_46im, x_46re) * y_46im))
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((Math.atan2(x_46_im, x_46_re) * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp((math.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(Float64(atan(x_46_im, x_46_re) * y_46_im)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp((atan2(x_46_im, x_46_re) * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}
\end{array}
Initial program 39.5%
Taylor expanded in y.im around 0 60.0%
Taylor expanded in y.re around 0 47.9%
unpow247.9%
unpow247.9%
swap-sqr49.9%
unpow249.9%
Simplified49.9%
Taylor expanded in y.re around 0 54.4%
distribute-rgt-neg-in54.4%
Simplified54.4%
add-log-exp54.4%
*-un-lft-identity54.4%
log-prod54.4%
metadata-eval54.4%
add-log-exp54.4%
add-sqr-sqrt25.6%
sqrt-unprod40.6%
sqr-neg40.6%
sqrt-unprod16.7%
add-sqr-sqrt29.0%
*-commutative29.0%
Applied egg-rr29.0%
+-lft-identity29.0%
Simplified29.0%
Final simplification29.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (- 1.0 (* (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 1.0 - (atan2(x_46_im, x_46_re) * y_46_im);
}
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 = 1.0d0 - (atan2(x_46im, x_46re) * y_46im)
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0 - (Math.atan2(x_46_im, x_46_re) * y_46_im);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return 1.0 - (math.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 Float64(1.0 - Float64(atan(x_46_im, x_46_re) * y_46_im)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 1.0 - (atan2(x_46_im, x_46_re) * y_46_im); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(1.0 - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im
\end{array}
Initial program 39.5%
Taylor expanded in y.im around 0 60.0%
Taylor expanded in y.re around 0 47.9%
unpow247.9%
unpow247.9%
swap-sqr49.9%
unpow249.9%
Simplified49.9%
Taylor expanded in y.re around 0 54.4%
distribute-rgt-neg-in54.4%
Simplified54.4%
Taylor expanded in y.im around 0 26.1%
+-commutative26.1%
mul-1-neg26.1%
*-commutative26.1%
unsub-neg26.1%
Simplified26.1%
Final simplification26.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 1.0)
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
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 = 1.0d0
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return 1.0
function code(x_46_re, x_46_im, y_46_re, y_46_im) return 1.0 end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 1.0; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 39.5%
Taylor expanded in y.im around 0 60.0%
Taylor expanded in y.re around 0 47.9%
unpow247.9%
unpow247.9%
swap-sqr49.9%
unpow249.9%
Simplified49.9%
Taylor expanded in y.re around 0 54.4%
distribute-rgt-neg-in54.4%
Simplified54.4%
Taylor expanded in y.im around 0 26.0%
Final simplification26.0%
herbie shell --seed 2023208
(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)))))