
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.05e+20)
(/
(/ (+ (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 5.0) beta)))
beta)
(+ (+ 2.0 alpha) beta)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.05e+20) {
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, 5.0) / beta))) / beta) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.05e+20) 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, 5.0) / beta))) / beta) / Float64(Float64(2.0 + alpha) + beta)); 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.05e+20], 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 + 5.0), $MachinePrecision] / beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.05 \cdot 10^{+20}:\\
\;\;\;\;\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, 5\right)}{\beta}}{\beta}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 1.05e20Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
if 1.05e20 < beta Initial program 76.6%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6480.5
Applied rewrites80.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites80.5%
Taylor expanded in beta around inf
lower-/.f64N/A
Applied rewrites79.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.05e+20)
(/
(/ (+ (fma beta alpha (+ beta alpha)) 1.0) t_0)
(* (+ 3.0 (+ beta alpha)) t_0))
(/ (/ (- alpha -1.0) (+ (+ alpha beta) 3.0)) (+ (+ 2.0 alpha) beta)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.05e+20) {
tmp = ((fma(beta, alpha, (beta + alpha)) + 1.0) / t_0) / ((3.0 + (beta + alpha)) * t_0);
} else {
tmp = ((alpha - -1.0) / ((alpha + beta) + 3.0)) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.05e+20) 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(alpha - -1.0) / Float64(Float64(alpha + beta) + 3.0)) / Float64(Float64(2.0 + alpha) + beta)); 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.05e+20], 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[(alpha - -1.0), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.05 \cdot 10^{+20}:\\
\;\;\;\;\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{\alpha - -1}{\left(\alpha + \beta\right) + 3}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 1.05e20Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
if 1.05e20 < beta Initial program 76.6%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6480.5
Applied rewrites80.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites80.5%
Final simplification93.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 1.05e+20)
(/
(+ (fma beta alpha (+ beta alpha)) 1.0)
(* t_0 (* (+ (+ 1.0 (+ alpha beta)) 2.0) t_0)))
(/ (/ (- alpha -1.0) (+ (+ alpha beta) 3.0)) (+ (+ 2.0 alpha) beta)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.05e+20) {
tmp = (fma(beta, alpha, (beta + alpha)) + 1.0) / (t_0 * (((1.0 + (alpha + beta)) + 2.0) * t_0));
} else {
tmp = ((alpha - -1.0) / ((alpha + beta) + 3.0)) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.05e+20) tmp = Float64(Float64(fma(beta, alpha, Float64(beta + alpha)) + 1.0) / Float64(t_0 * Float64(Float64(Float64(1.0 + Float64(alpha + beta)) + 2.0) * t_0))); else tmp = Float64(Float64(Float64(alpha - -1.0) / Float64(Float64(alpha + beta) + 3.0)) / Float64(Float64(2.0 + alpha) + beta)); 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.05e+20], N[(N[(N[(beta * alpha + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * N[(N[(N[(1.0 + N[(alpha + beta), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.05 \cdot 10^{+20}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\beta, \alpha, \beta + \alpha\right) + 1}{t\_0 \cdot \left(\left(\left(1 + \left(\alpha + \beta\right)\right) + 2\right) \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\left(\alpha + \beta\right) + 3}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 1.05e20Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites94.2%
lift-+.f64N/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
associate--l+N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate--l+N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6494.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.2
Applied rewrites94.2%
if 1.05e20 < beta Initial program 76.6%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6480.5
Applied rewrites80.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites80.5%
Final simplification90.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function.
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ (+ beta alpha) 2.0)))
(if (<= beta 1.05e+20)
(/
(+ (fma alpha beta 1.0) (+ alpha beta))
(* t_0 (* (+ 3.0 (+ beta alpha)) t_0)))
(/ (/ (- alpha -1.0) (+ (+ alpha beta) 3.0)) (+ (+ 2.0 alpha) beta)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (beta + alpha) + 2.0;
double tmp;
if (beta <= 1.05e+20) {
tmp = (fma(alpha, beta, 1.0) + (alpha + beta)) / (t_0 * ((3.0 + (beta + alpha)) * t_0));
} else {
tmp = ((alpha - -1.0) / ((alpha + beta) + 3.0)) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(beta + alpha) + 2.0) tmp = 0.0 if (beta <= 1.05e+20) tmp = Float64(Float64(fma(alpha, beta, 1.0) + Float64(alpha + beta)) / Float64(t_0 * Float64(Float64(3.0 + Float64(beta + alpha)) * t_0))); else tmp = Float64(Float64(Float64(alpha - -1.0) / Float64(Float64(alpha + beta) + 3.0)) / Float64(Float64(2.0 + alpha) + beta)); 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.05e+20], N[(N[(N[(alpha * beta + 1.0), $MachinePrecision] + N[(alpha + beta), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(N[(3.0 + N[(beta + alpha), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\beta + \alpha\right) + 2\\
\mathbf{if}\;\beta \leq 1.05 \cdot 10^{+20}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\alpha, \beta, 1\right) + \left(\alpha + \beta\right)}{t\_0 \cdot \left(\left(3 + \left(\beta + \alpha\right)\right) \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\left(\alpha + \beta\right) + 3}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 1.05e20Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites94.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-+r+N/A
+-commutativeN/A
lift-fma.f64N/A
lower-+.f6494.2
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6494.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6494.2
Applied rewrites94.2%
if 1.05e20 < beta Initial program 76.6%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6480.5
Applied rewrites80.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites80.5%
Final simplification90.1%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 1.05e+16) (/ (/ (+ 1.0 beta) (+ 2.0 beta)) (fma (+ 5.0 beta) beta 6.0)) (/ (/ (- alpha -1.0) (+ (+ alpha beta) 3.0)) (+ (+ 2.0 alpha) beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 1.05e+16) {
tmp = ((1.0 + beta) / (2.0 + beta)) / fma((5.0 + beta), beta, 6.0);
} else {
tmp = ((alpha - -1.0) / ((alpha + beta) + 3.0)) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 1.05e+16) tmp = Float64(Float64(Float64(1.0 + beta) / Float64(2.0 + beta)) / fma(Float64(5.0 + beta), beta, 6.0)); else tmp = Float64(Float64(Float64(alpha - -1.0) / Float64(Float64(alpha + beta) + 3.0)) / Float64(Float64(2.0 + alpha) + beta)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 1.05e+16], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(N[(5.0 + beta), $MachinePrecision] * beta + 6.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha - -1.0), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 1.05 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{1 + \beta}{2 + \beta}}{\mathsf{fma}\left(5 + \beta, \beta, 6\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha - -1}{\left(\alpha + \beta\right) + 3}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 1.05e16Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.5
Applied rewrites86.5%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6468.4
Applied rewrites68.4%
Taylor expanded in beta around 0
Applied rewrites68.4%
if 1.05e16 < beta Initial program 76.9%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6479.6
Applied rewrites79.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites79.6%
Final simplification71.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.4e+19) (/ (/ (+ 1.0 beta) (+ 2.0 beta)) (fma (+ 5.0 beta) beta 6.0)) (/ (/ (+ 1.0 alpha) beta) (+ (+ 2.0 alpha) beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.4e+19) {
tmp = ((1.0 + beta) / (2.0 + beta)) / fma((5.0 + beta), beta, 6.0);
} else {
tmp = ((1.0 + alpha) / beta) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.4e+19) tmp = Float64(Float64(Float64(1.0 + beta) / Float64(2.0 + beta)) / fma(Float64(5.0 + beta), beta, 6.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(2.0 + alpha) + beta)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 4.4e+19], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] / N[(N[(5.0 + beta), $MachinePrecision] * beta + 6.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.4 \cdot 10^{+19}:\\
\;\;\;\;\frac{\frac{1 + \beta}{2 + \beta}}{\mathsf{fma}\left(5 + \beta, \beta, 6\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 4.4e19Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.6
Applied rewrites86.6%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6468.0
Applied rewrites68.0%
Taylor expanded in beta around 0
Applied rewrites68.0%
if 4.4e19 < beta Initial program 76.6%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6480.5
Applied rewrites80.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites80.5%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6479.5
Applied rewrites79.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 2.55) (/ (fma (fma -0.125 beta 0.25) beta 0.5) (* (+ 3.0 beta) (+ 2.0 beta))) (/ (/ (+ 1.0 alpha) beta) (+ (+ 2.0 alpha) beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.55) {
tmp = fma(fma(-0.125, beta, 0.25), beta, 0.5) / ((3.0 + beta) * (2.0 + beta));
} else {
tmp = ((1.0 + alpha) / beta) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 2.55) tmp = Float64(fma(fma(-0.125, beta, 0.25), beta, 0.5) / Float64(Float64(3.0 + beta) * Float64(2.0 + beta))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(2.0 + alpha) + beta)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 2.55], N[(N[(N[(-0.125 * beta + 0.25), $MachinePrecision] * beta + 0.5), $MachinePrecision] / N[(N[(3.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2.55:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.125, \beta, 0.25\right), \beta, 0.5\right)}{\left(3 + \beta\right) \cdot \left(2 + \beta\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 2.5499999999999998Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.8
Applied rewrites86.8%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in beta around 0
Applied rewrites68.3%
if 2.5499999999999998 < beta Initial program 77.7%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6477.8
Applied rewrites77.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites77.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6476.7
Applied rewrites76.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.7) (/ (fma 0.25 beta 0.5) (* (+ 3.0 beta) (+ 2.0 beta))) (/ (/ (+ 1.0 alpha) beta) (+ (+ 2.0 alpha) beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.7) {
tmp = fma(0.25, beta, 0.5) / ((3.0 + beta) * (2.0 + beta));
} else {
tmp = ((1.0 + alpha) / beta) / ((2.0 + alpha) + beta);
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.7) tmp = Float64(fma(0.25, beta, 0.5) / Float64(Float64(3.0 + beta) * Float64(2.0 + beta))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(2.0 + alpha) + beta)); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 4.7], N[(N[(0.25 * beta + 0.5), $MachinePrecision] / N[(N[(3.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] + beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.7:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \beta, 0.5\right)}{\left(3 + \beta\right) \cdot \left(2 + \beta\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(2 + \alpha\right) + \beta}\\
\end{array}
\end{array}
if beta < 4.70000000000000018Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.8
Applied rewrites86.8%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in beta around 0
Applied rewrites67.9%
if 4.70000000000000018 < beta Initial program 77.7%
Taylor expanded in beta around -inf
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6477.8
Applied rewrites77.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
Applied rewrites77.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6476.7
Applied rewrites76.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.8) (/ 0.5 (* (+ 3.0 alpha) (+ 2.0 alpha))) (if (<= beta 4.9e+161) (/ (/ 1.0 beta) beta) (/ (/ alpha beta) beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.8) {
tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha));
} else if (beta <= 4.9e+161) {
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 (beta <= 4.8d0) then
tmp = 0.5d0 / ((3.0d0 + alpha) * (2.0d0 + alpha))
else if (beta <= 4.9d+161) 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 (beta <= 4.8) {
tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha));
} else if (beta <= 4.9e+161) {
tmp = (1.0 / beta) / beta;
} else {
tmp = (alpha / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 4.8: tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha)) elif beta <= 4.9e+161: 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 (beta <= 4.8) tmp = Float64(0.5 / Float64(Float64(3.0 + alpha) * Float64(2.0 + alpha))); elseif (beta <= 4.9e+161) tmp = Float64(Float64(1.0 / 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 (beta <= 4.8)
tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha));
elseif (beta <= 4.9e+161)
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[beta, 4.8], N[(0.5 / N[(N[(3.0 + alpha), $MachinePrecision] * N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[beta, 4.9e+161], N[(N[(1.0 / beta), $MachinePrecision] / beta), $MachinePrecision], N[(N[(alpha / beta), $MachinePrecision] / beta), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.8:\\
\;\;\;\;\frac{0.5}{\left(3 + \alpha\right) \cdot \left(2 + \alpha\right)}\\
\mathbf{elif}\;\beta \leq 4.9 \cdot 10^{+161}:\\
\;\;\;\;\frac{\frac{1}{\beta}}{\beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 4.79999999999999982Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6497.0
Applied rewrites97.0%
Taylor expanded in alpha around 0
Applied rewrites84.8%
Taylor expanded in beta around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6484.8
Applied rewrites84.8%
if 4.79999999999999982 < beta < 4.89999999999999974e161Initial program 75.7%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6461.0
Applied rewrites61.0%
Taylor expanded in alpha around inf
Applied rewrites61.0%
Taylor expanded in alpha around 0
Applied rewrites61.9%
Applied rewrites64.4%
if 4.89999999999999974e161 < beta Initial program 79.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6488.7
Applied rewrites88.7%
Taylor expanded in alpha around inf
Applied rewrites88.7%
Applied rewrites92.2%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 6.4) (/ (fma 0.25 beta 0.5) (* (+ 3.0 beta) (+ 2.0 beta))) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 6.4) {
tmp = fma(0.25, beta, 0.5) / ((3.0 + beta) * (2.0 + beta));
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 6.4) tmp = Float64(fma(0.25, beta, 0.5) / Float64(Float64(3.0 + beta) * Float64(2.0 + beta))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / beta); end return tmp end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 6.4], N[(N[(0.25 * beta + 0.5), $MachinePrecision] / N[(N[(3.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 6.4:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \beta, 0.5\right)}{\left(3 + \beta\right) \cdot \left(2 + \beta\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 6.4000000000000004Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6486.8
Applied rewrites86.8%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in beta around 0
Applied rewrites67.9%
if 6.4000000000000004 < beta Initial program 77.7%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6474.5
Applied rewrites74.5%
Applied rewrites76.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 4.8) (/ 0.5 (* (+ 3.0 alpha) (+ 2.0 alpha))) (/ (/ (+ 1.0 alpha) beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 4.8) {
tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha));
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 4.8d0) then
tmp = 0.5d0 / ((3.0d0 + alpha) * (2.0d0 + alpha))
else
tmp = ((1.0d0 + alpha) / beta) / beta
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 4.8) {
tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha));
} else {
tmp = ((1.0 + alpha) / beta) / beta;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 4.8: tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha)) else: tmp = ((1.0 + alpha) / beta) / beta return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 4.8) tmp = Float64(0.5 / Float64(Float64(3.0 + alpha) * Float64(2.0 + alpha))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / beta); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 4.8)
tmp = 0.5 / ((3.0 + alpha) * (2.0 + alpha));
else
tmp = ((1.0 + alpha) / beta) / beta;
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 4.8], N[(0.5 / N[(N[(3.0 + alpha), $MachinePrecision] * N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / beta), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 4.8:\\
\;\;\;\;\frac{0.5}{\left(3 + \alpha\right) \cdot \left(2 + \alpha\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 4.79999999999999982Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6497.0
Applied rewrites97.0%
Taylor expanded in alpha around 0
Applied rewrites84.8%
Taylor expanded in beta around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6484.8
Applied rewrites84.8%
if 4.79999999999999982 < beta Initial program 77.7%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6474.5
Applied rewrites74.5%
Applied rewrites76.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= alpha 0.012) (/ (/ 1.0 beta) beta) (/ (/ alpha beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (alpha <= 0.012) {
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.012d0) 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.012) {
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.012: 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.012) tmp = Float64(Float64(1.0 / 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.012)
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.012], N[(N[(1.0 / beta), $MachinePrecision] / beta), $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.012:\\
\;\;\;\;\frac{\frac{1}{\beta}}{\beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if alpha < 0.012Initial program 99.8%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6432.2
Applied rewrites32.2%
Taylor expanded in alpha around inf
Applied rewrites32.2%
Taylor expanded in alpha around 0
Applied rewrites32.2%
Applied rewrites32.9%
if 0.012 < alpha Initial program 79.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6413.0
Applied rewrites13.0%
Taylor expanded in alpha around inf
Applied rewrites13.0%
Applied rewrites13.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 5e+153) (/ (+ 1.0 alpha) (* beta beta)) (/ (/ alpha beta) beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5e+153) {
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 (beta <= 5d+153) 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 (beta <= 5e+153) {
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 beta <= 5e+153: 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 (beta <= 5e+153) 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 (beta <= 5e+153)
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[beta, 5e+153], 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}\;\beta \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\alpha}{\beta}}{\beta}\\
\end{array}
\end{array}
if beta < 5.00000000000000018e153Initial program 96.1%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6413.4
Applied rewrites13.4%
if 5.00000000000000018e153 < beta Initial program 77.7%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6485.2
Applied rewrites85.2%
Taylor expanded in alpha around inf
Applied rewrites85.2%
Applied rewrites86.0%
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 92.9%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6425.7
Applied rewrites25.7%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (/ 1.0 (* beta beta)))
assert(alpha < beta);
double code(double alpha, double beta) {
return 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 = 1.0d0 / (beta * beta)
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
return 1.0 / (beta * beta);
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): return 1.0 / (beta * beta)
alpha, beta = sort([alpha, beta]) function code(alpha, beta) return Float64(1.0 / Float64(beta * beta)) end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp = code(alpha, beta)
tmp = 1.0 / (beta * beta);
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := N[(1.0 / N[(beta * beta), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\frac{1}{\beta \cdot \beta}
\end{array}
Initial program 92.9%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6425.7
Applied rewrites25.7%
Taylor expanded in alpha around 0
Applied rewrites25.9%
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 92.9%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6425.7
Applied rewrites25.7%
Taylor expanded in alpha around inf
Applied rewrites17.1%
herbie shell --seed 2024359
(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)))