
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ alpha beta) 2.0)) (t_1 (+ (+ beta alpha) 2.0)))
(if (<= beta 2e+100)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) t_1)
(* t_1 (+ 3.0 (+ beta alpha))))
(/
(/
(-
(+ (+ (/ (+ 1.0 alpha) beta) alpha) 1.0)
(* (+ 1.0 alpha) (/ (+ 2.0 alpha) beta)))
t_0)
(+ t_0 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double t_1 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 2e+100) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / t_1) / (t_1 * (3.0 + (beta + alpha)));
} else {
tmp = ((((((1.0 + alpha) / beta) + alpha) + 1.0) - ((1.0 + alpha) * ((2.0 + alpha) / beta))) / t_0) / (t_0 + 1.0);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) t_1 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 2e+100) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / t_1) / Float64(t_1 * Float64(3.0 + Float64(beta + alpha)))); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(1.0 + alpha) / beta) + alpha) + 1.0) - Float64(Float64(1.0 + alpha) * Float64(Float64(2.0 + alpha) / beta))) / 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[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 2e+100], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$1), $MachinePrecision] / N[(t$95$1 * N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] + alpha), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(1.0 + alpha), $MachinePrecision] * N[(N[(2.0 + alpha), $MachinePrecision] / beta), $MachinePrecision]), $MachinePrecision]), $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(\alpha + \beta\right) + 2\\
t_1 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 2 \cdot 10^{+100}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_1}}{t\_1 \cdot \left(3 + \left(\beta + \alpha\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\left(\frac{1 + \alpha}{\beta} + \alpha\right) + 1\right) - \left(1 + \alpha\right) \cdot \frac{2 + \alpha}{\beta}}{t\_0}}{t\_0 + 1}\\
\end{array}
\end{array}
if beta < 2.00000000000000003e100Initial program 98.3%
lift-/.f64N/A
Applied rewrites98.0%
if 2.00000000000000003e100 < beta Initial program 81.5%
Taylor expanded in beta around inf
Applied rewrites92.2%
Final simplification96.7%
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 2e+100)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) t_0)
(* t_0 (+ 3.0 (+ beta alpha))))
(/
(/
(-
(+ (+ (/ (+ 1.0 alpha) beta) alpha) 1.0)
(* (+ 1.0 alpha) (/ (fma 2.0 alpha 4.0) beta)))
beta)
(+ (+ (+ alpha beta) 2.0) 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 2e+100) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / t_0) / (t_0 * (3.0 + (beta + alpha)));
} else {
tmp = ((((((1.0 + alpha) / beta) + alpha) + 1.0) - ((1.0 + alpha) * (fma(2.0, alpha, 4.0) / beta))) / beta) / (((alpha + beta) + 2.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 <= 2e+100) 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(Float64(Float64(Float64(Float64(1.0 + alpha) / beta) + alpha) + 1.0) - Float64(Float64(1.0 + alpha) * Float64(fma(2.0, alpha, 4.0) / beta))) / beta) / Float64(Float64(Float64(alpha + beta) + 2.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, 2e+100], 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[(N[(N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] + alpha), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(1.0 + alpha), $MachinePrecision] * N[(N[(2.0 * alpha + 4.0), $MachinePrecision] / beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision] + 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 2 \cdot 10^{+100}:\\
\;\;\;\;\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{\left(\left(\frac{1 + \alpha}{\beta} + \alpha\right) + 1\right) - \left(1 + \alpha\right) \cdot \frac{\mathsf{fma}\left(2, \alpha, 4\right)}{\beta}}{\beta}}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\end{array}
\end{array}
if beta < 2.00000000000000003e100Initial program 98.3%
lift-/.f64N/A
Applied rewrites98.0%
if 2.00000000000000003e100 < beta Initial program 81.5%
Taylor expanded in beta around inf
Applied rewrites92.1%
Final simplification96.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ alpha beta) 2.0)) (t_1 (+ (+ beta alpha) 2.0)))
(if (<= beta 2e+100)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) t_1)
(* t_1 (+ 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 = (alpha + beta) + 2.0;
double t_1 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 2e+100) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / t_1) / (t_1 * (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(alpha + beta) + 2.0) t_1 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 2e+100) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / t_1) / Float64(t_1 * 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[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 2e+100], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$1), $MachinePrecision] / N[(t$95$1 * 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(\alpha + \beta\right) + 2\\
t_1 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 2 \cdot 10^{+100}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_1}}{t\_1 \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 < 2.00000000000000003e100Initial program 98.3%
lift-/.f64N/A
Applied rewrites98.0%
if 2.00000000000000003e100 < beta Initial program 81.5%
Taylor expanded in beta around inf
Applied rewrites92.3%
lift-*.f64N/A
metadata-evalN/A
lift-*.f64N/A
metadata-evalN/A
Applied rewrites92.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ alpha beta) 2.0)))
(if (<= beta 5e+43)
(/
(* (+ 1.0 beta) (- beta 2.0))
(* (+ 2.0 beta) (* (+ 3.0 beta) (- (* beta beta) 4.0))))
(/ (/ (+ 1.0 alpha) t_0) (+ t_0 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 5e+43) {
tmp = ((1.0 + beta) * (beta - 2.0)) / ((2.0 + beta) * ((3.0 + beta) * ((beta * beta) - 4.0)));
} 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 = (alpha + beta) + 2.0d0
if (beta <= 5d+43) then
tmp = ((1.0d0 + beta) * (beta - 2.0d0)) / ((2.0d0 + beta) * ((3.0d0 + beta) * ((beta * beta) - 4.0d0)))
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 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 5e+43) {
tmp = ((1.0 + beta) * (beta - 2.0)) / ((2.0 + beta) * ((3.0 + beta) * ((beta * beta) - 4.0)));
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + 2.0 tmp = 0 if beta <= 5e+43: tmp = ((1.0 + beta) * (beta - 2.0)) / ((2.0 + beta) * ((3.0 + beta) * ((beta * beta) - 4.0))) 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(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 5e+43) tmp = Float64(Float64(Float64(1.0 + beta) * Float64(beta - 2.0)) / Float64(Float64(2.0 + beta) * Float64(Float64(3.0 + beta) * Float64(Float64(beta * beta) - 4.0)))); 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 = (alpha + beta) + 2.0;
tmp = 0.0;
if (beta <= 5e+43)
tmp = ((1.0 + beta) * (beta - 2.0)) / ((2.0 + beta) * ((3.0 + beta) * ((beta * beta) - 4.0)));
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[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 5e+43], N[(N[(N[(1.0 + beta), $MachinePrecision] * N[(beta - 2.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + beta), $MachinePrecision] * N[(N[(3.0 + beta), $MachinePrecision] * N[(N[(beta * beta), $MachinePrecision] - 4.0), $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(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 5 \cdot 10^{+43}:\\
\;\;\;\;\frac{\left(1 + \beta\right) \cdot \left(\beta - 2\right)}{\left(2 + \beta\right) \cdot \left(\left(3 + \beta\right) \cdot \left(\beta \cdot \beta - 4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{t\_0 + 1}\\
\end{array}
\end{array}
if beta < 5.0000000000000004e43Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in alpha around 0
Applied rewrites69.6%
Applied rewrites69.6%
if 5.0000000000000004e43 < beta Initial program 82.6%
Taylor expanded in beta around inf
Applied rewrites84.5%
lift-*.f64N/A
metadata-evalN/A
lift-*.f64N/A
metadata-evalN/A
Applied rewrites84.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ alpha beta) 2.0)))
(if (<= beta 6e+15)
(/
(/ (+ 1.0 beta) (+ 2.0 beta))
(* (+ (+ beta alpha) 2.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 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 6e+15) {
tmp = ((1.0 + beta) / (2.0 + beta)) / (((beta + alpha) + 2.0) * (3.0 + (beta + alpha)));
} 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 = (alpha + beta) + 2.0d0
if (beta <= 6d+15) then
tmp = ((1.0d0 + beta) / (2.0d0 + beta)) / (((beta + alpha) + 2.0d0) * (3.0d0 + (beta + alpha)))
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 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 6e+15) {
tmp = ((1.0 + beta) / (2.0 + beta)) / (((beta + alpha) + 2.0) * (3.0 + (beta + alpha)));
} else {
tmp = ((1.0 + alpha) / t_0) / (t_0 + 1.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + 2.0 tmp = 0 if beta <= 6e+15: tmp = ((1.0 + beta) / (2.0 + beta)) / (((beta + alpha) + 2.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(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 6e+15) tmp = Float64(Float64(Float64(1.0 + beta) / Float64(2.0 + beta)) / Float64(Float64(Float64(beta + alpha) + 2.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
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) + 2.0;
tmp = 0.0;
if (beta <= 6e+15)
tmp = ((1.0 + beta) / (2.0 + beta)) / (((beta + alpha) + 2.0) * (3.0 + (beta + alpha)));
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[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 6e+15], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision] * 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(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 6 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{1 + \beta}{2 + \beta}}{\left(\left(\beta + \alpha\right) + 2\right) \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 < 6e15Initial program 99.8%
lift-/.f64N/A
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites84.0%
if 6e15 < beta Initial program 83.5%
Taylor expanded in beta around inf
Applied rewrites84.2%
lift-*.f64N/A
metadata-evalN/A
lift-*.f64N/A
metadata-evalN/A
Applied rewrites84.2%
Final simplification84.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ alpha beta) 2.0)) (t_1 (+ t_0 1.0)))
(if (<= beta 1.35)
(/ (+ 0.25 (* -0.0625 (* beta beta))) t_1)
(/ (/ (+ 1.0 alpha) t_0) t_1))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double t_1 = t_0 + 1.0;
double tmp;
if (beta <= 1.35) {
tmp = (0.25 + (-0.0625 * (beta * beta))) / t_1;
} else {
tmp = ((1.0 + alpha) / t_0) / t_1;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (alpha + beta) + 2.0d0
t_1 = t_0 + 1.0d0
if (beta <= 1.35d0) then
tmp = (0.25d0 + ((-0.0625d0) * (beta * beta))) / t_1
else
tmp = ((1.0d0 + alpha) / t_0) / t_1
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double t_1 = t_0 + 1.0;
double tmp;
if (beta <= 1.35) {
tmp = (0.25 + (-0.0625 * (beta * beta))) / t_1;
} else {
tmp = ((1.0 + alpha) / t_0) / t_1;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) + 2.0 t_1 = t_0 + 1.0 tmp = 0 if beta <= 1.35: tmp = (0.25 + (-0.0625 * (beta * beta))) / t_1 else: tmp = ((1.0 + alpha) / t_0) / t_1 return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) t_1 = Float64(t_0 + 1.0) tmp = 0.0 if (beta <= 1.35) tmp = Float64(Float64(0.25 + Float64(-0.0625 * Float64(beta * beta))) / t_1); else tmp = Float64(Float64(Float64(1.0 + alpha) / t_0) / t_1); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) + 2.0;
t_1 = t_0 + 1.0;
tmp = 0.0;
if (beta <= 1.35)
tmp = (0.25 + (-0.0625 * (beta * beta))) / t_1;
else
tmp = ((1.0 + alpha) / t_0) / t_1;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + 1.0), $MachinePrecision]}, If[LessEqual[beta, 1.35], N[(N[(0.25 + N[(-0.0625 * N[(beta * beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
t_1 := t\_0 + 1\\
\mathbf{if}\;\beta \leq 1.35:\\
\;\;\;\;\frac{0.25 + -0.0625 \cdot \left(\beta \cdot \beta\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{t\_0}}{t\_1}\\
\end{array}
\end{array}
if beta < 1.3500000000000001Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites70.6%
Taylor expanded in beta around 0
Applied rewrites70.3%
if 1.3500000000000001 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites82.5%
lift-*.f64N/A
metadata-evalN/A
lift-*.f64N/A
metadata-evalN/A
Applied rewrites82.5%
Final simplification74.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 1.45) (/ (+ 0.25 (* -0.0625 (* beta beta))) (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) (+ 2.0 beta)) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1.45) {
tmp = (0.25 + (-0.0625 * (beta * beta))) / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / (2.0 + 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 <= 1.45d0) then
tmp = (0.25d0 + ((-0.0625d0) * (beta * beta))) / (((alpha + beta) + 2.0d0) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / (2.0d0 + 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 <= 1.45) {
tmp = (0.25 + (-0.0625 * (beta * beta))) / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / (2.0 + beta)) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 1.45: tmp = (0.25 + (-0.0625 * (beta * beta))) / (((alpha + beta) + 2.0) + 1.0) else: tmp = ((1.0 + alpha) / (2.0 + beta)) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1.45) tmp = Float64(Float64(0.25 + Float64(-0.0625 * Float64(beta * beta))) / Float64(Float64(Float64(alpha + beta) + 2.0) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(2.0 + 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 <= 1.45)
tmp = (0.25 + (-0.0625 * (beta * beta))) / (((alpha + beta) + 2.0) + 1.0);
else
tmp = ((1.0 + alpha) / (2.0 + 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, 1.45], N[(N[(0.25 + N[(-0.0625 * N[(beta * beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 1.45:\\
\;\;\;\;\frac{0.25 + -0.0625 \cdot \left(\beta \cdot \beta\right)}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{2 + \beta}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 1.44999999999999996Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites70.6%
Taylor expanded in beta around 0
Applied rewrites70.3%
if 1.44999999999999996 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites82.5%
Taylor expanded in alpha around 0
Applied rewrites82.1%
Taylor expanded in alpha around 0
Applied rewrites81.9%
Final simplification74.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 2.4) (/ 0.25 (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) (+ 2.0 beta)) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.4) {
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / (2.0 + 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 <= 2.4d0) then
tmp = 0.25d0 / (((alpha + beta) + 2.0d0) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / (2.0d0 + 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 <= 2.4) {
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / (2.0 + beta)) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 2.4: tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0) else: tmp = ((1.0 + alpha) / (2.0 + beta)) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 2.4) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + 2.0) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(2.0 + 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 <= 2.4)
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
else
tmp = ((1.0 + alpha) / (2.0 + 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, 2.4], N[(0.25 / N[(N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2.4:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{2 + \beta}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 2.39999999999999991Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites70.6%
Taylor expanded in beta around 0
Applied rewrites70.1%
if 2.39999999999999991 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites82.5%
Taylor expanded in alpha around 0
Applied rewrites82.1%
Taylor expanded in alpha around 0
Applied rewrites81.9%
Final simplification74.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.4) (/ 0.25 (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ 3.0 (+ alpha beta)))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.4) {
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + (alpha + 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.4d0) then
tmp = 0.25d0 / (((alpha + beta) + 2.0d0) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / (3.0d0 + (alpha + beta))
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 4.4) {
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + (alpha + beta));
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 4.4: tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0) else: tmp = ((1.0 + alpha) / beta) / (3.0 + (alpha + beta)) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.4) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + 2.0) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(3.0 + Float64(alpha + beta))); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 4.4)
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
else
tmp = ((1.0 + alpha) / beta) / (3.0 + (alpha + 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.4], N[(0.25 / N[(N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(3.0 + N[(alpha + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.4:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{3 + \left(\alpha + \beta\right)}\\
\end{array}
\end{array}
if beta < 4.4000000000000004Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites70.6%
Taylor expanded in beta around 0
Applied rewrites70.1%
if 4.4000000000000004 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites82.5%
Taylor expanded in beta around inf
Applied rewrites82.0%
Taylor expanded in alpha around 0
Applied rewrites82.0%
Final simplification74.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 5.0) (/ 0.25 (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ 3.0 beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5.0) {
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 5.0d0) then
tmp = 0.25d0 / (((alpha + beta) + 2.0d0) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / (3.0d0 + beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 5.0) {
tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (3.0 + beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 5.0: tmp = 0.25 / (((alpha + beta) + 2.0) + 1.0) else: tmp = ((1.0 + alpha) / beta) / (3.0 + beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 5.0) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + 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 <= 5.0)
tmp = 0.25 / (((alpha + beta) + 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, 5.0], N[(0.25 / N[(N[(N[(alpha + beta), $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 5:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{3 + \beta}\\
\end{array}
\end{array}
if beta < 5Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites70.6%
Taylor expanded in beta around 0
Applied rewrites70.1%
if 5 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites82.5%
Taylor expanded in beta around inf
Applied rewrites82.0%
Taylor expanded in alpha around 0
Applied rewrites81.8%
Final simplification74.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 6.8) (/ 0.25 (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 6.8) {
tmp = 0.25 / (((alpha + beta) + 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.8d0) then
tmp = 0.25d0 / (((alpha + beta) + 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.8) {
tmp = 0.25 / (((alpha + beta) + 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.8: tmp = 0.25 / (((alpha + beta) + 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.8) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + 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.8)
tmp = 0.25 / (((alpha + beta) + 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.8], N[(0.25 / N[(N[(N[(alpha + beta), $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.8:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 6.79999999999999982Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites70.6%
Taylor expanded in beta around 0
Applied rewrites70.1%
if 6.79999999999999982 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites82.5%
Taylor expanded in beta around inf
Applied rewrites82.0%
Taylor expanded in beta around inf
Applied rewrites81.7%
Final simplification74.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 2.2)
(+
0.08333333333333333
(*
beta
(-
(* beta (- (* 0.024691358024691357 beta) 0.011574074074074073))
0.027777777777777776)))
(/ (+ 1.0 alpha) (* beta beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.2) {
tmp = 0.08333333333333333 + (beta * ((beta * ((0.024691358024691357 * beta) - 0.011574074074074073)) - 0.027777777777777776));
} 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 <= 2.2d0) then
tmp = 0.08333333333333333d0 + (beta * ((beta * ((0.024691358024691357d0 * beta) - 0.011574074074074073d0)) - 0.027777777777777776d0))
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 <= 2.2) {
tmp = 0.08333333333333333 + (beta * ((beta * ((0.024691358024691357 * beta) - 0.011574074074074073)) - 0.027777777777777776));
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 2.2: tmp = 0.08333333333333333 + (beta * ((beta * ((0.024691358024691357 * beta) - 0.011574074074074073)) - 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 <= 2.2) tmp = Float64(0.08333333333333333 + Float64(beta * Float64(Float64(beta * Float64(Float64(0.024691358024691357 * beta) - 0.011574074074074073)) - 0.027777777777777776))); 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 <= 2.2)
tmp = 0.08333333333333333 + (beta * ((beta * ((0.024691358024691357 * beta) - 0.011574074074074073)) - 0.027777777777777776));
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, 2.2], N[(0.08333333333333333 + N[(beta * N[(N[(beta * N[(N[(0.024691358024691357 * beta), $MachinePrecision] - 0.011574074074074073), $MachinePrecision]), $MachinePrecision] - 0.027777777777777776), $MachinePrecision]), $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 2.2:\\
\;\;\;\;0.08333333333333333 + \beta \cdot \left(\beta \cdot \left(0.024691358024691357 \cdot \beta - 0.011574074074074073\right) - 0.027777777777777776\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 2.2000000000000002Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites69.3%
Taylor expanded in beta around 0
Applied rewrites69.3%
if 2.2000000000000002 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites77.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 6.8) (/ 0.25 (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (+ 1.0 alpha) (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 6.8) {
tmp = 0.25 / (((alpha + beta) + 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.8d0) then
tmp = 0.25d0 / (((alpha + beta) + 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.8) {
tmp = 0.25 / (((alpha + beta) + 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.8: tmp = 0.25 / (((alpha + beta) + 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.8) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + 2.0) + 1.0)); else tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 6.8)
tmp = 0.25 / (((alpha + beta) + 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.8], N[(0.25 / N[(N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 6.8:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 6.79999999999999982Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites70.6%
Taylor expanded in beta around 0
Applied rewrites70.1%
if 6.79999999999999982 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites77.2%
Final simplification72.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 1.7)
(+
0.08333333333333333
(* beta (- (* -0.011574074074074073 beta) 0.027777777777777776)))
(/ (+ 1.0 alpha) (* beta beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1.7) {
tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 0.027777777777777776));
} 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 <= 1.7d0) then
tmp = 0.08333333333333333d0 + (beta * (((-0.011574074074074073d0) * beta) - 0.027777777777777776d0))
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 <= 1.7) {
tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 0.027777777777777776));
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 1.7: tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 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 <= 1.7) tmp = Float64(0.08333333333333333 + Float64(beta * Float64(Float64(-0.011574074074074073 * beta) - 0.027777777777777776))); 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 <= 1.7)
tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 0.027777777777777776));
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, 1.7], N[(0.08333333333333333 + N[(beta * N[(N[(-0.011574074074074073 * beta), $MachinePrecision] - 0.027777777777777776), $MachinePrecision]), $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 1.7:\\
\;\;\;\;0.08333333333333333 + \beta \cdot \left(-0.011574074074074073 \cdot \beta - 0.027777777777777776\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 1.69999999999999996Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites69.3%
Taylor expanded in beta around 0
Applied rewrites69.0%
if 1.69999999999999996 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites77.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(if (<= beta 1.7)
(+
0.08333333333333333
(* beta (- (* -0.011574074074074073 beta) 0.027777777777777776)))
(/ 1.0 (* beta beta))))assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1.7) {
tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 0.027777777777777776));
} 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 <= 1.7d0) then
tmp = 0.08333333333333333d0 + (beta * (((-0.011574074074074073d0) * beta) - 0.027777777777777776d0))
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 <= 1.7) {
tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 0.027777777777777776));
} else {
tmp = 1.0 / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 1.7: tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 0.027777777777777776)) else: tmp = 1.0 / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1.7) tmp = Float64(0.08333333333333333 + Float64(beta * Float64(Float64(-0.011574074074074073 * beta) - 0.027777777777777776))); 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 <= 1.7)
tmp = 0.08333333333333333 + (beta * ((-0.011574074074074073 * beta) - 0.027777777777777776));
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, 1.7], N[(0.08333333333333333 + N[(beta * N[(N[(-0.011574074074074073 * beta), $MachinePrecision] - 0.027777777777777776), $MachinePrecision]), $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 1.7:\\
\;\;\;\;0.08333333333333333 + \beta \cdot \left(-0.011574074074074073 \cdot \beta - 0.027777777777777776\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 1.69999999999999996Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites69.3%
Taylor expanded in beta around 0
Applied rewrites69.0%
if 1.69999999999999996 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites77.2%
Taylor expanded in alpha around 0
Applied rewrites72.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 2.8) (+ 0.08333333333333333 (* -0.027777777777777776 beta)) (/ 1.0 (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.8) {
tmp = 0.08333333333333333 + (-0.027777777777777776 * beta);
} 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 <= 2.8d0) then
tmp = 0.08333333333333333d0 + ((-0.027777777777777776d0) * beta)
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 <= 2.8) {
tmp = 0.08333333333333333 + (-0.027777777777777776 * beta);
} else {
tmp = 1.0 / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 2.8: tmp = 0.08333333333333333 + (-0.027777777777777776 * beta) else: tmp = 1.0 / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 2.8) tmp = Float64(0.08333333333333333 + Float64(-0.027777777777777776 * beta)); 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 <= 2.8)
tmp = 0.08333333333333333 + (-0.027777777777777776 * beta);
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, 2.8], N[(0.08333333333333333 + N[(-0.027777777777777776 * beta), $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 2.8:\\
\;\;\;\;0.08333333333333333 + -0.027777777777777776 \cdot \beta\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 2.7999999999999998Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in alpha around 0
Applied rewrites69.3%
Taylor expanded in beta around 0
Applied rewrites68.9%
if 2.7999999999999998 < beta Initial program 84.1%
Taylor expanded in beta around inf
Applied rewrites77.2%
Taylor expanded in alpha around 0
Applied rewrites72.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 0.08333333333333333)
assert(alpha < beta);
double code(double alpha, double beta) {
return 0.08333333333333333;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = 0.08333333333333333d0
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return 0.08333333333333333;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return 0.08333333333333333
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return 0.08333333333333333 end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = 0.08333333333333333;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := 0.08333333333333333
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
0.08333333333333333
\end{array}
Initial program 94.4%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.6
Applied rewrites92.6%
Taylor expanded in alpha around 0
Applied rewrites67.1%
Taylor expanded in beta around 0
Applied rewrites46.1%
herbie shell --seed 2025025
(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)))