
(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 11 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 (fma y.im t_0 (* y.re (atan2 x.im x.re))))
(t_2 (cbrt t_1))
(t_3 (exp (- (* t_0 y.re) (* y.im (atan2 x.im x.re))))))
(if (<= y.im -2e-27)
(* t_3 (expm1 (log1p (cos t_1))))
(if (<= y.im 2e-281)
(* t_3 (cos (log (pow (hypot x.im x.re) y.im))))
(* t_3 (cos (* t_2 (pow t_2 2.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 = fma(y_46_im, t_0, (y_46_re * atan2(x_46_im, x_46_re)));
double t_2 = cbrt(t_1);
double t_3 = exp(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
double tmp;
if (y_46_im <= -2e-27) {
tmp = t_3 * expm1(log1p(cos(t_1)));
} else if (y_46_im <= 2e-281) {
tmp = t_3 * cos(log(pow(hypot(x_46_im, x_46_re), y_46_im)));
} else {
tmp = t_3 * cos((t_2 * pow(t_2, 2.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 = fma(y_46_im, t_0, Float64(y_46_re * atan(x_46_im, x_46_re))) t_2 = cbrt(t_1) t_3 = exp(Float64(Float64(t_0 * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) tmp = 0.0 if (y_46_im <= -2e-27) tmp = Float64(t_3 * expm1(log1p(cos(t_1)))); elseif (y_46_im <= 2e-281) tmp = Float64(t_3 * cos(log((hypot(x_46_im, x_46_re) ^ y_46_im)))); else tmp = Float64(t_3 * cos(Float64(t_2 * (t_2 ^ 2.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[(y$46$im * t$95$0 + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 1/3], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$im, -2e-27], N[(t$95$3 * N[(Exp[N[Log[1 + N[Cos[t$95$1], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 2e-281], N[(t$95$3 * N[Cos[N[Log[N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$3 * N[Cos[N[(t$95$2 * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := \mathsf{fma}\left(y.im, t_0, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
t_2 := \sqrt[3]{t_1}\\
t_3 := e^{t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;y.im \leq -2 \cdot 10^{-27}:\\
\;\;\;\;t_3 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos t_1\right)\right)\\
\mathbf{elif}\;y.im \leq 2 \cdot 10^{-281}:\\
\;\;\;\;t_3 \cdot \cos \log \left({\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.im}\right)\\
\mathbf{else}:\\
\;\;\;\;t_3 \cdot \cos \left(t_2 \cdot {t_2}^{2}\right)\\
\end{array}
\end{array}
if y.im < -2.0000000000000001e-27Initial program 46.4%
Simplified75.7%
add-cube-cbrt68.9%
pow268.9%
fma-udef68.9%
*-commutative68.9%
*-commutative68.9%
fma-def68.9%
fma-udef68.9%
*-commutative68.9%
*-commutative68.9%
fma-def68.9%
Applied egg-rr68.9%
expm1-log1p-u68.9%
unpow268.9%
add-cube-cbrt75.7%
Applied egg-rr75.7%
if -2.0000000000000001e-27 < y.im < 2e-281Initial program 40.3%
Simplified86.6%
Taylor expanded in y.im around inf 39.7%
+-commutative39.7%
unpow239.7%
unpow239.7%
hypot-def95.0%
log-pow95.0%
hypot-def39.7%
unpow239.7%
unpow239.7%
+-commutative39.7%
unpow239.7%
unpow239.7%
hypot-def95.0%
Simplified95.0%
if 2e-281 < y.im Initial program 35.1%
Simplified72.1%
add-cube-cbrt84.8%
pow284.8%
fma-udef84.8%
*-commutative84.8%
*-commutative84.8%
fma-def84.8%
fma-udef84.8%
*-commutative84.8%
*-commutative84.8%
fma-def84.8%
Applied egg-rr84.8%
Final simplification85.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re)))
(t_1 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_2 (exp (- (* y.re t_1) t_0)))
(t_3 (* y.re (atan2 x.im x.re))))
(if (<= (* t_2 (cos (+ t_3 (* y.im t_1)))) INFINITY)
(* (cos t_3) t_2)
(exp (- (log (pow (hypot x.re x.im) y.re)) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * atan2(x_46_im, x_46_re);
double t_1 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_2 = exp(((y_46_re * t_1) - t_0));
double t_3 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if ((t_2 * cos((t_3 + (y_46_im * t_1)))) <= ((double) INFINITY)) {
tmp = cos(t_3) * t_2;
} else {
tmp = exp((log(pow(hypot(x_46_re, x_46_im), y_46_re)) - t_0));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * Math.atan2(x_46_im, x_46_re);
double t_1 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_2 = Math.exp(((y_46_re * t_1) - t_0));
double t_3 = y_46_re * Math.atan2(x_46_im, x_46_re);
double tmp;
if ((t_2 * Math.cos((t_3 + (y_46_im * t_1)))) <= Double.POSITIVE_INFINITY) {
tmp = Math.cos(t_3) * t_2;
} else {
tmp = Math.exp((Math.log(Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re)) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = y_46_im * math.atan2(x_46_im, x_46_re) t_1 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) t_2 = math.exp(((y_46_re * t_1) - t_0)) t_3 = y_46_re * math.atan2(x_46_im, x_46_re) tmp = 0 if (t_2 * math.cos((t_3 + (y_46_im * t_1)))) <= math.inf: tmp = math.cos(t_3) * t_2 else: tmp = math.exp((math.log(math.pow(math.hypot(x_46_re, x_46_im), y_46_re)) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) t_1 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_2 = exp(Float64(Float64(y_46_re * t_1) - t_0)) t_3 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (Float64(t_2 * cos(Float64(t_3 + Float64(y_46_im * t_1)))) <= Inf) tmp = Float64(cos(t_3) * t_2); else tmp = exp(Float64(log((hypot(x_46_re, x_46_im) ^ y_46_re)) - t_0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = y_46_im * atan2(x_46_im, x_46_re); t_1 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); t_2 = exp(((y_46_re * t_1) - t_0)); t_3 = y_46_re * atan2(x_46_im, x_46_re); tmp = 0.0; if ((t_2 * cos((t_3 + (y_46_im * t_1)))) <= Inf) tmp = cos(t_3) * t_2; else tmp = exp((log((hypot(x_46_re, x_46_im) ^ y_46_re)) - t_0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[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[Exp[N[(N[(y$46$re * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$2 * N[Cos[N[(t$95$3 + N[(y$46$im * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Cos[t$95$3], $MachinePrecision] * t$95$2), $MachinePrecision], N[Exp[N[(N[Log[N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $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}\\
t_1 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_2 := e^{y.re \cdot t_1 - t_0}\\
t_3 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;t_2 \cdot \cos \left(t_3 + y.im \cdot t_1\right) \leq \infty:\\
\;\;\;\;\cos t_3 \cdot t_2\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left({\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) - 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)))) < +inf.0Initial program 78.4%
Taylor expanded in y.im around 0 79.4%
if +inf.0 < (*.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 0.0%
Taylor expanded in y.im around 0 46.7%
Taylor expanded in y.re around 0 49.1%
add-log-exp49.1%
hypot-udef79.3%
exp-to-pow79.3%
Applied egg-rr79.3%
Final simplification79.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (fma y.im t_0 (* y.re (atan2 x.im x.re))))
(t_2 (exp (- (* t_0 y.re) (* y.im (atan2 x.im x.re))))))
(if (<= y.im -2e-26)
(* t_2 (expm1 (log1p (cos t_1))))
(if (<= y.im 1e-278)
(* t_2 (cos (log (pow (hypot x.im x.re) y.im))))
(* t_2 (cos (pow (cbrt t_1) 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 = fma(y_46_im, t_0, (y_46_re * atan2(x_46_im, x_46_re)));
double t_2 = exp(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
double tmp;
if (y_46_im <= -2e-26) {
tmp = t_2 * expm1(log1p(cos(t_1)));
} else if (y_46_im <= 1e-278) {
tmp = t_2 * cos(log(pow(hypot(x_46_im, x_46_re), y_46_im)));
} else {
tmp = t_2 * cos(pow(cbrt(t_1), 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 = fma(y_46_im, t_0, Float64(y_46_re * atan(x_46_im, x_46_re))) t_2 = exp(Float64(Float64(t_0 * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) tmp = 0.0 if (y_46_im <= -2e-26) tmp = Float64(t_2 * expm1(log1p(cos(t_1)))); elseif (y_46_im <= 1e-278) tmp = Float64(t_2 * cos(log((hypot(x_46_im, x_46_re) ^ y_46_im)))); else tmp = Float64(t_2 * cos((cbrt(t_1) ^ 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[(y$46$im * t$95$0 + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$im, -2e-26], N[(t$95$2 * N[(Exp[N[Log[1 + N[Cos[t$95$1], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 1e-278], N[(t$95$2 * N[Cos[N[Log[N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[Cos[N[Power[N[Power[t$95$1, 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 := \mathsf{fma}\left(y.im, t_0, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
t_2 := e^{t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;y.im \leq -2 \cdot 10^{-26}:\\
\;\;\;\;t_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos t_1\right)\right)\\
\mathbf{elif}\;y.im \leq 10^{-278}:\\
\;\;\;\;t_2 \cdot \cos \log \left({\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.im}\right)\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \cos \left({\left(\sqrt[3]{t_1}\right)}^{3}\right)\\
\end{array}
\end{array}
if y.im < -2.0000000000000001e-26Initial program 46.4%
Simplified75.7%
add-cube-cbrt68.9%
pow268.9%
fma-udef68.9%
*-commutative68.9%
*-commutative68.9%
fma-def68.9%
fma-udef68.9%
*-commutative68.9%
*-commutative68.9%
fma-def68.9%
Applied egg-rr68.9%
expm1-log1p-u68.9%
unpow268.9%
add-cube-cbrt75.7%
Applied egg-rr75.7%
if -2.0000000000000001e-26 < y.im < 9.99999999999999938e-279Initial program 40.3%
Simplified86.6%
Taylor expanded in y.im around inf 39.7%
+-commutative39.7%
unpow239.7%
unpow239.7%
hypot-def95.0%
log-pow95.0%
hypot-def39.7%
unpow239.7%
unpow239.7%
+-commutative39.7%
unpow239.7%
unpow239.7%
hypot-def95.0%
Simplified95.0%
if 9.99999999999999938e-279 < y.im Initial program 35.1%
Simplified72.1%
add-cube-cbrt84.8%
pow382.4%
fma-udef82.4%
*-commutative82.4%
*-commutative82.4%
fma-def82.4%
Applied egg-rr82.4%
Final simplification83.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (* y.re (atan2 x.im x.re)))
(t_2 (* y.im (atan2 x.im x.re))))
(if (<= x.im -6e-9)
(* (exp (- (* y.re (log (- x.im))) t_2)) (cos t_1))
(if (<= x.im -1.45e-261)
(exp (- (log (pow (hypot x.re x.im) y.re)) t_2))
(* (exp (- (* t_0 y.re) t_2)) (cos (fma t_0 y.im t_1)))))))
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 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = y_46_im * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= -6e-9) {
tmp = exp(((y_46_re * log(-x_46_im)) - t_2)) * cos(t_1);
} else if (x_46_im <= -1.45e-261) {
tmp = exp((log(pow(hypot(x_46_re, x_46_im), y_46_re)) - t_2));
} else {
tmp = exp(((t_0 * y_46_re) - t_2)) * cos(fma(t_0, y_46_im, t_1));
}
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 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_2 = Float64(y_46_im * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_im <= -6e-9) tmp = Float64(exp(Float64(Float64(y_46_re * log(Float64(-x_46_im))) - t_2)) * cos(t_1)); elseif (x_46_im <= -1.45e-261) tmp = exp(Float64(log((hypot(x_46_re, x_46_im) ^ y_46_re)) - t_2)); else tmp = Float64(exp(Float64(Float64(t_0 * y_46_re) - t_2)) * cos(fma(t_0, y_46_im, t_1))); 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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -6e-9], N[(N[Exp[N[(N[(y$46$re * N[Log[(-x$46$im)], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, -1.45e-261], N[Exp[N[(N[Log[N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision], N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(t$95$0 * y$46$im + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq -6 \cdot 10^{-9}:\\
\;\;\;\;e^{y.re \cdot \log \left(-x.im\right) - t_2} \cdot \cos t_1\\
\mathbf{elif}\;x.im \leq -1.45 \cdot 10^{-261}:\\
\;\;\;\;e^{\log \left({\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) - t_2}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 \cdot y.re - t_2} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, t_1\right)\right)\\
\end{array}
\end{array}
if x.im < -5.99999999999999996e-9Initial program 34.4%
Taylor expanded in y.im around 0 69.3%
Taylor expanded in x.im around -inf 85.2%
mul-1-neg77.9%
Simplified85.2%
if -5.99999999999999996e-9 < x.im < -1.44999999999999993e-261Initial program 43.6%
Taylor expanded in y.im around 0 63.5%
Taylor expanded in y.re around 0 72.2%
add-log-exp72.2%
hypot-udef85.4%
exp-to-pow85.4%
Applied egg-rr85.4%
if -1.44999999999999993e-261 < x.im Initial program 40.2%
Simplified79.9%
Final simplification82.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))))
(if (<= x.im -2.9e-10)
(* (exp (- (* y.re (log (- x.im))) t_0)) (cos (* y.re (atan2 x.im x.re))))
(exp (- (log (pow (hypot x.re x.im) y.re)) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= -2.9e-10) {
tmp = exp(((y_46_re * log(-x_46_im)) - t_0)) * cos((y_46_re * atan2(x_46_im, x_46_re)));
} else {
tmp = exp((log(pow(hypot(x_46_re, x_46_im), y_46_re)) - t_0));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * Math.atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= -2.9e-10) {
tmp = Math.exp(((y_46_re * Math.log(-x_46_im)) - t_0)) * Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
} else {
tmp = Math.exp((Math.log(Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re)) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = y_46_im * math.atan2(x_46_im, x_46_re) tmp = 0 if x_46_im <= -2.9e-10: tmp = math.exp(((y_46_re * math.log(-x_46_im)) - t_0)) * math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) else: tmp = math.exp((math.log(math.pow(math.hypot(x_46_re, x_46_im), y_46_re)) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_im <= -2.9e-10) tmp = Float64(exp(Float64(Float64(y_46_re * log(Float64(-x_46_im))) - t_0)) * cos(Float64(y_46_re * atan(x_46_im, x_46_re)))); else tmp = exp(Float64(log((hypot(x_46_re, x_46_im) ^ y_46_re)) - t_0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = y_46_im * atan2(x_46_im, x_46_re); tmp = 0.0; if (x_46_im <= -2.9e-10) tmp = exp(((y_46_re * log(-x_46_im)) - t_0)) * cos((y_46_re * atan2(x_46_im, x_46_re))); else tmp = exp((log((hypot(x_46_re, x_46_im) ^ y_46_re)) - t_0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -2.9e-10], N[(N[Exp[N[(N[(y$46$re * N[Log[(-x$46$im)], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Log[N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $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 -2.9 \cdot 10^{-10}:\\
\;\;\;\;e^{y.re \cdot \log \left(-x.im\right) - t_0} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left({\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) - t_0}\\
\end{array}
\end{array}
if x.im < -2.89999999999999981e-10Initial program 33.9%
Taylor expanded in y.im around 0 68.2%
Taylor expanded in x.im around -inf 83.9%
mul-1-neg76.7%
Simplified83.9%
if -2.89999999999999981e-10 < x.im Initial program 41.3%
Taylor expanded in y.im around 0 61.6%
Taylor expanded in y.re around 0 64.5%
add-log-exp62.0%
hypot-udef77.3%
exp-to-pow77.3%
Applied egg-rr77.3%
Final simplification78.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (- (log (pow (hypot x.re x.im) y.re)) (* y.im (atan2 x.im x.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp((log(pow(hypot(x_46_re, x_46_im), y_46_re)) - (y_46_im * atan2(x_46_im, x_46_re))));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.exp((Math.log(Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re)) - (y_46_im * Math.atan2(x_46_im, x_46_re))));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp((math.log(math.pow(math.hypot(x_46_re, x_46_im), y_46_re)) - (y_46_im * math.atan2(x_46_im, x_46_re))))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return exp(Float64(log((hypot(x_46_re, x_46_im) ^ y_46_re)) - Float64(y_46_im * atan(x_46_im, x_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp((log((hypot(x_46_re, x_46_im) ^ y_46_re)) - (y_46_im * atan2(x_46_im, x_46_re)))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[Log[N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\log \left({\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}
\end{array}
Initial program 39.5%
Taylor expanded in y.im around 0 63.2%
Taylor expanded in y.re around 0 64.1%
add-log-exp61.8%
hypot-udef76.8%
exp-to-pow76.8%
Applied egg-rr76.8%
Final simplification76.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))))
(if (<= x.re -2.85e-269)
(exp (- (* y.re (log (- x.re))) t_0))
(if (<= x.re 1.4e-54)
(exp (- (* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im))))) t_0))
(exp (- (* y.re (log x.re)) t_0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_re <= -2.85e-269) {
tmp = exp(((y_46_re * log(-x_46_re)) - t_0));
} else if (x_46_re <= 1.4e-54) {
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_re)) - 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_46re <= (-2.85d-269)) then
tmp = exp(((y_46re * log(-x_46re)) - t_0))
else if (x_46re <= 1.4d-54) then
tmp = exp(((y_46re * log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))) - t_0))
else
tmp = exp(((y_46re * log(x_46re)) - 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_re <= -2.85e-269) {
tmp = Math.exp(((y_46_re * Math.log(-x_46_re)) - t_0));
} else if (x_46_re <= 1.4e-54) {
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_re)) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = y_46_im * math.atan2(x_46_im, x_46_re) tmp = 0 if x_46_re <= -2.85e-269: tmp = math.exp(((y_46_re * math.log(-x_46_re)) - t_0)) elif x_46_re <= 1.4e-54: 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_re)) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_re <= -2.85e-269) tmp = exp(Float64(Float64(y_46_re * log(Float64(-x_46_re))) - t_0)); elseif (x_46_re <= 1.4e-54) 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_re)) - t_0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = y_46_im * atan2(x_46_im, x_46_re); tmp = 0.0; if (x_46_re <= -2.85e-269) tmp = exp(((y_46_re * log(-x_46_re)) - t_0)); elseif (x_46_re <= 1.4e-54) 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_re)) - t_0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -2.85e-269], N[Exp[N[(N[(y$46$re * N[Log[(-x$46$re)], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[x$46$re, 1.4e-54], 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$re], $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.re \leq -2.85 \cdot 10^{-269}:\\
\;\;\;\;e^{y.re \cdot \log \left(-x.re\right) - t_0}\\
\mathbf{elif}\;x.re \leq 1.4 \cdot 10^{-54}:\\
\;\;\;\;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.re - t_0}\\
\end{array}
\end{array}
if x.re < -2.84999999999999985e-269Initial program 34.4%
Taylor expanded in y.im around 0 55.5%
Taylor expanded in y.re around 0 59.7%
Taylor expanded in x.re around -inf 78.7%
mul-1-neg78.7%
Simplified78.7%
if -2.84999999999999985e-269 < x.re < 1.4000000000000001e-54Initial program 60.0%
Taylor expanded in y.im around 0 78.7%
Taylor expanded in y.re around 0 75.9%
if 1.4000000000000001e-54 < x.re Initial program 29.4%
Taylor expanded in y.im around 0 62.0%
Taylor expanded in y.re around 0 60.6%
Taylor expanded in x.re around inf 72.1%
Final simplification76.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))))
(if (<= x.re -1e-309)
(exp (- (* y.re (log (- x.re))) t_0))
(if (<= x.re 1.05e-54)
(exp (- (* y.re (log (+ x.re (* 0.5 (/ (* x.im x.im) x.re))))) t_0))
(exp (- (* y.re (log x.re)) t_0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_re <= -1e-309) {
tmp = exp(((y_46_re * log(-x_46_re)) - t_0));
} else if (x_46_re <= 1.05e-54) {
tmp = exp(((y_46_re * log((x_46_re + (0.5 * ((x_46_im * x_46_im) / x_46_re))))) - t_0));
} else {
tmp = exp(((y_46_re * log(x_46_re)) - 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_46re <= (-1d-309)) then
tmp = exp(((y_46re * log(-x_46re)) - t_0))
else if (x_46re <= 1.05d-54) then
tmp = exp(((y_46re * log((x_46re + (0.5d0 * ((x_46im * x_46im) / x_46re))))) - t_0))
else
tmp = exp(((y_46re * log(x_46re)) - 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_re <= -1e-309) {
tmp = Math.exp(((y_46_re * Math.log(-x_46_re)) - t_0));
} else if (x_46_re <= 1.05e-54) {
tmp = Math.exp(((y_46_re * Math.log((x_46_re + (0.5 * ((x_46_im * x_46_im) / x_46_re))))) - t_0));
} else {
tmp = Math.exp(((y_46_re * Math.log(x_46_re)) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = y_46_im * math.atan2(x_46_im, x_46_re) tmp = 0 if x_46_re <= -1e-309: tmp = math.exp(((y_46_re * math.log(-x_46_re)) - t_0)) elif x_46_re <= 1.05e-54: tmp = math.exp(((y_46_re * math.log((x_46_re + (0.5 * ((x_46_im * x_46_im) / x_46_re))))) - t_0)) else: tmp = math.exp(((y_46_re * math.log(x_46_re)) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_re <= -1e-309) tmp = exp(Float64(Float64(y_46_re * log(Float64(-x_46_re))) - t_0)); elseif (x_46_re <= 1.05e-54) tmp = exp(Float64(Float64(y_46_re * log(Float64(x_46_re + Float64(0.5 * Float64(Float64(x_46_im * x_46_im) / x_46_re))))) - t_0)); else tmp = exp(Float64(Float64(y_46_re * log(x_46_re)) - t_0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = y_46_im * atan2(x_46_im, x_46_re); tmp = 0.0; if (x_46_re <= -1e-309) tmp = exp(((y_46_re * log(-x_46_re)) - t_0)); elseif (x_46_re <= 1.05e-54) tmp = exp(((y_46_re * log((x_46_re + (0.5 * ((x_46_im * x_46_im) / x_46_re))))) - t_0)); else tmp = exp(((y_46_re * log(x_46_re)) - t_0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -1e-309], N[Exp[N[(N[(y$46$re * N[Log[(-x$46$re)], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[x$46$re, 1.05e-54], N[Exp[N[(N[(y$46$re * N[Log[N[(x$46$re + N[(0.5 * N[(N[(x$46$im * x$46$im), $MachinePrecision] / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(y$46$re * N[Log[x$46$re], $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.re \leq -1 \cdot 10^{-309}:\\
\;\;\;\;e^{y.re \cdot \log \left(-x.re\right) - t_0}\\
\mathbf{elif}\;x.re \leq 1.05 \cdot 10^{-54}:\\
\;\;\;\;e^{y.re \cdot \log \left(x.re + 0.5 \cdot \frac{x.im \cdot x.im}{x.re}\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - t_0}\\
\end{array}
\end{array}
if x.re < -1.000000000000002e-309Initial program 33.8%
Taylor expanded in y.im around 0 56.7%
Taylor expanded in y.re around 0 59.9%
Taylor expanded in x.re around -inf 76.1%
mul-1-neg76.1%
Simplified76.1%
if -1.000000000000002e-309 < x.re < 1.05e-54Initial program 65.0%
Taylor expanded in y.im around 0 79.2%
Taylor expanded in y.re around 0 77.7%
Taylor expanded in x.re around inf 71.4%
unpow271.4%
Simplified71.4%
if 1.05e-54 < x.re Initial program 29.4%
Taylor expanded in y.im around 0 62.0%
Taylor expanded in y.re around 0 60.6%
Taylor expanded in x.re around inf 72.1%
Final simplification73.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))))
(if (<= x.im -1e-310)
(exp (- (* y.re (log (- 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 <= -1e-310) {
tmp = exp(((y_46_re * log(-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 <= (-1d-310)) then
tmp = exp(((y_46re * log(-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 <= -1e-310) {
tmp = Math.exp(((y_46_re * Math.log(-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 <= -1e-310: tmp = math.exp(((y_46_re * math.log(-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 <= -1e-310) tmp = exp(Float64(Float64(y_46_re * log(Float64(-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 <= -1e-310) tmp = exp(((y_46_re * log(-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[LessEqual[x$46$im, -1e-310], N[Exp[N[(N[(y$46$re * N[Log[(-x$46$im)], $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 -1 \cdot 10^{-310}:\\
\;\;\;\;e^{y.re \cdot \log \left(-x.im\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.im - t_0}\\
\end{array}
\end{array}
if x.im < -9.999999999999969e-311Initial program 37.8%
Taylor expanded in y.im around 0 66.4%
Taylor expanded in y.re around 0 67.3%
Taylor expanded in x.im around -inf 73.7%
mul-1-neg73.7%
Simplified73.7%
if -9.999999999999969e-311 < x.im Initial program 41.1%
Taylor expanded in y.im around 0 60.3%
Taylor expanded in y.re around 0 61.1%
Taylor expanded in x.re around 0 71.1%
Final simplification72.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))))
(if (<= x.re -2.9e-307)
(exp (- (* y.re (log x.im)) t_0))
(exp (- (* y.re (log x.re)) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_re <= -2.9e-307) {
tmp = exp(((y_46_re * log(x_46_im)) - t_0));
} else {
tmp = exp(((y_46_re * log(x_46_re)) - 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_46re <= (-2.9d-307)) then
tmp = exp(((y_46re * log(x_46im)) - t_0))
else
tmp = exp(((y_46re * log(x_46re)) - 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_re <= -2.9e-307) {
tmp = Math.exp(((y_46_re * Math.log(x_46_im)) - t_0));
} else {
tmp = Math.exp(((y_46_re * Math.log(x_46_re)) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = y_46_im * math.atan2(x_46_im, x_46_re) tmp = 0 if x_46_re <= -2.9e-307: tmp = math.exp(((y_46_re * math.log(x_46_im)) - t_0)) else: tmp = math.exp(((y_46_re * math.log(x_46_re)) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_re <= -2.9e-307) tmp = exp(Float64(Float64(y_46_re * log(x_46_im)) - t_0)); else tmp = exp(Float64(Float64(y_46_re * log(x_46_re)) - t_0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = y_46_im * atan2(x_46_im, x_46_re); tmp = 0.0; if (x_46_re <= -2.9e-307) tmp = exp(((y_46_re * log(x_46_im)) - t_0)); else tmp = exp(((y_46_re * log(x_46_re)) - t_0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -2.9e-307], N[Exp[N[(N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(y$46$re * N[Log[x$46$re], $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.re \leq -2.9 \cdot 10^{-307}:\\
\;\;\;\;e^{y.re \cdot \log x.im - t_0}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - t_0}\\
\end{array}
\end{array}
if x.re < -2.9e-307Initial program 34.1%
Taylor expanded in y.im around 0 56.4%
Taylor expanded in y.re around 0 59.5%
Taylor expanded in x.re around 0 43.7%
if -2.9e-307 < x.re Initial program 44.8%
Taylor expanded in y.im around 0 69.8%
Taylor expanded in y.re around 0 68.4%
Taylor expanded in x.re around inf 65.9%
Final simplification55.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 39.5%
Taylor expanded in y.im around 0 63.2%
Taylor expanded in y.re around 0 64.1%
Taylor expanded in x.re around 0 37.2%
Final simplification37.2%
herbie shell --seed 2023192
(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)))))