
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 6e+151)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) t_0)
(* t_0 (+ 3.0 (+ beta alpha))))
(/ (/ (+ 1.0 alpha) t_0) (+ t_0 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 6e+151) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / t_0) / (t_0 * (3.0 + (beta + alpha)));
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 6e+151) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / t_0) / Float64(t_0 * Float64(3.0 + Float64(beta + alpha)))); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / Float64(t_0 + 1.0)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 6e+151], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 * N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 6 \cdot 10^{+151}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_0}}{t\_0 \cdot \left(3 + \left(\beta + \alpha\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{t\_0 + 1}\\
\end{array}
\end{array}
if beta < 5.9999999999999998e151Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.8%
if 5.9999999999999998e151 < beta Initial program 82.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6482.1
lift-*.f64N/A
metadata-eval82.1
Applied rewrites82.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6482.1
lift-*.f64N/A
metadata-eval82.1
Applied rewrites82.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6482.1
lift-*.f64N/A
metadata-eval82.1
Applied rewrites82.1%
Taylor expanded in beta around inf
lift-+.f6499.4
Applied rewrites99.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 5e+99)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) (* t_0 t_0))
(+ 3.0 (+ beta alpha)))
(/ (/ (+ 1.0 alpha) t_0) (+ t_0 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 5e+99) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / (t_0 * t_0)) / (3.0 + (beta + alpha));
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 5e+99) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / Float64(t_0 * t_0)) / Float64(3.0 + Float64(beta + alpha))); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / Float64(t_0 + 1.0)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 5e+99], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 5 \cdot 10^{+99}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_0 \cdot t\_0}}{3 + \left(\beta + \alpha\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{t\_0 + 1}\\
\end{array}
\end{array}
if beta < 5.00000000000000008e99Initial program 99.8%
Applied rewrites99.8%
if 5.00000000000000008e99 < beta Initial program 86.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.0
lift-*.f64N/A
metadata-eval86.0
Applied rewrites86.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.0
lift-*.f64N/A
metadata-eval86.0
Applied rewrites86.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.0
lift-*.f64N/A
metadata-eval86.0
Applied rewrites86.0%
Taylor expanded in beta around inf
lift-+.f6499.2
Applied rewrites99.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 1e+16)
(/ (/ (/ (+ 1.0 beta) (+ 2.0 beta)) t_0) (+ 3.0 beta))
(/ (/ (+ 1.0 alpha) t_0) (+ t_0 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1e+16) {
tmp = (((1.0 + beta) / (2.0 + beta)) / t_0) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.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 = (beta + alpha) + 2.0d0
if (beta <= 1d+16) then
tmp = (((1.0d0 + beta) / (2.0d0 + beta)) / t_0) / (3.0d0 + beta)
else
tmp = ((1.0d0 + alpha) / t_0) / (t_0 + 1.0d0)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1e+16) {
tmp = (((1.0 + beta) / (2.0 + beta)) / t_0) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (beta + alpha) + 2.0 tmp = 0 if beta <= 1e+16: tmp = (((1.0 + beta) / (2.0 + beta)) / t_0) / (3.0 + beta) else: tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1e+16) tmp = Float64(Float64(Float64(Float64(1.0 + beta) / Float64(2.0 + beta)) / t_0) / Float64(3.0 + beta)); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / Float64(t_0 + 1.0)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (beta + alpha) + 2.0;
tmp = 0.0;
if (beta <= 1e+16)
tmp = (((1.0 + beta) / (2.0 + beta)) / t_0) / (3.0 + beta);
else
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.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[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1e+16], N[(N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 10^{+16}:\\
\;\;\;\;\frac{\frac{\frac{1 + \beta}{2 + \beta}}{t\_0}}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{t\_0 + 1}\\
\end{array}
\end{array}
if beta < 1e16Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lift-+.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in alpha around 0
lower-+.f6497.7
Applied rewrites97.7%
if 1e16 < beta Initial program 89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
Taylor expanded in beta around inf
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
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 1e+16)
(/ (/ (/ (+ 1.0 beta) (+ 2.0 beta)) (+ beta 2.0)) (+ 3.0 beta))
(/ (/ (+ 1.0 alpha) t_0) (+ t_0 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1e+16) {
tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.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 = (beta + alpha) + 2.0d0
if (beta <= 1d+16) then
tmp = (((1.0d0 + beta) / (2.0d0 + beta)) / (beta + 2.0d0)) / (3.0d0 + beta)
else
tmp = ((1.0d0 + alpha) / t_0) / (t_0 + 1.0d0)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1e+16) {
tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (beta + alpha) + 2.0 tmp = 0 if beta <= 1e+16: tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta) else: tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1e+16) tmp = Float64(Float64(Float64(Float64(1.0 + beta) / Float64(2.0 + beta)) / Float64(beta + 2.0)) / Float64(3.0 + beta)); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / Float64(t_0 + 1.0)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (beta + alpha) + 2.0;
tmp = 0.0;
if (beta <= 1e+16)
tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta);
else
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.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[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1e+16], N[(N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(beta + 2.0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 10^{+16}:\\
\;\;\;\;\frac{\frac{\frac{1 + \beta}{2 + \beta}}{\beta + 2}}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{t\_0 + 1}\\
\end{array}
\end{array}
if beta < 1e16Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lift-+.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in alpha around 0
lower-+.f6497.7
Applied rewrites97.7%
Taylor expanded in alpha around 0
Applied rewrites97.6%
if 1e16 < beta Initial program 89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
Taylor expanded in beta around inf
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 1e+16) (/ (/ (/ (+ 1.0 beta) (+ 2.0 beta)) (+ beta 2.0)) (+ 3.0 beta)) (/ (/ (+ 1.0 alpha) (+ (+ beta alpha) 2.0)) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1e+16) {
tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 1d+16) then
tmp = (((1.0d0 + beta) / (2.0d0 + beta)) / (beta + 2.0d0)) / (3.0d0 + beta)
else
tmp = ((1.0d0 + alpha) / ((beta + alpha) + 2.0d0)) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 1e+16) {
tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta);
} else {
tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 1e+16: tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta) else: tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1e+16) tmp = Float64(Float64(Float64(Float64(1.0 + beta) / Float64(2.0 + beta)) / Float64(beta + 2.0)) / Float64(3.0 + beta)); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(Float64(beta + alpha) + 2.0)) / Float64(3.0 + beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 1e+16)
tmp = (((1.0 + beta) / (2.0 + beta)) / (beta + 2.0)) / (3.0 + beta);
else
tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 1e+16], N[(N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(beta + 2.0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 10^{+16}:\\
\;\;\;\;\frac{\frac{\frac{1 + \beta}{2 + \beta}}{\beta + 2}}{3 + \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\left(\beta + \alpha\right) + 2}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 1e16Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lift-+.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in alpha around 0
lower-+.f6497.7
Applied rewrites97.7%
Taylor expanded in alpha around 0
Applied rewrites97.6%
if 1e16 < beta Initial program 89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
Taylor expanded in alpha around 0
lower-/.f64N/A
lift-+.f64N/A
lower-+.f6489.3
Applied rewrites89.3%
Taylor expanded in alpha around 0
lower-+.f6489.3
Applied rewrites89.3%
Taylor expanded in beta around inf
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 1e+16) (/ (+ 1.0 beta) (* (+ 3.0 beta) (* (+ 2.0 beta) (+ 2.0 beta)))) (/ (/ (+ 1.0 alpha) (+ (+ beta alpha) 2.0)) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1e+16) {
tmp = (1.0 + beta) / ((3.0 + beta) * ((2.0 + beta) * (2.0 + beta)));
} else {
tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 1d+16) then
tmp = (1.0d0 + beta) / ((3.0d0 + beta) * ((2.0d0 + beta) * (2.0d0 + beta)))
else
tmp = ((1.0d0 + alpha) / ((beta + alpha) + 2.0d0)) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 1e+16) {
tmp = (1.0 + beta) / ((3.0 + beta) * ((2.0 + beta) * (2.0 + beta)));
} else {
tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 1e+16: tmp = (1.0 + beta) / ((3.0 + beta) * ((2.0 + beta) * (2.0 + beta))) else: tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1e+16) tmp = Float64(Float64(1.0 + beta) / Float64(Float64(3.0 + beta) * Float64(Float64(2.0 + beta) * Float64(2.0 + beta)))); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(Float64(beta + alpha) + 2.0)) / Float64(3.0 + beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 1e+16)
tmp = (1.0 + beta) / ((3.0 + beta) * ((2.0 + beta) * (2.0 + beta)));
else
tmp = ((1.0 + alpha) / ((beta + alpha) + 2.0)) / (3.0 + beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 1e+16], N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(3.0 + beta), $MachinePrecision] * N[(N[(2.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 10^{+16}:\\
\;\;\;\;\frac{1 + \beta}{\left(3 + \beta\right) \cdot \left(\left(2 + \beta\right) \cdot \left(2 + \beta\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\left(\beta + \alpha\right) + 2}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 1e16Initial program 99.9%
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.6
Applied rewrites97.6%
if 1e16 < beta Initial program 89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
lift-*.f64N/A
metadata-eval89.4
Applied rewrites89.4%
Taylor expanded in alpha around 0
lower-/.f64N/A
lift-+.f64N/A
lower-+.f6489.3
Applied rewrites89.3%
Taylor expanded in alpha around 0
lower-+.f6489.3
Applied rewrites89.3%
Taylor expanded in beta around inf
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
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.35)
(/ (- 0.25 (* 0.0625 (* alpha alpha))) (+ t_0 1.0))
(/ (/ (+ 1.0 alpha) t_0) (+ 3.0 beta)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.35) {
tmp = (0.25 - (0.0625 * (alpha * alpha))) / (t_0 + 1.0);
} else {
tmp = ((1.0 + alpha) / t_0) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: tmp
t_0 = (beta + alpha) + 2.0d0
if (beta <= 1.35d0) then
tmp = (0.25d0 - (0.0625d0 * (alpha * alpha))) / (t_0 + 1.0d0)
else
tmp = ((1.0d0 + alpha) / t_0) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.35) {
tmp = (0.25 - (0.0625 * (alpha * alpha))) / (t_0 + 1.0);
} else {
tmp = ((1.0 + alpha) / t_0) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (beta + alpha) + 2.0 tmp = 0 if beta <= 1.35: tmp = (0.25 - (0.0625 * (alpha * alpha))) / (t_0 + 1.0) else: tmp = ((1.0 + alpha) / t_0) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.35) tmp = Float64(Float64(0.25 - Float64(0.0625 * Float64(alpha * alpha))) / Float64(t_0 + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / Float64(3.0 + beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (beta + alpha) + 2.0;
tmp = 0.0;
if (beta <= 1.35)
tmp = (0.25 - (0.0625 * (alpha * alpha))) / (t_0 + 1.0);
else
tmp = ((1.0 + alpha) / t_0) / (3.0 + beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.35], N[(N[(0.25 - N[(0.0625 * N[(alpha * alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.35:\\
\;\;\;\;\frac{0.25 - 0.0625 \cdot \left(\alpha \cdot \alpha\right)}{t\_0 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 1.3500000000000001Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
pow2N/A
lift-*.f6498.3
Applied rewrites98.3%
if 1.3500000000000001 < beta Initial program 89.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.8
lift-*.f64N/A
metadata-eval89.8
Applied rewrites89.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.8
lift-*.f64N/A
metadata-eval89.8
Applied rewrites89.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.8
lift-*.f64N/A
metadata-eval89.8
Applied rewrites89.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lift-+.f64N/A
lower-+.f6489.5
Applied rewrites89.5%
Taylor expanded in alpha around 0
lower-+.f6489.5
Applied rewrites89.5%
Taylor expanded in beta around inf
lift-+.f6497.5
Applied rewrites97.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 2.2)
(/ 0.25 (+ t_0 1.0))
(/ (/ (+ 1.0 alpha) t_0) (+ 3.0 beta)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 2.2) {
tmp = 0.25 / (t_0 + 1.0);
} else {
tmp = ((1.0 + alpha) / t_0) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: tmp
t_0 = (beta + alpha) + 2.0d0
if (beta <= 2.2d0) then
tmp = 0.25d0 / (t_0 + 1.0d0)
else
tmp = ((1.0d0 + alpha) / t_0) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 2.2) {
tmp = 0.25 / (t_0 + 1.0);
} else {
tmp = ((1.0 + alpha) / t_0) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (beta + alpha) + 2.0 tmp = 0 if beta <= 2.2: tmp = 0.25 / (t_0 + 1.0) else: tmp = ((1.0 + alpha) / t_0) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 2.2) tmp = Float64(0.25 / Float64(t_0 + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / Float64(3.0 + beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (beta + alpha) + 2.0;
tmp = 0.0;
if (beta <= 2.2)
tmp = 0.25 / (t_0 + 1.0);
else
tmp = ((1.0 + alpha) / t_0) / (3.0 + beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 2.2], N[(0.25 / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 2.2:\\
\;\;\;\;\frac{0.25}{t\_0 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 2.2000000000000002Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
Taylor expanded in alpha around 0
Applied rewrites97.8%
if 2.2000000000000002 < beta Initial program 89.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.8
lift-*.f64N/A
metadata-eval89.8
Applied rewrites89.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.8
lift-*.f64N/A
metadata-eval89.8
Applied rewrites89.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.8
lift-*.f64N/A
metadata-eval89.8
Applied rewrites89.8%
Taylor expanded in alpha around 0
lower-/.f64N/A
lift-+.f64N/A
lower-+.f6489.5
Applied rewrites89.5%
Taylor expanded in alpha around 0
lower-+.f6489.5
Applied rewrites89.5%
Taylor expanded in beta around inf
lift-+.f6497.5
Applied rewrites97.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.1) (/ 0.25 (+ (+ (+ beta alpha) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ (+ alpha beta) 3.0))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.1) {
tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / ((alpha + beta) + 3.0);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 4.1d0) then
tmp = 0.25d0 / (((beta + alpha) + 2.0d0) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / ((alpha + beta) + 3.0d0)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 4.1) {
tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / ((alpha + beta) + 3.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 4.1: tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0) else: tmp = ((1.0 + alpha) / beta) / ((alpha + beta) + 3.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.1) tmp = Float64(0.25 / Float64(Float64(Float64(beta + alpha) + 2.0) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(alpha + beta) + 3.0)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 4.1)
tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0);
else
tmp = ((1.0 + alpha) / beta) / ((alpha + beta) + 3.0);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 4.1], N[(0.25 / N[(N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.1:\\
\;\;\;\;\frac{0.25}{\left(\left(\beta + \alpha\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\alpha + \beta\right) + 3}\\
\end{array}
\end{array}
if beta < 4.0999999999999996Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in alpha around 0
Applied rewrites97.8%
if 4.0999999999999996 < beta Initial program 89.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f64N/A
lift-+.f6497.5
Applied rewrites97.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.1) (/ 0.25 (+ (+ (+ beta alpha) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.1) {
tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 4.1d0) then
tmp = 0.25d0 / (((beta + alpha) + 2.0d0) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 4.1) {
tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 4.1: tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0) else: tmp = ((1.0 + alpha) / beta) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.1) tmp = Float64(0.25 / Float64(Float64(Float64(beta + alpha) + 2.0) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(3.0 + beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 4.1)
tmp = 0.25 / (((beta + alpha) + 2.0) + 1.0);
else
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 4.1], N[(0.25 / N[(N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.1:\\
\;\;\;\;\frac{0.25}{\left(\left(\beta + \alpha\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 4.0999999999999996Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in alpha around 0
Applied rewrites97.8%
if 4.0999999999999996 < beta Initial program 89.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in alpha around 0
lower-+.f6497.5
Applied rewrites97.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 6.7) (/ 0.25 (+ (+ (+ beta alpha) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 6.7) {
tmp = 0.25 / (((beta + alpha) + 2.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.7d0) then
tmp = 0.25d0 / (((beta + alpha) + 2.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.7) {
tmp = 0.25 / (((beta + alpha) + 2.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.7: tmp = 0.25 / (((beta + alpha) + 2.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.7) tmp = Float64(0.25 / Float64(Float64(Float64(beta + alpha) + 2.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.7)
tmp = 0.25 / (((beta + alpha) + 2.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.7], N[(0.25 / N[(N[(N[(beta + alpha), $MachinePrecision] + 2.0), $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.7:\\
\;\;\;\;\frac{0.25}{\left(\left(\beta + \alpha\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 6.70000000000000018Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in alpha around 0
Applied rewrites97.7%
if 6.70000000000000018 < beta Initial program 89.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in beta around inf
Applied rewrites97.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 3.05)
(+
0.08333333333333333
(* alpha (fma -0.011574074074074073 alpha -0.027777777777777776)))
(/ (/ (+ 1.0 alpha) beta) beta)))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.05) {
tmp = 0.08333333333333333 + (alpha * fma(-0.011574074074074073, alpha, -0.027777777777777776));
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.05) tmp = Float64(0.08333333333333333 + Float64(alpha * fma(-0.011574074074074073, alpha, -0.027777777777777776))); 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.05], N[(0.08333333333333333 + N[(alpha * N[(-0.011574074074074073 * alpha + -0.027777777777777776), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.05:\\
\;\;\;\;0.08333333333333333 + \alpha \cdot \mathsf{fma}\left(-0.011574074074074073, \alpha, -0.027777777777777776\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 3.0499999999999998Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6497.9
Applied rewrites97.9%
Taylor expanded in alpha around 0
lower-+.f64N/A
lower-*.f64N/A
negate-subN/A
metadata-evalN/A
lower-fma.f6497.2
Applied rewrites97.2%
if 3.0499999999999998 < beta Initial program 89.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in beta around inf
Applied rewrites97.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.5) (- 0.08333333333333333 (* 0.027777777777777776 alpha)) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.5) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} 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 <= 3.5d0) then
tmp = 0.08333333333333333d0 - (0.027777777777777776d0 * alpha)
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 <= 3.5) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 3.5: tmp = 0.08333333333333333 - (0.027777777777777776 * alpha) else: tmp = ((1.0 + alpha) / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.5) tmp = Float64(0.08333333333333333 - Float64(0.027777777777777776 * alpha)); 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 <= 3.5)
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
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, 3.5], N[(0.08333333333333333 - N[(0.027777777777777776 * alpha), $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 3.5:\\
\;\;\;\;0.08333333333333333 - 0.027777777777777776 \cdot \alpha\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 3.5Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6497.9
Applied rewrites97.9%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6496.9
Applied rewrites96.9%
if 3.5 < beta Initial program 89.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in beta around inf
Applied rewrites97.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.5) (- 0.08333333333333333 (* 0.027777777777777776 alpha)) (/ (+ 1.0 alpha) (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.5) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} 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 <= 3.5d0) then
tmp = 0.08333333333333333d0 - (0.027777777777777776d0 * alpha)
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 <= 3.5) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 3.5: tmp = 0.08333333333333333 - (0.027777777777777776 * alpha) else: tmp = (1.0 + alpha) / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.5) tmp = Float64(0.08333333333333333 - Float64(0.027777777777777776 * alpha)); else tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 3.5)
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
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, 3.5], N[(0.08333333333333333 - N[(0.027777777777777776 * alpha), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.5:\\
\;\;\;\;0.08333333333333333 - 0.027777777777777776 \cdot \alpha\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 3.5Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6497.9
Applied rewrites97.9%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6496.9
Applied rewrites96.9%
if 3.5 < beta Initial program 89.8%
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.05) (- 0.08333333333333333 (* 0.027777777777777776 alpha)) (/ (/ 1.0 beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.05) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} else {
tmp = (1.0 / beta) / beta;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 3.05d0) then
tmp = 0.08333333333333333d0 - (0.027777777777777776d0 * alpha)
else
tmp = (1.0d0 / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 3.05) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} else {
tmp = (1.0 / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 3.05: tmp = 0.08333333333333333 - (0.027777777777777776 * alpha) else: tmp = (1.0 / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.05) tmp = Float64(0.08333333333333333 - Float64(0.027777777777777776 * alpha)); else tmp = Float64(Float64(1.0 / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 3.05)
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
else
tmp = (1.0 / beta) / beta;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 3.05], N[(0.08333333333333333 - N[(0.027777777777777776 * alpha), $MachinePrecision]), $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.05:\\
\;\;\;\;0.08333333333333333 - 0.027777777777777776 \cdot \alpha\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 3.0499999999999998Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6497.9
Applied rewrites97.9%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6496.9
Applied rewrites96.9%
if 3.0499999999999998 < beta Initial program 89.8%
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.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6488.0
Applied rewrites88.0%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.05) (- 0.08333333333333333 (* 0.027777777777777776 alpha)) (/ 1.0 (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.05) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} else {
tmp = 1.0 / (beta * beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 3.05d0) then
tmp = 0.08333333333333333d0 - (0.027777777777777776d0 * alpha)
else
tmp = 1.0d0 / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 3.05) {
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
} else {
tmp = 1.0 / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 3.05: tmp = 0.08333333333333333 - (0.027777777777777776 * alpha) else: tmp = 1.0 / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.05) tmp = Float64(0.08333333333333333 - Float64(0.027777777777777776 * alpha)); else tmp = Float64(1.0 / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 3.05)
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
else
tmp = 1.0 / (beta * beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 3.05], N[(0.08333333333333333 - N[(0.027777777777777776 * alpha), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.05:\\
\;\;\;\;0.08333333333333333 - 0.027777777777777776 \cdot \alpha\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 3.0499999999999998Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-*.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6497.9
Applied rewrites97.9%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6496.9
Applied rewrites96.9%
if 3.0499999999999998 < beta Initial program 89.8%
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.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (- 0.08333333333333333 (* 0.027777777777777776 alpha)))
assert(alpha < beta);
double code(double alpha, double beta) {
return 0.08333333333333333 - (0.027777777777777776 * alpha);
}
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 - (0.027777777777777776d0 * alpha)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return 0.08333333333333333 - (0.027777777777777776 * alpha);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return 0.08333333333333333 - (0.027777777777777776 * alpha)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(0.08333333333333333 - Float64(0.027777777777777776 * alpha)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = 0.08333333333333333 - (0.027777777777777776 * alpha);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(0.08333333333333333 - N[(0.027777777777777776 * alpha), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
0.08333333333333333 - 0.027777777777777776 \cdot \alpha
\end{array}
Initial program 94.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.3
lift-*.f64N/A
metadata-eval94.3
Applied rewrites94.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.3
lift-*.f64N/A
metadata-eval94.3
Applied rewrites94.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.3
lift-*.f64N/A
metadata-eval94.3
Applied rewrites94.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6448.9
Applied rewrites48.9%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6445.7
Applied rewrites45.7%
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.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.3
lift-*.f64N/A
metadata-eval94.3
Applied rewrites94.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.3
lift-*.f64N/A
metadata-eval94.3
Applied rewrites94.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.3
lift-*.f64N/A
metadata-eval94.3
Applied rewrites94.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6448.9
Applied rewrites48.9%
Taylor expanded in alpha around 0
Applied rewrites45.3%
herbie shell --seed 2025120
(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)))