
(FPCore (alpha beta i)
:precision binary64
(let* ((t_0 (* i (+ (+ alpha beta) i)))
(t_1 (+ (+ alpha beta) (* 2.0 i)))
(t_2 (* t_1 t_1)))
(/ (/ (* t_0 (+ (* beta alpha) t_0)) t_2) (- t_2 1.0))))
double code(double alpha, double beta, double i) {
double t_0 = i * ((alpha + beta) + i);
double t_1 = (alpha + beta) + (2.0 * i);
double t_2 = t_1 * t_1;
return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 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, i)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8), intent (in) :: i
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = i * ((alpha + beta) + i)
t_1 = (alpha + beta) + (2.0d0 * i)
t_2 = t_1 * t_1
code = ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0d0)
end function
public static double code(double alpha, double beta, double i) {
double t_0 = i * ((alpha + beta) + i);
double t_1 = (alpha + beta) + (2.0 * i);
double t_2 = t_1 * t_1;
return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0);
}
def code(alpha, beta, i): t_0 = i * ((alpha + beta) + i) t_1 = (alpha + beta) + (2.0 * i) t_2 = t_1 * t_1 return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0)
function code(alpha, beta, i) t_0 = Float64(i * Float64(Float64(alpha + beta) + i)) t_1 = Float64(Float64(alpha + beta) + Float64(2.0 * i)) t_2 = Float64(t_1 * t_1) return Float64(Float64(Float64(t_0 * Float64(Float64(beta * alpha) + t_0)) / t_2) / Float64(t_2 - 1.0)) end
function tmp = code(alpha, beta, i) t_0 = i * ((alpha + beta) + i); t_1 = (alpha + beta) + (2.0 * i); t_2 = t_1 * t_1; tmp = ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0); end
code[alpha_, beta_, i_] := Block[{t$95$0 = N[(i * N[(N[(alpha + beta), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, N[(N[(N[(t$95$0 * N[(N[(beta * alpha), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] / N[(t$95$2 - 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := i \cdot \left(\left(\alpha + \beta\right) + i\right)\\
t_1 := \left(\alpha + \beta\right) + 2 \cdot i\\
t_2 := t\_1 \cdot t\_1\\
\frac{\frac{t\_0 \cdot \left(\beta \cdot \alpha + t\_0\right)}{t\_2}}{t\_2 - 1}
\end{array}
\end{array}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha beta i)
:precision binary64
(let* ((t_0 (* i (+ (+ alpha beta) i)))
(t_1 (+ (+ alpha beta) (* 2.0 i)))
(t_2 (* t_1 t_1)))
(/ (/ (* t_0 (+ (* beta alpha) t_0)) t_2) (- t_2 1.0))))
double code(double alpha, double beta, double i) {
double t_0 = i * ((alpha + beta) + i);
double t_1 = (alpha + beta) + (2.0 * i);
double t_2 = t_1 * t_1;
return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 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, i)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8), intent (in) :: i
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = i * ((alpha + beta) + i)
t_1 = (alpha + beta) + (2.0d0 * i)
t_2 = t_1 * t_1
code = ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0d0)
end function
public static double code(double alpha, double beta, double i) {
double t_0 = i * ((alpha + beta) + i);
double t_1 = (alpha + beta) + (2.0 * i);
double t_2 = t_1 * t_1;
return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0);
}
def code(alpha, beta, i): t_0 = i * ((alpha + beta) + i) t_1 = (alpha + beta) + (2.0 * i) t_2 = t_1 * t_1 return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0)
function code(alpha, beta, i) t_0 = Float64(i * Float64(Float64(alpha + beta) + i)) t_1 = Float64(Float64(alpha + beta) + Float64(2.0 * i)) t_2 = Float64(t_1 * t_1) return Float64(Float64(Float64(t_0 * Float64(Float64(beta * alpha) + t_0)) / t_2) / Float64(t_2 - 1.0)) end
function tmp = code(alpha, beta, i) t_0 = i * ((alpha + beta) + i); t_1 = (alpha + beta) + (2.0 * i); t_2 = t_1 * t_1; tmp = ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0); end
code[alpha_, beta_, i_] := Block[{t$95$0 = N[(i * N[(N[(alpha + beta), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, N[(N[(N[(t$95$0 * N[(N[(beta * alpha), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] / N[(t$95$2 - 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := i \cdot \left(\left(\alpha + \beta\right) + i\right)\\
t_1 := \left(\alpha + \beta\right) + 2 \cdot i\\
t_2 := t\_1 \cdot t\_1\\
\frac{\frac{t\_0 \cdot \left(\beta \cdot \alpha + t\_0\right)}{t\_2}}{t\_2 - 1}
\end{array}
\end{array}
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
(FPCore (alpha beta i)
:precision binary64
(let* ((t_0 (* 0.125 (/ beta i))))
(if (<= beta 6.5e+186)
(- (+ 0.0625 t_0) t_0)
(* (/ i beta) (/ (+ alpha i) beta)))))assert(alpha < beta && beta < i);
double code(double alpha, double beta, double i) {
double t_0 = 0.125 * (beta / i);
double tmp;
if (beta <= 6.5e+186) {
tmp = (0.0625 + t_0) - t_0;
} else {
tmp = (i / beta) * ((alpha + i) / beta);
}
return tmp;
}
NOTE: alpha, beta, and i 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, i)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8), intent (in) :: i
real(8) :: t_0
real(8) :: tmp
t_0 = 0.125d0 * (beta / i)
if (beta <= 6.5d+186) then
tmp = (0.0625d0 + t_0) - t_0
else
tmp = (i / beta) * ((alpha + i) / beta)
end if
code = tmp
end function
assert alpha < beta && beta < i;
public static double code(double alpha, double beta, double i) {
double t_0 = 0.125 * (beta / i);
double tmp;
if (beta <= 6.5e+186) {
tmp = (0.0625 + t_0) - t_0;
} else {
tmp = (i / beta) * ((alpha + i) / beta);
}
return tmp;
}
[alpha, beta, i] = sort([alpha, beta, i]) def code(alpha, beta, i): t_0 = 0.125 * (beta / i) tmp = 0 if beta <= 6.5e+186: tmp = (0.0625 + t_0) - t_0 else: tmp = (i / beta) * ((alpha + i) / beta) return tmp
alpha, beta, i = sort([alpha, beta, i]) function code(alpha, beta, i) t_0 = Float64(0.125 * Float64(beta / i)) tmp = 0.0 if (beta <= 6.5e+186) tmp = Float64(Float64(0.0625 + t_0) - t_0); else tmp = Float64(Float64(i / beta) * Float64(Float64(alpha + i) / beta)); end return tmp end
alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
function tmp_2 = code(alpha, beta, i)
t_0 = 0.125 * (beta / i);
tmp = 0.0;
if (beta <= 6.5e+186)
tmp = (0.0625 + t_0) - t_0;
else
tmp = (i / beta) * ((alpha + i) / beta);
end
tmp_2 = tmp;
end
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
code[alpha_, beta_, i_] := Block[{t$95$0 = N[(0.125 * N[(beta / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[beta, 6.5e+186], N[(N[(0.0625 + t$95$0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(i / beta), $MachinePrecision] * N[(N[(alpha + i), $MachinePrecision] / beta), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
\\
\begin{array}{l}
t_0 := 0.125 \cdot \frac{\beta}{i}\\
\mathbf{if}\;\beta \leq 6.5 \cdot 10^{+186}:\\
\;\;\;\;\left(0.0625 + t\_0\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{i}{\beta} \cdot \frac{\alpha + i}{\beta}\\
\end{array}
\end{array}
if beta < 6.4999999999999997e186Initial program 21.9%
Taylor expanded in i around inf
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lift-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f6486.8
Applied rewrites86.8%
Taylor expanded in alpha around 0
lower-*.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
Taylor expanded in alpha around 0
Applied rewrites86.8%
if 6.4999999999999997e186 < beta Initial program 0.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6429.0
Applied rewrites29.0%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6480.2
Applied rewrites80.2%
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. (FPCore (alpha beta i) :precision binary64 (if (<= beta 2.2e+186) 0.0625 (* (/ i beta) (/ (+ alpha i) beta))))
assert(alpha < beta && beta < i);
double code(double alpha, double beta, double i) {
double tmp;
if (beta <= 2.2e+186) {
tmp = 0.0625;
} else {
tmp = (i / beta) * ((alpha + i) / beta);
}
return tmp;
}
NOTE: alpha, beta, and i 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, i)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8), intent (in) :: i
real(8) :: tmp
if (beta <= 2.2d+186) then
tmp = 0.0625d0
else
tmp = (i / beta) * ((alpha + i) / beta)
end if
code = tmp
end function
assert alpha < beta && beta < i;
public static double code(double alpha, double beta, double i) {
double tmp;
if (beta <= 2.2e+186) {
tmp = 0.0625;
} else {
tmp = (i / beta) * ((alpha + i) / beta);
}
return tmp;
}
[alpha, beta, i] = sort([alpha, beta, i]) def code(alpha, beta, i): tmp = 0 if beta <= 2.2e+186: tmp = 0.0625 else: tmp = (i / beta) * ((alpha + i) / beta) return tmp
alpha, beta, i = sort([alpha, beta, i]) function code(alpha, beta, i) tmp = 0.0 if (beta <= 2.2e+186) tmp = 0.0625; else tmp = Float64(Float64(i / beta) * Float64(Float64(alpha + i) / beta)); end return tmp end
alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
function tmp_2 = code(alpha, beta, i)
tmp = 0.0;
if (beta <= 2.2e+186)
tmp = 0.0625;
else
tmp = (i / beta) * ((alpha + i) / beta);
end
tmp_2 = tmp;
end
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. code[alpha_, beta_, i_] := If[LessEqual[beta, 2.2e+186], 0.0625, N[(N[(i / beta), $MachinePrecision] * N[(N[(alpha + i), $MachinePrecision] / beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2.2 \cdot 10^{+186}:\\
\;\;\;\;0.0625\\
\mathbf{else}:\\
\;\;\;\;\frac{i}{\beta} \cdot \frac{\alpha + i}{\beta}\\
\end{array}
\end{array}
if beta < 2.1999999999999998e186Initial program 21.9%
Taylor expanded in i around inf
Applied rewrites86.7%
if 2.1999999999999998e186 < beta Initial program 0.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6428.9
Applied rewrites28.9%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6480.3
Applied rewrites80.3%
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. (FPCore (alpha beta i) :precision binary64 (if (<= beta 5e+241) 0.0625 (* (/ i beta) (/ alpha beta))))
assert(alpha < beta && beta < i);
double code(double alpha, double beta, double i) {
double tmp;
if (beta <= 5e+241) {
tmp = 0.0625;
} else {
tmp = (i / beta) * (alpha / beta);
}
return tmp;
}
NOTE: alpha, beta, and i 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, i)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8), intent (in) :: i
real(8) :: tmp
if (beta <= 5d+241) then
tmp = 0.0625d0
else
tmp = (i / beta) * (alpha / beta)
end if
code = tmp
end function
assert alpha < beta && beta < i;
public static double code(double alpha, double beta, double i) {
double tmp;
if (beta <= 5e+241) {
tmp = 0.0625;
} else {
tmp = (i / beta) * (alpha / beta);
}
return tmp;
}
[alpha, beta, i] = sort([alpha, beta, i]) def code(alpha, beta, i): tmp = 0 if beta <= 5e+241: tmp = 0.0625 else: tmp = (i / beta) * (alpha / beta) return tmp
alpha, beta, i = sort([alpha, beta, i]) function code(alpha, beta, i) tmp = 0.0 if (beta <= 5e+241) tmp = 0.0625; else tmp = Float64(Float64(i / beta) * Float64(alpha / beta)); end return tmp end
alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
function tmp_2 = code(alpha, beta, i)
tmp = 0.0;
if (beta <= 5e+241)
tmp = 0.0625;
else
tmp = (i / beta) * (alpha / beta);
end
tmp_2 = tmp;
end
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. code[alpha_, beta_, i_] := If[LessEqual[beta, 5e+241], 0.0625, N[(N[(i / beta), $MachinePrecision] * N[(alpha / beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 5 \cdot 10^{+241}:\\
\;\;\;\;0.0625\\
\mathbf{else}:\\
\;\;\;\;\frac{i}{\beta} \cdot \frac{\alpha}{\beta}\\
\end{array}
\end{array}
if beta < 5.00000000000000025e241Initial program 19.2%
Taylor expanded in i around inf
Applied rewrites79.8%
if 5.00000000000000025e241 < beta Initial program 0.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6436.3
Applied rewrites36.3%
Taylor expanded in alpha around inf
Applied rewrites38.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6445.9
Applied rewrites45.9%
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. (FPCore (alpha beta i) :precision binary64 (if (<= beta 5e+241) 0.0625 (/ (* i alpha) (* beta beta))))
assert(alpha < beta && beta < i);
double code(double alpha, double beta, double i) {
double tmp;
if (beta <= 5e+241) {
tmp = 0.0625;
} else {
tmp = (i * alpha) / (beta * beta);
}
return tmp;
}
NOTE: alpha, beta, and i 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, i)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8), intent (in) :: i
real(8) :: tmp
if (beta <= 5d+241) then
tmp = 0.0625d0
else
tmp = (i * alpha) / (beta * beta)
end if
code = tmp
end function
assert alpha < beta && beta < i;
public static double code(double alpha, double beta, double i) {
double tmp;
if (beta <= 5e+241) {
tmp = 0.0625;
} else {
tmp = (i * alpha) / (beta * beta);
}
return tmp;
}
[alpha, beta, i] = sort([alpha, beta, i]) def code(alpha, beta, i): tmp = 0 if beta <= 5e+241: tmp = 0.0625 else: tmp = (i * alpha) / (beta * beta) return tmp
alpha, beta, i = sort([alpha, beta, i]) function code(alpha, beta, i) tmp = 0.0 if (beta <= 5e+241) tmp = 0.0625; else tmp = Float64(Float64(i * alpha) / Float64(beta * beta)); end return tmp end
alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
function tmp_2 = code(alpha, beta, i)
tmp = 0.0;
if (beta <= 5e+241)
tmp = 0.0625;
else
tmp = (i * alpha) / (beta * beta);
end
tmp_2 = tmp;
end
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. code[alpha_, beta_, i_] := If[LessEqual[beta, 5e+241], 0.0625, N[(N[(i * alpha), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 5 \cdot 10^{+241}:\\
\;\;\;\;0.0625\\
\mathbf{else}:\\
\;\;\;\;\frac{i \cdot \alpha}{\beta \cdot \beta}\\
\end{array}
\end{array}
if beta < 5.00000000000000025e241Initial program 19.2%
Taylor expanded in i around inf
Applied rewrites79.8%
if 5.00000000000000025e241 < beta Initial program 0.0%
Taylor expanded in beta around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
unpow2N/A
lower-*.f6436.3
Applied rewrites36.3%
Taylor expanded in alpha around inf
Applied rewrites38.0%
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. (FPCore (alpha beta i) :precision binary64 0.0625)
assert(alpha < beta && beta < i);
double code(double alpha, double beta, double i) {
return 0.0625;
}
NOTE: alpha, beta, and i 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, i)
use fmin_fmax_functions
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8), intent (in) :: i
code = 0.0625d0
end function
assert alpha < beta && beta < i;
public static double code(double alpha, double beta, double i) {
return 0.0625;
}
[alpha, beta, i] = sort([alpha, beta, i]) def code(alpha, beta, i): return 0.0625
alpha, beta, i = sort([alpha, beta, i]) function code(alpha, beta, i) return 0.0625 end
alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
function tmp = code(alpha, beta, i)
tmp = 0.0625;
end
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function. code[alpha_, beta_, i_] := 0.0625
\begin{array}{l}
[alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
\\
0.0625
\end{array}
Initial program 16.6%
Taylor expanded in i around inf
Applied rewrites70.7%
herbie shell --seed 2025103
(FPCore (alpha beta i)
:name "Octave 3.8, jcobi/4"
:precision binary64
:pre (and (and (> alpha -1.0) (> beta -1.0)) (> i 1.0))
(/ (/ (* (* i (+ (+ alpha beta) i)) (+ (* beta alpha) (* i (+ (+ alpha beta) i)))) (* (+ (+ alpha beta) (* 2.0 i)) (+ (+ alpha beta) (* 2.0 i)))) (- (* (+ (+ alpha beta) (* 2.0 i)) (+ (+ alpha beta) (* 2.0 i))) 1.0)))