
(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 14 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 -1.05e-21)
(*
t_0
(sin (+ (- (fma y.im t_1 (* (atan2 x.im x.re) y.re))) (/ (PI) 2.0))))
(if (<= y.re 0.00068)
(*
(exp (* (- y.im) (atan2 x.im x.re)))
(sin (fma 0.5 (PI) (* y.im t_1))))
(* 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 -1.05 \cdot 10^{-21}:\\
\;\;\;\;t\_0 \cdot \sin \left(\left(-\mathsf{fma}\left(y.im, t\_1, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\\
\mathbf{elif}\;y.re \leq 0.00068:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\mathsf{fma}\left(0.5, \mathsf{PI}\left(\right), y.im \cdot t\_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(t\_1 \cdot y.im\right)\\
\end{array}
\end{array}
if y.re < -1.05000000000000006e-21Initial program 45.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
Applied rewrites84.5%
if -1.05000000000000006e-21 < y.re < 6.8e-4Initial program 39.5%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.2%
Taylor expanded in y.re around 0
Applied rewrites85.4%
if 6.8e-4 < y.re Initial program 42.9%
Taylor expanded in y.re around 0
Applied rewrites85.8%
Final simplification85.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.im x.re))))
(if (or (<= y.re -1.05e-21) (not (<= y.re 0.00068)))
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(cos (* t_0 y.im)))
(*
(exp (* (- y.im) (atan2 x.im x.re)))
(sin (fma 0.5 (PI) (* y.im t_0)))))))\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.05 \cdot 10^{-21} \lor \neg \left(y.re \leq 0.00068\right):\\
\;\;\;\;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(t\_0 \cdot y.im\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\mathsf{fma}\left(0.5, \mathsf{PI}\left(\right), y.im \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if y.re < -1.05000000000000006e-21 or 6.8e-4 < y.re Initial program 43.9%
Taylor expanded in y.re around 0
Applied rewrites84.3%
if -1.05000000000000006e-21 < y.re < 6.8e-4Initial program 39.5%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.2%
Taylor expanded in y.re around 0
Applied rewrites85.4%
Final simplification84.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -2.5e-8)
(*
(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 9.5e-8)
(*
(exp (* (- y.im) (atan2 x.im x.re)))
(sin (fma 0.5 (PI) (* y.im (log (hypot x.im x.re))))))
(* (pow (hypot x.im x.re) y.re) 1.0))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.5 \cdot 10^{-8}:\\
\;\;\;\;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 9.5 \cdot 10^{-8}:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\mathsf{fma}\left(0.5, \mathsf{PI}\left(\right), y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot 1\\
\end{array}
\end{array}
if y.re < -2.4999999999999999e-8Initial program 44.9%
Taylor expanded in y.re around inf
Applied rewrites77.6%
if -2.4999999999999999e-8 < y.re < 9.50000000000000036e-8Initial program 39.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites45.9%
Taylor expanded in y.re around 0
Applied rewrites85.0%
if 9.50000000000000036e-8 < y.re Initial program 42.2%
Taylor expanded in y.im around 0
Applied rewrites76.7%
Taylor expanded in y.re around 0
Applied rewrites77.8%
Final simplification81.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re)))
(if (<= y.re -1.05e-21)
(* t_0 (sin (fma (- (atan2 x.im x.re)) y.re (/ (PI) 2.0))))
(if (<= y.re 9.5e-8)
(*
(exp (* (- y.im) (atan2 x.im x.re)))
(sin (fma 0.5 (PI) (* y.im (log (hypot x.im x.re))))))
(* t_0 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.05 \cdot 10^{-21}:\\
\;\;\;\;t\_0 \cdot \sin \left(\mathsf{fma}\left(-\tan^{-1}_* \frac{x.im}{x.re}, y.re, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\\
\mathbf{elif}\;y.re \leq 9.5 \cdot 10^{-8}:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\mathsf{fma}\left(0.5, \mathsf{PI}\left(\right), y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot 1\\
\end{array}
\end{array}
if y.re < -1.05000000000000006e-21Initial program 45.1%
Taylor expanded in y.im around 0
Applied rewrites68.9%
Applied rewrites74.8%
if -1.05000000000000006e-21 < y.re < 9.50000000000000036e-8Initial program 39.8%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.5%
Taylor expanded in y.re around 0
Applied rewrites85.7%
if 9.50000000000000036e-8 < y.re Initial program 42.2%
Taylor expanded in y.im around 0
Applied rewrites76.7%
Taylor expanded in y.re around 0
Applied rewrites77.8%
Final simplification81.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re)))
(if (<= y.re -1.05e-21)
(* t_0 (sin (fma (- (atan2 x.im x.re)) y.re (/ (PI) 2.0))))
(if (<= y.re 1.3e-8)
(* 1.0 (exp (* (- y.im) (atan2 x.im x.re))))
(* t_0 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.05 \cdot 10^{-21}:\\
\;\;\;\;t\_0 \cdot \sin \left(\mathsf{fma}\left(-\tan^{-1}_* \frac{x.im}{x.re}, y.re, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\\
\mathbf{elif}\;y.re \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;1 \cdot e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot 1\\
\end{array}
\end{array}
if y.re < -1.05000000000000006e-21Initial program 45.1%
Taylor expanded in y.im around 0
Applied rewrites68.9%
Applied rewrites74.8%
if -1.05000000000000006e-21 < y.re < 1.3000000000000001e-8Initial program 39.8%
Taylor expanded in y.re around 0
Applied rewrites81.9%
Taylor expanded in x.re around -inf
Applied rewrites45.9%
Taylor expanded in y.im around 0
Applied rewrites80.4%
if 1.3000000000000001e-8 < y.re Initial program 42.2%
Taylor expanded in y.im around 0
Applied rewrites76.7%
Taylor expanded in y.re around 0
Applied rewrites77.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -65000000000000.0)
(* (pow (fma (/ (* x.im x.im) x.re) 0.5 x.re) y.re) 1.0)
(if (<= y.re 1.3e-8)
(* 1.0 (exp (* (- y.im) (atan2 x.im x.re))))
(* (pow (hypot x.im x.re) y.re) 1.0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -65000000000000.0) {
tmp = pow(fma(((x_46_im * x_46_im) / x_46_re), 0.5, x_46_re), y_46_re) * 1.0;
} else if (y_46_re <= 1.3e-8) {
tmp = 1.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) * 1.0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -65000000000000.0) tmp = Float64((fma(Float64(Float64(x_46_im * x_46_im) / x_46_re), 0.5, x_46_re) ^ y_46_re) * 1.0); elseif (y_46_re <= 1.3e-8) tmp = Float64(1.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) * 1.0); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -65000000000000.0], N[(N[Power[N[(N[(N[(x$46$im * x$46$im), $MachinePrecision] / x$46$re), $MachinePrecision] * 0.5 + x$46$re), $MachinePrecision], y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[y$46$re, 1.3e-8], N[(1.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] * 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -65000000000000:\\
\;\;\;\;{\left(\mathsf{fma}\left(\frac{x.im \cdot x.im}{x.re}, 0.5, x.re\right)\right)}^{y.re} \cdot 1\\
\mathbf{elif}\;y.re \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;1 \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 1\\
\end{array}
\end{array}
if y.re < -6.5e13Initial program 43.5%
Taylor expanded in y.im around 0
Applied rewrites71.9%
Taylor expanded in y.re around 0
Applied rewrites74.1%
Taylor expanded in x.im around 0
Applied rewrites78.4%
if -6.5e13 < y.re < 1.3000000000000001e-8Initial program 40.5%
Taylor expanded in y.re around 0
Applied rewrites81.6%
Taylor expanded in x.re around -inf
Applied rewrites44.3%
Taylor expanded in y.im around 0
Applied rewrites78.8%
if 1.3000000000000001e-8 < y.re Initial program 42.2%
Taylor expanded in y.im around 0
Applied rewrites76.7%
Taylor expanded in y.re around 0
Applied rewrites77.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.im -3.3e+40) (* (pow (* (fma (/ 0.5 x.re) (/ (* x.im x.im) x.re) 1.0) x.re) y.re) 1.0) (* (pow (hypot x.im x.re) y.re) 1.0)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -3.3e+40) {
tmp = pow((fma((0.5 / x_46_re), ((x_46_im * x_46_im) / x_46_re), 1.0) * x_46_re), y_46_re) * 1.0;
} else {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * 1.0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -3.3e+40) tmp = Float64((Float64(fma(Float64(0.5 / x_46_re), Float64(Float64(x_46_im * x_46_im) / x_46_re), 1.0) * x_46_re) ^ y_46_re) * 1.0); else tmp = Float64((hypot(x_46_im, x_46_re) ^ y_46_re) * 1.0); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -3.3e+40], N[(N[Power[N[(N[(N[(0.5 / x$46$re), $MachinePrecision] * N[(N[(x$46$im * x$46$im), $MachinePrecision] / x$46$re), $MachinePrecision] + 1.0), $MachinePrecision] * x$46$re), $MachinePrecision], y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -3.3 \cdot 10^{+40}:\\
\;\;\;\;{\left(\mathsf{fma}\left(\frac{0.5}{x.re}, \frac{x.im \cdot x.im}{x.re}, 1\right) \cdot x.re\right)}^{y.re} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot 1\\
\end{array}
\end{array}
if y.im < -3.2999999999999998e40Initial program 42.6%
Taylor expanded in y.im around 0
Applied rewrites27.8%
Taylor expanded in y.re around 0
Applied rewrites24.1%
Taylor expanded in x.re around inf
Applied rewrites38.0%
if -3.2999999999999998e40 < y.im Initial program 41.1%
Taylor expanded in y.im around 0
Applied rewrites73.0%
Taylor expanded in y.re around 0
Applied rewrites74.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (* x.im x.im) x.re)))
(if (<= y.re -2.4e-27)
(* (pow (* (fma (/ 0.5 x.re) t_0 1.0) x.re) y.re) 1.0)
(if (<= y.re 1.6e-5)
(fma (- y.im) (atan2 x.im x.re) 1.0)
(* (pow (fma t_0 0.5 x.re) y.re) 1.0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = (x_46_im * x_46_im) / x_46_re;
double tmp;
if (y_46_re <= -2.4e-27) {
tmp = pow((fma((0.5 / x_46_re), t_0, 1.0) * x_46_re), y_46_re) * 1.0;
} else if (y_46_re <= 1.6e-5) {
tmp = fma(-y_46_im, atan2(x_46_im, x_46_re), 1.0);
} else {
tmp = pow(fma(t_0, 0.5, x_46_re), y_46_re) * 1.0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(x_46_im * x_46_im) / x_46_re) tmp = 0.0 if (y_46_re <= -2.4e-27) tmp = Float64((Float64(fma(Float64(0.5 / x_46_re), t_0, 1.0) * x_46_re) ^ y_46_re) * 1.0); elseif (y_46_re <= 1.6e-5) tmp = fma(Float64(-y_46_im), atan(x_46_im, x_46_re), 1.0); else tmp = Float64((fma(t_0, 0.5, x_46_re) ^ y_46_re) * 1.0); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * x$46$im), $MachinePrecision] / x$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -2.4e-27], N[(N[Power[N[(N[(N[(0.5 / x$46$re), $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision] * x$46$re), $MachinePrecision], y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[y$46$re, 1.6e-5], N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision] + 1.0), $MachinePrecision], N[(N[Power[N[(t$95$0 * 0.5 + x$46$re), $MachinePrecision], y$46$re], $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.im \cdot x.im}{x.re}\\
\mathbf{if}\;y.re \leq -2.4 \cdot 10^{-27}:\\
\;\;\;\;{\left(\mathsf{fma}\left(\frac{0.5}{x.re}, t\_0, 1\right) \cdot x.re\right)}^{y.re} \cdot 1\\
\mathbf{elif}\;y.re \leq 1.6 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(-y.im, \tan^{-1}_* \frac{x.im}{x.re}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(t\_0, 0.5, x.re\right)\right)}^{y.re} \cdot 1\\
\end{array}
\end{array}
if y.re < -2.40000000000000002e-27Initial program 46.2%
Taylor expanded in y.im around 0
Applied rewrites67.6%
Taylor expanded in y.re around 0
Applied rewrites69.5%
Taylor expanded in x.re around inf
Applied rewrites71.4%
if -2.40000000000000002e-27 < y.re < 1.59999999999999993e-5Initial program 39.0%
Taylor expanded in y.re around 0
Applied rewrites81.4%
Taylor expanded in x.re around -inf
Applied rewrites45.4%
Taylor expanded in y.im around 0
Applied rewrites55.8%
if 1.59999999999999993e-5 < y.re Initial program 42.9%
Taylor expanded in y.im around 0
Applied rewrites76.3%
Taylor expanded in y.re around 0
Applied rewrites77.9%
Taylor expanded in x.im around 0
Applied rewrites76.3%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -2.55e-27) (not (<= y.re 1.6e-5))) (* (pow (fma (/ (* x.im x.im) x.re) 0.5 x.re) y.re) 1.0) (fma (- y.im) (atan2 x.im x.re) 1.0)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -2.55e-27) || !(y_46_re <= 1.6e-5)) {
tmp = pow(fma(((x_46_im * x_46_im) / x_46_re), 0.5, x_46_re), y_46_re) * 1.0;
} else {
tmp = fma(-y_46_im, atan2(x_46_im, x_46_re), 1.0);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -2.55e-27) || !(y_46_re <= 1.6e-5)) tmp = Float64((fma(Float64(Float64(x_46_im * x_46_im) / x_46_re), 0.5, x_46_re) ^ y_46_re) * 1.0); else tmp = fma(Float64(-y_46_im), atan(x_46_im, x_46_re), 1.0); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -2.55e-27], N[Not[LessEqual[y$46$re, 1.6e-5]], $MachinePrecision]], N[(N[Power[N[(N[(N[(x$46$im * x$46$im), $MachinePrecision] / x$46$re), $MachinePrecision] * 0.5 + x$46$re), $MachinePrecision], y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.55 \cdot 10^{-27} \lor \neg \left(y.re \leq 1.6 \cdot 10^{-5}\right):\\
\;\;\;\;{\left(\mathsf{fma}\left(\frac{x.im \cdot x.im}{x.re}, 0.5, x.re\right)\right)}^{y.re} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y.im, \tan^{-1}_* \frac{x.im}{x.re}, 1\right)\\
\end{array}
\end{array}
if y.re < -2.55e-27 or 1.59999999999999993e-5 < y.re Initial program 44.3%
Taylor expanded in y.im around 0
Applied rewrites72.4%
Taylor expanded in y.re around 0
Applied rewrites74.1%
Taylor expanded in x.im around 0
Applied rewrites74.1%
if -2.55e-27 < y.re < 1.59999999999999993e-5Initial program 39.0%
Taylor expanded in y.re around 0
Applied rewrites81.4%
Taylor expanded in x.re around -inf
Applied rewrites45.4%
Taylor expanded in y.im around 0
Applied rewrites55.8%
Final simplification64.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= x.re -5e-310)
(* (pow (- x.re) y.re) 1.0)
(if (<= x.re 1.5e-18)
(* (pow (* x.im x.im) (/ y.re 2.0)) 1.0)
(* (pow x.re y.re) 1.0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (x_46_re <= -5e-310) {
tmp = pow(-x_46_re, y_46_re) * 1.0;
} else if (x_46_re <= 1.5e-18) {
tmp = pow((x_46_im * x_46_im), (y_46_re / 2.0)) * 1.0;
} else {
tmp = pow(x_46_re, y_46_re) * 1.0;
}
return tmp;
}
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) :: tmp
if (x_46re <= (-5d-310)) then
tmp = (-x_46re ** y_46re) * 1.0d0
else if (x_46re <= 1.5d-18) then
tmp = ((x_46im * x_46im) ** (y_46re / 2.0d0)) * 1.0d0
else
tmp = (x_46re ** y_46re) * 1.0d0
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 tmp;
if (x_46_re <= -5e-310) {
tmp = Math.pow(-x_46_re, y_46_re) * 1.0;
} else if (x_46_re <= 1.5e-18) {
tmp = Math.pow((x_46_im * x_46_im), (y_46_re / 2.0)) * 1.0;
} else {
tmp = Math.pow(x_46_re, y_46_re) * 1.0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if x_46_re <= -5e-310: tmp = math.pow(-x_46_re, y_46_re) * 1.0 elif x_46_re <= 1.5e-18: tmp = math.pow((x_46_im * x_46_im), (y_46_re / 2.0)) * 1.0 else: tmp = math.pow(x_46_re, y_46_re) * 1.0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (x_46_re <= -5e-310) tmp = Float64((Float64(-x_46_re) ^ y_46_re) * 1.0); elseif (x_46_re <= 1.5e-18) tmp = Float64((Float64(x_46_im * x_46_im) ^ Float64(y_46_re / 2.0)) * 1.0); else tmp = Float64((x_46_re ^ y_46_re) * 1.0); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if (x_46_re <= -5e-310) tmp = (-x_46_re ^ y_46_re) * 1.0; elseif (x_46_re <= 1.5e-18) tmp = ((x_46_im * x_46_im) ^ (y_46_re / 2.0)) * 1.0; else tmp = (x_46_re ^ y_46_re) * 1.0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[x$46$re, -5e-310], N[(N[Power[(-x$46$re), y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[x$46$re, 1.5e-18], N[(N[Power[N[(x$46$im * x$46$im), $MachinePrecision], N[(y$46$re / 2.0), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Power[x$46$re, y$46$re], $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5 \cdot 10^{-310}:\\
\;\;\;\;{\left(-x.re\right)}^{y.re} \cdot 1\\
\mathbf{elif}\;x.re \leq 1.5 \cdot 10^{-18}:\\
\;\;\;\;{\left(x.im \cdot x.im\right)}^{\left(\frac{y.re}{2}\right)} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;{x.re}^{y.re} \cdot 1\\
\end{array}
\end{array}
if x.re < -4.999999999999985e-310Initial program 43.7%
Taylor expanded in y.im around 0
Applied rewrites65.2%
Taylor expanded in y.re around 0
Applied rewrites65.8%
Taylor expanded in x.re around -inf
Applied rewrites61.3%
if -4.999999999999985e-310 < x.re < 1.49999999999999991e-18Initial program 54.5%
Taylor expanded in y.im around 0
Applied rewrites58.0%
Taylor expanded in y.re around 0
Applied rewrites62.3%
Taylor expanded in x.re around 0
Applied rewrites50.4%
Applied rewrites55.1%
if 1.49999999999999991e-18 < x.re Initial program 23.7%
Taylor expanded in y.im around 0
Applied rewrites66.0%
Taylor expanded in y.re around 0
Applied rewrites63.0%
Taylor expanded in x.re around inf
Applied rewrites62.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -2.1e-11) (not (<= y.re 1.55))) (* (pow x.im y.re) 1.0) 1.0))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -2.1e-11) || !(y_46_re <= 1.55)) {
tmp = pow(x_46_im, y_46_re) * 1.0;
} else {
tmp = 1.0;
}
return tmp;
}
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) :: tmp
if ((y_46re <= (-2.1d-11)) .or. (.not. (y_46re <= 1.55d0))) then
tmp = (x_46im ** y_46re) * 1.0d0
else
tmp = 1.0d0
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 tmp;
if ((y_46_re <= -2.1e-11) || !(y_46_re <= 1.55)) {
tmp = Math.pow(x_46_im, y_46_re) * 1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -2.1e-11) or not (y_46_re <= 1.55): tmp = math.pow(x_46_im, y_46_re) * 1.0 else: tmp = 1.0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -2.1e-11) || !(y_46_re <= 1.55)) tmp = Float64((x_46_im ^ y_46_re) * 1.0); else tmp = 1.0; 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 <= -2.1e-11) || ~((y_46_re <= 1.55))) tmp = (x_46_im ^ y_46_re) * 1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -2.1e-11], N[Not[LessEqual[y$46$re, 1.55]], $MachinePrecision]], N[(N[Power[x$46$im, y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.1 \cdot 10^{-11} \lor \neg \left(y.re \leq 1.55\right):\\
\;\;\;\;{x.im}^{y.re} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y.re < -2.0999999999999999e-11 or 1.55000000000000004 < y.re Initial program 43.4%
Taylor expanded in y.im around 0
Applied rewrites73.6%
Taylor expanded in y.re around 0
Applied rewrites75.4%
Taylor expanded in x.re around 0
Applied rewrites54.5%
if -2.0999999999999999e-11 < y.re < 1.55000000000000004Initial program 39.9%
Taylor expanded in y.im around 0
Applied rewrites55.4%
Taylor expanded in y.re around 0
Applied rewrites54.6%
Final simplification54.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= x.im -1.9e-296) (* (pow (- x.im) y.re) 1.0) (if (<= x.im 5.5e-27) (* (pow x.re y.re) 1.0) (* (pow x.im y.re) 1.0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (x_46_im <= -1.9e-296) {
tmp = pow(-x_46_im, y_46_re) * 1.0;
} else if (x_46_im <= 5.5e-27) {
tmp = pow(x_46_re, y_46_re) * 1.0;
} else {
tmp = pow(x_46_im, y_46_re) * 1.0;
}
return tmp;
}
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) :: tmp
if (x_46im <= (-1.9d-296)) then
tmp = (-x_46im ** y_46re) * 1.0d0
else if (x_46im <= 5.5d-27) then
tmp = (x_46re ** y_46re) * 1.0d0
else
tmp = (x_46im ** y_46re) * 1.0d0
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 tmp;
if (x_46_im <= -1.9e-296) {
tmp = Math.pow(-x_46_im, y_46_re) * 1.0;
} else if (x_46_im <= 5.5e-27) {
tmp = Math.pow(x_46_re, y_46_re) * 1.0;
} else {
tmp = Math.pow(x_46_im, y_46_re) * 1.0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if x_46_im <= -1.9e-296: tmp = math.pow(-x_46_im, y_46_re) * 1.0 elif x_46_im <= 5.5e-27: tmp = math.pow(x_46_re, y_46_re) * 1.0 else: tmp = math.pow(x_46_im, y_46_re) * 1.0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (x_46_im <= -1.9e-296) tmp = Float64((Float64(-x_46_im) ^ y_46_re) * 1.0); elseif (x_46_im <= 5.5e-27) tmp = Float64((x_46_re ^ y_46_re) * 1.0); else tmp = Float64((x_46_im ^ y_46_re) * 1.0); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if (x_46_im <= -1.9e-296) tmp = (-x_46_im ^ y_46_re) * 1.0; elseif (x_46_im <= 5.5e-27) tmp = (x_46_re ^ y_46_re) * 1.0; else tmp = (x_46_im ^ y_46_re) * 1.0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[x$46$im, -1.9e-296], N[(N[Power[(-x$46$im), y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[x$46$im, 5.5e-27], N[(N[Power[x$46$re, y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Power[x$46$im, y$46$re], $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -1.9 \cdot 10^{-296}:\\
\;\;\;\;{\left(-x.im\right)}^{y.re} \cdot 1\\
\mathbf{elif}\;x.im \leq 5.5 \cdot 10^{-27}:\\
\;\;\;\;{x.re}^{y.re} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;{x.im}^{y.re} \cdot 1\\
\end{array}
\end{array}
if x.im < -1.9000000000000001e-296Initial program 43.4%
Taylor expanded in y.im around 0
Applied rewrites62.1%
Taylor expanded in y.re around 0
Applied rewrites65.0%
Taylor expanded in x.im around -inf
Applied rewrites60.4%
if -1.9000000000000001e-296 < x.im < 5.5000000000000002e-27Initial program 45.0%
Taylor expanded in y.im around 0
Applied rewrites63.0%
Taylor expanded in y.re around 0
Applied rewrites61.4%
Taylor expanded in x.re around inf
Applied rewrites52.0%
if 5.5000000000000002e-27 < x.im Initial program 33.7%
Taylor expanded in y.im around 0
Applied rewrites66.7%
Taylor expanded in y.re around 0
Applied rewrites65.1%
Taylor expanded in x.re around 0
Applied rewrites65.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -2.1e-11) (* (pow x.im y.re) 1.0) (if (<= y.re 2e-5) 1.0 (* (pow x.re y.re) 1.0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -2.1e-11) {
tmp = pow(x_46_im, y_46_re) * 1.0;
} else if (y_46_re <= 2e-5) {
tmp = 1.0;
} else {
tmp = pow(x_46_re, y_46_re) * 1.0;
}
return tmp;
}
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) :: tmp
if (y_46re <= (-2.1d-11)) then
tmp = (x_46im ** y_46re) * 1.0d0
else if (y_46re <= 2d-5) then
tmp = 1.0d0
else
tmp = (x_46re ** y_46re) * 1.0d0
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 tmp;
if (y_46_re <= -2.1e-11) {
tmp = Math.pow(x_46_im, y_46_re) * 1.0;
} else if (y_46_re <= 2e-5) {
tmp = 1.0;
} else {
tmp = Math.pow(x_46_re, y_46_re) * 1.0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if y_46_re <= -2.1e-11: tmp = math.pow(x_46_im, y_46_re) * 1.0 elif y_46_re <= 2e-5: tmp = 1.0 else: tmp = math.pow(x_46_re, y_46_re) * 1.0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -2.1e-11) tmp = Float64((x_46_im ^ y_46_re) * 1.0); elseif (y_46_re <= 2e-5) tmp = 1.0; else tmp = Float64((x_46_re ^ y_46_re) * 1.0); 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 <= -2.1e-11) tmp = (x_46_im ^ y_46_re) * 1.0; elseif (y_46_re <= 2e-5) tmp = 1.0; else tmp = (x_46_re ^ y_46_re) * 1.0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -2.1e-11], N[(N[Power[x$46$im, y$46$re], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[y$46$re, 2e-5], 1.0, N[(N[Power[x$46$re, y$46$re], $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.1 \cdot 10^{-11}:\\
\;\;\;\;{x.im}^{y.re} \cdot 1\\
\mathbf{elif}\;y.re \leq 2 \cdot 10^{-5}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;{x.re}^{y.re} \cdot 1\\
\end{array}
\end{array}
if y.re < -2.0999999999999999e-11Initial program 44.0%
Taylor expanded in y.im around 0
Applied rewrites70.3%
Taylor expanded in y.re around 0
Applied rewrites72.3%
Taylor expanded in x.re around 0
Applied rewrites50.5%
if -2.0999999999999999e-11 < y.re < 2.00000000000000016e-5Initial program 39.9%
Taylor expanded in y.im around 0
Applied rewrites55.4%
Taylor expanded in y.re around 0
Applied rewrites54.6%
if 2.00000000000000016e-5 < y.re Initial program 42.9%
Taylor expanded in y.im around 0
Applied rewrites76.3%
Taylor expanded in y.re around 0
Applied rewrites77.9%
Taylor expanded in x.re around inf
Applied rewrites68.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 1.0)
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
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
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return 1.0
function code(x_46_re, x_46_im, y_46_re, y_46_im) return 1.0 end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 1.0; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 41.4%
Taylor expanded in y.im around 0
Applied rewrites63.5%
Taylor expanded in y.re around 0
Applied rewrites31.9%
herbie shell --seed 2025018
(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)))))