
(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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
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 (* y.re (atan2 x.im x.re))))
(if (<= y.re 3.3e+89)
(*
(exp (fma (log (hypot x.re x.im)) y.re (* (- (atan2 x.im x.re)) y.im)))
(cos t_0))
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(- 1.0 (* y.im (* (log (hypot x.im x.re)) (sin 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_re * atan2(x_46_im, x_46_re);
double tmp;
if (y_46_re <= 3.3e+89) {
tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (-atan2(x_46_im, x_46_re) * y_46_im))) * cos(t_0);
} else {
tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * (1.0 - (y_46_im * (log(hypot(x_46_im, x_46_re)) * sin(t_0))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (y_46_re <= 3.3e+89) tmp = Float64(exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(Float64(-atan(x_46_im, x_46_re)) * y_46_im))) * cos(t_0)); else tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * Float64(1.0 - Float64(y_46_im * Float64(log(hypot(x_46_im, x_46_re)) * sin(t_0))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, 3.3e+89], 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[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(y$46$im * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;y.re \leq 3.3 \cdot 10^{+89}:\\
\;\;\;\;e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \cos t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(1 - y.im \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot \sin t\_0\right)\right)\\
\end{array}
\end{array}
if y.re < 3.29999999999999974e89Initial program 39.7%
Applied rewrites83.6%
Taylor expanded in y.re around inf
lift-atan2.f64N/A
lift-*.f6485.4
Applied rewrites85.4%
if 3.29999999999999974e89 < y.re Initial program 29.3%
Taylor expanded in y.im around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites61.1%
Taylor expanded in y.re around 0
Applied rewrites78.1%
Final simplification84.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.im x.re)))
(t_1
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im))))
(t_2 (log (hypot x.re x.im)))
(t_3 (* y.re (atan2 x.im x.re)))
(t_4 (* t_0 (sin t_3)))
(t_5 (cos t_3)))
(if (<= y.im -5.1e+111)
(* t_1 (sin (+ (fma t_2 y.im (* (atan2 x.im x.re) y.re)) (/ PI 2.0))))
(if (<= y.im 5e+117)
(*
(exp (fma t_2 y.re (* (- (atan2 x.im x.re)) y.im)))
(+ t_5 (* y.im (- (* -0.5 (* y.im (* t_5 (pow t_0 2.0)))) t_4))))
(* t_1 (- 1.0 (* y.im t_4)))))))
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_im, x_46_re));
double t_1 = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_2 = log(hypot(x_46_re, x_46_im));
double t_3 = y_46_re * atan2(x_46_im, x_46_re);
double t_4 = t_0 * sin(t_3);
double t_5 = cos(t_3);
double tmp;
if (y_46_im <= -5.1e+111) {
tmp = t_1 * sin((fma(t_2, y_46_im, (atan2(x_46_im, x_46_re) * y_46_re)) + (((double) M_PI) / 2.0)));
} else if (y_46_im <= 5e+117) {
tmp = exp(fma(t_2, y_46_re, (-atan2(x_46_im, x_46_re) * y_46_im))) * (t_5 + (y_46_im * ((-0.5 * (y_46_im * (t_5 * pow(t_0, 2.0)))) - t_4)));
} else {
tmp = t_1 * (1.0 - (y_46_im * t_4));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_im, x_46_re)) t_1 = exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_2 = log(hypot(x_46_re, x_46_im)) t_3 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_4 = Float64(t_0 * sin(t_3)) t_5 = cos(t_3) tmp = 0.0 if (y_46_im <= -5.1e+111) tmp = Float64(t_1 * sin(Float64(fma(t_2, y_46_im, Float64(atan(x_46_im, x_46_re) * y_46_re)) + Float64(pi / 2.0)))); elseif (y_46_im <= 5e+117) tmp = Float64(exp(fma(t_2, y_46_re, Float64(Float64(-atan(x_46_im, x_46_re)) * y_46_im))) * Float64(t_5 + Float64(y_46_im * Float64(Float64(-0.5 * Float64(y_46_im * Float64(t_5 * (t_0 ^ 2.0)))) - t_4)))); else tmp = Float64(t_1 * Float64(1.0 - Float64(y_46_im * t_4))); 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$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 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[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Cos[t$95$3], $MachinePrecision]}, If[LessEqual[y$46$im, -5.1e+111], N[(t$95$1 * N[Sin[N[(N[(t$95$2 * y$46$im + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 5e+117], N[(N[Exp[N[(t$95$2 * y$46$re + N[((-N[ArcTan[x$46$im / x$46$re], $MachinePrecision]) * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$5 + N[(y$46$im * N[(N[(-0.5 * N[(y$46$im * N[(t$95$5 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(y$46$im * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
t_1 := e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_2 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_3 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_4 := t\_0 \cdot \sin t\_3\\
t_5 := \cos t\_3\\
\mathbf{if}\;y.im \leq -5.1 \cdot 10^{+111}:\\
\;\;\;\;t\_1 \cdot \sin \left(\mathsf{fma}\left(t\_2, y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)\\
\mathbf{elif}\;y.im \leq 5 \cdot 10^{+117}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_2, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \left(t\_5 + y.im \cdot \left(-0.5 \cdot \left(y.im \cdot \left(t\_5 \cdot {t\_0}^{2}\right)\right) - t\_4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - y.im \cdot t\_4\right)\\
\end{array}
\end{array}
if y.im < -5.0999999999999997e111Initial program 35.7%
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-atan2.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
Applied rewrites69.2%
if -5.0999999999999997e111 < y.im < 4.99999999999999983e117Initial program 42.1%
Applied rewrites86.2%
Taylor expanded in y.im around 0
lower-+.f64N/A
lift-atan2.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites84.8%
if 4.99999999999999983e117 < y.im Initial program 26.9%
Taylor expanded in y.im around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites63.7%
Taylor expanded in y.re around 0
Applied rewrites63.7%
Final simplification78.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re)))
(t_1 (cos t_0))
(t_2 (log (hypot x.im x.re)))
(t_3 (sin t_0))
(t_4
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im))))
(t_5 (pow (hypot x.im x.re) y.re)))
(if (<= y.im -5.8e-61)
(*
t_4
(sin
(+
(fma (log (hypot x.re x.im)) y.im (* (atan2 x.im x.re) y.re))
(/ PI 2.0))))
(if (<= y.im 6.6e-24)
(fma
y.im
(fma -1.0 (* t_1 (* (atan2 x.im x.re) t_5)) (* (- t_2) (* t_3 t_5)))
(* t_1 t_5))
(* t_4 (- 1.0 (* y.im (* t_2 t_3))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_re * atan2(x_46_im, x_46_re);
double t_1 = cos(t_0);
double t_2 = log(hypot(x_46_im, x_46_re));
double t_3 = sin(t_0);
double t_4 = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_5 = pow(hypot(x_46_im, x_46_re), y_46_re);
double tmp;
if (y_46_im <= -5.8e-61) {
tmp = t_4 * sin((fma(log(hypot(x_46_re, x_46_im)), y_46_im, (atan2(x_46_im, x_46_re) * y_46_re)) + (((double) M_PI) / 2.0)));
} else if (y_46_im <= 6.6e-24) {
tmp = fma(y_46_im, fma(-1.0, (t_1 * (atan2(x_46_im, x_46_re) * t_5)), (-t_2 * (t_3 * t_5))), (t_1 * t_5));
} else {
tmp = t_4 * (1.0 - (y_46_im * (t_2 * t_3)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_1 = cos(t_0) t_2 = log(hypot(x_46_im, x_46_re)) t_3 = sin(t_0) t_4 = exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_5 = hypot(x_46_im, x_46_re) ^ y_46_re tmp = 0.0 if (y_46_im <= -5.8e-61) tmp = Float64(t_4 * sin(Float64(fma(log(hypot(x_46_re, x_46_im)), y_46_im, Float64(atan(x_46_im, x_46_re) * y_46_re)) + Float64(pi / 2.0)))); elseif (y_46_im <= 6.6e-24) tmp = fma(y_46_im, fma(-1.0, Float64(t_1 * Float64(atan(x_46_im, x_46_re) * t_5)), Float64(Float64(-t_2) * Float64(t_3 * t_5))), Float64(t_1 * t_5)); else tmp = Float64(t_4 * Float64(1.0 - Float64(y_46_im * Float64(t_2 * t_3)))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$4 = N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[y$46$im, -5.8e-61], N[(t$95$4 * N[Sin[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 6.6e-24], N[(y$46$im * N[(-1.0 * N[(t$95$1 * N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision] + N[((-t$95$2) * N[(t$95$3 * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * t$95$5), $MachinePrecision]), $MachinePrecision], N[(t$95$4 * N[(1.0 - N[(y$46$im * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \cos t\_0\\
t_2 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
t_3 := \sin t\_0\\
t_4 := e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_5 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;y.im \leq -5.8 \cdot 10^{-61}:\\
\;\;\;\;t\_4 \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)\\
\mathbf{elif}\;y.im \leq 6.6 \cdot 10^{-24}:\\
\;\;\;\;\mathsf{fma}\left(y.im, \mathsf{fma}\left(-1, t\_1 \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot t\_5\right), \left(-t\_2\right) \cdot \left(t\_3 \cdot t\_5\right)\right), t\_1 \cdot t\_5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4 \cdot \left(1 - y.im \cdot \left(t\_2 \cdot t\_3\right)\right)\\
\end{array}
\end{array}
if y.im < -5.7999999999999999e-61Initial program 45.9%
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-atan2.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
Applied rewrites68.0%
if -5.7999999999999999e-61 < y.im < 6.59999999999999968e-24Initial program 37.9%
Taylor expanded in y.im around 0
lower-fma.f64N/A
Applied rewrites87.0%
if 6.59999999999999968e-24 < y.im Initial program 29.3%
Taylor expanded in y.im around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites65.5%
Taylor expanded in y.re around 0
Applied rewrites65.5%
Final simplification75.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re))))
(if (<= x.im 7.8e-243)
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(- 1.0 (* y.im (* (log (hypot x.im x.re)) (sin t_0)))))
(*
(cos (fma y.im (log x.im) t_0))
(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) {
double t_0 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= 7.8e-243) {
tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * (1.0 - (y_46_im * (log(hypot(x_46_im, x_46_re)) * sin(t_0))));
} else {
tmp = cos(fma(y_46_im, log(x_46_im), t_0)) * exp(((y_46_re * log(x_46_im)) - (y_46_im * atan2(x_46_im, x_46_re))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_im <= 7.8e-243) tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * Float64(1.0 - Float64(y_46_im * Float64(log(hypot(x_46_im, x_46_re)) * sin(t_0))))); else tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_0)) * exp(Float64(Float64(y_46_re * log(x_46_im)) - Float64(y_46_im * atan(x_46_im, x_46_re))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 7.8e-243], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(y$46$im * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * 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]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq 7.8 \cdot 10^{-243}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(1 - y.im \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot \sin t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_0\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\end{array}
\end{array}
if x.im < 7.8000000000000003e-243Initial program 36.9%
Taylor expanded in y.im around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites70.2%
Taylor expanded in y.re around 0
Applied rewrites72.0%
if 7.8000000000000003e-243 < x.im Initial program 39.2%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6474.6
Applied rewrites74.6%
Final simplification73.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re))
(t_1 (log (hypot x.im x.re)))
(t_2 (- t_1))
(t_3 (* y.re (atan2 x.im x.re)))
(t_4 (sin t_3))
(t_5 (cos t_3)))
(if (<= x.im -2.3e+136)
(fma
y.im
(fma -1.0 (* t_5 (* (atan2 x.im x.re) t_0)) (* t_2 (* t_4 t_0)))
(* t_5 t_0))
(if (<= x.im 4e-245)
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(+ t_5 (* y.im (fma -0.5 (* y.im (* t_5 (pow t_1 2.0))) (* t_2 t_4)))))
(*
(cos (fma y.im (log x.im) t_3))
(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) {
double t_0 = pow(hypot(x_46_im, x_46_re), y_46_re);
double t_1 = log(hypot(x_46_im, x_46_re));
double t_2 = -t_1;
double t_3 = y_46_re * atan2(x_46_im, x_46_re);
double t_4 = sin(t_3);
double t_5 = cos(t_3);
double tmp;
if (x_46_im <= -2.3e+136) {
tmp = fma(y_46_im, fma(-1.0, (t_5 * (atan2(x_46_im, x_46_re) * t_0)), (t_2 * (t_4 * t_0))), (t_5 * t_0));
} else if (x_46_im <= 4e-245) {
tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * (t_5 + (y_46_im * fma(-0.5, (y_46_im * (t_5 * pow(t_1, 2.0))), (t_2 * t_4))));
} else {
tmp = cos(fma(y_46_im, log(x_46_im), t_3)) * exp(((y_46_re * log(x_46_im)) - (y_46_im * atan2(x_46_im, x_46_re))));
}
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 = log(hypot(x_46_im, x_46_re)) t_2 = Float64(-t_1) t_3 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_4 = sin(t_3) t_5 = cos(t_3) tmp = 0.0 if (x_46_im <= -2.3e+136) tmp = fma(y_46_im, fma(-1.0, Float64(t_5 * Float64(atan(x_46_im, x_46_re) * t_0)), Float64(t_2 * Float64(t_4 * t_0))), Float64(t_5 * t_0)); elseif (x_46_im <= 4e-245) tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * Float64(t_5 + Float64(y_46_im * fma(-0.5, Float64(y_46_im * Float64(t_5 * (t_1 ^ 2.0))), Float64(t_2 * t_4))))); else tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_3)) * exp(Float64(Float64(y_46_re * log(x_46_im)) - Float64(y_46_im * atan(x_46_im, x_46_re))))); end return 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[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = (-t$95$1)}, Block[{t$95$3 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[t$95$3], $MachinePrecision]}, Block[{t$95$5 = N[Cos[t$95$3], $MachinePrecision]}, If[LessEqual[x$46$im, -2.3e+136], N[(y$46$im * N[(-1.0 * N[(t$95$5 * N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[(t$95$4 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$5 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 4e-245], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$5 + N[(y$46$im * N[(-0.5 * N[(y$46$im * N[(t$95$5 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] * 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]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
t_1 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
t_2 := -t\_1\\
t_3 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_4 := \sin t\_3\\
t_5 := \cos t\_3\\
\mathbf{if}\;x.im \leq -2.3 \cdot 10^{+136}:\\
\;\;\;\;\mathsf{fma}\left(y.im, \mathsf{fma}\left(-1, t\_5 \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot t\_0\right), t\_2 \cdot \left(t\_4 \cdot t\_0\right)\right), t\_5 \cdot t\_0\right)\\
\mathbf{elif}\;x.im \leq 4 \cdot 10^{-245}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(t\_5 + y.im \cdot \mathsf{fma}\left(-0.5, y.im \cdot \left(t\_5 \cdot {t\_1}^{2}\right), t\_2 \cdot t\_4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_3\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\end{array}
\end{array}
if x.im < -2.3e136Initial program 5.6%
Taylor expanded in y.im around 0
lower-fma.f64N/A
Applied rewrites58.7%
if -2.3e136 < x.im < 3.9999999999999997e-245Initial program 49.2%
Taylor expanded in y.im around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-*.f64N/A
Applied rewrites54.3%
if 3.9999999999999997e-245 < x.im Initial program 39.2%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6474.6
Applied rewrites74.6%
Final simplification65.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re))
(t_1 (* y.re (atan2 x.im x.re)))
(t_2 (cos t_1)))
(if (<= x.im 6.8e-278)
(fma
y.im
(fma
-1.0
(* t_2 (* (atan2 x.im x.re) t_0))
(* (- (log (hypot x.im x.re))) (* (sin t_1) t_0)))
(* t_2 t_0))
(*
(cos (fma y.im (log x.im) t_1))
(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) {
double t_0 = pow(hypot(x_46_im, x_46_re), y_46_re);
double t_1 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = cos(t_1);
double tmp;
if (x_46_im <= 6.8e-278) {
tmp = fma(y_46_im, fma(-1.0, (t_2 * (atan2(x_46_im, x_46_re) * t_0)), (-log(hypot(x_46_im, x_46_re)) * (sin(t_1) * t_0))), (t_2 * t_0));
} else {
tmp = cos(fma(y_46_im, log(x_46_im), t_1)) * exp(((y_46_re * log(x_46_im)) - (y_46_im * atan2(x_46_im, x_46_re))));
}
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(y_46_re * atan(x_46_im, x_46_re)) t_2 = cos(t_1) tmp = 0.0 if (x_46_im <= 6.8e-278) tmp = fma(y_46_im, fma(-1.0, Float64(t_2 * Float64(atan(x_46_im, x_46_re) * t_0)), Float64(Float64(-log(hypot(x_46_im, x_46_re))) * Float64(sin(t_1) * t_0))), Float64(t_2 * t_0)); else tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_1)) * exp(Float64(Float64(y_46_re * log(x_46_im)) - Float64(y_46_im * atan(x_46_im, x_46_re))))); end return 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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$1], $MachinePrecision]}, If[LessEqual[x$46$im, 6.8e-278], N[(y$46$im * N[(-1.0 * N[(t$95$2 * N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[((-N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]) * N[(N[Sin[t$95$1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * 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]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := \cos t\_1\\
\mathbf{if}\;x.im \leq 6.8 \cdot 10^{-278}:\\
\;\;\;\;\mathsf{fma}\left(y.im, \mathsf{fma}\left(-1, t\_2 \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot t\_0\right), \left(-\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot \left(\sin t\_1 \cdot t\_0\right)\right), t\_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_1\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\end{array}
\end{array}
if x.im < 6.8000000000000001e-278Initial program 37.0%
Taylor expanded in y.im around 0
lower-fma.f64N/A
Applied rewrites52.7%
if 6.8000000000000001e-278 < x.im Initial program 39.1%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6473.4
Applied rewrites73.4%
Final simplification63.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re))) (t_1 (* y.re (atan2 x.im x.re))))
(if (<= x.re 1e-309)
(* (cos (fma y.im (log x.im) t_1)) (exp (- (* y.re (log x.im)) t_0)))
(* (cos (fma y.im (log x.re) t_1)) (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 t_1 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_re <= 1e-309) {
tmp = cos(fma(y_46_im, log(x_46_im), t_1)) * exp(((y_46_re * log(x_46_im)) - t_0));
} else {
tmp = cos(fma(y_46_im, log(x_46_re), t_1)) * exp(((y_46_re * 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)) t_1 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_re <= 1e-309) tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_1)) * exp(Float64(Float64(y_46_re * log(x_46_im)) - t_0))); else tmp = Float64(cos(fma(y_46_im, log(x_46_re), t_1)) * exp(Float64(Float64(y_46_re * log(x_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[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, 1e-309], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$re], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.re \leq 10^{-309}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_1\right)\right) \cdot e^{y.re \cdot \log x.im - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.re, t\_1\right)\right) \cdot e^{y.re \cdot \log x.re - t\_0}\\
\end{array}
\end{array}
if x.re < 1.000000000000002e-309Initial program 43.5%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6447.8
Applied rewrites47.8%
if 1.000000000000002e-309 < x.re Initial program 32.8%
Taylor expanded in x.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6463.6
Applied rewrites63.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (cos (fma y.im (log x.im) (* y.re (atan2 x.im x.re)))) (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 cos(fma(y_46_im, log(x_46_im), (y_46_re * atan2(x_46_im, x_46_re)))) * exp(((y_46_re * log(x_46_im)) - (y_46_im * atan2(x_46_im, x_46_re))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(cos(fma(y_46_im, log(x_46_im), Float64(y_46_re * atan(x_46_im, x_46_re)))) * exp(Float64(Float64(y_46_re * log(x_46_im)) - Float64(y_46_im * atan(x_46_im, x_46_re))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 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]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}
\end{array}
Initial program 38.1%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6438.3
Applied rewrites38.3%
herbie shell --seed 2025057
(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)))))