
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (+ (+ alpha beta) (* 2.0 1.0)))) (/ (/ (/ (+ (+ (+ alpha beta) (* beta alpha)) 1.0) t_0) t_0) (+ t_0 1.0))))
double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
t_0 = (alpha + beta) + (2.0d0 * 1.0d0)
code = (((((alpha + beta) + (beta * alpha)) + 1.0d0) / t_0) / t_0) / (t_0 + 1.0d0)
end function
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) + (2.0 * 1.0);
return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0);
}
def code(alpha, beta): t_0 = (alpha + beta) + (2.0 * 1.0) return (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0)
function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) return Float64(Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) + 1.0) / t_0) / t_0) / Float64(t_0 + 1.0)) end
function tmp = code(alpha, beta) t_0 = (alpha + beta) + (2.0 * 1.0); tmp = (((((alpha + beta) + (beta * alpha)) + 1.0) / t_0) / t_0) / (t_0 + 1.0); end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) + 2 \cdot 1\\
\frac{\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) + 1}{t\_0}}{t\_0}}{t\_0 + 1}
\end{array}
\end{array}
Herbie found 10 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 2.15e+18)
(/
(/ (- (+ (+ alpha beta) (* beta alpha)) -1.0) t_0)
(* t_0 (- t_0 -1.0)))
(/ (/ (+ 1.0 alpha) beta) (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0)))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = (alpha + beta) - -2.0;
double tmp;
if (beta <= 2.15e+18) {
tmp = ((((alpha + beta) + (beta * alpha)) - -1.0) / t_0) / (t_0 * (t_0 - -1.0));
} else {
tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: tmp
t_0 = (alpha + beta) - (-2.0d0)
if (beta <= 2.15d+18) then
tmp = ((((alpha + beta) + (beta * alpha)) - (-1.0d0)) / t_0) / (t_0 * (t_0 - (-1.0d0)))
else
tmp = ((1.0d0 + alpha) / beta) / (((alpha + beta) + (2.0d0 * 1.0d0)) + 1.0d0)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double t_0 = (alpha + beta) - -2.0;
double tmp;
if (beta <= 2.15e+18) {
tmp = ((((alpha + beta) + (beta * alpha)) - -1.0) / t_0) / (t_0 * (t_0 - -1.0));
} else {
tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = (alpha + beta) - -2.0 tmp = 0 if beta <= 2.15e+18: tmp = ((((alpha + beta) + (beta * alpha)) - -1.0) / t_0) / (t_0 * (t_0 - -1.0)) else: tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(alpha + beta) - -2.0) tmp = 0.0 if (beta <= 2.15e+18) tmp = Float64(Float64(Float64(Float64(Float64(alpha + beta) + Float64(beta * alpha)) - -1.0) / t_0) / Float64(t_0 * Float64(t_0 - -1.0))); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
t_0 = (alpha + beta) - -2.0;
tmp = 0.0;
if (beta <= 2.15e+18)
tmp = ((((alpha + beta) + (beta * alpha)) - -1.0) / t_0) / (t_0 * (t_0 - -1.0));
else
tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function.
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] - -2.0), $MachinePrecision]}, If[LessEqual[beta, 2.15e+18], N[(N[(N[(N[(N[(alpha + beta), $MachinePrecision] + N[(beta * alpha), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 * N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) - -2\\
\mathbf{if}\;\beta \leq 2.15 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{\left(\left(\alpha + \beta\right) + \beta \cdot \alpha\right) - -1}{t\_0}}{t\_0 \cdot \left(t\_0 - -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\end{array}
\end{array}
if beta < 2.15e18Initial program 94.3%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites93.0%
if 2.15e18 < beta Initial program 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6456.4
Applied rewrites56.4%
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 1.0)) 1.0)))
(if (<= beta 5.8e+17)
(/ (/ (+ 1.0 beta) (* (+ 2.0 beta) (+ 2.0 beta))) t_0)
(/ (/ (+ 1.0 alpha) beta) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = ((alpha + beta) + (2.0 * 1.0)) + 1.0;
double tmp;
if (beta <= 5.8e+17) {
tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + 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 = ((alpha + beta) + (2.0d0 * 1.0d0)) + 1.0d0
if (beta <= 5.8d+17) then
tmp = ((1.0d0 + beta) / ((2.0d0 + beta) * (2.0d0 + 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 = ((alpha + beta) + (2.0 * 1.0)) + 1.0;
double tmp;
if (beta <= 5.8e+17) {
tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + beta))) / t_0;
} else {
tmp = ((1.0 + alpha) / beta) / t_0;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = ((alpha + beta) + (2.0 * 1.0)) + 1.0 tmp = 0 if beta <= 5.8e+17: tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + 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(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0) tmp = 0.0 if (beta <= 5.8e+17) tmp = Float64(Float64(Float64(1.0 + beta) / Float64(Float64(2.0 + beta) * Float64(2.0 + 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 = ((alpha + beta) + (2.0 * 1.0)) + 1.0;
tmp = 0.0;
if (beta <= 5.8e+17)
tmp = ((1.0 + beta) / ((2.0 + beta) * (2.0 + 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[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[beta, 5.8e+17], N[(N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(2.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $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 := \left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1\\
\mathbf{if}\;\beta \leq 5.8 \cdot 10^{+17}:\\
\;\;\;\;\frac{\frac{1 + \beta}{\left(2 + \beta\right) \cdot \left(2 + \beta\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 5.8e17Initial program 94.3%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6493.6
Applied rewrites93.6%
if 5.8e17 < beta Initial program 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6456.4
Applied rewrites56.4%
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 1.0)) 1.0)))
(if (<= beta 19.5)
(/ (/ (+ 1.0 alpha) (* (+ 2.0 alpha) (+ 2.0 alpha))) t_0)
(/ (/ (+ 1.0 alpha) beta) t_0))))assert(alpha < beta);
double code(double alpha, double beta) {
double t_0 = ((alpha + beta) + (2.0 * 1.0)) + 1.0;
double tmp;
if (beta <= 19.5) {
tmp = ((1.0 + alpha) / ((2.0 + alpha) * (2.0 + alpha))) / 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 = ((alpha + beta) + (2.0d0 * 1.0d0)) + 1.0d0
if (beta <= 19.5d0) then
tmp = ((1.0d0 + alpha) / ((2.0d0 + alpha) * (2.0d0 + alpha))) / 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 = ((alpha + beta) + (2.0 * 1.0)) + 1.0;
double tmp;
if (beta <= 19.5) {
tmp = ((1.0 + alpha) / ((2.0 + alpha) * (2.0 + alpha))) / t_0;
} else {
tmp = ((1.0 + alpha) / beta) / t_0;
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): t_0 = ((alpha + beta) + (2.0 * 1.0)) + 1.0 tmp = 0 if beta <= 19.5: tmp = ((1.0 + alpha) / ((2.0 + alpha) * (2.0 + alpha))) / t_0 else: tmp = ((1.0 + alpha) / beta) / t_0 return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) t_0 = Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0) tmp = 0.0 if (beta <= 19.5) tmp = Float64(Float64(Float64(1.0 + alpha) / Float64(Float64(2.0 + alpha) * Float64(2.0 + alpha))) / 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 = ((alpha + beta) + (2.0 * 1.0)) + 1.0;
tmp = 0.0;
if (beta <= 19.5)
tmp = ((1.0 + alpha) / ((2.0 + alpha) * (2.0 + alpha))) / 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[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[beta, 19.5], N[(N[(N[(1.0 + alpha), $MachinePrecision] / N[(N[(2.0 + alpha), $MachinePrecision] * N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $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 := \left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1\\
\mathbf{if}\;\beta \leq 19.5:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\left(2 + \alpha\right) \cdot \left(2 + \alpha\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{t\_0}\\
\end{array}
\end{array}
if beta < 19.5Initial program 94.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
if 19.5 < beta Initial program 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6456.4
Applied rewrites56.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 3.6) (/ (+ 0.25 (* -0.0625 (* alpha alpha))) (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (/ (+ 1.0 alpha) beta) (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 3.6) {
tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 3.6d0) then
tmp = (0.25d0 + ((-0.0625d0) * (alpha * alpha))) / (((alpha + beta) + 2.0d0) + 1.0d0)
else
tmp = ((1.0d0 + alpha) / beta) / (((alpha + beta) + (2.0d0 * 1.0d0)) + 1.0d0)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 3.6) {
tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 3.6: tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0) else: tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 3.6) tmp = Float64(Float64(0.25 + Float64(-0.0625 * Float64(alpha * alpha))) / Float64(Float64(Float64(alpha + beta) + 2.0) + 1.0)); else tmp = Float64(Float64(Float64(1.0 + alpha) / beta) / Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 3.6)
tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0);
else
tmp = ((1.0 + alpha) / beta) / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 3.6], N[(N[(0.25 + N[(-0.0625 * N[(alpha * alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + alpha), $MachinePrecision] / beta), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 3.6:\\
\;\;\;\;\frac{0.25 + -0.0625 \cdot \left(\alpha \cdot \alpha\right)}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \alpha}{\beta}}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\end{array}
\end{array}
if beta < 3.60000000000000009Initial program 94.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
Taylor expanded in alpha around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6447.0
Applied rewrites47.0%
lift-*.f64N/A
metadata-eval47.0
Applied rewrites47.0%
if 3.60000000000000009 < beta Initial program 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f6456.4
Applied rewrites56.4%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 5.6) (/ (+ 0.25 (* -0.0625 (* alpha alpha))) (+ (+ (+ alpha beta) 2.0) 1.0)) (/ (+ 1.0 alpha) (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 5.6) {
tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 5.6d0) then
tmp = (0.25d0 + ((-0.0625d0) * (alpha * alpha))) / (((alpha + beta) + 2.0d0) + 1.0d0)
else
tmp = (1.0d0 + alpha) / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 5.6) {
tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0);
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 5.6: tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0) else: tmp = (1.0 + alpha) / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 5.6) tmp = Float64(Float64(0.25 + Float64(-0.0625 * Float64(alpha * alpha))) / Float64(Float64(Float64(alpha + beta) + 2.0) + 1.0)); else tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 5.6)
tmp = (0.25 + (-0.0625 * (alpha * alpha))) / (((alpha + beta) + 2.0) + 1.0);
else
tmp = (1.0 + alpha) / (beta * beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 5.6], N[(N[(0.25 + N[(-0.0625 * N[(alpha * alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 5.6:\\
\;\;\;\;\frac{0.25 + -0.0625 \cdot \left(\alpha \cdot \alpha\right)}{\left(\left(\alpha + \beta\right) + 2\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 5.5999999999999996Initial program 94.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
Taylor expanded in alpha around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6447.0
Applied rewrites47.0%
lift-*.f64N/A
metadata-eval47.0
Applied rewrites47.0%
if 5.5999999999999996 < beta Initial program 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 2e+19) (/ (+ 1.0 beta) (* (* (+ 2.0 beta) (+ 2.0 beta)) (+ 3.0 beta))) (/ (+ 1.0 alpha) (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 2e+19) {
tmp = (1.0 + beta) / (((2.0 + beta) * (2.0 + beta)) * (3.0 + beta));
} 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 <= 2d+19) then
tmp = (1.0d0 + beta) / (((2.0d0 + beta) * (2.0d0 + beta)) * (3.0d0 + beta))
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 <= 2e+19) {
tmp = (1.0 + beta) / (((2.0 + beta) * (2.0 + beta)) * (3.0 + beta));
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 2e+19: tmp = (1.0 + beta) / (((2.0 + beta) * (2.0 + beta)) * (3.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 <= 2e+19) tmp = Float64(Float64(1.0 + beta) / Float64(Float64(Float64(2.0 + beta) * Float64(2.0 + beta)) * Float64(3.0 + beta))); else tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 2e+19)
tmp = (1.0 + beta) / (((2.0 + beta) * (2.0 + beta)) * (3.0 + beta));
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, 2e+19], N[(N[(1.0 + beta), $MachinePrecision] / N[(N[(N[(2.0 + beta), $MachinePrecision] * N[(2.0 + beta), $MachinePrecision]), $MachinePrecision] * N[(3.0 + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2 \cdot 10^{+19}:\\
\;\;\;\;\frac{1 + \beta}{\left(\left(2 + \beta\right) \cdot \left(2 + \beta\right)\right) \cdot \left(3 + \beta\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 2e19Initial program 94.3%
Taylor expanded in alpha around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6486.7
Applied rewrites86.7%
if 2e19 < beta Initial program 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
NOTE: alpha and beta should be sorted in increasing order before calling this function. (FPCore (alpha beta) :precision binary64 (if (<= beta 7.0) (/ 0.25 (+ (+ (+ alpha beta) (* 2.0 1.0)) 1.0)) (/ (+ 1.0 alpha) (* beta beta))))
assert(alpha < beta);
double code(double alpha, double beta) {
double tmp;
if (beta <= 7.0) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
NOTE: alpha and beta should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(alpha, beta)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 7.0d0) then
tmp = 0.25d0 / (((alpha + beta) + (2.0d0 * 1.0d0)) + 1.0d0)
else
tmp = (1.0d0 + alpha) / (beta * beta)
end if
code = tmp
end function
assert alpha < beta;
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 7.0) {
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
} else {
tmp = (1.0 + alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta] = sort([alpha, beta]) def code(alpha, beta): tmp = 0 if beta <= 7.0: tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0) else: tmp = (1.0 + alpha) / (beta * beta) return tmp
alpha, beta = sort([alpha, beta]) function code(alpha, beta) tmp = 0.0 if (beta <= 7.0) tmp = Float64(0.25 / Float64(Float64(Float64(alpha + beta) + Float64(2.0 * 1.0)) + 1.0)); else tmp = Float64(Float64(1.0 + alpha) / Float64(beta * beta)); end return tmp end
alpha, beta = num2cell(sort([alpha, beta])){:}
function tmp_2 = code(alpha, beta)
tmp = 0.0;
if (beta <= 7.0)
tmp = 0.25 / (((alpha + beta) + (2.0 * 1.0)) + 1.0);
else
tmp = (1.0 + alpha) / (beta * beta);
end
tmp_2 = tmp;
end
NOTE: alpha and beta should be sorted in increasing order before calling this function. code[alpha_, beta_] := If[LessEqual[beta, 7.0], N[(0.25 / N[(N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta] = \mathsf{sort}([alpha, beta])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 7:\\
\;\;\;\;\frac{0.25}{\left(\left(\alpha + \beta\right) + 2 \cdot 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 7Initial program 94.3%
Taylor expanded in beta around 0
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
Taylor expanded in alpha around 0
Applied rewrites47.5%
if 7 < beta Initial program 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
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 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
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 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
Taylor expanded in alpha around 0
Applied rewrites50.7%
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 94.3%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
Taylor expanded in alpha around inf
lower-/.f64N/A
pow2N/A
lift-*.f6432.8
Applied rewrites32.8%
herbie shell --seed 2025136
(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)))