
(FPCore (alpha beta) :precision binary64 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))
double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.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
code = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
end function
public static double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
def code(alpha, beta): return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
function code(alpha, beta) return Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) end
function tmp = code(alpha, beta) tmp = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0; end
code[alpha_, beta_] := N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha beta) :precision binary64 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))
double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.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
code = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
end function
public static double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
def code(alpha, beta): return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
function code(alpha, beta) return Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) end
function tmp = code(alpha, beta) tmp = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0; end
code[alpha_, beta_] := N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}
\end{array}
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ alpha beta) 2.0)) (t_1 (* t_0 2.0)))
(if (<= (/ (+ (/ (- beta alpha) t_0) 1.0) 2.0) 2.8e-12)
(/ (+ 1.0 beta) alpha)
(/ (/ (fma (- beta alpha) 2.0 t_1) t_1) 2.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double t_1 = t_0 * 2.0;
double tmp;
if (((((beta - alpha) / t_0) + 1.0) / 2.0) <= 2.8e-12) {
tmp = (1.0 + beta) / alpha;
} else {
tmp = (fma((beta - alpha), 2.0, t_1) / t_1) / 2.0;
}
return tmp;
}
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) t_1 = Float64(t_0 * 2.0) tmp = 0.0 if (Float64(Float64(Float64(Float64(beta - alpha) / t_0) + 1.0) / 2.0) <= 2.8e-12) tmp = Float64(Float64(1.0 + beta) / alpha); else tmp = Float64(Float64(fma(Float64(beta - alpha), 2.0, t_1) / t_1) / 2.0); end return tmp end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * 2.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(beta - alpha), $MachinePrecision] / t$95$0), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 2.8e-12], N[(N[(1.0 + beta), $MachinePrecision] / alpha), $MachinePrecision], N[(N[(N[(N[(beta - alpha), $MachinePrecision] * 2.0 + t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
t_1 := t\_0 \cdot 2\\
\mathbf{if}\;\frac{\frac{\beta - \alpha}{t\_0} + 1}{2} \leq 2.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{1 + \beta}{\alpha}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta - \alpha, 2, t\_1\right)}{t\_1}}{2}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2.8000000000000002e-12Initial program 5.9%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in beta around 0
div-add-revN/A
lower-/.f64N/A
lower-+.f6499.7
Applied rewrites99.7%
if 2.8000000000000002e-12 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 99.6%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
metadata-evalN/A
frac-addN/A
lower-/.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6499.8
Applied rewrites99.8%
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))) (if (<= t_0 2e-10) (/ (+ 1.0 beta) alpha) t_0)))
double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-10) {
tmp = (1.0 + beta) / alpha;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
if (t_0 <= 2d-10) then
tmp = (1.0d0 + beta) / alpha
else
tmp = t_0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-10) {
tmp = (1.0 + beta) / alpha;
} else {
tmp = t_0;
}
return tmp;
}
def code(alpha, beta): t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0 tmp = 0 if t_0 <= 2e-10: tmp = (1.0 + beta) / alpha else: tmp = t_0 return tmp
function code(alpha, beta) t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) tmp = 0.0 if (t_0 <= 2e-10) tmp = Float64(Float64(1.0 + beta) / alpha); else tmp = t_0; end return tmp end
function tmp_2 = code(alpha, beta) t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0; tmp = 0.0; if (t_0 <= 2e-10) tmp = (1.0 + beta) / alpha; else tmp = t_0; end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-10], N[(N[(1.0 + beta), $MachinePrecision] / alpha), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{1 + \beta}{\alpha}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2.00000000000000007e-10Initial program 6.3%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.5
Applied rewrites99.5%
Taylor expanded in beta around 0
div-add-revN/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
if 2.00000000000000007e-10 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 99.7%
(FPCore (alpha beta) :precision binary64 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 2e-8) (/ (+ 1.0 beta) alpha) (* (+ (/ beta (+ 2.0 beta)) 1.0) 0.5)))
double code(double alpha, double beta) {
double tmp;
if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 2e-8) {
tmp = (1.0 + beta) / alpha;
} else {
tmp = ((beta / (2.0 + beta)) + 1.0) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (((((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0) <= 2d-8) then
tmp = (1.0d0 + beta) / alpha
else
tmp = ((beta / (2.0d0 + beta)) + 1.0d0) * 0.5d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double tmp;
if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 2e-8) {
tmp = (1.0 + beta) / alpha;
} else {
tmp = ((beta / (2.0 + beta)) + 1.0) * 0.5;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if ((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 2e-8: tmp = (1.0 + beta) / alpha else: tmp = ((beta / (2.0 + beta)) + 1.0) * 0.5 return tmp
function code(alpha, beta) tmp = 0.0 if (Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) <= 2e-8) tmp = Float64(Float64(1.0 + beta) / alpha); else tmp = Float64(Float64(Float64(beta / Float64(2.0 + beta)) + 1.0) * 0.5); end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 2e-8) tmp = (1.0 + beta) / alpha; else tmp = ((beta / (2.0 + beta)) + 1.0) * 0.5; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 2e-8], N[(N[(1.0 + beta), $MachinePrecision] / alpha), $MachinePrecision], N[(N[(N[(beta / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{1 + \beta}{\alpha}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\beta}{2 + \beta} + 1\right) \cdot 0.5\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2e-8Initial program 6.6%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
Taylor expanded in beta around 0
div-add-revN/A
lower-/.f64N/A
lower-+.f6499.3
Applied rewrites99.3%
if 2e-8 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 99.8%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
(if (<= t_0 2.8e-12)
(/ (+ 1.0 beta) alpha)
(if (<= t_0 0.6) (/ 1.0 (+ 2.0 alpha)) (- 1.0 (/ 1.0 beta))))))
double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2.8e-12) {
tmp = (1.0 + beta) / alpha;
} else if (t_0 <= 0.6) {
tmp = 1.0 / (2.0 + alpha);
} else {
tmp = 1.0 - (1.0 / beta);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
if (t_0 <= 2.8d-12) then
tmp = (1.0d0 + beta) / alpha
else if (t_0 <= 0.6d0) then
tmp = 1.0d0 / (2.0d0 + alpha)
else
tmp = 1.0d0 - (1.0d0 / beta)
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2.8e-12) {
tmp = (1.0 + beta) / alpha;
} else if (t_0 <= 0.6) {
tmp = 1.0 / (2.0 + alpha);
} else {
tmp = 1.0 - (1.0 / beta);
}
return tmp;
}
def code(alpha, beta): t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0 tmp = 0 if t_0 <= 2.8e-12: tmp = (1.0 + beta) / alpha elif t_0 <= 0.6: tmp = 1.0 / (2.0 + alpha) else: tmp = 1.0 - (1.0 / beta) return tmp
function code(alpha, beta) t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) tmp = 0.0 if (t_0 <= 2.8e-12) tmp = Float64(Float64(1.0 + beta) / alpha); elseif (t_0 <= 0.6) tmp = Float64(1.0 / Float64(2.0 + alpha)); else tmp = Float64(1.0 - Float64(1.0 / beta)); end return tmp end
function tmp_2 = code(alpha, beta) t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0; tmp = 0.0; if (t_0 <= 2.8e-12) tmp = (1.0 + beta) / alpha; elseif (t_0 <= 0.6) tmp = 1.0 / (2.0 + alpha); else tmp = 1.0 - (1.0 / beta); end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 2.8e-12], N[(N[(1.0 + beta), $MachinePrecision] / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(1.0 / N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 2.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{1 + \beta}{\alpha}\\
\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\frac{1}{2 + \alpha}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{\beta}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2.8000000000000002e-12Initial program 5.9%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in beta around 0
div-add-revN/A
lower-/.f64N/A
lower-+.f6499.7
Applied rewrites99.7%
if 2.8000000000000002e-12 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978Initial program 99.3%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
metadata-evalN/A
frac-addN/A
lower-/.f64N/A
lower-fma.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6499.7
Applied rewrites99.7%
Taylor expanded in beta around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
distribute-lft-inN/A
metadata-evalN/A
lower-+.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-+.f6497.2
Applied rewrites97.2%
Taylor expanded in alpha around 0
Applied rewrites97.2%
if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in beta around inf
lower--.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
(if (<= t_0 2e-8)
(/ (+ 1.0 beta) alpha)
(if (<= t_0 0.6) (fma -0.25 alpha 0.5) (- 1.0 (/ 1.0 beta))))))
double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-8) {
tmp = (1.0 + beta) / alpha;
} else if (t_0 <= 0.6) {
tmp = fma(-0.25, alpha, 0.5);
} else {
tmp = 1.0 - (1.0 / beta);
}
return tmp;
}
function code(alpha, beta) t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) tmp = 0.0 if (t_0 <= 2e-8) tmp = Float64(Float64(1.0 + beta) / alpha); elseif (t_0 <= 0.6) tmp = fma(-0.25, alpha, 0.5); else tmp = Float64(1.0 - Float64(1.0 / beta)); end return tmp end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-8], N[(N[(1.0 + beta), $MachinePrecision] / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(-0.25 * alpha + 0.5), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{1 + \beta}{\alpha}\\
\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-0.25, \alpha, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{\beta}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2e-8Initial program 6.6%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
Taylor expanded in beta around 0
div-add-revN/A
lower-/.f64N/A
lower-+.f6499.3
Applied rewrites99.3%
if 2e-8 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978Initial program 99.7%
Taylor expanded in beta around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6497.3
Applied rewrites97.3%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6495.5
Applied rewrites95.5%
if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in beta around inf
lower--.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
(if (<= t_0 2e-8)
(/ 1.0 alpha)
(if (<= t_0 0.6) (fma -0.25 alpha 0.5) (- 1.0 (/ 1.0 beta))))))
double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-8) {
tmp = 1.0 / alpha;
} else if (t_0 <= 0.6) {
tmp = fma(-0.25, alpha, 0.5);
} else {
tmp = 1.0 - (1.0 / beta);
}
return tmp;
}
function code(alpha, beta) t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) tmp = 0.0 if (t_0 <= 2e-8) tmp = Float64(1.0 / alpha); elseif (t_0 <= 0.6) tmp = fma(-0.25, alpha, 0.5); else tmp = Float64(1.0 - Float64(1.0 / beta)); end return tmp end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-8], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(-0.25 * alpha + 0.5), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\alpha}\\
\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-0.25, \alpha, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{\beta}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2e-8Initial program 6.6%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
Taylor expanded in beta around 0
lower-/.f6479.1
Applied rewrites79.1%
if 2e-8 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978Initial program 99.7%
Taylor expanded in beta around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6497.3
Applied rewrites97.3%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6495.5
Applied rewrites95.5%
if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in beta around inf
lower--.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
(if (<= t_0 2e-8)
(/ 1.0 alpha)
(if (<= t_0 0.6) (fma -0.25 alpha 0.5) 1.0))))
double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-8) {
tmp = 1.0 / alpha;
} else if (t_0 <= 0.6) {
tmp = fma(-0.25, alpha, 0.5);
} else {
tmp = 1.0;
}
return tmp;
}
function code(alpha, beta) t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) tmp = 0.0 if (t_0 <= 2e-8) tmp = Float64(1.0 / alpha); elseif (t_0 <= 0.6) tmp = fma(-0.25, alpha, 0.5); else tmp = 1.0; end return tmp end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-8], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(-0.25 * alpha + 0.5), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\alpha}\\
\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-0.25, \alpha, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2e-8Initial program 6.6%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
Taylor expanded in beta around 0
lower-/.f6479.1
Applied rewrites79.1%
if 2e-8 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978Initial program 99.7%
Taylor expanded in beta around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6497.3
Applied rewrites97.3%
Taylor expanded in alpha around 0
+-commutativeN/A
lower-fma.f6495.5
Applied rewrites95.5%
if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in beta around inf
Applied rewrites97.1%
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))) (if (<= t_0 2e-8) (/ 1.0 alpha) (if (<= t_0 0.6) (fma 0.25 beta 0.5) 1.0))))
double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-8) {
tmp = 1.0 / alpha;
} else if (t_0 <= 0.6) {
tmp = fma(0.25, beta, 0.5);
} else {
tmp = 1.0;
}
return tmp;
}
function code(alpha, beta) t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) tmp = 0.0 if (t_0 <= 2e-8) tmp = Float64(1.0 / alpha); elseif (t_0 <= 0.6) tmp = fma(0.25, beta, 0.5); else tmp = 1.0; end return tmp end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-8], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(0.25 * beta + 0.5), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\alpha}\\
\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(0.25, \beta, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2e-8Initial program 6.6%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
Taylor expanded in beta around 0
lower-/.f6479.1
Applied rewrites79.1%
if 2e-8 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978Initial program 99.7%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6496.6
Applied rewrites96.6%
Taylor expanded in beta around 0
+-commutativeN/A
lower-fma.f6495.6
Applied rewrites95.6%
if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in beta around inf
Applied rewrites97.1%
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))) (if (<= t_0 2e-8) (/ 1.0 alpha) (if (<= t_0 0.6) 0.5 1.0))))
double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-8) {
tmp = 1.0 / alpha;
} else if (t_0 <= 0.6) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
if (t_0 <= 2d-8) then
tmp = 1.0d0 / alpha
else if (t_0 <= 0.6d0) then
tmp = 0.5d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
double tmp;
if (t_0 <= 2e-8) {
tmp = 1.0 / alpha;
} else if (t_0 <= 0.6) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(alpha, beta): t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0 tmp = 0 if t_0 <= 2e-8: tmp = 1.0 / alpha elif t_0 <= 0.6: tmp = 0.5 else: tmp = 1.0 return tmp
function code(alpha, beta) t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) tmp = 0.0 if (t_0 <= 2e-8) tmp = Float64(1.0 / alpha); elseif (t_0 <= 0.6) tmp = 0.5; else tmp = 1.0; end return tmp end
function tmp_2 = code(alpha, beta) t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0; tmp = 0.0; if (t_0 <= 2e-8) tmp = 1.0 / alpha; elseif (t_0 <= 0.6) tmp = 0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-8], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], 0.5, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\alpha}\\
\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 2e-8Initial program 6.6%
Taylor expanded in alpha around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
Taylor expanded in beta around 0
lower-/.f6479.1
Applied rewrites79.1%
if 2e-8 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978Initial program 99.7%
Taylor expanded in beta around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6497.3
Applied rewrites97.3%
Taylor expanded in alpha around 0
Applied rewrites94.6%
if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in beta around inf
Applied rewrites97.1%
(FPCore (alpha beta) :precision binary64 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.75) 0.5 1.0))
double code(double alpha, double beta) {
double tmp;
if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (((((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0) <= 0.75d0) then
tmp = 0.5d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double tmp;
if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if ((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75: tmp = 0.5 else: tmp = 1.0 return tmp
function code(alpha, beta) tmp = 0.0 if (Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75) tmp = 0.5; else tmp = 1.0; end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75) tmp = 0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 0.75], 0.5, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.75:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.75Initial program 65.3%
Taylor expanded in beta around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6463.5
Applied rewrites63.5%
Taylor expanded in alpha around 0
Applied rewrites61.5%
if 0.75 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in beta around inf
Applied rewrites97.4%
(FPCore (alpha beta) :precision binary64 1.0)
double code(double alpha, double beta) {
return 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = 1.0d0
end function
public static double code(double alpha, double beta) {
return 1.0;
}
def code(alpha, beta): return 1.0
function code(alpha, beta) return 1.0 end
function tmp = code(alpha, beta) tmp = 1.0; end
code[alpha_, beta_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 75.1%
Taylor expanded in beta around inf
Applied rewrites37.3%
herbie shell --seed 2025117
(FPCore (alpha beta)
:name "Octave 3.8, jcobi/1"
:precision binary64
:pre (and (> alpha -1.0) (> beta -1.0))
(/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))