
(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 15 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 1.0))) (t_1 (+ t_0 1.0)))
(if (<= beta 1.8e+16)
(/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) t_1)
(/ (/ (+ 1.0 alpha) beta) 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.8e+16) {
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / t_1;
} else {
tmp = ((1.0 + alpha) / beta) / t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
t_1 = t_0 + 1.0d0
if (beta <= 1.8d+16) then
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / t_1
else
tmp = ((1.0d0 + alpha) / beta) / t_1
end if
code = tmp
end function
assert alpha < beta;
public static 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.8e+16) {
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / t_1;
} else {
tmp = ((1.0 + alpha) / beta) / t_1;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) t_1 = t_0 + 1.0 tmp = 0 if beta <= 1.8e+16: tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / t_1 else: tmp = ((1.0 + alpha) / beta) / 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.8e+16) tmp = Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / t_1); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / t_1); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) + (2.0 * 1.0);
t_1 = t_0 + 1.0;
tmp = 0.0;
if (beta <= 1.8e+16)
tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / t_1;
else
tmp = ((1.0 + alpha) / beta) / t_1;
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] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + 1.0), $MachinePrecision]}, If[LessEqual[beta, 1.8e+16], 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] / t$95$1), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $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.8 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{t\_1}\\
\end{array}
\end{array}
if beta < 1.8e16Initial program 99.9%
if 1.8e16 < beta Initial program 89.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6499.1
Applied rewrites99.1%
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)) 1.0)))
(if (<= beta 3.5e+17)
(/ (/ (+ 1.0 beta) (* (+ 2.0 beta) (+ 2.0 beta))) t_0)
(/ (/ (+ 1.0 alpha) beta) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = ((alpha + beta) + (2.0 * 1.0)) + 1.0;
double tmp;
if (beta <= 3.5e+17) {
tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + beta))) / t_0;
} else {
tmp = ((1.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 * 1.0d0)) + 1.0d0
if (beta <= 3.5d+17) then
tmp = ((1.0d0 + beta) / ((2.0d0 + beta) * (2.0d0 + beta))) / t_0
else
tmp = ((1.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 * 1.0)) + 1.0;
double tmp;
if (beta <= 3.5e+17) {
tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + beta))) / t_0;
} else {
tmp = ((1.0 + alpha) / beta) / t_0;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = ((alpha + beta) + (2.0 * 1.0)) + 1.0 tmp = 0 if beta <= 3.5e+17: tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + beta))) / t_0 else: tmp = ((1.0 + alpha) / beta) / t_0 return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0) tmp = 0.0 if (beta <= 3.5e+17) tmp = Float64(Float64(Float64(1.0 + beta) / Float64(Float64(2.0 + beta) * Float64(2.0 + beta))) / t_0); else tmp = Float64(Float64(Float64(1.0 + 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 * 1.0)) + 1.0;
tmp = 0.0;
if (beta <= 3.5e+17)
tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + beta))) / t_0;
else
tmp = ((1.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[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[beta, 3.5e+17], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(2.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1\\
\mathbf{if}\;\beta \leq 3.5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\left(2 + \beta\right) \cdot \left(2 + \beta\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 3.5e17Initial 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.7
Applied rewrites98.7%
if 3.5e17 < beta Initial program 89.7%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6499.1
Applied rewrites99.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 1e+65) (/ (+ 1.0 beta) (fma beta (fma beta (+ 7.0 beta) 16.0) 12.0)) (/ (/ (+ 1.0 alpha) beta) (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1e+65) {
tmp = (1.0 + beta) / fma(beta, fma(beta, (7.0 + beta), 16.0), 12.0);
} else {
tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1e+65) tmp = Float64(Float64(1.0 + beta) / fma(beta, fma(beta, Float64(7.0 + beta), 16.0), 12.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.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, 1e+65], N[(N[(1.0 + beta), $MachinePrecision] / N[(beta * N[(beta * N[(7.0 + beta), $MachinePrecision] + 16.0), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 10^{+65}:\\
\;\;\;\;\frac{1 + \beta}{\mathsf{fma}\left(\beta, \mathsf{fma}\left(\beta, 7 + \beta, 16\right), 12\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\end{array}
\end{array}
if beta < 9.9999999999999999e64Initial program 99.8%
Taylor expanded in alpha 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-+.f6497.1
Applied rewrites97.1%
Taylor expanded in beta around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6497.1
Applied rewrites97.1%
if 9.9999999999999999e64 < beta Initial program 88.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6499.1
Applied rewrites99.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 1e+65) (/ (+ 1.0 beta) (fma beta (fma beta (+ 7.0 beta) 16.0) 12.0)) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1e+65) {
tmp = (1.0 + beta) / fma(beta, fma(beta, (7.0 + beta), 16.0), 12.0);
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1e+65) tmp = Float64(Float64(1.0 + beta) / fma(beta, fma(beta, Float64(7.0 + beta), 16.0), 12.0)); 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_] := If[LessEqual[beta, 1e+65], N[(N[(1.0 + beta), $MachinePrecision] / N[(beta * N[(beta * N[(7.0 + beta), $MachinePrecision] + 16.0), $MachinePrecision] + 12.0), $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}
\mathbf{if}\;\beta \leq 10^{+65}:\\
\;\;\;\;\frac{1 + \beta}{\mathsf{fma}\left(\beta, \mathsf{fma}\left(\beta, 7 + \beta, 16\right), 12\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 9.9999999999999999e64Initial program 99.8%
Taylor expanded in alpha 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-+.f6497.1
Applied rewrites97.1%
Taylor expanded in beta around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6497.1
Applied rewrites97.1%
if 9.9999999999999999e64 < beta Initial program 88.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.5
Applied rewrites92.5%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f6499.1
Applied rewrites99.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 5.7) (/ (+ 1.0 alpha) (fma (fma (+ 7.0 alpha) alpha 16.0) alpha 12.0)) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5.7) {
tmp = (1.0 + alpha) / fma(fma((7.0 + alpha), alpha, 16.0), alpha, 12.0);
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 5.7) tmp = Float64(Float64(1.0 + alpha) / fma(fma(Float64(7.0 + alpha), alpha, 16.0), alpha, 12.0)); 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_] := If[LessEqual[beta, 5.7], N[(N[(1.0 + alpha), $MachinePrecision] / N[(N[(N[(7.0 + alpha), $MachinePrecision] * alpha + 16.0), $MachinePrecision] * alpha + 12.0), $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}
\mathbf{if}\;\beta \leq 5.7:\\
\;\;\;\;\frac{1 + \alpha}{\mathsf{fma}\left(\mathsf{fma}\left(7 + \alpha, \alpha, 16\right), \alpha, 12\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 5.70000000000000018Initial 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-+.f6497.8
Applied rewrites97.8%
Taylor expanded in alpha around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6497.8
Applied rewrites97.8%
if 5.70000000000000018 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.3
Applied rewrites92.3%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f6497.7
Applied rewrites97.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 6.5) (/ 0.25 (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0)) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 6.5) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.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 <= 6.5d0) then
tmp = 0.25d0 / (((alpha + beta) + (2.0d0 * 1.0d0)) + 1.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 <= 6.5) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 6.5: tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0) else: tmp = ((1.0 + alpha) / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 6.5) 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) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 6.5)
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.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, 6.5], 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] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 6.5:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 6.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.8
Applied rewrites98.8%
Taylor expanded in beta around 0
Applied rewrites97.8%
if 6.5 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.3
Applied rewrites92.3%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f6497.7
Applied rewrites97.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 3.4)
(fma
(- (* -0.011574074074074073 alpha) 0.027777777777777776)
alpha
0.08333333333333333)
(/ (/ (+ 1.0 alpha) beta) beta)))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.4) {
tmp = fma(((-0.011574074074074073 * alpha) - 0.027777777777777776), alpha, 0.08333333333333333);
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.4) tmp = fma(Float64(Float64(-0.011574074074074073 * alpha) - 0.027777777777777776), alpha, 0.08333333333333333); 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_] := If[LessEqual[beta, 3.4], N[(N[(N[(-0.011574074074074073 * alpha), $MachinePrecision] - 0.027777777777777776), $MachinePrecision] * alpha + 0.08333333333333333), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.4:\\
\;\;\;\;\mathsf{fma}\left(-0.011574074074074073 \cdot \alpha - 0.027777777777777776, \alpha, 0.08333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 3.39999999999999991Initial 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-+.f6497.8
Applied rewrites97.8%
Taylor expanded in alpha around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
if 3.39999999999999991 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.2
Applied rewrites92.2%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f6497.6
Applied rewrites97.6%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.4) (fma -0.027777777777777776 alpha 0.08333333333333333) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.4) {
tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333);
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.4) tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333); 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_] := If[LessEqual[beta, 3.4], N[(-0.027777777777777776 * alpha + 0.08333333333333333), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.4:\\
\;\;\;\;\mathsf{fma}\left(-0.027777777777777776, \alpha, 0.08333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 3.39999999999999991Initial 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-+.f6497.8
Applied rewrites97.8%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
if 3.39999999999999991 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.2
Applied rewrites92.2%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f6497.6
Applied rewrites97.6%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.4) (fma -0.027777777777777776 alpha 0.08333333333333333) (/ (+ 1.0 alpha) (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.4) {
tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333);
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.4) tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333); else tmp = Float64(Float64(1.0 + alpha) / Float64(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, 3.4], N[(-0.027777777777777776 * alpha + 0.08333333333333333), $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 3.4:\\
\;\;\;\;\mathsf{fma}\left(-0.027777777777777776, \alpha, 0.08333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 3.39999999999999991Initial 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-+.f6497.8
Applied rewrites97.8%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
if 3.39999999999999991 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.2
Applied rewrites92.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.4) (fma -0.027777777777777776 alpha 0.08333333333333333) (/ (/ 1.0 beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.4) {
tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333);
} else {
tmp = (1.0 / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.4) tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333); else tmp = Float64(Float64(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, 3.4], N[(-0.027777777777777776 * alpha + 0.08333333333333333), $MachinePrecision], N[(N[(1.0 / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.4:\\
\;\;\;\;\mathsf{fma}\left(-0.027777777777777776, \alpha, 0.08333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 3.39999999999999991Initial 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-+.f6497.8
Applied rewrites97.8%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
if 3.39999999999999991 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.2
Applied rewrites92.2%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f6497.6
Applied rewrites97.6%
Taylor expanded in alpha around 0
Applied rewrites88.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.4) (fma -0.027777777777777776 alpha 0.08333333333333333) (/ 1.0 (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.4) {
tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333);
} else {
tmp = 1.0 / (beta * beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.4) tmp = fma(-0.027777777777777776, alpha, 0.08333333333333333); else tmp = Float64(1.0 / Float64(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, 3.4], N[(-0.027777777777777776 * alpha + 0.08333333333333333), $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 3.4:\\
\;\;\;\;\mathsf{fma}\left(-0.027777777777777776, \alpha, 0.08333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 3.39999999999999991Initial 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-+.f6497.8
Applied rewrites97.8%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
if 3.39999999999999991 < beta Initial program 90.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6492.2
Applied rewrites92.2%
Taylor expanded in alpha around 0
Applied rewrites87.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 5.3e+128) (/ 0.25 (+ 3.0 beta)) (/ 1.0 (* alpha alpha))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 5.3e+128) {
tmp = 0.25 / (3.0 + beta);
} else {
tmp = 1.0 / (alpha * alpha);
}
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 <= 5.3d+128) then
tmp = 0.25d0 / (3.0d0 + beta)
else
tmp = 1.0d0 / (alpha * alpha)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 5.3e+128) {
tmp = 0.25 / (3.0 + beta);
} else {
tmp = 1.0 / (alpha * alpha);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if alpha <= 5.3e+128: tmp = 0.25 / (3.0 + beta) else: tmp = 1.0 / (alpha * alpha) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (alpha <= 5.3e+128) tmp = Float64(0.25 / Float64(3.0 + beta)); else tmp = Float64(1.0 / Float64(alpha * alpha)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (alpha <= 5.3e+128)
tmp = 0.25 / (3.0 + beta);
else
tmp = 1.0 / (alpha * alpha);
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, 5.3e+128], N[(0.25 / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(alpha * alpha), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 5.3 \cdot 10^{+128}:\\
\;\;\;\;\frac{0.25}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\alpha \cdot \alpha}\\
\end{array}
\end{array}
if alpha < 5.3000000000000002e128Initial program 97.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6494.9
Applied rewrites94.9%
Taylor expanded in alpha around 0
lift-+.f6494.4
Applied rewrites94.4%
Taylor expanded in beta around 0
Applied rewrites48.2%
if 5.3000000000000002e128 < alpha Initial program 5.5%
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-+.f6451.5
Applied rewrites51.5%
Taylor expanded in alpha around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6441.7
Applied rewrites41.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ 0.25 (+ 3.0 beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
return 0.25 / (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 = 0.25d0 / (3.0d0 + beta)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return 0.25 / (3.0 + beta);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return 0.25 / (3.0 + beta)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(0.25 / Float64(3.0 + beta)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = 0.25 / (3.0 + beta);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(0.25 / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{0.25}{3 + \beta}
\end{array}
Initial program 94.4%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6493.2
Applied rewrites93.2%
Taylor expanded in alpha around 0
lift-+.f6492.8
Applied rewrites92.8%
Taylor expanded in beta around 0
Applied rewrites46.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (fma -0.027777777777777776 alpha 0.08333333333333333))
assert(alpha < beta);
double code(double alpha, double beta) {
return fma(-0.027777777777777776, alpha, 0.08333333333333333);
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return fma(-0.027777777777777776, alpha, 0.08333333333333333) end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(-0.027777777777777776 * alpha + 0.08333333333333333), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\mathsf{fma}\left(-0.027777777777777776, \alpha, 0.08333333333333333\right)
\end{array}
Initial program 94.4%
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-+.f6448.0
Applied rewrites48.0%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6444.8
Applied rewrites44.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 0.08333333333333333)
assert(alpha < beta);
double code(double alpha, double beta) {
return 0.08333333333333333;
}
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 = 0.08333333333333333d0
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return 0.08333333333333333;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return 0.08333333333333333
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return 0.08333333333333333 end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = 0.08333333333333333;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := 0.08333333333333333
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
0.08333333333333333
\end{array}
Initial program 94.4%
Taylor expanded in alpha 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-+.f6485.8
Applied rewrites85.8%
Taylor expanded in beta around 0
Applied rewrites44.6%
herbie shell --seed 2025115
(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)))