
(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 15 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
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im))))
(t_1 (log (hypot x.im x.re))))
(if (<= y.re -6e-11)
(* t_0 (cos (* (atan2 x.im x.re) y.re)))
(if (<= y.re 1.7e-5)
(*
(sin (fma t_1 y.im (* (PI) 0.5)))
(exp (* (- y.im) (atan2 x.im x.re))))
(* t_0 (cos (* t_1 y.im)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 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_1 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
\mathbf{if}\;y.re \leq -6 \cdot 10^{-11}:\\
\;\;\;\;t\_0 \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{elif}\;y.re \leq 1.7 \cdot 10^{-5}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(t\_1, y.im, \mathsf{PI}\left(\right) \cdot 0.5\right)\right) \cdot e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(t\_1 \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -6e-11Initial program 44.7%
Taylor expanded in y.re around inf
Applied rewrites84.3%
if -6e-11 < y.re < 1.7e-5Initial program 40.2%
Taylor expanded in y.im around 0
Applied rewrites21.2%
Applied rewrites43.9%
Taylor expanded in y.re around 0
Applied rewrites76.6%
if 1.7e-5 < y.re Initial program 39.7%
Taylor expanded in y.re around 0
Applied rewrites75.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.im x.re))))
(if (<= y.re -6e-11)
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(cos (* (atan2 x.im x.re) y.re)))
(if (<= y.re 88000.0)
(*
(sin (fma t_0 y.im (* (PI) 0.5)))
(exp (* (- y.im) (atan2 x.im x.re))))
(* (pow (hypot x.im x.re) y.re) (cos (* t_0 y.im)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
\mathbf{if}\;y.re \leq -6 \cdot 10^{-11}:\\
\;\;\;\;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 \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{elif}\;y.re \leq 88000:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(t\_0, y.im, \mathsf{PI}\left(\right) \cdot 0.5\right)\right) \cdot e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(t\_0 \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -6e-11Initial program 44.7%
Taylor expanded in y.re around inf
Applied rewrites84.3%
if -6e-11 < y.re < 88000Initial program 40.7%
Taylor expanded in y.im around 0
Applied rewrites21.0%
Applied rewrites43.5%
Taylor expanded in y.re around 0
Applied rewrites76.8%
if 88000 < y.re Initial program 38.6%
Taylor expanded in y.im around 0
Applied rewrites33.4%
Taylor expanded in y.re around 0
Applied rewrites70.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.im x.re))))
(if (<= y.re -1.9e-9)
(*
(pow (fma x.im x.im (* x.re x.re)) (* 0.5 y.re))
(cos (* (atan2 x.im x.re) y.re)))
(if (<= y.re 88000.0)
(*
(sin (fma t_0 y.im (* (PI) 0.5)))
(exp (* (- y.im) (atan2 x.im x.re))))
(* (pow (hypot x.im x.re) y.re) (cos (* t_0 y.im)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
\mathbf{if}\;y.re \leq -1.9 \cdot 10^{-9}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\left(0.5 \cdot y.re\right)} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{elif}\;y.re \leq 88000:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(t\_0, y.im, \mathsf{PI}\left(\right) \cdot 0.5\right)\right) \cdot e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(t\_0 \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -1.90000000000000006e-9Initial program 44.7%
Taylor expanded in y.im around 0
Applied rewrites39.6%
Taylor expanded in y.re around inf
Applied rewrites79.2%
Applied rewrites79.2%
if -1.90000000000000006e-9 < y.re < 88000Initial program 40.7%
Taylor expanded in y.im around 0
Applied rewrites21.0%
Applied rewrites43.5%
Taylor expanded in y.re around 0
Applied rewrites76.8%
if 88000 < y.re Initial program 38.6%
Taylor expanded in y.im around 0
Applied rewrites33.4%
Taylor expanded in y.re around 0
Applied rewrites70.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* (log (hypot x.im x.re)) y.im))))
(if (<= y.re -1.9e-9)
(*
(pow (fma x.im x.im (* x.re x.re)) (* 0.5 y.re))
(cos (* (atan2 x.im x.re) y.re)))
(if (<= y.re 8500.0)
(* t_0 (exp (* (- y.im) (atan2 x.im x.re))))
(* (pow (hypot x.im x.re) 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 = cos((log(hypot(x_46_im, x_46_re)) * y_46_im));
double tmp;
if (y_46_re <= -1.9e-9) {
tmp = pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), (0.5 * y_46_re)) * cos((atan2(x_46_im, x_46_re) * y_46_re));
} else if (y_46_re <= 8500.0) {
tmp = t_0 * exp((-y_46_im * atan2(x_46_im, x_46_re)));
} else {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(log(hypot(x_46_im, x_46_re)) * y_46_im)) tmp = 0.0 if (y_46_re <= -1.9e-9) tmp = Float64((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ Float64(0.5 * y_46_re)) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))); elseif (y_46_re <= 8500.0) tmp = Float64(t_0 * exp(Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re)))); else tmp = Float64((hypot(x_46_im, x_46_re) ^ 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[Cos[N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -1.9e-9], N[(N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(0.5 * y$46$re), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 8500.0], N[(t$95$0 * N[Exp[N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\mathbf{if}\;y.re \leq -1.9 \cdot 10^{-9}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\left(0.5 \cdot y.re\right)} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{elif}\;y.re \leq 8500:\\
\;\;\;\;t\_0 \cdot e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot t\_0\\
\end{array}
\end{array}
if y.re < -1.90000000000000006e-9Initial program 44.7%
Taylor expanded in y.im around 0
Applied rewrites39.6%
Taylor expanded in y.re around inf
Applied rewrites79.2%
Applied rewrites79.2%
if -1.90000000000000006e-9 < y.re < 8500Initial program 40.7%
Taylor expanded in x.re around 0
Applied rewrites28.2%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-PI.f6424.9
Applied rewrites24.9%
Taylor expanded in y.im around 0
Applied rewrites47.3%
Taylor expanded in y.re around 0
Applied rewrites75.1%
if 8500 < y.re Initial program 38.6%
Taylor expanded in y.im around 0
Applied rewrites33.4%
Taylor expanded in y.re around 0
Applied rewrites70.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* (atan2 x.im x.re) y.re))))
(if (<= y.re -6.5e-21)
(* (pow (fma x.im x.im (* x.re x.re)) (* 0.5 y.re)) t_0)
(if (<= y.re 85000.0)
(* (exp (* (- y.im) (atan2 x.im x.re))) t_0)
(*
(pow (hypot x.im x.re) y.re)
(cos (* (log (hypot x.im x.re)) y.im)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = cos((atan2(x_46_im, x_46_re) * y_46_re));
double tmp;
if (y_46_re <= -6.5e-21) {
tmp = pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), (0.5 * y_46_re)) * t_0;
} else if (y_46_re <= 85000.0) {
tmp = exp((-y_46_im * atan2(x_46_im, x_46_re))) * t_0;
} else {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * cos((log(hypot(x_46_im, x_46_re)) * y_46_im));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(atan(x_46_im, x_46_re) * y_46_re)) tmp = 0.0 if (y_46_re <= -6.5e-21) tmp = Float64((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ Float64(0.5 * y_46_re)) * t_0); elseif (y_46_re <= 85000.0) tmp = Float64(exp(Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re))) * t_0); else tmp = Float64((hypot(x_46_im, x_46_re) ^ y_46_re) * cos(Float64(log(hypot(x_46_im, x_46_re)) * y_46_im))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -6.5e-21], N[(N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(0.5 * y$46$re), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[y$46$re, 85000.0], N[(N[Exp[N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[Cos[N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{if}\;y.re \leq -6.5 \cdot 10^{-21}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\left(0.5 \cdot y.re\right)} \cdot t\_0\\
\mathbf{elif}\;y.re \leq 85000:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -6.49999999999999987e-21Initial program 45.1%
Taylor expanded in y.im around 0
Applied rewrites38.9%
Taylor expanded in y.re around inf
Applied rewrites77.2%
Applied rewrites77.2%
if -6.49999999999999987e-21 < y.re < 85000Initial program 40.3%
Taylor expanded in y.re around inf
Applied rewrites48.0%
Taylor expanded in x.re around inf
Applied rewrites40.6%
Taylor expanded in y.re around 0
Applied rewrites75.8%
if 85000 < y.re Initial program 38.6%
Taylor expanded in y.im around 0
Applied rewrites33.4%
Taylor expanded in y.re around 0
Applied rewrites70.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.re)) (t_1 (cos t_0)))
(if (<= y.re -6.5e-21)
(* (pow (fma x.im x.im (* x.re x.re)) (* 0.5 y.re)) t_1)
(if (<= y.re 85000.0)
(* (exp (* (- y.im) (atan2 x.im x.re))) t_1)
(* (pow (hypot x.im x.re) y.re) (sin (+ (- t_0) (/ (PI) 2.0))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\\
t_1 := \cos t\_0\\
\mathbf{if}\;y.re \leq -6.5 \cdot 10^{-21}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\left(0.5 \cdot y.re\right)} \cdot t\_1\\
\mathbf{elif}\;y.re \leq 85000:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \sin \left(\left(-t\_0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\\
\end{array}
\end{array}
if y.re < -6.49999999999999987e-21Initial program 45.1%
Taylor expanded in y.im around 0
Applied rewrites38.9%
Taylor expanded in y.re around inf
Applied rewrites77.2%
Applied rewrites77.2%
if -6.49999999999999987e-21 < y.re < 85000Initial program 40.3%
Taylor expanded in y.re around inf
Applied rewrites48.0%
Taylor expanded in x.re around inf
Applied rewrites40.6%
Taylor expanded in y.re around 0
Applied rewrites75.8%
if 85000 < y.re Initial program 38.6%
Taylor expanded in y.im around 0
Applied rewrites33.4%
Taylor expanded in y.re around inf
Applied rewrites54.5%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
lower-neg.f6463.3
Applied rewrites63.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.re)) (t_1 (cos t_0)))
(if (<= y.re -6.5e-21)
(* (pow (fma x.im x.im (* x.re x.re)) (* 0.5 y.re)) t_1)
(if (<= y.re 4.8e+16)
(* (exp (* (- y.im) (atan2 x.im x.re))) t_1)
(if (<= y.re 3.3e+123)
(* (pow x.re y.re) t_1)
(* (pow (hypot x.im x.re) y.re) (sin (fma (PI) 0.5 t_0))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\\
t_1 := \cos t\_0\\
\mathbf{if}\;y.re \leq -6.5 \cdot 10^{-21}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\left(0.5 \cdot y.re\right)} \cdot t\_1\\
\mathbf{elif}\;y.re \leq 4.8 \cdot 10^{+16}:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot t\_1\\
\mathbf{elif}\;y.re \leq 3.3 \cdot 10^{+123}:\\
\;\;\;\;{x.re}^{y.re} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, t\_0\right)\right)\\
\end{array}
\end{array}
if y.re < -6.49999999999999987e-21Initial program 45.1%
Taylor expanded in y.im around 0
Applied rewrites38.9%
Taylor expanded in y.re around inf
Applied rewrites77.2%
Applied rewrites77.2%
if -6.49999999999999987e-21 < y.re < 4.8e16Initial program 41.0%
Taylor expanded in y.re around inf
Applied rewrites49.3%
Taylor expanded in x.re around inf
Applied rewrites40.4%
Taylor expanded in y.re around 0
Applied rewrites75.6%
if 4.8e16 < y.re < 3.30000000000000003e123Initial program 33.3%
Taylor expanded in y.im around 0
Applied rewrites22.5%
Taylor expanded in y.re around inf
Applied rewrites44.8%
Taylor expanded in x.im around 0
Applied rewrites61.4%
if 3.30000000000000003e123 < y.re Initial program 38.9%
Taylor expanded in y.im around 0
Applied rewrites36.2%
Applied rewrites69.5%
Taylor expanded in y.im around 0
Applied rewrites69.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re)) (t_1 (* (atan2 x.im x.re) y.re)))
(if (<= y.re 1.85e+121)
(* t_0 (cos t_1))
(* t_0 (sin (fma (PI) 0.5 t_1))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
t_1 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\\
\mathbf{if}\;y.re \leq 1.85 \cdot 10^{+121}:\\
\;\;\;\;t\_0 \cdot \cos t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, t\_1\right)\right)\\
\end{array}
\end{array}
if y.re < 1.85000000000000006e121Initial program 42.0%
Taylor expanded in y.im around 0
Applied rewrites28.3%
Taylor expanded in y.re around inf
Applied rewrites56.7%
if 1.85000000000000006e121 < y.re Initial program 37.8%
Taylor expanded in y.im around 0
Applied rewrites35.2%
Applied rewrites67.6%
Taylor expanded in y.im around 0
Applied rewrites67.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* (atan2 x.im x.re) y.re))))
(if (<= y.im -1.3e+41)
(* (pow (fma x.im x.im (* x.re x.re)) (* 0.5 y.re)) t_0)
(* (pow (hypot x.im x.re) 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 = cos((atan2(x_46_im, x_46_re) * y_46_re));
double tmp;
if (y_46_im <= -1.3e+41) {
tmp = pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), (0.5 * y_46_re)) * t_0;
} else {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(atan(x_46_im, x_46_re) * y_46_re)) tmp = 0.0 if (y_46_im <= -1.3e+41) tmp = Float64((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ Float64(0.5 * y_46_re)) * t_0); else tmp = Float64((hypot(x_46_im, x_46_re) ^ 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[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$im, -1.3e+41], N[(N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(0.5 * y$46$re), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{if}\;y.im \leq -1.3 \cdot 10^{+41}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\left(0.5 \cdot y.re\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot t\_0\\
\end{array}
\end{array}
if y.im < -1.3e41Initial program 37.9%
Taylor expanded in y.im around 0
Applied rewrites17.7%
Taylor expanded in y.re around inf
Applied rewrites24.2%
Applied rewrites34.3%
if -1.3e41 < y.im Initial program 42.2%
Taylor expanded in y.im around 0
Applied rewrites32.0%
Taylor expanded in y.re around inf
Applied rewrites63.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (or (<= y.re -9.5e-13) (not (<= y.re 1.15e-167)))
(*
(pow (fma x.im x.im (* x.re x.re)) (* 0.5 y.re))
(cos (* (atan2 x.im x.re) y.re)))
(* 1.0 (cos (* (log (hypot x.im x.re)) y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -9.5e-13) || !(y_46_re <= 1.15e-167)) {
tmp = pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), (0.5 * y_46_re)) * cos((atan2(x_46_im, x_46_re) * y_46_re));
} else {
tmp = 1.0 * cos((log(hypot(x_46_im, x_46_re)) * y_46_im));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -9.5e-13) || !(y_46_re <= 1.15e-167)) tmp = Float64((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ Float64(0.5 * y_46_re)) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))); else tmp = Float64(1.0 * cos(Float64(log(hypot(x_46_im, x_46_re)) * y_46_im))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -9.5e-13], N[Not[LessEqual[y$46$re, 1.15e-167]], $MachinePrecision]], N[(N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(0.5 * y$46$re), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Cos[N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -9.5 \cdot 10^{-13} \lor \neg \left(y.re \leq 1.15 \cdot 10^{-167}\right):\\
\;\;\;\;{\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\left(0.5 \cdot y.re\right)} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -9.49999999999999991e-13 or 1.1500000000000001e-167 < y.re Initial program 42.1%
Taylor expanded in y.im around 0
Applied rewrites33.1%
Taylor expanded in y.re around inf
Applied rewrites60.8%
Applied rewrites60.9%
if -9.49999999999999991e-13 < y.re < 1.1500000000000001e-167Initial program 40.2%
Taylor expanded in y.im around 0
Applied rewrites22.6%
Taylor expanded in y.re around inf
Applied rewrites48.5%
Taylor expanded in y.re around 0
Applied rewrites48.5%
Taylor expanded in y.re around 0
Applied rewrites50.0%
Final simplification56.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (cos (* (atan2 x.im x.re) y.re))))
(if (<= y.re -4e+151)
(* (pow x.im y.re) t_0)
(if (or (<= y.re -1650000000000.0) (not (<= y.re 9.8e-70)))
(* (pow x.re y.re) t_0)
(* 1.0 (cos (* (log (hypot x.im x.re)) y.im)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = cos((atan2(x_46_im, x_46_re) * y_46_re));
double tmp;
if (y_46_re <= -4e+151) {
tmp = pow(x_46_im, y_46_re) * t_0;
} else if ((y_46_re <= -1650000000000.0) || !(y_46_re <= 9.8e-70)) {
tmp = pow(x_46_re, y_46_re) * t_0;
} else {
tmp = 1.0 * cos((log(hypot(x_46_im, x_46_re)) * y_46_im));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re));
double tmp;
if (y_46_re <= -4e+151) {
tmp = Math.pow(x_46_im, y_46_re) * t_0;
} else if ((y_46_re <= -1650000000000.0) || !(y_46_re <= 9.8e-70)) {
tmp = Math.pow(x_46_re, y_46_re) * t_0;
} else {
tmp = 1.0 * Math.cos((Math.log(Math.hypot(x_46_im, x_46_re)) * y_46_im));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.cos((math.atan2(x_46_im, x_46_re) * y_46_re)) tmp = 0 if y_46_re <= -4e+151: tmp = math.pow(x_46_im, y_46_re) * t_0 elif (y_46_re <= -1650000000000.0) or not (y_46_re <= 9.8e-70): tmp = math.pow(x_46_re, y_46_re) * t_0 else: tmp = 1.0 * math.cos((math.log(math.hypot(x_46_im, x_46_re)) * y_46_im)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos(Float64(atan(x_46_im, x_46_re) * y_46_re)) tmp = 0.0 if (y_46_re <= -4e+151) tmp = Float64((x_46_im ^ y_46_re) * t_0); elseif ((y_46_re <= -1650000000000.0) || !(y_46_re <= 9.8e-70)) tmp = Float64((x_46_re ^ y_46_re) * t_0); else tmp = Float64(1.0 * cos(Float64(log(hypot(x_46_im, x_46_re)) * y_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = cos((atan2(x_46_im, x_46_re) * y_46_re)); tmp = 0.0; if (y_46_re <= -4e+151) tmp = (x_46_im ^ y_46_re) * t_0; elseif ((y_46_re <= -1650000000000.0) || ~((y_46_re <= 9.8e-70))) tmp = (x_46_re ^ y_46_re) * t_0; else tmp = 1.0 * cos((log(hypot(x_46_im, x_46_re)) * y_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -4e+151], N[(N[Power[x$46$im, y$46$re], $MachinePrecision] * t$95$0), $MachinePrecision], If[Or[LessEqual[y$46$re, -1650000000000.0], N[Not[LessEqual[y$46$re, 9.8e-70]], $MachinePrecision]], N[(N[Power[x$46$re, y$46$re], $MachinePrecision] * t$95$0), $MachinePrecision], N[(1.0 * N[Cos[N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{if}\;y.re \leq -4 \cdot 10^{+151}:\\
\;\;\;\;{x.im}^{y.re} \cdot t\_0\\
\mathbf{elif}\;y.re \leq -1650000000000 \lor \neg \left(y.re \leq 9.8 \cdot 10^{-70}\right):\\
\;\;\;\;{x.re}^{y.re} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -4.00000000000000007e151Initial program 45.9%
Taylor expanded in y.im around 0
Applied rewrites43.3%
Taylor expanded in y.re around inf
Applied rewrites86.6%
Taylor expanded in x.re around 0
Applied rewrites75.9%
if -4.00000000000000007e151 < y.re < -1.65e12 or 9.8000000000000001e-70 < y.re Initial program 40.8%
Taylor expanded in y.im around 0
Applied rewrites30.7%
Taylor expanded in y.re around inf
Applied rewrites56.7%
Taylor expanded in x.im around 0
Applied rewrites54.8%
if -1.65e12 < y.re < 9.8000000000000001e-70Initial program 40.5%
Taylor expanded in y.im around 0
Applied rewrites23.4%
Taylor expanded in y.re around inf
Applied rewrites46.1%
Taylor expanded in y.re around 0
Applied rewrites42.6%
Taylor expanded in y.re around 0
Applied rewrites44.1%
Final simplification53.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -45.0) (not (<= y.re 0.0095))) (* (pow x.im y.re) (cos (* (atan2 x.im x.re) y.re))) (* 1.0 (cos (* (log (hypot x.im x.re)) y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -45.0) || !(y_46_re <= 0.0095)) {
tmp = pow(x_46_im, y_46_re) * cos((atan2(x_46_im, x_46_re) * y_46_re));
} else {
tmp = 1.0 * cos((log(hypot(x_46_im, x_46_re)) * y_46_im));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -45.0) || !(y_46_re <= 0.0095)) {
tmp = Math.pow(x_46_im, y_46_re) * Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re));
} else {
tmp = 1.0 * Math.cos((Math.log(Math.hypot(x_46_im, x_46_re)) * y_46_im));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -45.0) or not (y_46_re <= 0.0095): tmp = math.pow(x_46_im, y_46_re) * math.cos((math.atan2(x_46_im, x_46_re) * y_46_re)) else: tmp = 1.0 * math.cos((math.log(math.hypot(x_46_im, x_46_re)) * y_46_im)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -45.0) || !(y_46_re <= 0.0095)) tmp = Float64((x_46_im ^ y_46_re) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))); else tmp = Float64(1.0 * cos(Float64(log(hypot(x_46_im, x_46_re)) * y_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -45.0) || ~((y_46_re <= 0.0095))) tmp = (x_46_im ^ y_46_re) * cos((atan2(x_46_im, x_46_re) * y_46_re)); else tmp = 1.0 * cos((log(hypot(x_46_im, x_46_re)) * y_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -45.0], N[Not[LessEqual[y$46$re, 0.0095]], $MachinePrecision]], N[(N[Power[x$46$im, y$46$re], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Cos[N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -45 \lor \neg \left(y.re \leq 0.0095\right):\\
\;\;\;\;{x.im}^{y.re} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -45 or 0.00949999999999999976 < y.re Initial program 41.2%
Taylor expanded in y.im around 0
Applied rewrites35.2%
Taylor expanded in y.re around inf
Applied rewrites67.4%
Taylor expanded in x.re around 0
Applied rewrites50.1%
if -45 < y.re < 0.00949999999999999976Initial program 41.6%
Taylor expanded in y.im around 0
Applied rewrites23.1%
Taylor expanded in y.re around inf
Applied rewrites44.7%
Taylor expanded in y.re around 0
Applied rewrites42.9%
Taylor expanded in y.re around 0
Applied rewrites44.1%
Final simplification47.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* 1.0 (cos (* (log (hypot 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 * cos((log(hypot(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 1.0 * Math.cos((Math.log(Math.hypot(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.cos((math.log(math.hypot(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 * cos(Float64(log(hypot(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 * cos((log(hypot(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[Cos[N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)
\end{array}
Initial program 41.4%
Taylor expanded in y.im around 0
Applied rewrites29.3%
Taylor expanded in y.re around inf
Applied rewrites56.3%
Taylor expanded in y.re around 0
Applied rewrites22.3%
Taylor expanded in y.re around 0
Applied rewrites22.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* 1.0 (sin (+ (/ (PI) 2.0) (* (atan2 x.im x.re) y.re)))))
\begin{array}{l}
\\
1 \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
Initial program 41.4%
Taylor expanded in y.im around 0
Applied rewrites29.3%
Taylor expanded in y.re around inf
Applied rewrites56.3%
Taylor expanded in y.re around 0
Applied rewrites22.3%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
+-commutativeN/A
lower-+.f6422.3
Applied rewrites22.3%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* 1.0 (cos (* (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) {
return 1.0 * cos((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
code = 1.0d0 * cos((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) {
return 1.0 * Math.cos((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): return 1.0 * math.cos((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) return Float64(1.0 * cos(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) tmp = 1.0 * cos((atan2(x_46_im, x_46_re) * y_46_re)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(1.0 * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
Initial program 41.4%
Taylor expanded in y.im around 0
Applied rewrites29.3%
Taylor expanded in y.re around inf
Applied rewrites56.3%
Taylor expanded in y.re around 0
Applied rewrites22.3%
herbie shell --seed 2025019
(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)))))