
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 (- INFINITY))
(/ x y)
(if (<= t_0 4e+225) (/ (fma (/ x y) x (* 1.0 x)) (+ x 1.0)) (/ x y)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x / y;
} else if (t_0 <= 4e+225) {
tmp = fma((x / y), x, (1.0 * x)) / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x / y); elseif (t_0 <= 4e+225) tmp = Float64(fma(Float64(x / y), x, Float64(1.0 * x)) / Float64(x + 1.0)); else tmp = Float64(x / y); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 4e+225], N[(N[(N[(x / y), $MachinePrecision] * x + N[(1.0 * x), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+225}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, 1 \cdot x\right)}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -inf.0 or 3.99999999999999971e225 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 52.8%
Taylor expanded in x around inf
lift-/.f6499.0
Applied rewrites99.0%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.99999999999999971e225Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-/.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))) (if (<= t_0 (- INFINITY)) (/ x y) (if (<= t_0 4e+225) t_0 (/ x y)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x / y;
} else if (t_0 <= 4e+225) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x / y;
} else if (t_0 <= 4e+225) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -math.inf: tmp = x / y elif t_0 <= 4e+225: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x / y); elseif (t_0 <= 4e+225) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if (t_0 <= -Inf) tmp = x / y; elseif (t_0 <= 4e+225) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 4e+225], t$95$0, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+225}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -inf.0 or 3.99999999999999971e225 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 52.8%
Taylor expanded in x around inf
lift-/.f6499.0
Applied rewrites99.0%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.99999999999999971e225Initial program 99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (/ (* x x) (- x -1.0)) y))
(t_1 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_1 (- INFINITY))
(/ x y)
(if (<= t_1 -20.0)
t_0
(if (<= t_1 1e-12)
(/ (fma (/ x y) x x) 1.0)
(if (<= t_1 2.0)
(/ x (- x -1.0))
(if (<= t_1 4e+225) t_0 (/ x y))))))))
double code(double x, double y) {
double t_0 = ((x * x) / (x - -1.0)) / y;
double t_1 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x / y;
} else if (t_1 <= -20.0) {
tmp = t_0;
} else if (t_1 <= 1e-12) {
tmp = fma((x / y), x, x) / 1.0;
} else if (t_1 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_1 <= 4e+225) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(Float64(x * x) / Float64(x - -1.0)) / y) t_1 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x / y); elseif (t_1 <= -20.0) tmp = t_0; elseif (t_1 <= 1e-12) tmp = Float64(fma(Float64(x / y), x, x) / 1.0); elseif (t_1 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_1 <= 4e+225) tmp = t_0; else tmp = Float64(x / y); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x / y), $MachinePrecision], If[LessEqual[t$95$1, -20.0], t$95$0, If[LessEqual[t$95$1, 1e-12], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / 1.0), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+225], t$95$0, N[(x / y), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{x \cdot x}{x - -1}}{y}\\
t_1 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq -20:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+225}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -inf.0 or 3.99999999999999971e225 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 52.8%
Taylor expanded in x around inf
lift-/.f6499.0
Applied rewrites99.0%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.99999999999999971e225Initial program 99.7%
Taylor expanded in y around 0
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in x around inf
pow2N/A
lift-*.f6482.1
Applied rewrites82.1%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 9.9999999999999998e-13Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.1%
lift-+.f64N/A
lift-/.f64N/A
lower-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
lift-/.f64N/A
*-lft-identity99.1
Applied rewrites99.1%
if 9.9999999999999998e-13 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6493.3
Applied rewrites93.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -4e+236)
(/ x y)
(if (<= t_0 -20.0)
(/ (* x x) (* (- x -1.0) y))
(if (<= t_0 1e-12)
(/ (fma (/ x y) x x) 1.0)
(if (<= t_0 2.0)
(/ x (- x -1.0))
(if (<= t_0 4e+225) (* x (/ x (fma y x y))) (/ x y))))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -4e+236) {
tmp = x / y;
} else if (t_0 <= -20.0) {
tmp = (x * x) / ((x - -1.0) * y);
} else if (t_0 <= 1e-12) {
tmp = fma((x / y), x, x) / 1.0;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_0 <= 4e+225) {
tmp = x * (x / fma(y, x, y));
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= -4e+236) tmp = Float64(x / y); elseif (t_0 <= -20.0) tmp = Float64(Float64(x * x) / Float64(Float64(x - -1.0) * y)); elseif (t_0 <= 1e-12) tmp = Float64(fma(Float64(x / y), x, x) / 1.0); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_0 <= 4e+225) tmp = Float64(x * Float64(x / fma(y, x, y))); else tmp = Float64(x / y); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e+236], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, -20.0], N[(N[(x * x), $MachinePrecision] / N[(N[(x - -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-12], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / 1.0), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+225], N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+236}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq -20:\\
\;\;\;\;\frac{x \cdot x}{\left(x - -1\right) \cdot y}\\
\mathbf{elif}\;t\_0 \leq 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+225}:\\
\;\;\;\;x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -4.00000000000000021e236 or 3.99999999999999971e225 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 53.8%
Taylor expanded in x around inf
lift-/.f6498.3
Applied rewrites98.3%
if -4.00000000000000021e236 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20Initial program 99.7%
Taylor expanded in y around 0
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6481.0
Applied rewrites81.0%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 9.9999999999999998e-13Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.1%
lift-+.f64N/A
lift-/.f64N/A
lower-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
lift-/.f64N/A
*-lft-identity99.1
Applied rewrites99.1%
if 9.9999999999999998e-13 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6493.3
Applied rewrites93.3%
if 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.99999999999999971e225Initial program 99.7%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-/.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6480.9
Applied rewrites80.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
negate-subN/A
metadata-evalN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.2
Applied rewrites86.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ x (fma y x y))))
(t_1 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_1 -1e+199)
(/ x y)
(if (<= t_1 -20.0)
t_0
(if (<= t_1 1e-12)
(/ (fma (/ x y) x x) 1.0)
(if (<= t_1 2.0)
(/ x (- x -1.0))
(if (<= t_1 4e+225) t_0 (/ x y))))))))
double code(double x, double y) {
double t_0 = x * (x / fma(y, x, y));
double t_1 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_1 <= -1e+199) {
tmp = x / y;
} else if (t_1 <= -20.0) {
tmp = t_0;
} else if (t_1 <= 1e-12) {
tmp = fma((x / y), x, x) / 1.0;
} else if (t_1 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_1 <= 4e+225) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(x * Float64(x / fma(y, x, y))) t_1 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= -1e+199) tmp = Float64(x / y); elseif (t_1 <= -20.0) tmp = t_0; elseif (t_1 <= 1e-12) tmp = Float64(fma(Float64(x / y), x, x) / 1.0); elseif (t_1 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_1 <= 4e+225) tmp = t_0; else tmp = Float64(x / y); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+199], N[(x / y), $MachinePrecision], If[LessEqual[t$95$1, -20.0], t$95$0, If[LessEqual[t$95$1, 1e-12], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / 1.0), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+225], t$95$0, N[(x / y), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
t_1 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+199}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq -20:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+225}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1.0000000000000001e199 or 3.99999999999999971e225 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 55.0%
Taylor expanded in x around inf
lift-/.f6497.4
Applied rewrites97.4%
if -1.0000000000000001e199 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.99999999999999971e225Initial program 99.7%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-/.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6480.1
Applied rewrites80.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
negate-subN/A
metadata-evalN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.8
Applied rewrites85.8%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 9.9999999999999998e-13Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.1%
lift-+.f64N/A
lift-/.f64N/A
lower-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
lift-/.f64N/A
*-lft-identity99.1
Applied rewrites99.1%
if 9.9999999999999998e-13 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6493.3
Applied rewrites93.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ x (fma y x y))))
(t_1 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_1 -1e+199)
(/ x y)
(if (<= t_1 -20.0)
t_0
(if (<= t_1 2.0) (/ x (- x -1.0)) (if (<= t_1 4e+225) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x * (x / fma(y, x, y));
double t_1 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_1 <= -1e+199) {
tmp = x / y;
} else if (t_1 <= -20.0) {
tmp = t_0;
} else if (t_1 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_1 <= 4e+225) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(x * Float64(x / fma(y, x, y))) t_1 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= -1e+199) tmp = Float64(x / y); elseif (t_1 <= -20.0) tmp = t_0; elseif (t_1 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_1 <= 4e+225) tmp = t_0; else tmp = Float64(x / y); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+199], N[(x / y), $MachinePrecision], If[LessEqual[t$95$1, -20.0], t$95$0, If[LessEqual[t$95$1, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+225], t$95$0, N[(x / y), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
t_1 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+199}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq -20:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+225}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1.0000000000000001e199 or 3.99999999999999971e225 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 55.0%
Taylor expanded in x around inf
lift-/.f6497.4
Applied rewrites97.4%
if -1.0000000000000001e199 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.99999999999999971e225Initial program 99.7%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-/.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6480.1
Applied rewrites80.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
negate-subN/A
metadata-evalN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.8
Applied rewrites85.8%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6487.4
Applied rewrites87.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -20.0)
(/ x y)
(if (<= t_0 2.0)
(/ x (- x -1.0))
(if (<= t_0 1e+85) (* (/ x y) x) (/ x y))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_0 <= 1e+85) {
tmp = (x / y) * x;
} 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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
if (t_0 <= (-20.0d0)) then
tmp = x / y
else if (t_0 <= 2.0d0) then
tmp = x / (x - (-1.0d0))
else if (t_0 <= 1d+85) then
tmp = (x / y) * x
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_0 <= 1e+85) {
tmp = (x / y) * x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -20.0: tmp = x / y elif t_0 <= 2.0: tmp = x / (x - -1.0) elif t_0 <= 1e+85: tmp = (x / y) * x else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= -20.0) tmp = Float64(x / y); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_0 <= 1e+85) tmp = Float64(Float64(x / y) * x); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if (t_0 <= -20.0) tmp = x / y; elseif (t_0 <= 2.0) tmp = x / (x - -1.0); elseif (t_0 <= 1e+85) tmp = (x / y) * x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+85], N[(N[(x / y), $MachinePrecision] * x), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -20:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;t\_0 \leq 10^{+85}:\\
\;\;\;\;\frac{x}{y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20 or 1e85 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 68.2%
Taylor expanded in x around inf
lift-/.f6487.6
Applied rewrites87.6%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6487.4
Applied rewrites87.4%
if 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1e85Initial program 99.7%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-/.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6470.4
Applied rewrites70.4%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6430.7
Applied rewrites30.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))) (if (<= t_0 -20.0) (/ x y) (if (<= t_0 2.0) (/ x (- x -1.0)) (/ x y)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2.0) {
tmp = x / (x - -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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
if (t_0 <= (-20.0d0)) then
tmp = x / y
else if (t_0 <= 2.0d0) then
tmp = x / (x - (-1.0d0))
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -20.0: tmp = x / y elif t_0 <= 2.0: tmp = x / (x - -1.0) else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= -20.0) tmp = Float64(x / y); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if (t_0 <= -20.0) tmp = x / y; elseif (t_0 <= 2.0) tmp = x / (x - -1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -20:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 71.4%
Taylor expanded in x around inf
lift-/.f6485.0
Applied rewrites85.0%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6487.4
Applied rewrites87.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -20.0)
(/ x y)
(if (<= t_0 2e-22) x (if (<= t_0 2.0) (- 1.0 (/ 1.0 x)) (/ x y))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2e-22) {
tmp = x;
} else if (t_0 <= 2.0) {
tmp = 1.0 - (1.0 / x);
} 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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
if (t_0 <= (-20.0d0)) then
tmp = x / y
else if (t_0 <= 2d-22) then
tmp = x
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 - (1.0d0 / x)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2e-22) {
tmp = x;
} else if (t_0 <= 2.0) {
tmp = 1.0 - (1.0 / x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -20.0: tmp = x / y elif t_0 <= 2e-22: tmp = x elif t_0 <= 2.0: tmp = 1.0 - (1.0 / x) else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= -20.0) tmp = Float64(x / y); elseif (t_0 <= 2e-22) tmp = x; elseif (t_0 <= 2.0) tmp = Float64(1.0 - Float64(1.0 / x)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if (t_0 <= -20.0) tmp = x / y; elseif (t_0 <= 2e-22) tmp = x; elseif (t_0 <= 2.0) tmp = 1.0 - (1.0 / x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 2e-22], x, If[LessEqual[t$95$0, 2.0], N[(1.0 - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -20:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-22}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1 - \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 71.4%
Taylor expanded in x around inf
lift-/.f6485.0
Applied rewrites85.0%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2.0000000000000001e-22Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites85.4%
if 2.0000000000000001e-22 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6491.8
Applied rewrites91.8%
Taylor expanded in x around inf
lower--.f64N/A
lower-/.f6484.3
Applied rewrites84.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -20.0)
(/ x y)
(if (<= t_0 2e-22) x (if (<= t_0 4e+42) 1.0 (/ x y))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2e-22) {
tmp = x;
} else if (t_0 <= 4e+42) {
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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
if (t_0 <= (-20.0d0)) then
tmp = x / y
else if (t_0 <= 2d-22) then
tmp = x
else if (t_0 <= 4d+42) 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 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -20.0) {
tmp = x / y;
} else if (t_0 <= 2e-22) {
tmp = x;
} else if (t_0 <= 4e+42) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -20.0: tmp = x / y elif t_0 <= 2e-22: tmp = x elif t_0 <= 4e+42: tmp = 1.0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if (t_0 <= -20.0) tmp = Float64(x / y); elseif (t_0 <= 2e-22) tmp = x; elseif (t_0 <= 4e+42) tmp = 1.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if (t_0 <= -20.0) tmp = x / y; elseif (t_0 <= 2e-22) tmp = x; elseif (t_0 <= 4e+42) tmp = 1.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 2e-22], x, If[LessEqual[t$95$0, 4e+42], 1.0, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -20:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-22}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+42}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -20 or 4.00000000000000018e42 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 69.8%
Taylor expanded in x around inf
lift-/.f6486.6
Applied rewrites86.6%
if -20 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2.0000000000000001e-22Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites85.4%
if 2.0000000000000001e-22 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 4.00000000000000018e42Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6479.1
Applied rewrites79.1%
Taylor expanded in x around inf
Applied rewrites72.2%
(FPCore (x y) :precision binary64 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) 2e-22) x 1.0))
double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-22) {
tmp = x;
} else {
tmp = 1.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) :: tmp
if (((x * ((x / y) + 1.0d0)) / (x + 1.0d0)) <= 2d-22) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-22) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if ((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-22: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= 2e-22) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-22) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 2e-22], x, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq 2 \cdot 10^{-22}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2.0000000000000001e-22Initial program 90.6%
Taylor expanded in x around 0
Applied rewrites57.5%
if 2.0000000000000001e-22 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 81.5%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6437.2
Applied rewrites37.2%
Taylor expanded in x around inf
Applied rewrites34.3%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
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 = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.3%
Taylor expanded in x around 0
Applied rewrites38.7%
herbie shell --seed 2025110
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))