
(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 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 (+ (+ alpha beta) 2.0)))
(if (<= beta 1.6e+16)
(/
(/ (/ (* (- (+ (/ (+ 1.0 alpha) beta) alpha) -1.0) beta) t_0) t_0)
(- t_0 -1.0))
(/
(/
(fma
(- (- alpha) 1.0)
(/ (+ 2.0 alpha) beta)
(- (+ (/ (- alpha -1.0) beta) alpha) -1.0))
(+ (+ 2.0 alpha) beta))
(+ 3.0 (+ beta alpha))))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + 2.0;
double tmp;
if (beta <= 1.6e+16) {
tmp = (((((((1.0 + alpha) / beta) + alpha) - -1.0) * beta) / t_0) / t_0) / (t_0 - -1.0);
} else {
tmp = (fma((-alpha - 1.0), ((2.0 + alpha) / beta), ((((alpha - -1.0) / beta) + alpha) - -1.0)) / ((2.0 + alpha) + beta)) / (3.0 + (beta + alpha));
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + 2.0) tmp = 0.0 if (beta <= 1.6e+16) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(1.0 + alpha) / beta) + alpha) - -1.0) * beta) / t_0) / t_0) / Float64(t_0 - -1.0)); else tmp = Float64(Float64(fma(Float64(Float64(-alpha) - 1.0), Float64(Float64(2.0 + alpha) / beta), Float64(Float64(Float64(Float64(alpha - -1.0) / beta) + alpha) - -1.0)) / Float64(Float64(2.0 + alpha) + beta)) / Float64(3.0 + Float64(beta + alpha))); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.6e+16], N[(N[(N[(N[(N[(N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] + alpha), $MachinePrecision] - -1.0), $MachinePrecision] * beta), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[((-alpha) - 1.0), $MachinePrecision] * N[(N[(2.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] + N[(N[(N[(N[(alpha - -1.0), $MachinePrecision] / beta), $MachinePrecision] + alpha), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2\\
\mathbf{if}\;\beta \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\frac{\left(\left(\frac{1 + \alpha}{\beta} + \alpha\right) - -1\right) \cdot \beta}{t\_0}}{t\_0}}{t\_0 - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-\alpha\right) - 1, \frac{2 + \alpha}{\beta}, \left(\frac{\alpha - -1}{\beta} + \alpha\right) - -1\right)}{\left(2 + \alpha\right) + \beta}}{3 + \left(\beta + \alpha\right)}\\
\end{array}
\end{array}
if beta < 1.6e16Initial program 99.9%
Taylor expanded in beta around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f6478.7
Applied rewrites78.7%
if 1.6e16 < beta Initial program 84.1%
Taylor expanded in beta around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6485.1
Applied rewrites85.1%
Applied rewrites85.1%
Final simplification80.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ 3.0 (+ beta alpha))) (t_1 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.6e+16)
(/ (/ (- (fma beta alpha (+ beta alpha)) -1.0) t_1) (* t_0 t_1))
(/
(/
(fma
(- (- alpha) 1.0)
(/ (+ 2.0 alpha) beta)
(- (+ (/ (- alpha -1.0) beta) alpha) -1.0))
(+ (+ 2.0 alpha) beta))
t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = 3.0 + (beta + alpha);
double t_1 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.6e+16) {
tmp = ((fma(beta, alpha, (beta + alpha)) - -1.0) / t_1) / (t_0 * t_1);
} else {
tmp = (fma((-alpha - 1.0), ((2.0 + alpha) / beta), ((((alpha - -1.0) / beta) + alpha) - -1.0)) / ((2.0 + alpha) + beta)) / t_0;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(3.0 + Float64(beta + alpha)) t_1 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.6e+16) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) - -1.0) / t_1) / Float64(t_0 * t_1)); else tmp = Float64(Float64(fma(Float64(Float64(-alpha) - 1.0), Float64(Float64(2.0 + alpha) / beta), Float64(Float64(Float64(Float64(alpha - -1.0) / beta) + alpha) - -1.0)) / Float64(Float64(2.0 + alpha) + beta)) / t_0); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.6e+16], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / t$95$1), $MachinePrecision] / N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[((-alpha) - 1.0), $MachinePrecision] * N[(N[(2.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] + N[(N[(N[(N[(alpha - -1.0), $MachinePrecision] / beta), $MachinePrecision] + alpha), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := 3 + \left(\beta + \alpha\right)\\
t_1 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) - -1}{t\_1}}{t\_0 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-\alpha\right) - 1, \frac{2 + \alpha}{\beta}, \left(\frac{\alpha - -1}{\beta} + \alpha\right) - -1\right)}{\left(2 + \alpha\right) + \beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 1.6e16Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.4%
if 1.6e16 < beta Initial program 84.1%
Taylor expanded in beta around inf
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6485.1
Applied rewrites85.1%
Applied rewrites85.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ 3.0 (+ beta alpha))) (t_1 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.6e+16)
(/ (/ (- (fma beta alpha (+ beta alpha)) -1.0) t_1) (* t_0 t_1))
(/
(/
(-
(- (+ (/ (+ 1.0 alpha) beta) alpha) -1.0)
(* (+ 1.0 alpha) (/ (fma 2.0 alpha 4.0) beta)))
beta)
t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = 3.0 + (beta + alpha);
double t_1 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.6e+16) {
tmp = ((fma(beta, alpha, (beta + alpha)) - -1.0) / t_1) / (t_0 * t_1);
} else {
tmp = ((((((1.0 + alpha) / beta) + alpha) - -1.0) - ((1.0 + alpha) * (fma(2.0, alpha, 4.0) / beta))) / beta) / t_0;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(3.0 + Float64(beta + alpha)) t_1 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.6e+16) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) - -1.0) / t_1) / Float64(t_0 * t_1)); 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) / t_0); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.6e+16], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / t$95$1), $MachinePrecision] / N[(t$95$0 * t$95$1), $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] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := 3 + \left(\beta + \alpha\right)\\
t_1 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) - -1}{t\_1}}{t\_0 \cdot t\_1}\\
\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}}{t\_0}\\
\end{array}
\end{array}
if beta < 1.6e16Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.4%
if 1.6e16 < beta Initial program 84.1%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6485.0
Applied rewrites85.0%
Applied rewrites85.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6485.0
Applied rewrites85.0%
Final simplification95.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 1.6e+16)
(/
(/ (- (fma beta alpha (+ beta alpha)) -1.0) t_0)
(* (+ 3.0 (+ beta alpha)) t_0))
(/
(/
(-
(- (+ (/ (+ 1.0 alpha) beta) alpha) -1.0)
(* (+ 1.0 alpha) (/ (fma 2.0 alpha 4.0) beta)))
beta)
(- beta -3.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.6e+16) {
tmp = ((fma(beta, alpha, (beta + alpha)) - -1.0) / t_0) / ((3.0 + (beta + alpha)) * t_0);
} else {
tmp = ((((((1.0 + alpha) / beta) + alpha) - -1.0) - ((1.0 + alpha) * (fma(2.0, alpha, 4.0) / beta))) / beta) / (beta - -3.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 <= 1.6e+16) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) - -1.0) / t_0) / Float64(Float64(3.0 + Float64(beta + alpha)) * t_0)); else tmp = Float64(Float64(Float64(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(beta - -3.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, 1.6e+16], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(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[(beta - -3.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 1.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) - -1}{t\_0}}{\left(3 + \left(\beta + \alpha\right)\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\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}}{\beta - -3}\\
\end{array}
\end{array}
if beta < 1.6e16Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.4%
if 1.6e16 < beta Initial program 84.1%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.6
Applied rewrites85.6%
Taylor expanded in alpha around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower--.f64N/A
metadata-eval85.3
Applied rewrites85.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6484.7
Applied rewrites84.7%
Final simplification95.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ 3.0 (+ beta alpha))) (t_1 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.6e+16)
(/ (/ (- (fma beta alpha (+ beta alpha)) -1.0) t_1) (* t_0 t_1))
(/ (/ (- alpha -1.0) (+ (+ 2.0 alpha) beta)) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = 3.0 + (beta + alpha);
double t_1 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.6e+16) {
tmp = ((fma(beta, alpha, (beta + alpha)) - -1.0) / t_1) / (t_0 * t_1);
} else {
tmp = ((alpha - -1.0) / ((2.0 + alpha) + beta)) / t_0;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(3.0 + Float64(beta + alpha)) t_1 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.6e+16) tmp = Float64(Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) - -1.0) / t_1) / Float64(t_0 * t_1)); else tmp = Float64(Float64(Float64(alpha - -1.0) / Float64(Float64(2.0 + alpha) + beta)) / t_0); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 1.6e+16], N[(N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / t$95$1), $MachinePrecision] / N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := 3 + \left(\beta + \alpha\right)\\
t_1 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) - -1}{t\_1}}{t\_0 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\left(2 + \alpha\right) + \beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 1.6e16Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.4%
if 1.6e16 < beta Initial program 84.1%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.6
Applied rewrites85.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites87.6%
Taylor expanded in alpha around 0
Applied rewrites87.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites85.6%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ 3.0 (+ beta alpha))) (t_1 (+ (+ beta alpha) 2.0)))
(if (<= beta 2.2e+70)
(/ (- (fma beta alpha (+ beta alpha)) -1.0) (* t_1 (* t_0 t_1)))
(/ (/ (- alpha -1.0) (+ (+ 2.0 alpha) beta)) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = 3.0 + (beta + alpha);
double t_1 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 2.2e+70) {
tmp = (fma(beta, alpha, (beta + alpha)) - -1.0) / (t_1 * (t_0 * t_1));
} else {
tmp = ((alpha - -1.0) / ((2.0 + alpha) + beta)) / t_0;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(3.0 + Float64(beta + alpha)) t_1 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 2.2e+70) tmp = Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) - -1.0) / Float64(t_1 * Float64(t_0 * t_1))); else tmp = Float64(Float64(Float64(alpha - -1.0) / Float64(Float64(2.0 + alpha) + beta)) / t_0); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[beta, 2.2e+70], N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := 3 + \left(\beta + \alpha\right)\\
t_1 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 2.2 \cdot 10^{+70}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) - -1}{t\_1 \cdot \left(t\_0 \cdot t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\left(2 + \alpha\right) + \beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 2.20000000000000001e70Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites96.9%
if 2.20000000000000001e70 < beta Initial program 79.9%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6486.5
Applied rewrites86.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites88.0%
Taylor expanded in alpha around 0
Applied rewrites88.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites86.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 5.3e+14) (/ (/ (- beta -1.0) (+ 2.0 beta)) (* (- beta -3.0) (- beta -2.0))) (/ (/ (- alpha -1.0) (+ (+ 2.0 alpha) beta)) (+ 3.0 (+ beta alpha)))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5.3e+14) {
tmp = ((beta - -1.0) / (2.0 + beta)) / ((beta - -3.0) * (beta - -2.0));
} else {
tmp = ((alpha - -1.0) / ((2.0 + alpha) + beta)) / (3.0 + (beta + alpha));
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 5.3d+14) then
tmp = ((beta - (-1.0d0)) / (2.0d0 + beta)) / ((beta - (-3.0d0)) * (beta - (-2.0d0)))
else
tmp = ((alpha - (-1.0d0)) / ((2.0d0 + alpha) + beta)) / (3.0d0 + (beta + alpha))
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 5.3e+14) {
tmp = ((beta - -1.0) / (2.0 + beta)) / ((beta - -3.0) * (beta - -2.0));
} else {
tmp = ((alpha - -1.0) / ((2.0 + alpha) + beta)) / (3.0 + (beta + alpha));
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 5.3e+14: tmp = ((beta - -1.0) / (2.0 + beta)) / ((beta - -3.0) * (beta - -2.0)) else: tmp = ((alpha - -1.0) / ((2.0 + alpha) + beta)) / (3.0 + (beta + alpha)) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 5.3e+14) tmp = Float64(Float64(Float64(beta - -1.0) / Float64(2.0 + beta)) / Float64(Float64(beta - -3.0) * Float64(beta - -2.0))); else tmp = Float64(Float64(Float64(alpha - -1.0) / Float64(Float64(2.0 + alpha) + beta)) / Float64(3.0 + Float64(beta + alpha))); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 5.3e+14)
tmp = ((beta - -1.0) / (2.0 + beta)) / ((beta - -3.0) * (beta - -2.0));
else
tmp = ((alpha - -1.0) / ((2.0 + alpha) + beta)) / (3.0 + (beta + alpha));
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 5.3e+14], N[(N[(N[(beta - -1.0), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(N[(beta - -3.0), $MachinePrecision] * N[(beta - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 5.3 \cdot 10^{+14}:\\
\;\;\;\;\frac{\frac{\beta - -1}{2 + \beta}}{\left(\beta - -3\right) \cdot \left(\beta - -2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\left(2 + \alpha\right) + \beta}}{3 + \left(\beta + \alpha\right)}\\
\end{array}
\end{array}
if beta < 5.3e14Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6488.6
Applied rewrites88.6%
Applied rewrites88.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites88.6%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6466.7
Applied rewrites66.7%
if 5.3e14 < beta Initial program 84.1%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.6
Applied rewrites85.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites87.6%
Taylor expanded in alpha around 0
Applied rewrites87.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites85.6%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ 2.0 alpha) beta)) (t_1 (+ 3.0 (+ beta alpha))))
(if (<= beta 3.9)
(/ (fma 0.25 beta 0.5) (* t_0 t_1))
(/ (/ (- alpha -1.0) t_0) t_1))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (2.0 + alpha) + beta;
double t_1 = 3.0 + (beta + alpha);
double tmp;
if (beta <= 3.9) {
tmp = fma(0.25, beta, 0.5) / (t_0 * t_1);
} else {
tmp = ((alpha - -1.0) / t_0) / t_1;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(2.0 + alpha) + beta) t_1 = Float64(3.0 + Float64(beta + alpha)) tmp = 0.0 if (beta <= 3.9) tmp = Float64(fma(0.25, beta, 0.5) / Float64(t_0 * t_1)); else tmp = Float64(Float64(Float64(alpha - -1.0) / t_0) / t_1); 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[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[beta, 3.9], N[(N[(0.25 * beta + 0.5), $MachinePrecision] / N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(2 + \alpha\right) + \beta\\
t_1 := 3 + \left(\beta + \alpha\right)\\
\mathbf{if}\;\beta \leq 3.9:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \beta, 0.5\right)}{t\_0 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{t\_0}}{t\_1}\\
\end{array}
\end{array}
if beta < 3.89999999999999991Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6488.8
Applied rewrites88.8%
Applied rewrites88.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites88.9%
Taylor expanded in beta around 0
Applied rewrites87.7%
if 3.89999999999999991 < beta Initial program 84.7%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6483.9
Applied rewrites83.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites85.9%
Taylor expanded in alpha around 0
Applied rewrites85.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites83.9%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ 3.0 (+ beta alpha))))
(if (<= beta 5.5)
(/ (fma 0.25 beta 0.5) (* (+ (+ 2.0 alpha) beta) t_0))
(/ (/ (+ 1.0 alpha) beta) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = 3.0 + (beta + alpha);
double tmp;
if (beta <= 5.5) {
tmp = fma(0.25, beta, 0.5) / (((2.0 + alpha) + beta) * t_0);
} else {
tmp = ((1.0 + alpha) / beta) / t_0;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(3.0 + Float64(beta + alpha)) tmp = 0.0 if (beta <= 5.5) tmp = Float64(fma(0.25, beta, 0.5) / Float64(Float64(Float64(2.0 + alpha) + beta) * t_0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / t_0); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[beta, 5.5], N[(N[(0.25 * beta + 0.5), $MachinePrecision] / N[(N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := 3 + \left(\beta + \alpha\right)\\
\mathbf{if}\;\beta \leq 5.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \beta, 0.5\right)}{\left(\left(2 + \alpha\right) + \beta\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 5.5Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6488.8
Applied rewrites88.8%
Applied rewrites88.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites88.9%
Taylor expanded in beta around 0
Applied rewrites87.7%
if 5.5 < beta Initial program 84.7%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6484.5
Applied rewrites84.5%
Applied rewrites84.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6483.5
Applied rewrites83.5%
Final simplification86.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ 3.0 (+ beta alpha))))
(if (<= beta 6.8)
(/ 0.5 (* (+ (+ 2.0 alpha) beta) t_0))
(/ (/ (+ 1.0 alpha) beta) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = 3.0 + (beta + alpha);
double tmp;
if (beta <= 6.8) {
tmp = 0.5 / (((2.0 + alpha) + beta) * t_0);
} else {
tmp = ((1.0 + alpha) / beta) / t_0;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: tmp
t_0 = 3.0d0 + (beta + alpha)
if (beta <= 6.8d0) then
tmp = 0.5d0 / (((2.0d0 + alpha) + beta) * t_0)
else
tmp = ((1.0d0 + alpha) / beta) / t_0
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = 3.0 + (beta + alpha);
double tmp;
if (beta <= 6.8) {
tmp = 0.5 / (((2.0 + alpha) + beta) * t_0);
} else {
tmp = ((1.0 + alpha) / beta) / t_0;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = 3.0 + (beta + alpha) tmp = 0 if beta <= 6.8: tmp = 0.5 / (((2.0 + alpha) + beta) * t_0) else: tmp = ((1.0 + alpha) / beta) / t_0 return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(3.0 + Float64(beta + alpha)) tmp = 0.0 if (beta <= 6.8) tmp = Float64(0.5 / Float64(Float64(Float64(2.0 + alpha) + beta) * t_0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / t_0); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = 3.0 + (beta + alpha);
tmp = 0.0;
if (beta <= 6.8)
tmp = 0.5 / (((2.0 + alpha) + beta) * t_0);
else
tmp = ((1.0 + alpha) / beta) / t_0;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[beta, 6.8], N[(0.5 / N[(N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := 3 + \left(\beta + \alpha\right)\\
\mathbf{if}\;\beta \leq 6.8:\\
\;\;\;\;\frac{0.5}{\left(\left(2 + \alpha\right) + \beta\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 6.79999999999999982Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6488.8
Applied rewrites88.8%
Applied rewrites88.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites88.9%
Taylor expanded in beta around 0
Applied rewrites87.4%
if 6.79999999999999982 < beta Initial program 84.7%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6484.5
Applied rewrites84.5%
Applied rewrites84.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6483.5
Applied rewrites83.5%
Final simplification86.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.5 (* (+ (+ 2.0 alpha) beta) (+ 3.0 (+ beta alpha)))) (/ (/ (+ 1.0 alpha) beta) (- beta -3.0))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 6.8) {
tmp = 0.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha)));
} else {
tmp = ((1.0 + alpha) / beta) / (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 <= 6.8d0) then
tmp = 0.5d0 / (((2.0d0 + alpha) + beta) * (3.0d0 + (beta + alpha)))
else
tmp = ((1.0d0 + alpha) / beta) / (beta - (-3.0d0))
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.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha)));
} else {
tmp = ((1.0 + alpha) / beta) / (beta - -3.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 6.8: tmp = 0.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha))) else: tmp = ((1.0 + alpha) / beta) / (beta - -3.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 6.8) tmp = Float64(0.5 / Float64(Float64(Float64(2.0 + alpha) + beta) * Float64(3.0 + Float64(beta + alpha)))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(beta - -3.0)); 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.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha)));
else
tmp = ((1.0 + alpha) / beta) / (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, 6.8], N[(0.5 / N[(N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision] * N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(beta - -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 6.8:\\
\;\;\;\;\frac{0.5}{\left(\left(2 + \alpha\right) + \beta\right) \cdot \left(3 + \left(\beta + \alpha\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta - -3}\\
\end{array}
\end{array}
if beta < 6.79999999999999982Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6488.8
Applied rewrites88.8%
Applied rewrites88.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites88.9%
Taylor expanded in beta around 0
Applied rewrites87.4%
if 6.79999999999999982 < beta Initial program 84.7%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6483.9
Applied rewrites83.9%
Taylor expanded in alpha around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower--.f64N/A
metadata-eval83.5
Applied rewrites83.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6483.3
Applied rewrites83.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 36.0) (/ 0.5 (* (+ (+ 2.0 alpha) beta) (+ 3.0 (+ beta alpha)))) (/ (/ (- alpha -1.0) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 36.0) {
tmp = 0.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha)));
} else {
tmp = ((alpha - -1.0) / beta) / beta;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 36.0d0) then
tmp = 0.5d0 / (((2.0d0 + alpha) + beta) * (3.0d0 + (beta + alpha)))
else
tmp = ((alpha - (-1.0d0)) / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 36.0) {
tmp = 0.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha)));
} else {
tmp = ((alpha - -1.0) / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 36.0: tmp = 0.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha))) else: tmp = ((alpha - -1.0) / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 36.0) tmp = Float64(0.5 / Float64(Float64(Float64(2.0 + alpha) + beta) * Float64(3.0 + Float64(beta + alpha)))); else tmp = Float64(Float64(Float64(alpha - -1.0) / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 36.0)
tmp = 0.5 / (((2.0 + alpha) + beta) * (3.0 + (beta + alpha)));
else
tmp = ((alpha - -1.0) / beta) / beta;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 36.0], N[(0.5 / N[(N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision] * N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 36:\\
\;\;\;\;\frac{0.5}{\left(\left(2 + \alpha\right) + \beta\right) \cdot \left(3 + \left(\beta + \alpha\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 36Initial program 99.9%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6488.8
Applied rewrites88.8%
Applied rewrites88.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites88.9%
Taylor expanded in beta around 0
Applied rewrites87.4%
if 36 < beta Initial program 84.7%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6480.9
Applied rewrites80.9%
Applied rewrites83.3%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 8e+17) (/ 1.0 (* (+ 3.0 (+ beta alpha)) (+ (+ 2.0 alpha) beta))) (/ (/ (- alpha -1.0) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 8e+17) {
tmp = 1.0 / ((3.0 + (beta + alpha)) * ((2.0 + alpha) + beta));
} else {
tmp = ((alpha - -1.0) / beta) / beta;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 8d+17) then
tmp = 1.0d0 / ((3.0d0 + (beta + alpha)) * ((2.0d0 + alpha) + beta))
else
tmp = ((alpha - (-1.0d0)) / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 8e+17) {
tmp = 1.0 / ((3.0 + (beta + alpha)) * ((2.0 + alpha) + beta));
} else {
tmp = ((alpha - -1.0) / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 8e+17: tmp = 1.0 / ((3.0 + (beta + alpha)) * ((2.0 + alpha) + beta)) else: tmp = ((alpha - -1.0) / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 8e+17) tmp = Float64(1.0 / Float64(Float64(3.0 + Float64(beta + alpha)) * Float64(Float64(2.0 + alpha) + beta))); else tmp = Float64(Float64(Float64(alpha - -1.0) / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 8e+17)
tmp = 1.0 / ((3.0 + (beta + alpha)) * ((2.0 + alpha) + beta));
else
tmp = ((alpha - -1.0) / beta) / beta;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 8e+17], N[(1.0 / N[(N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 8 \cdot 10^{+17}:\\
\;\;\;\;\frac{1}{\left(3 + \left(\beta + \alpha\right)\right) \cdot \left(\left(2 + \alpha\right) + \beta\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 8e17Initial program 99.9%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6415.3
Applied rewrites15.3%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites34.9%
Taylor expanded in alpha around 0
Applied rewrites45.4%
if 8e17 < beta Initial program 84.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6482.7
Applied rewrites82.7%
Applied rewrites85.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 0.054) (/ (+ 1.0 alpha) (* beta beta)) (/ (/ alpha beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 0.054) {
tmp = (1.0 + alpha) / (beta * beta);
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 0.054d0) then
tmp = (1.0d0 + alpha) / (beta * beta)
else
tmp = (alpha / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 0.054) {
tmp = (1.0 + alpha) / (beta * beta);
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if alpha <= 0.054: tmp = (1.0 + alpha) / (beta * beta) else: tmp = (alpha / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (alpha <= 0.054) tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); else tmp = Float64(Float64(alpha / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (alpha <= 0.054)
tmp = (1.0 + alpha) / (beta * beta);
else
tmp = (alpha / beta) / beta;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[alpha, 0.054], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision], N[(N[(alpha / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 0.054:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if alpha < 0.0539999999999999994Initial program 99.9%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6432.8
Applied rewrites32.8%
if 0.0539999999999999994 < alpha Initial program 85.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6415.2
Applied rewrites15.2%
Taylor expanded in alpha around inf
Applied rewrites15.2%
Applied rewrites16.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ (/ (- alpha -1.0) beta) beta))
assert(alpha < beta);
double code(double alpha, double beta) {
return ((alpha - -1.0) / beta) / beta;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = ((alpha - (-1.0d0)) / beta) / beta
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return ((alpha - -1.0) / beta) / beta;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return ((alpha - -1.0) / beta) / beta
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(Float64(Float64(alpha - -1.0) / beta) / beta) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = ((alpha - -1.0) / beta) / beta;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(N[(N[(alpha - -1.0), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{\frac{\alpha - -1}{\beta}}{\beta}
\end{array}
Initial program 95.2%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6427.1
Applied rewrites27.1%
Applied rewrites27.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 0.054) (/ 1.0 (* beta beta)) (/ alpha (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 0.054) {
tmp = 1.0 / (beta * beta);
} else {
tmp = alpha / (beta * beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 0.054d0) then
tmp = 1.0d0 / (beta * beta)
else
tmp = alpha / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 0.054) {
tmp = 1.0 / (beta * beta);
} else {
tmp = alpha / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if alpha <= 0.054: tmp = 1.0 / (beta * beta) else: tmp = alpha / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (alpha <= 0.054) tmp = Float64(1.0 / Float64(beta * beta)); else tmp = Float64(alpha / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (alpha <= 0.054)
tmp = 1.0 / (beta * beta);
else
tmp = alpha / (beta * beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[alpha, 0.054], N[(1.0 / N[(beta * beta), $MachinePrecision]), $MachinePrecision], N[(alpha / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 0.054:\\
\;\;\;\;\frac{1}{\beta \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if alpha < 0.0539999999999999994Initial program 99.9%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6432.8
Applied rewrites32.8%
Taylor expanded in alpha around 0
Applied rewrites32.5%
if 0.0539999999999999994 < alpha Initial program 85.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6415.2
Applied rewrites15.2%
Taylor expanded in alpha around inf
Applied rewrites15.2%
Final simplification26.8%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ (+ 1.0 alpha) (* beta beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
return (1.0 + alpha) / (beta * beta);
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = (1.0d0 + alpha) / (beta * beta)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return (1.0 + alpha) / (beta * beta);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return (1.0 + alpha) / (beta * beta)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(Float64(1.0 + alpha) / Float64(beta * beta)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = (1.0 + alpha) / (beta * beta);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{1 + \alpha}{\beta \cdot \beta}
\end{array}
Initial program 95.2%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6427.1
Applied rewrites27.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ alpha (* beta beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
return alpha / (beta * beta);
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = alpha / (beta * beta)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return alpha / (beta * beta);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return alpha / (beta * beta)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(alpha / Float64(beta * beta)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = alpha / (beta * beta);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(alpha / N[(beta * beta), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{\alpha}{\beta \cdot \beta}
\end{array}
Initial program 95.2%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in alpha around inf
Applied rewrites16.0%
herbie shell --seed 2024360
(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)))