
(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}
Sampling outcomes in binary64 precision:
Herbie found 17 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 (+ (+ alpha beta) 2.0)))
(if (<= beta 1.65e+124)
(/
(/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0)
(+ (+ 1.0 (+ beta alpha)) 2.0))
(+ (pow beta -2.0) (/ (/ alpha beta) beta)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 1.65e+124) {
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0);
} else {
tmp = pow(beta, -2.0) + ((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) :: t_0
real(8) :: tmp
t_0 = (alpha + beta) + 2.0d0
if (beta <= 1.65d+124) then
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / ((1.0d0 + (beta + alpha)) + 2.0d0)
else
tmp = (beta ** (-2.0d0)) + ((alpha / beta) / beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 1.65e+124) {
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0);
} else {
tmp = Math.pow(beta, -2.0) + ((alpha / beta) / beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + 2.0 tmp = 0 if beta <= 1.65e+124: tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0) else: tmp = math.pow(beta, -2.0) + ((alpha / beta) / beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 1.65e+124) tmp = Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(Float64(1.0 + Float64(beta + alpha)) + 2.0)); else tmp = Float64((beta ^ -2.0) + Float64(Float64(alpha / beta) / beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) + 2.0;
tmp = 0.0;
if (beta <= 1.65e+124)
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0);
else
tmp = (beta ^ -2.0) + ((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_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.65e+124], 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[(N[(1.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[beta, -2.0], $MachinePrecision] + N[(N[(alpha / beta), $MachinePrecision] / beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 1.65 \cdot 10^{+124}:\\
\;\;\;\;\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{\left(1 + \left(\beta + \alpha\right)\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;{\beta}^{-2} + \frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 1.65000000000000007e124Initial program 98.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f6498.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.8
lift-*.f64N/A
metadata-eval98.8
Applied rewrites98.8%
if 1.65000000000000007e124 < beta Initial program 74.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6488.3
Applied rewrites88.3%
Applied rewrites94.5%
Final simplification98.0%
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)))
(if (<= beta 1e+122)
(/
(/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0)
(+ (+ 1.0 (+ beta alpha)) 2.0))
(/ (/ (+ alpha 1.0) beta) beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 1e+122) {
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0);
} else {
tmp = ((alpha + 1.0) / 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) :: t_0
real(8) :: tmp
t_0 = (alpha + beta) + 2.0d0
if (beta <= 1d+122) then
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / ((1.0d0 + (beta + alpha)) + 2.0d0)
else
tmp = ((alpha + 1.0d0) / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 1e+122) {
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0);
} else {
tmp = ((alpha + 1.0) / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + 2.0 tmp = 0 if beta <= 1e+122: tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0) else: tmp = ((alpha + 1.0) / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 1e+122) tmp = Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(Float64(1.0 + Float64(beta + alpha)) + 2.0)); else tmp = Float64(Float64(Float64(alpha + 1.0) / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) + 2.0;
tmp = 0.0;
if (beta <= 1e+122)
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / ((1.0 + (beta + alpha)) + 2.0);
else
tmp = ((alpha + 1.0) / beta) / beta;
end
tmp_2 = 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] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1e+122], 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[(N[(1.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha + 1.0), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 10^{+122}:\\
\;\;\;\;\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{\left(1 + \left(\beta + \alpha\right)\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha + 1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 1.00000000000000001e122Initial program 98.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f6498.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.8
lift-*.f64N/A
metadata-eval98.8
Applied rewrites98.8%
if 1.00000000000000001e122 < beta Initial program 74.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6488.3
Applied rewrites88.3%
Applied rewrites94.5%
Final simplification97.9%
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 5.5e+126)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) t_0)
(* (+ 3.0 (+ beta alpha)) t_0))
(/ (/ (+ alpha 1.0) beta) beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 5.5e+126) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / t_0) / ((3.0 + (beta + alpha)) * t_0);
} else {
tmp = ((alpha + 1.0) / 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 <= 5.5e+126) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / t_0) / Float64(Float64(3.0 + Float64(beta + alpha)) * t_0)); else tmp = Float64(Float64(Float64(alpha + 1.0) / 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, 5.5e+126], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha + 1.0), $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 5.5 \cdot 10^{+126}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_0}}{\left(3 + \left(\beta + \alpha\right)\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha + 1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 5.5000000000000004e126Initial program 98.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites97.4%
if 5.5000000000000004e126 < beta Initial program 74.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6488.3
Applied rewrites88.3%
Applied rewrites94.5%
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 2.6e+17)
(/
(+ (fma beta alpha (+ beta alpha)) 1.0)
(* t_0 (* (+ 3.0 (+ beta alpha)) t_0)))
(/ (/ (+ 1.0 alpha) (+ 3.0 (+ alpha beta))) (+ (+ alpha beta) 2.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 2.6e+17) {
tmp = (fma(beta, alpha, (beta + alpha)) + 1.0) / (t_0 * ((3.0 + (beta + alpha)) * t_0));
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / ((alpha + beta) + 2.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 2.6e+17) tmp = Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / Float64(t_0 * Float64(Float64(3.0 + Float64(beta + alpha)) * t_0))); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(3.0 + Float64(alpha + beta))) / Float64(Float64(alpha + beta) + 2.0)); 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, 2.6e+17], N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * N[(N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(3.0 + N[(alpha + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 2.6 \cdot 10^{+17}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_0 \cdot \left(\left(3 + \left(\beta + \alpha\right)\right) \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{3 + \left(\alpha + \beta\right)}}{\left(\alpha + \beta\right) + 2}\\
\end{array}
\end{array}
if beta < 2.6e17Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites95.7%
if 2.6e17 < beta Initial program 80.6%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6481.9
Applied rewrites81.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites81.9%
Taylor expanded in beta around inf
lower-+.f6485.4
Applied rewrites85.4%
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)))
(if (<= beta 2.6e+15)
(/ (/ (/ (+ 1.0 beta) (+ 2.0 beta)) (+ 3.0 beta)) t_0)
(/ (/ (+ 1.0 alpha) (+ 3.0 (+ alpha beta))) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 2.6e+15) {
tmp = (((1.0 + beta) / (2.0 + beta)) / (3.0 + beta)) / t_0;
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_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) :: t_0
real(8) :: tmp
t_0 = (alpha + beta) + 2.0d0
if (beta <= 2.6d+15) then
tmp = (((1.0d0 + beta) / (2.0d0 + beta)) / (3.0d0 + beta)) / t_0
else
tmp = ((1.0d0 + alpha) / (3.0d0 + (alpha + beta))) / t_0
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 2.6e+15) {
tmp = (((1.0 + beta) / (2.0 + beta)) / (3.0 + beta)) / t_0;
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_0;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + 2.0 tmp = 0 if beta <= 2.6e+15: tmp = (((1.0 + beta) / (2.0 + beta)) / (3.0 + beta)) / t_0 else: tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_0 return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 2.6e+15) tmp = Float64(Float64(Float64(Float64(1.0 + beta) / Float64(2.0 + beta)) / Float64(3.0 + beta)) / t_0); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(3.0 + Float64(alpha + beta))) / t_0); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) + 2.0;
tmp = 0.0;
if (beta <= 2.6e+15)
tmp = (((1.0 + beta) / (2.0 + beta)) / (3.0 + beta)) / t_0;
else
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_0;
end
tmp_2 = 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] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 2.6e+15], N[(N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(3.0 + N[(alpha + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 2.6 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{\frac{1 + \beta}{2 + \beta}}{3 + \beta}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{3 + \left(\alpha + \beta\right)}}{t\_0}\\
\end{array}
\end{array}
if beta < 2.6e15Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.4
Applied rewrites86.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites86.4%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.2
Applied rewrites73.2%
if 2.6e15 < beta Initial program 80.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6482.1
Applied rewrites82.1%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites82.1%
Taylor expanded in beta around inf
lower-+.f6484.4
Applied rewrites84.4%
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)))
(if (<= beta 2.6e+15)
(/ (/ (+ 1.0 beta) (* (+ 3.0 beta) (+ 2.0 beta))) t_0)
(/ (/ (+ 1.0 alpha) (+ 3.0 (+ alpha beta))) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 2.6e+15) {
tmp = ((1.0 + beta) / ((3.0 + beta) * (2.0 + beta))) / t_0;
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_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) :: t_0
real(8) :: tmp
t_0 = (alpha + beta) + 2.0d0
if (beta <= 2.6d+15) then
tmp = ((1.0d0 + beta) / ((3.0d0 + beta) * (2.0d0 + beta))) / t_0
else
tmp = ((1.0d0 + alpha) / (3.0d0 + (alpha + beta))) / t_0
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 2.6e+15) {
tmp = ((1.0 + beta) / ((3.0 + beta) * (2.0 + beta))) / t_0;
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_0;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + 2.0 tmp = 0 if beta <= 2.6e+15: tmp = ((1.0 + beta) / ((3.0 + beta) * (2.0 + beta))) / t_0 else: tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_0 return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 2.6e+15) tmp = Float64(Float64(Float64(1.0 + beta) / Float64(Float64(3.0 + beta) * Float64(2.0 + beta))) / t_0); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(3.0 + Float64(alpha + beta))) / t_0); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) + 2.0;
tmp = 0.0;
if (beta <= 2.6e+15)
tmp = ((1.0 + beta) / ((3.0 + beta) * (2.0 + beta))) / t_0;
else
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_0;
end
tmp_2 = 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] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 2.6e+15], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(3.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(3.0 + N[(alpha + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 2.6 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\left(3 + \beta\right) \cdot \left(2 + \beta\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{3 + \left(\alpha + \beta\right)}}{t\_0}\\
\end{array}
\end{array}
if beta < 2.6e15Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.4
Applied rewrites86.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites86.4%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.2
Applied rewrites73.2%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6473.2
Applied rewrites73.2%
if 2.6e15 < beta Initial program 80.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6482.1
Applied rewrites82.1%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites82.1%
Taylor expanded in beta around inf
lower-+.f6484.4
Applied rewrites84.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 2.6e+15) (/ (/ (+ beta 1.0) (+ beta 2.0)) (* (+ 2.0 beta) (+ 3.0 beta))) (/ (/ (+ 1.0 alpha) (+ 3.0 (+ alpha beta))) (+ (+ alpha beta) 2.0))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.6e+15) {
tmp = ((beta + 1.0) / (beta + 2.0)) / ((2.0 + beta) * (3.0 + beta));
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / ((alpha + beta) + 2.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 <= 2.6d+15) then
tmp = ((beta + 1.0d0) / (beta + 2.0d0)) / ((2.0d0 + beta) * (3.0d0 + beta))
else
tmp = ((1.0d0 + alpha) / (3.0d0 + (alpha + beta))) / ((alpha + beta) + 2.0d0)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 2.6e+15) {
tmp = ((beta + 1.0) / (beta + 2.0)) / ((2.0 + beta) * (3.0 + beta));
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / ((alpha + beta) + 2.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 2.6e+15: tmp = ((beta + 1.0) / (beta + 2.0)) / ((2.0 + beta) * (3.0 + beta)) else: tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / ((alpha + beta) + 2.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 2.6e+15) tmp = Float64(Float64(Float64(beta + 1.0) / Float64(beta + 2.0)) / Float64(Float64(2.0 + beta) * Float64(3.0 + beta))); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(3.0 + Float64(alpha + beta))) / Float64(Float64(alpha + beta) + 2.0)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 2.6e+15)
tmp = ((beta + 1.0) / (beta + 2.0)) / ((2.0 + beta) * (3.0 + beta));
else
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / ((alpha + beta) + 2.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, 2.6e+15], N[(N[(N[(beta + 1.0), $MachinePrecision] / N[(beta + 2.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + beta), $MachinePrecision] * N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(3.0 + N[(alpha + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2.6 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{\beta + 1}{\beta + 2}}{\left(2 + \beta\right) \cdot \left(3 + \beta\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{3 + \left(\alpha + \beta\right)}}{\left(\alpha + \beta\right) + 2}\\
\end{array}
\end{array}
if beta < 2.6e15Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.4
Applied rewrites86.4%
Applied rewrites86.5%
Taylor expanded in alpha around 0
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6472.4
Applied rewrites72.4%
if 2.6e15 < beta Initial program 80.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6482.1
Applied rewrites82.1%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites82.1%
Taylor expanded in beta around inf
lower-+.f6484.4
Applied rewrites84.4%
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)))
(if (<= beta 1.55)
(/
(fma
(fma
(- (* 0.03780864197530864 beta) 0.05092592592592592)
beta
0.027777777777777776)
beta
0.16666666666666666)
t_0)
(/ (/ (+ 1.0 alpha) (+ 3.0 (+ alpha beta))) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 1.55) {
tmp = fma(fma(((0.03780864197530864 * beta) - 0.05092592592592592), beta, 0.027777777777777776), beta, 0.16666666666666666) / t_0;
} else {
tmp = ((1.0 + alpha) / (3.0 + (alpha + beta))) / t_0;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 1.55) tmp = Float64(fma(fma(Float64(Float64(0.03780864197530864 * beta) - 0.05092592592592592), beta, 0.027777777777777776), beta, 0.16666666666666666) / t_0); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(3.0 + Float64(alpha + beta))) / t_0); 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] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.55], N[(N[(N[(N[(N[(0.03780864197530864 * beta), $MachinePrecision] - 0.05092592592592592), $MachinePrecision] * beta + 0.027777777777777776), $MachinePrecision] * beta + 0.16666666666666666), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(3.0 + N[(alpha + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 1.55:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.03780864197530864 \cdot \beta - 0.05092592592592592, \beta, 0.027777777777777776\right), \beta, 0.16666666666666666\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{3 + \left(\alpha + \beta\right)}}{t\_0}\\
\end{array}
\end{array}
if beta < 1.55000000000000004Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites73.1%
if 1.55000000000000004 < beta Initial program 82.1%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6481.3
Applied rewrites81.3%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites81.3%
Taylor expanded in beta around inf
lower-+.f6481.1
Applied rewrites81.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 4.0)
(/
(fma
(fma
(- (* 0.03780864197530864 beta) 0.05092592592592592)
beta
0.027777777777777776)
beta
0.16666666666666666)
(+ (+ alpha beta) 2.0))
(/ (/ (+ alpha 1.0) beta) beta)))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.0) {
tmp = fma(fma(((0.03780864197530864 * beta) - 0.05092592592592592), beta, 0.027777777777777776), beta, 0.16666666666666666) / ((alpha + beta) + 2.0);
} else {
tmp = ((alpha + 1.0) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.0) tmp = Float64(fma(fma(Float64(Float64(0.03780864197530864 * beta) - 0.05092592592592592), beta, 0.027777777777777776), beta, 0.16666666666666666) / Float64(Float64(alpha + beta) + 2.0)); else tmp = Float64(Float64(Float64(alpha + 1.0) / beta) / beta); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 4.0], N[(N[(N[(N[(N[(0.03780864197530864 * beta), $MachinePrecision] - 0.05092592592592592), $MachinePrecision] * beta + 0.027777777777777776), $MachinePrecision] * beta + 0.16666666666666666), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha + 1.0), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.03780864197530864 \cdot \beta - 0.05092592592592592, \beta, 0.027777777777777776\right), \beta, 0.16666666666666666\right)}{\left(\alpha + \beta\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha + 1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 4Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites73.1%
if 4 < beta Initial program 82.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6476.6
Applied rewrites76.6%
Applied rewrites80.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 2.1)
(/
(fma
(fma -0.05092592592592592 beta 0.027777777777777776)
beta
0.16666666666666666)
(+ (+ alpha beta) 2.0))
(/ (/ (+ alpha 1.0) beta) beta)))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.1) {
tmp = fma(fma(-0.05092592592592592, beta, 0.027777777777777776), beta, 0.16666666666666666) / ((alpha + beta) + 2.0);
} else {
tmp = ((alpha + 1.0) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 2.1) tmp = Float64(fma(fma(-0.05092592592592592, beta, 0.027777777777777776), beta, 0.16666666666666666) / Float64(Float64(alpha + beta) + 2.0)); else tmp = Float64(Float64(Float64(alpha + 1.0) / beta) / beta); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 2.1], N[(N[(N[(-0.05092592592592592 * beta + 0.027777777777777776), $MachinePrecision] * beta + 0.16666666666666666), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha + 1.0), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2.1:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.05092592592592592, \beta, 0.027777777777777776\right), \beta, 0.16666666666666666\right)}{\left(\alpha + \beta\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha + 1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 2.10000000000000009Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites72.9%
if 2.10000000000000009 < beta Initial program 82.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6476.6
Applied rewrites76.6%
Applied rewrites80.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 5.2)
(/
(fma 0.027777777777777776 beta 0.16666666666666666)
(+ (+ alpha beta) 2.0))
(if (<= beta 5e+159)
(/ (+ 1.0 alpha) (* beta beta))
(/ (/ alpha beta) beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5.2) {
tmp = fma(0.027777777777777776, beta, 0.16666666666666666) / ((alpha + beta) + 2.0);
} else if (beta <= 5e+159) {
tmp = (1.0 + alpha) / (beta * beta);
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 5.2) tmp = Float64(fma(0.027777777777777776, beta, 0.16666666666666666) / Float64(Float64(alpha + beta) + 2.0)); elseif (beta <= 5e+159) tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); else tmp = Float64(Float64(alpha / beta) / beta); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 5.2], N[(N[(0.027777777777777776 * beta + 0.16666666666666666), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[beta, 5e+159], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision], N[(N[(alpha / beta), $MachinePrecision] / beta), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 5.2:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.027777777777777776, \beta, 0.16666666666666666\right)}{\left(\alpha + \beta\right) + 2}\\
\mathbf{elif}\;\beta \leq 5 \cdot 10^{+159}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 5.20000000000000018Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites72.6%
if 5.20000000000000018 < beta < 5.00000000000000003e159Initial program 88.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
if 5.00000000000000003e159 < beta Initial program 75.9%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6491.0
Applied rewrites91.0%
Taylor expanded in alpha around inf
Applied rewrites91.0%
Applied rewrites99.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 8.5)
(/ 0.16666666666666666 (+ (+ alpha beta) 2.0))
(if (<= beta 5e+159)
(/ (+ 1.0 alpha) (* beta beta))
(/ (/ alpha beta) beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 8.5) {
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
} else if (beta <= 5e+159) {
tmp = (1.0 + alpha) / (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 (beta <= 8.5d0) then
tmp = 0.16666666666666666d0 / ((alpha + beta) + 2.0d0)
else if (beta <= 5d+159) then
tmp = (1.0d0 + alpha) / (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 (beta <= 8.5) {
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
} else if (beta <= 5e+159) {
tmp = (1.0 + alpha) / (beta * beta);
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 8.5: tmp = 0.16666666666666666 / ((alpha + beta) + 2.0) elif beta <= 5e+159: tmp = (1.0 + alpha) / (beta * beta) else: tmp = (alpha / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 8.5) tmp = Float64(0.16666666666666666 / Float64(Float64(alpha + beta) + 2.0)); elseif (beta <= 5e+159) tmp = Float64(Float64(1.0 + alpha) / Float64(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 (beta <= 8.5)
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
elseif (beta <= 5e+159)
tmp = (1.0 + alpha) / (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[beta, 8.5], N[(0.16666666666666666 / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[beta, 5e+159], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision], N[(N[(alpha / beta), $MachinePrecision] / beta), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 8.5:\\
\;\;\;\;\frac{0.16666666666666666}{\left(\alpha + \beta\right) + 2}\\
\mathbf{elif}\;\beta \leq 5 \cdot 10^{+159}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 8.5Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites71.6%
if 8.5 < beta < 5.00000000000000003e159Initial program 88.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
if 5.00000000000000003e159 < beta Initial program 75.9%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6491.0
Applied rewrites91.0%
Taylor expanded in alpha around inf
Applied rewrites91.0%
Applied rewrites99.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 5.2)
(/
(fma 0.027777777777777776 beta 0.16666666666666666)
(+ (+ alpha beta) 2.0))
(/ (/ (+ alpha 1.0) beta) beta)))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5.2) {
tmp = fma(0.027777777777777776, beta, 0.16666666666666666) / ((alpha + beta) + 2.0);
} else {
tmp = ((alpha + 1.0) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 5.2) tmp = Float64(fma(0.027777777777777776, beta, 0.16666666666666666) / Float64(Float64(alpha + beta) + 2.0)); else tmp = Float64(Float64(Float64(alpha + 1.0) / beta) / beta); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 5.2], N[(N[(0.027777777777777776 * beta + 0.16666666666666666), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha + 1.0), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 5.2:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.027777777777777776, \beta, 0.16666666666666666\right)}{\left(\alpha + \beta\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha + 1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 5.20000000000000018Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites72.6%
if 5.20000000000000018 < beta Initial program 82.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6476.6
Applied rewrites76.6%
Applied rewrites80.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 8.5) (/ 0.16666666666666666 (+ (+ alpha beta) 2.0)) (/ (+ 1.0 alpha) (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 8.5) {
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
} else {
tmp = (1.0 + 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 (beta <= 8.5d0) then
tmp = 0.16666666666666666d0 / ((alpha + beta) + 2.0d0)
else
tmp = (1.0d0 + alpha) / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 8.5) {
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 8.5: tmp = 0.16666666666666666 / ((alpha + beta) + 2.0) else: tmp = (1.0 + alpha) / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 8.5) tmp = Float64(0.16666666666666666 / Float64(Float64(alpha + beta) + 2.0)); else tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 8.5)
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
else
tmp = (1.0 + 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[beta, 8.5], N[(0.16666666666666666 / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 8.5:\\
\;\;\;\;\frac{0.16666666666666666}{\left(\alpha + \beta\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 8.5Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites71.6%
if 8.5 < beta Initial program 82.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6476.6
Applied rewrites76.6%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 8.5) (/ 0.16666666666666666 (+ (+ alpha beta) 2.0)) (/ 1.0 (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 8.5) {
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
} else {
tmp = 1.0 / (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 (beta <= 8.5d0) then
tmp = 0.16666666666666666d0 / ((alpha + beta) + 2.0d0)
else
tmp = 1.0d0 / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 8.5) {
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
} else {
tmp = 1.0 / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 8.5: tmp = 0.16666666666666666 / ((alpha + beta) + 2.0) else: tmp = 1.0 / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 8.5) tmp = Float64(0.16666666666666666 / Float64(Float64(alpha + beta) + 2.0)); else tmp = Float64(1.0 / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 8.5)
tmp = 0.16666666666666666 / ((alpha + beta) + 2.0);
else
tmp = 1.0 / (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[beta, 8.5], N[(0.16666666666666666 / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 8.5:\\
\;\;\;\;\frac{0.16666666666666666}{\left(\alpha + \beta\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 8.5Initial program 99.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites87.0%
Taylor expanded in alpha around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6473.4
Applied rewrites73.4%
Taylor expanded in beta around 0
Applied rewrites71.6%
if 8.5 < beta Initial program 82.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6476.6
Applied rewrites76.6%
Taylor expanded in alpha around 0
Applied rewrites74.0%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 1.0) (/ 1.0 (* beta beta)) (/ alpha (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 1.0) {
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.0d0) 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.0) {
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.0: 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.0) 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.0)
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.0], 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:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if alpha < 1Initial program 99.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6433.4
Applied rewrites33.4%
Taylor expanded in alpha around 0
Applied rewrites33.0%
if 1 < alpha Initial program 79.4%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6419.1
Applied rewrites19.1%
Taylor expanded in alpha around inf
Applied rewrites18.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ alpha (* beta beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
return 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 = alpha / (beta * beta)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return alpha / (beta * beta);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return alpha / (beta * beta)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(alpha / Float64(beta * beta)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = alpha / (beta * beta);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(alpha / N[(beta * beta), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{\alpha}{\beta \cdot \beta}
\end{array}
Initial program 93.7%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6429.1
Applied rewrites29.1%
Taylor expanded in alpha around inf
Applied rewrites19.9%
herbie shell --seed 2024358
(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)))