
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.05e+148)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) t_0)
(* t_0 (+ 3.0 (+ beta alpha))))
(/ (/ (+ 1.0 alpha) beta) beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.05e+148) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / t_0) / (t_0 * (3.0 + (beta + alpha)));
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.05e+148) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / t_0) / Float64(t_0 * Float64(3.0 + Float64(beta + alpha)))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / beta); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.05e+148], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 * N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.05 \cdot 10^{+148}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_0}}{t\_0 \cdot \left(3 + \left(\beta + \alpha\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 1.04999999999999999e148Initial program 99.7%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.8%
if 1.04999999999999999e148 < beta Initial program 83.6%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in beta around inf
Applied rewrites99.0%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.05e+148)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) (* t_0 t_0))
(+ 3.0 (+ beta alpha)))
(/ (/ (+ 1.0 alpha) beta) beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.05e+148) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / (t_0 * t_0)) / (3.0 + (beta + alpha));
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.05e+148) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / Float64(t_0 * t_0)) / Float64(3.0 + Float64(beta + alpha))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / beta); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.05e+148], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.05 \cdot 10^{+148}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_0 \cdot t\_0}}{3 + \left(\beta + \alpha\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 1.04999999999999999e148Initial program 99.7%
Applied rewrites99.7%
if 1.04999999999999999e148 < beta Initial program 83.6%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in beta around inf
Applied rewrites99.0%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 7.5e-20)
(/ (/ (+ alpha 1.0) (* (+ 2.0 alpha) (+ 2.0 alpha))) (+ 3.0 (+ beta alpha)))
(if (<= beta 1.32e+16)
(/
(/ (+ 1.0 beta) (fma (+ 4.0 beta) beta 4.0))
(* (+ (/ 3.0 beta) 1.0) beta))
(/ (/ (+ 1.0 alpha) beta) (+ (+ beta alpha) 3.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 7.5e-20) {
tmp = ((alpha + 1.0) / ((2.0 + alpha) * (2.0 + alpha))) / (3.0 + (beta + alpha));
} else if (beta <= 1.32e+16) {
tmp = ((1.0 + beta) / fma((4.0 + beta), beta, 4.0)) / (((3.0 / beta) + 1.0) * beta);
} else {
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 7.5e-20) tmp = Float64(Float64(Float64(alpha + 1.0) / Float64(Float64(2.0 + alpha) * Float64(2.0 + alpha))) / Float64(3.0 + Float64(beta + alpha))); elseif (beta <= 1.32e+16) tmp = Float64(Float64(Float64(1.0 + beta) / fma(Float64(4.0 + beta), beta, 4.0)) / Float64(Float64(Float64(3.0 / beta) + 1.0) * beta)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(beta + alpha) + 3.0)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 7.5e-20], N[(N[(N[(alpha + 1.0), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] * N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[beta, 1.32e+16], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(4.0 + beta), $MachinePrecision] * beta + 4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(3.0 / beta), $MachinePrecision] + 1.0), $MachinePrecision] * beta), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 7.5 \cdot 10^{-20}:\\
\;\;\;\;\frac{\frac{\alpha + 1}{\left(2 + \alpha\right) \cdot \left(2 + \alpha\right)}}{3 + \left(\beta + \alpha\right)}\\
\mathbf{elif}\;\beta \leq 1.32 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\mathsf{fma}\left(4 + \beta, \beta, 4\right)}}{\left(\frac{3}{\beta} + 1\right) \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\beta + \alpha\right) + 3}\\
\end{array}
\end{array}
if beta < 7.49999999999999981e-20Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in beta around 0
Applied rewrites99.9%
Taylor expanded in beta around 0
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
if 7.49999999999999981e-20 < beta < 1.32e16Initial program 99.2%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in beta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6497.8
Applied rewrites97.8%
Taylor expanded in beta around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
lower-+.f6497.7
Applied rewrites97.7%
Taylor expanded in alpha around 0
Applied rewrites97.4%
if 1.32e16 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f6498.9
Applied rewrites98.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 3.4e-72)
(/ (/ (+ alpha 1.0) (* (+ 2.0 alpha) (+ 2.0 alpha))) (+ 3.0 (+ beta alpha)))
(if (<= beta 1.3e+16)
(/ (/ (+ 1.0 beta) (fma (+ 4.0 beta) beta 4.0)) (+ 3.0 beta))
(/ (/ (+ 1.0 alpha) beta) (+ (+ beta alpha) 3.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.4e-72) {
tmp = ((alpha + 1.0) / ((2.0 + alpha) * (2.0 + alpha))) / (3.0 + (beta + alpha));
} else if (beta <= 1.3e+16) {
tmp = ((1.0 + beta) / fma((4.0 + beta), beta, 4.0)) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.4e-72) tmp = Float64(Float64(Float64(alpha + 1.0) / Float64(Float64(2.0 + alpha) * Float64(2.0 + alpha))) / Float64(3.0 + Float64(beta + alpha))); elseif (beta <= 1.3e+16) tmp = Float64(Float64(Float64(1.0 + beta) / fma(Float64(4.0 + beta), beta, 4.0)) / Float64(3.0 + beta)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(beta + alpha) + 3.0)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 3.4e-72], N[(N[(N[(alpha + 1.0), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] * N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[beta, 1.3e+16], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(4.0 + beta), $MachinePrecision] * beta + 4.0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.4 \cdot 10^{-72}:\\
\;\;\;\;\frac{\frac{\alpha + 1}{\left(2 + \alpha\right) \cdot \left(2 + \alpha\right)}}{3 + \left(\beta + \alpha\right)}\\
\mathbf{elif}\;\beta \leq 1.3 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\mathsf{fma}\left(4 + \beta, \beta, 4\right)}}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\beta + \alpha\right) + 3}\\
\end{array}
\end{array}
if beta < 3.3999999999999998e-72Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in beta around 0
Applied rewrites99.9%
Taylor expanded in beta around 0
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
if 3.3999999999999998e-72 < beta < 1.3e16Initial program 99.6%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.5
Applied rewrites98.5%
Taylor expanded in beta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6498.7
Applied rewrites98.7%
Taylor expanded in alpha around 0
lower-+.f6498.3
Applied rewrites98.3%
if 1.3e16 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f6498.9
Applied rewrites98.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 3.4e-72)
(/ (+ 1.0 alpha) (* (+ 3.0 alpha) (* (+ 2.0 alpha) (+ 2.0 alpha))))
(if (<= beta 1.3e+16)
(/ (/ (+ 1.0 beta) (fma (+ 4.0 beta) beta 4.0)) (+ 3.0 beta))
(/ (/ (+ 1.0 alpha) beta) (+ (+ beta alpha) 3.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.4e-72) {
tmp = (1.0 + alpha) / ((3.0 + alpha) * ((2.0 + alpha) * (2.0 + alpha)));
} else if (beta <= 1.3e+16) {
tmp = ((1.0 + beta) / fma((4.0 + beta), beta, 4.0)) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.4e-72) tmp = Float64(Float64(1.0 + alpha) / Float64(Float64(3.0 + alpha) * Float64(Float64(2.0 + alpha) * Float64(2.0 + alpha)))); elseif (beta <= 1.3e+16) tmp = Float64(Float64(Float64(1.0 + beta) / fma(Float64(4.0 + beta), beta, 4.0)) / Float64(3.0 + beta)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(beta + alpha) + 3.0)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 3.4e-72], N[(N[(1.0 + alpha), $MachinePrecision] / N[(N[(3.0 + alpha), $MachinePrecision] * N[(N[(2.0 + alpha), $MachinePrecision] * N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[beta, 1.3e+16], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(4.0 + beta), $MachinePrecision] * beta + 4.0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.4 \cdot 10^{-72}:\\
\;\;\;\;\frac{1 + \alpha}{\left(3 + \alpha\right) \cdot \left(\left(2 + \alpha\right) \cdot \left(2 + \alpha\right)\right)}\\
\mathbf{elif}\;\beta \leq 1.3 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\mathsf{fma}\left(4 + \beta, \beta, 4\right)}}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\beta + \alpha\right) + 3}\\
\end{array}
\end{array}
if beta < 3.3999999999999998e-72Initial program 99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
if 3.3999999999999998e-72 < beta < 1.3e16Initial program 99.6%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.5
Applied rewrites98.5%
Taylor expanded in beta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6498.7
Applied rewrites98.7%
Taylor expanded in alpha around 0
lower-+.f6498.3
Applied rewrites98.3%
if 1.3e16 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f6498.9
Applied rewrites98.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0))) (t_1 (+ t_0 1.0)))
(if (<= beta 1.3e+16)
(/ (/ (+ 1.0 beta) (fma (+ 4.0 beta) beta 4.0)) t_1)
(/ (/ (+ 1.0 alpha) t_0) t_1))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
double t_1 = t_0 + 1.0;
double tmp;
if (beta <= 1.3e+16) {
tmp = ((1.0 + beta) / fma((4.0 + beta), beta, 4.0)) / t_1;
} else {
tmp = ((1.0 + alpha) / t_0) / t_1;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) t_1 = Float64(t_0 + 1.0) tmp = 0.0 if (beta <= 1.3e+16) tmp = Float64(Float64(Float64(1.0 + beta) / fma(Float64(4.0 + beta), beta, 4.0)) / t_1); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / t_1); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + 1.0), $MachinePrecision]}, If[LessEqual[beta, 1.3e+16], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(4.0 + beta), $MachinePrecision] * beta + 4.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
t_1 := t\_0 + 1\\
\mathbf{if}\;\beta \leq 1.3 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\mathsf{fma}\left(4 + \beta, \beta, 4\right)}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{t\_1}\\
\end{array}
\end{array}
if beta < 1.3e16Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
Taylor expanded in beta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
if 1.3e16 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-+.f6498.9
Applied rewrites98.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 1.3e+16)
(/
(/ (+ 1.0 beta) (fma (+ 4.0 beta) beta 4.0))
(+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0))
(/ (/ (+ 1.0 alpha) beta) (+ (+ beta alpha) 3.0))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1.3e+16) {
tmp = ((1.0 + beta) / fma((4.0 + beta), beta, 4.0)) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1.3e+16) tmp = Float64(Float64(Float64(1.0 + beta) / fma(Float64(4.0 + beta), beta, 4.0)) / Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(beta + alpha) + 3.0)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 1.3e+16], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(4.0 + beta), $MachinePrecision] * beta + 4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 1.3 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\mathsf{fma}\left(4 + \beta, \beta, 4\right)}}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\beta + \alpha\right) + 3}\\
\end{array}
\end{array}
if beta < 1.3e16Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
Taylor expanded in beta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
if 1.3e16 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f6498.9
Applied rewrites98.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 1.3e+16) (/ (/ (+ 1.0 beta) (fma (+ 4.0 beta) beta 4.0)) (+ 3.0 beta)) (/ (/ (+ 1.0 alpha) beta) (+ (+ beta alpha) 3.0))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1.3e+16) {
tmp = ((1.0 + beta) / fma((4.0 + beta), beta, 4.0)) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1.3e+16) tmp = Float64(Float64(Float64(1.0 + beta) / fma(Float64(4.0 + beta), beta, 4.0)) / Float64(3.0 + beta)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(beta + alpha) + 3.0)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 1.3e+16], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(4.0 + beta), $MachinePrecision] * beta + 4.0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 1.3 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\mathsf{fma}\left(4 + \beta, \beta, 4\right)}}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\beta + \alpha\right) + 3}\\
\end{array}
\end{array}
if beta < 1.3e16Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
Taylor expanded in beta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
Taylor expanded in alpha around 0
lower-+.f6497.9
Applied rewrites97.9%
if 1.3e16 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f6498.9
Applied rewrites98.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.8) (/ 0.25 (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ (+ beta alpha) 3.0))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.8) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 4.8d0) then
tmp = 0.25d0 / (((alpha + beta) + (2.0d0 * 1.0d0)) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / ((beta + alpha) + 3.0d0)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 4.8) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 4.8: tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0) else: tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.8) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(beta + alpha) + 3.0)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 4.8)
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
else
tmp = ((1.0 + alpha) / beta) / ((beta + alpha) + 3.0);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 4.8], N[(0.25 / N[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.8:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\beta + \alpha\right) + 3}\\
\end{array}
\end{array}
if beta < 4.79999999999999982Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
Taylor expanded in beta around 0
Applied rewrites97.8%
if 4.79999999999999982 < beta Initial program 90.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.3
Applied rewrites97.3%
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f6497.3
Applied rewrites97.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 5.0) (/ 0.25 (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5.0) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 5.0d0) then
tmp = 0.25d0 / (((alpha + beta) + (2.0d0 * 1.0d0)) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 5.0) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 5.0: tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0) else: tmp = ((1.0 + alpha) / beta) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 5.0) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(3.0 + beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 5.0)
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
else
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 5.0], N[(0.25 / N[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 5:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 5Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
Taylor expanded in beta around 0
Applied rewrites97.8%
if 5 < beta Initial program 90.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.3
Applied rewrites97.3%
Taylor expanded in alpha around 0
lower-+.f6497.2
Applied rewrites97.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 0.92) (/ (/ (+ 1.0 beta) 2.0) (+ 2.0 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 0.92) {
tmp = ((1.0 + beta) / 2.0) / (2.0 + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 0.92d0) then
tmp = ((1.0d0 + beta) / 2.0d0) / (2.0d0 + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 0.92) {
tmp = ((1.0 + beta) / 2.0) / (2.0 + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 0.92: tmp = ((1.0 + beta) / 2.0) / (2.0 + 1.0) else: tmp = ((1.0 + alpha) / beta) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 0.92) tmp = Float64(Float64(Float64(1.0 + beta) / 2.0) / Float64(2.0 + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(3.0 + beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 0.92)
tmp = ((1.0 + beta) / 2.0) / (2.0 + 1.0);
else
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 0.92], N[(N[(N[(1.0 + beta), $MachinePrecision] / 2.0), $MachinePrecision] / N[(2.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 0.92:\\
\;\;\;\;\frac{\frac{1 + \beta}{2}}{2 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 0.92000000000000004Initial program 99.9%
Taylor expanded in alpha around inf
lower-+.f6418.7
Applied rewrites18.7%
Taylor expanded in beta around 0
+-commutativeN/A
metadata-evalN/A
lower-+.f6418.7
Applied rewrites18.7%
Taylor expanded in beta around 0
+-commutativeN/A
metadata-evalN/A
lower-+.f6418.7
Applied rewrites18.7%
Taylor expanded in alpha around 0
Applied rewrites18.7%
Taylor expanded in alpha around 0
Applied rewrites18.7%
if 0.92000000000000004 < beta Initial program 90.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.0
Applied rewrites97.0%
Taylor expanded in alpha around 0
lower-+.f6497.0
Applied rewrites97.0%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ (/ (+ 1.0 alpha) beta) (+ 3.0 beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
return ((1.0 + alpha) / beta) / (3.0 + beta);
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = ((1.0d0 + alpha) / beta) / (3.0d0 + beta)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return ((1.0 + alpha) / beta) / (3.0 + beta);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return ((1.0 + alpha) / beta) / (3.0 + beta)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(3.0 + beta)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{\frac{1 + \alpha}{\beta}}{3 + \beta}
\end{array}
Initial program 94.6%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6456.6
Applied rewrites56.6%
Taylor expanded in alpha around 0
lower-+.f6456.6
Applied rewrites56.6%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 1.55e-12) (/ (/ 1.0 beta) (+ 3.0 beta)) (/ (/ alpha beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = (1.0 / beta) / (3.0 + beta);
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 1.55d-12) then
tmp = (1.0d0 / beta) / (3.0d0 + beta)
else
tmp = (alpha / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = (1.0 / beta) / (3.0 + beta);
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if alpha <= 1.55e-12: tmp = (1.0 / beta) / (3.0 + beta) else: tmp = (alpha / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (alpha <= 1.55e-12) tmp = Float64(Float64(1.0 / beta) / Float64(3.0 + beta)); else tmp = Float64(Float64(alpha / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (alpha <= 1.55e-12)
tmp = (1.0 / beta) / (3.0 + beta);
else
tmp = (alpha / beta) / beta;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[alpha, 1.55e-12], N[(N[(1.0 / beta), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(N[(alpha / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{1}{\beta}}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if alpha < 1.5500000000000001e-12Initial program 99.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6451.4
Applied rewrites51.4%
Taylor expanded in alpha around 0
lower-+.f6451.4
Applied rewrites51.4%
Taylor expanded in alpha around 0
lower-/.f6451.0
Applied rewrites51.0%
if 1.5500000000000001e-12 < alpha Initial program 56.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6473.1
Applied rewrites73.1%
Taylor expanded in alpha around inf
Applied rewrites68.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6490.8
Applied rewrites90.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ (/ (+ 1.0 alpha) beta) beta))
assert(alpha < beta);
double code(double alpha, double beta) {
return ((1.0 + alpha) / beta) / beta;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = ((1.0d0 + alpha) / beta) / beta
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return ((1.0 + alpha) / beta) / beta;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return ((1.0 + alpha) / beta) / beta
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(Float64(Float64(1.0 + alpha) / beta) / beta) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = ((1.0 + alpha) / beta) / beta;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{\frac{1 + \alpha}{\beta}}{\beta}
\end{array}
Initial program 94.6%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6456.6
Applied rewrites56.6%
Taylor expanded in beta around inf
Applied rewrites56.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 1.55e-12) (/ (/ 1.0 beta) beta) (/ (/ alpha beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = (1.0 / beta) / beta;
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 1.55d-12) then
tmp = (1.0d0 / beta) / beta
else
tmp = (alpha / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = (1.0 / beta) / beta;
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if alpha <= 1.55e-12: tmp = (1.0 / beta) / beta else: tmp = (alpha / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (alpha <= 1.55e-12) tmp = Float64(Float64(1.0 / beta) / beta); else tmp = Float64(Float64(alpha / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (alpha <= 1.55e-12)
tmp = (1.0 / beta) / beta;
else
tmp = (alpha / beta) / beta;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[alpha, 1.55e-12], N[(N[(1.0 / beta), $MachinePrecision] / beta), $MachinePrecision], N[(N[(alpha / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{1}{\beta}}{\beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if alpha < 1.5500000000000001e-12Initial program 99.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6450.5
Applied rewrites50.5%
Taylor expanded in alpha around 0
Applied rewrites50.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.8
Applied rewrites50.8%
if 1.5500000000000001e-12 < alpha Initial program 56.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6473.1
Applied rewrites73.1%
Taylor expanded in alpha around inf
Applied rewrites68.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6490.8
Applied rewrites90.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 1.55e-12) (/ (/ 1.0 beta) beta) (/ alpha (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = (1.0 / beta) / beta;
} else {
tmp = alpha / (beta * beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 1.55d-12) then
tmp = (1.0d0 / beta) / beta
else
tmp = alpha / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = (1.0 / beta) / beta;
} else {
tmp = alpha / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if alpha <= 1.55e-12: tmp = (1.0 / beta) / beta else: tmp = alpha / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (alpha <= 1.55e-12) tmp = Float64(Float64(1.0 / beta) / beta); else tmp = Float64(alpha / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (alpha <= 1.55e-12)
tmp = (1.0 / beta) / beta;
else
tmp = alpha / (beta * beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[alpha, 1.55e-12], N[(N[(1.0 / beta), $MachinePrecision] / beta), $MachinePrecision], N[(alpha / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{1}{\beta}}{\beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if alpha < 1.5500000000000001e-12Initial program 99.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6450.5
Applied rewrites50.5%
Taylor expanded in alpha around 0
Applied rewrites50.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.8
Applied rewrites50.8%
if 1.5500000000000001e-12 < alpha Initial program 56.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6473.1
Applied rewrites73.1%
Taylor expanded in alpha around inf
Applied rewrites68.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 1.55e-12) (/ 1.0 (* beta beta)) (/ alpha (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = 1.0 / (beta * beta);
} else {
tmp = alpha / (beta * beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 1.55d-12) then
tmp = 1.0d0 / (beta * beta)
else
tmp = alpha / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.55e-12) {
tmp = 1.0 / (beta * beta);
} else {
tmp = alpha / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if alpha <= 1.55e-12: tmp = 1.0 / (beta * beta) else: tmp = alpha / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (alpha <= 1.55e-12) tmp = Float64(1.0 / Float64(beta * beta)); else tmp = Float64(alpha / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (alpha <= 1.55e-12)
tmp = 1.0 / (beta * beta);
else
tmp = alpha / (beta * beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[alpha, 1.55e-12], N[(1.0 / N[(beta * beta), $MachinePrecision]), $MachinePrecision], N[(alpha / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if alpha < 1.5500000000000001e-12Initial program 99.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6450.5
Applied rewrites50.5%
Taylor expanded in alpha around 0
Applied rewrites50.2%
if 1.5500000000000001e-12 < alpha Initial program 56.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6473.1
Applied rewrites73.1%
Taylor expanded in alpha around inf
Applied rewrites68.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ 1.0 (* beta beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
return 1.0 / (beta * beta);
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
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(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = 1.0d0 / (beta * beta)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return 1.0 / (beta * beta);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return 1.0 / (beta * beta)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(1.0 / Float64(beta * beta)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = 1.0 / (beta * beta);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(1.0 / N[(beta * beta), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{1}{\beta \cdot \beta}
\end{array}
Initial program 94.6%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6453.2
Applied rewrites53.2%
Taylor expanded in alpha around 0
Applied rewrites50.4%
herbie shell --seed 2025134
(FPCore (alpha beta)
:name "Octave 3.8, jcobi/3"
:precision binary64
:pre (and (> alpha -1.0) (> beta -1.0))
(/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) (+ (+ alpha beta) (* 2.0 1.0))) (+ (+ alpha beta) (* 2.0 1.0))) (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0)))