
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1.0 y))))
(if (<= y -140000.0)
t_0
(if (<= y 160000000000.0)
(/ (fma (- x 1.0) y (- y -1.0)) (- y -1.0))
t_0))))double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -140000.0) {
tmp = t_0;
} else if (y <= 160000000000.0) {
tmp = fma((x - 1.0), y, (y - -1.0)) / (y - -1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(x + Float64(1.0 / y)) tmp = 0.0 if (y <= -140000.0) tmp = t_0; elseif (y <= 160000000000.0) tmp = Float64(fma(Float64(x - 1.0), y, Float64(y - -1.0)) / Float64(y - -1.0)); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -140000.0], t$95$0, If[LessEqual[y, 160000000000.0], N[(N[(N[(x - 1.0), $MachinePrecision] * y + N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
\mathbf{if}\;y \leq -140000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 160000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x - 1, y, y - -1\right)}{y - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.4e5 or 1.6e11 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
Taylor expanded in x around 0
lower-/.f6450.5%
Applied rewrites50.5%
if -1.4e5 < y < 1.6e11Initial program 66.2%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lower-/.f64N/A
sub-flipN/A
*-lft-identityN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f6466.6%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval66.6%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval66.6%
Applied rewrites66.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1.0 y))))
(if (<= y -140000.0)
t_0
(if (<= y 2350000.0) (fma y (/ (- x 1.0) (- y -1.0)) 1.0) t_0))))double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -140000.0) {
tmp = t_0;
} else if (y <= 2350000.0) {
tmp = fma(y, ((x - 1.0) / (y - -1.0)), 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(x + Float64(1.0 / y)) tmp = 0.0 if (y <= -140000.0) tmp = t_0; elseif (y <= 2350000.0) tmp = fma(y, Float64(Float64(x - 1.0) / Float64(y - -1.0)), 1.0); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -140000.0], t$95$0, If[LessEqual[y, 2350000.0], N[(y * N[(N[(x - 1.0), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
\mathbf{if}\;y \leq -140000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2350000:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x - 1}{y - -1}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.4e5 or 2.35e6 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
Taylor expanded in x around 0
lower-/.f6450.5%
Applied rewrites50.5%
if -1.4e5 < y < 2.35e6Initial program 66.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
remove-double-negN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6477.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval77.3%
Applied rewrites77.3%
(FPCore (x y) :precision binary64 (let* ((t_0 (- x (/ (- x 1.0) y)))) (if (<= y -0.09) t_0 (if (<= y 0.96) (fma (- x 1.0) y 1.0) t_0))))
double code(double x, double y) {
double t_0 = x - ((x - 1.0) / y);
double tmp;
if (y <= -0.09) {
tmp = t_0;
} else if (y <= 0.96) {
tmp = fma((x - 1.0), y, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(x - Float64(Float64(x - 1.0) / y)) tmp = 0.0 if (y <= -0.09) tmp = t_0; elseif (y <= 0.96) tmp = fma(Float64(x - 1.0), y, 1.0); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.09], t$95$0, If[LessEqual[y, 0.96], N[(N[(x - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x - \frac{x - 1}{y}\\
\mathbf{if}\;y \leq -0.09:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.96:\\
\;\;\;\;\mathsf{fma}\left(x - 1, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -0.089999999999999997 or 0.95999999999999996 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
if -0.089999999999999997 < y < 0.95999999999999996Initial program 66.2%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6450.5%
Applied rewrites50.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6450.5%
Applied rewrites50.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1.0 y))))
(if (<= y -1.85e-13)
t_0
(if (<= y 0.075) (fma (- x 1.0) y 1.0) t_0))))double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -1.85e-13) {
tmp = t_0;
} else if (y <= 0.075) {
tmp = fma((x - 1.0), y, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(x + Float64(1.0 / y)) tmp = 0.0 if (y <= -1.85e-13) tmp = t_0; elseif (y <= 0.075) tmp = fma(Float64(x - 1.0), y, 1.0); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.85e-13], t$95$0, If[LessEqual[y, 0.075], N[(N[(x - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
\mathbf{if}\;y \leq -1.85 \cdot 10^{-13}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.075:\\
\;\;\;\;\mathsf{fma}\left(x - 1, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.8499999999999999e-13 or 0.074999999999999997 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
Taylor expanded in x around 0
lower-/.f6450.5%
Applied rewrites50.5%
if -1.8499999999999999e-13 < y < 0.074999999999999997Initial program 66.2%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6450.5%
Applied rewrites50.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6450.5%
Applied rewrites50.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1.0 y))))
(if (<= y -30000.0)
t_0
(if (<= y 1.85e-53)
(/ 1.0 (+ 1.0 y))
(if (<= y 4.8e-13) (* x y) t_0)))))double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -30000.0) {
tmp = t_0;
} else if (y <= 1.85e-53) {
tmp = 1.0 / (1.0 + y);
} else if (y <= 4.8e-13) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x + (1.0d0 / y)
if (y <= (-30000.0d0)) then
tmp = t_0
else if (y <= 1.85d-53) then
tmp = 1.0d0 / (1.0d0 + y)
else if (y <= 4.8d-13) then
tmp = x * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -30000.0) {
tmp = t_0;
} else if (y <= 1.85e-53) {
tmp = 1.0 / (1.0 + y);
} else if (y <= 4.8e-13) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x + (1.0 / y) tmp = 0 if y <= -30000.0: tmp = t_0 elif y <= 1.85e-53: tmp = 1.0 / (1.0 + y) elif y <= 4.8e-13: tmp = x * y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x + Float64(1.0 / y)) tmp = 0.0 if (y <= -30000.0) tmp = t_0; elseif (y <= 1.85e-53) tmp = Float64(1.0 / Float64(1.0 + y)); elseif (y <= 4.8e-13) tmp = Float64(x * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x + (1.0 / y); tmp = 0.0; if (y <= -30000.0) tmp = t_0; elseif (y <= 1.85e-53) tmp = 1.0 / (1.0 + y); elseif (y <= 4.8e-13) tmp = x * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -30000.0], t$95$0, If[LessEqual[y, 1.85e-53], N[(1.0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e-13], N[(x * y), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
\mathbf{if}\;y \leq -30000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-53}:\\
\;\;\;\;\frac{1}{1 + y}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-13}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -3e4 or 4.7999999999999997e-13 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
Taylor expanded in x around 0
lower-/.f6450.5%
Applied rewrites50.5%
if -3e4 < y < 1.8499999999999999e-53Initial program 66.2%
Taylor expanded in x around 0
Applied rewrites40.0%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
sub-negate-revN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
lower-/.f64N/A
*-lft-identityN/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
sub-negate-revN/A
lower--.f6440.4%
Applied rewrites40.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.2%
Applied rewrites51.2%
if 1.8499999999999999e-53 < y < 4.7999999999999997e-13Initial program 66.2%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6439.3%
Applied rewrites39.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l*N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lower-/.f6445.1%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6445.1%
Applied rewrites45.1%
Taylor expanded in y around 0
lower-*.f6414.6%
Applied rewrites14.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0)))))
(if (<= t_0 -100.0)
(- 1.0 (- 1.0 x))
(if (<= t_0 4e+53) (/ 1.0 (+ 1.0 y)) (- 1.0 (- x))))))double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double tmp;
if (t_0 <= -100.0) {
tmp = 1.0 - (1.0 - x);
} else if (t_0 <= 4e+53) {
tmp = 1.0 / (1.0 + y);
} else {
tmp = 1.0 - -x;
}
return tmp;
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
if (t_0 <= (-100.0d0)) then
tmp = 1.0d0 - (1.0d0 - x)
else if (t_0 <= 4d+53) then
tmp = 1.0d0 / (1.0d0 + y)
else
tmp = 1.0d0 - -x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double tmp;
if (t_0 <= -100.0) {
tmp = 1.0 - (1.0 - x);
} else if (t_0 <= 4e+53) {
tmp = 1.0 / (1.0 + y);
} else {
tmp = 1.0 - -x;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)) tmp = 0 if t_0 <= -100.0: tmp = 1.0 - (1.0 - x) elif t_0 <= 4e+53: tmp = 1.0 / (1.0 + y) else: tmp = 1.0 - -x return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) tmp = 0.0 if (t_0 <= -100.0) tmp = Float64(1.0 - Float64(1.0 - x)); elseif (t_0 <= 4e+53) tmp = Float64(1.0 / Float64(1.0 + y)); else tmp = Float64(1.0 - Float64(-x)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)); tmp = 0.0; if (t_0 <= -100.0) tmp = 1.0 - (1.0 - x); elseif (t_0 <= 4e+53) tmp = 1.0 / (1.0 + y); else tmp = 1.0 - -x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(1.0 - N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+53], N[(1.0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision], N[(1.0 - (-x)), $MachinePrecision]]]]
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{if}\;t\_0 \leq -100:\\
\;\;\;\;1 - \left(1 - x\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+53}:\\
\;\;\;\;\frac{1}{1 + y}\\
\mathbf{else}:\\
\;\;\;\;1 - \left(-x\right)\\
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < -100Initial program 66.2%
Taylor expanded in y around inf
lower--.f6427.7%
Applied rewrites27.7%
if -100 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 4e53Initial program 66.2%
Taylor expanded in x around 0
Applied rewrites40.0%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
sub-negate-revN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
lower-/.f64N/A
*-lft-identityN/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
sub-negate-revN/A
lower--.f6440.4%
Applied rewrites40.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.2%
Applied rewrites51.2%
if 4e53 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) Initial program 66.2%
Taylor expanded in y around inf
lower--.f6427.7%
Applied rewrites27.7%
Taylor expanded in x around inf
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6449.6%
Applied rewrites49.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0)))))
(if (<= t_0 -100.0)
(- 1.0 (- 1.0 x))
(if (<= t_0 1e-11)
(/ 1.0 y)
(if (<= t_0 4e+53) (fma -1.0 y 1.0) (- 1.0 (- x)))))))double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double tmp;
if (t_0 <= -100.0) {
tmp = 1.0 - (1.0 - x);
} else if (t_0 <= 1e-11) {
tmp = 1.0 / y;
} else if (t_0 <= 4e+53) {
tmp = fma(-1.0, y, 1.0);
} else {
tmp = 1.0 - -x;
}
return tmp;
}
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) tmp = 0.0 if (t_0 <= -100.0) tmp = Float64(1.0 - Float64(1.0 - x)); elseif (t_0 <= 1e-11) tmp = Float64(1.0 / y); elseif (t_0 <= 4e+53) tmp = fma(-1.0, y, 1.0); else tmp = Float64(1.0 - Float64(-x)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(1.0 - N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-11], N[(1.0 / y), $MachinePrecision], If[LessEqual[t$95$0, 4e+53], N[(-1.0 * y + 1.0), $MachinePrecision], N[(1.0 - (-x)), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{if}\;t\_0 \leq -100:\\
\;\;\;\;1 - \left(1 - x\right)\\
\mathbf{elif}\;t\_0 \leq 10^{-11}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(-1, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(-x\right)\\
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < -100Initial program 66.2%
Taylor expanded in y around inf
lower--.f6427.7%
Applied rewrites27.7%
if -100 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 9.9999999999999994e-12Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
Taylor expanded in x around 0
lower-/.f6414.7%
Applied rewrites14.7%
if 9.9999999999999994e-12 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 4e53Initial program 66.2%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6450.5%
Applied rewrites50.5%
Taylor expanded in x around 0
Applied rewrites38.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6438.7%
Applied rewrites38.7%
if 4e53 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) Initial program 66.2%
Taylor expanded in y around inf
lower--.f6427.7%
Applied rewrites27.7%
Taylor expanded in x around inf
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6449.6%
Applied rewrites49.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(t_1 (- 1.0 (- x))))
(if (<= t_0 -100.0)
t_1
(if (<= t_0 1e-11)
(/ 1.0 y)
(if (<= t_0 4e+53) (fma -1.0 y 1.0) t_1)))))double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double t_1 = 1.0 - -x;
double tmp;
if (t_0 <= -100.0) {
tmp = t_1;
} else if (t_0 <= 1e-11) {
tmp = 1.0 / y;
} else if (t_0 <= 4e+53) {
tmp = fma(-1.0, y, 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) t_1 = Float64(1.0 - Float64(-x)) tmp = 0.0 if (t_0 <= -100.0) tmp = t_1; elseif (t_0 <= 1e-11) tmp = Float64(1.0 / y); elseif (t_0 <= 4e+53) tmp = fma(-1.0, y, 1.0); else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - (-x)), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], t$95$1, If[LessEqual[t$95$0, 1e-11], N[(1.0 / y), $MachinePrecision], If[LessEqual[t$95$0, 4e+53], N[(-1.0 * y + 1.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
t_1 := 1 - \left(-x\right)\\
\mathbf{if}\;t\_0 \leq -100:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{-11}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(-1, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < -100 or 4e53 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) Initial program 66.2%
Taylor expanded in y around inf
lower--.f6427.7%
Applied rewrites27.7%
Taylor expanded in x around inf
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6449.6%
Applied rewrites49.6%
if -100 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 9.9999999999999994e-12Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
Taylor expanded in x around 0
lower-/.f6414.7%
Applied rewrites14.7%
if 9.9999999999999994e-12 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 4e53Initial program 66.2%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6450.5%
Applied rewrites50.5%
Taylor expanded in x around 0
Applied rewrites38.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6438.7%
Applied rewrites38.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(t_1 (- 1.0 (- x))))
(if (<= t_0 -100.0)
t_1
(if (<= t_0 1e-11) (/ 1.0 y) (if (<= t_0 4e+53) 1.0 t_1)))))double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double t_1 = 1.0 - -x;
double tmp;
if (t_0 <= -100.0) {
tmp = t_1;
} else if (t_0 <= 1e-11) {
tmp = 1.0 / y;
} else if (t_0 <= 4e+53) {
tmp = 1.0;
} else {
tmp = t_1;
}
return tmp;
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
t_1 = 1.0d0 - -x
if (t_0 <= (-100.0d0)) then
tmp = t_1
else if (t_0 <= 1d-11) then
tmp = 1.0d0 / y
else if (t_0 <= 4d+53) then
tmp = 1.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double t_1 = 1.0 - -x;
double tmp;
if (t_0 <= -100.0) {
tmp = t_1;
} else if (t_0 <= 1e-11) {
tmp = 1.0 / y;
} else if (t_0 <= 4e+53) {
tmp = 1.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)) t_1 = 1.0 - -x tmp = 0 if t_0 <= -100.0: tmp = t_1 elif t_0 <= 1e-11: tmp = 1.0 / y elif t_0 <= 4e+53: tmp = 1.0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) t_1 = Float64(1.0 - Float64(-x)) tmp = 0.0 if (t_0 <= -100.0) tmp = t_1; elseif (t_0 <= 1e-11) tmp = Float64(1.0 / y); elseif (t_0 <= 4e+53) tmp = 1.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)); t_1 = 1.0 - -x; tmp = 0.0; if (t_0 <= -100.0) tmp = t_1; elseif (t_0 <= 1e-11) tmp = 1.0 / y; elseif (t_0 <= 4e+53) tmp = 1.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - (-x)), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], t$95$1, If[LessEqual[t$95$0, 1e-11], N[(1.0 / y), $MachinePrecision], If[LessEqual[t$95$0, 4e+53], 1.0, t$95$1]]]]]
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
t_1 := 1 - \left(-x\right)\\
\mathbf{if}\;t\_0 \leq -100:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{-11}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+53}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < -100 or 4e53 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) Initial program 66.2%
Taylor expanded in y around inf
lower--.f6427.7%
Applied rewrites27.7%
Taylor expanded in x around inf
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6449.6%
Applied rewrites49.6%
if -100 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 9.9999999999999994e-12Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
Taylor expanded in x around 0
lower-/.f6414.7%
Applied rewrites14.7%
if 9.9999999999999994e-12 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 4e53Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites38.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (- x))))
(if (<= y -3e-8)
t_0
(if (<= y 1.85e-53) 1.0 (if (<= y 4.8e-13) (* x y) t_0)))))double code(double x, double y) {
double t_0 = 1.0 - -x;
double tmp;
if (y <= -3e-8) {
tmp = t_0;
} else if (y <= 1.85e-53) {
tmp = 1.0;
} else if (y <= 4.8e-13) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - -x
if (y <= (-3d-8)) then
tmp = t_0
else if (y <= 1.85d-53) then
tmp = 1.0d0
else if (y <= 4.8d-13) then
tmp = x * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - -x;
double tmp;
if (y <= -3e-8) {
tmp = t_0;
} else if (y <= 1.85e-53) {
tmp = 1.0;
} else if (y <= 4.8e-13) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - -x tmp = 0 if y <= -3e-8: tmp = t_0 elif y <= 1.85e-53: tmp = 1.0 elif y <= 4.8e-13: tmp = x * y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(-x)) tmp = 0.0 if (y <= -3e-8) tmp = t_0; elseif (y <= 1.85e-53) tmp = 1.0; elseif (y <= 4.8e-13) tmp = Float64(x * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - -x; tmp = 0.0; if (y <= -3e-8) tmp = t_0; elseif (y <= 1.85e-53) tmp = 1.0; elseif (y <= 4.8e-13) tmp = x * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - (-x)), $MachinePrecision]}, If[LessEqual[y, -3e-8], t$95$0, If[LessEqual[y, 1.85e-53], 1.0, If[LessEqual[y, 4.8e-13], N[(x * y), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := 1 - \left(-x\right)\\
\mathbf{if}\;y \leq -3 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-53}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-13}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -2.9999999999999997e-8 or 4.7999999999999997e-13 < y Initial program 66.2%
Taylor expanded in y around inf
lower--.f6427.7%
Applied rewrites27.7%
Taylor expanded in x around inf
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6449.6%
Applied rewrites49.6%
if -2.9999999999999997e-8 < y < 1.8499999999999999e-53Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites38.9%
if 1.8499999999999999e-53 < y < 4.7999999999999997e-13Initial program 66.2%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6439.3%
Applied rewrites39.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l*N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lower-/.f6445.1%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6445.1%
Applied rewrites45.1%
Taylor expanded in y around 0
lower-*.f6414.6%
Applied rewrites14.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0)))) (if (<= t_0 -2e+21) (* x y) (if (<= t_0 1.00002) 1.0 (* x y)))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (y + 1.0);
double tmp;
if (t_0 <= -2e+21) {
tmp = x * y;
} else if (t_0 <= 1.00002) {
tmp = 1.0;
} else {
tmp = x * y;
}
return tmp;
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 - x) * y) / (y + 1.0d0)
if (t_0 <= (-2d+21)) then
tmp = x * y
else if (t_0 <= 1.00002d0) then
tmp = 1.0d0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (y + 1.0);
double tmp;
if (t_0 <= -2e+21) {
tmp = x * y;
} else if (t_0 <= 1.00002) {
tmp = 1.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): t_0 = ((1.0 - x) * y) / (y + 1.0) tmp = 0 if t_0 <= -2e+21: tmp = x * y elif t_0 <= 1.00002: tmp = 1.0 else: tmp = x * y return tmp
function code(x, y) t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)) tmp = 0.0 if (t_0 <= -2e+21) tmp = Float64(x * y); elseif (t_0 <= 1.00002) tmp = 1.0; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (y + 1.0); tmp = 0.0; if (t_0 <= -2e+21) tmp = x * y; elseif (t_0 <= 1.00002) tmp = 1.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+21], N[(x * y), $MachinePrecision], If[LessEqual[t$95$0, 1.00002], 1.0, N[(x * y), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+21}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;t\_0 \leq 1.00002:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -2e21 or 1.0000199999999999 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 66.2%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6439.3%
Applied rewrites39.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l*N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lower-/.f6445.1%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6445.1%
Applied rewrites45.1%
Taylor expanded in y around 0
lower-*.f6414.6%
Applied rewrites14.6%
if -2e21 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.0000199999999999Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites38.9%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
1
Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.3%
Applied rewrites50.3%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites38.9%
herbie shell --seed 2025210
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))