
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
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 - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
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 - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
(FPCore (x y) :precision binary64 (- (/ x (- 1.0 y)) (/ y (- 1.0 y))))
double code(double x, double y) {
return (x / (1.0 - y)) - (y / (1.0 - y));
}
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 / (1.0d0 - y)) - (y / (1.0d0 - y))
end function
public static double code(double x, double y) {
return (x / (1.0 - y)) - (y / (1.0 - y));
}
def code(x, y): return (x / (1.0 - y)) - (y / (1.0 - y))
function code(x, y) return Float64(Float64(x / Float64(1.0 - y)) - Float64(y / Float64(1.0 - y))) end
function tmp = code(x, y) tmp = (x / (1.0 - y)) - (y / (1.0 - y)); end
code[x_, y_] := N[(N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 - y} - \frac{y}{1 - y}
\end{array}
Initial program 100.0%
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64100.0
Applied rewrites100.0%
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
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 - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (- (/ x (- 1.0 y)) -1.0))) (if (<= y -1.05e-5) t_0 (if (<= y 0.000106) (fma (- x 1.0) y x) t_0))))
double code(double x, double y) {
double t_0 = (x / (1.0 - y)) - -1.0;
double tmp;
if (y <= -1.05e-5) {
tmp = t_0;
} else if (y <= 0.000106) {
tmp = fma((x - 1.0), y, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x / Float64(1.0 - y)) - -1.0) tmp = 0.0 if (y <= -1.05e-5) tmp = t_0; elseif (y <= 0.000106) tmp = fma(Float64(x - 1.0), y, x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, -1.05e-5], t$95$0, If[LessEqual[y, 0.000106], N[(N[(x - 1.0), $MachinePrecision] * y + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 - y} - -1\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.000106:\\
\;\;\;\;\mathsf{fma}\left(x - 1, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.04999999999999994e-5 or 1.06e-4 < y Initial program 100.0%
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites98.6%
if -1.04999999999999994e-5 < y < 1.06e-4Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower--.f6499.4
Applied rewrites99.4%
(FPCore (x y) :precision binary64 (if (<= y -0.84) (- (/ x (- y)) -1.0) (if (<= y 1.0) (fma (- x 1.0) y x) (- (/ (- 1.0 x) y) -1.0))))
double code(double x, double y) {
double tmp;
if (y <= -0.84) {
tmp = (x / -y) - -1.0;
} else if (y <= 1.0) {
tmp = fma((x - 1.0), y, x);
} else {
tmp = ((1.0 - x) / y) - -1.0;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -0.84) tmp = Float64(Float64(x / Float64(-y)) - -1.0); elseif (y <= 1.0) tmp = fma(Float64(x - 1.0), y, x); else tmp = Float64(Float64(Float64(1.0 - x) / y) - -1.0); end return tmp end
code[x_, y_] := If[LessEqual[y, -0.84], N[(N[(x / (-y)), $MachinePrecision] - -1.0), $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(x - 1.0), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.84:\\
\;\;\;\;\frac{x}{-y} - -1\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\mathsf{fma}\left(x - 1, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{y} - -1\\
\end{array}
\end{array}
if y < -0.839999999999999969Initial program 100.0%
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites99.1%
Taylor expanded in y around inf
mul-1-negN/A
lift-neg.f6498.1
Applied rewrites98.1%
if -0.839999999999999969 < y < 1Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower--.f6498.6
Applied rewrites98.6%
if 1 < y Initial program 100.0%
Taylor expanded in y around inf
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6498.6
Applied rewrites98.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (- (/ x (- y)) -1.0))) (if (<= y -0.84) t_0 (if (<= y 1.0) (fma (- x 1.0) y x) t_0))))
double code(double x, double y) {
double t_0 = (x / -y) - -1.0;
double tmp;
if (y <= -0.84) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = fma((x - 1.0), y, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x / Float64(-y)) - -1.0) tmp = 0.0 if (y <= -0.84) tmp = t_0; elseif (y <= 1.0) tmp = fma(Float64(x - 1.0), y, x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / (-y)), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, -0.84], t$95$0, If[LessEqual[y, 1.0], N[(N[(x - 1.0), $MachinePrecision] * y + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-y} - -1\\
\mathbf{if}\;y \leq -0.84:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\mathsf{fma}\left(x - 1, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.839999999999999969 or 1 < y Initial program 100.0%
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites99.1%
Taylor expanded in y around inf
mul-1-negN/A
lift-neg.f6498.2
Applied rewrites98.2%
if -0.839999999999999969 < y < 1Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower--.f6498.6
Applied rewrites98.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- x y) (- 1.0 y))) (t_1 (/ x (- 1.0 y))))
(if (<= t_0 -50000000000.0)
t_1
(if (<= t_0 0.8) (fma -1.0 y x) (if (<= t_0 2.0) 1.0 t_1)))))
double code(double x, double y) {
double t_0 = (x - y) / (1.0 - y);
double t_1 = x / (1.0 - y);
double tmp;
if (t_0 <= -50000000000.0) {
tmp = t_1;
} else if (t_0 <= 0.8) {
tmp = fma(-1.0, y, x);
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x - y) / Float64(1.0 - y)) t_1 = Float64(x / Float64(1.0 - y)) tmp = 0.0 if (t_0 <= -50000000000.0) tmp = t_1; elseif (t_0 <= 0.8) tmp = fma(-1.0, y, x); elseif (t_0 <= 2.0) tmp = 1.0; else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50000000000.0], t$95$1, If[LessEqual[t$95$0, 0.8], N[(-1.0 * y + x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], 1.0, t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{1 - y}\\
t_1 := \frac{x}{1 - y}\\
\mathbf{if}\;t\_0 \leq -50000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.8:\\
\;\;\;\;\mathsf{fma}\left(-1, y, x\right)\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < -5e10 or 2 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites99.2%
if -5e10 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < 0.80000000000000004Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower--.f6496.4
Applied rewrites96.4%
Taylor expanded in x around 0
Applied rewrites96.4%
if 0.80000000000000004 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < 2Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites97.5%
(FPCore (x y) :precision binary64 (let* ((t_0 (- (/ x (- y)) -1.0))) (if (<= y -1.0) t_0 (if (<= y 1.0) (fma -1.0 y x) t_0))))
double code(double x, double y) {
double t_0 = (x / -y) - -1.0;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = fma(-1.0, y, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x / Float64(-y)) - -1.0) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = fma(-1.0, y, x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / (-y)), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.0], N[(-1.0 * y + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-y} - -1\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-1, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites99.1%
Taylor expanded in y around inf
mul-1-negN/A
lift-neg.f6498.2
Applied rewrites98.2%
if -1 < y < 1Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower--.f6498.6
Applied rewrites98.6%
Taylor expanded in x around 0
Applied rewrites98.0%
(FPCore (x y) :precision binary64 (if (<= y -1.25e+29) 1.0 (if (<= y 1.0) (fma -1.0 y x) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.25e+29) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = fma(-1.0, y, x);
} else {
tmp = 1.0;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -1.25e+29) tmp = 1.0; elseif (y <= 1.0) tmp = fma(-1.0, y, x); else tmp = 1.0; end return tmp end
code[x_, y_] := If[LessEqual[y, -1.25e+29], 1.0, If[LessEqual[y, 1.0], N[(-1.0 * y + x), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+29}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-1, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.25e29 or 1 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites76.5%
if -1.25e29 < y < 1Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower--.f6494.6
Applied rewrites94.6%
Taylor expanded in x around 0
Applied rewrites94.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- x y) (- 1.0 y))))
(if (<= t_0 -4e-32)
x
(if (<= t_0 0.5) (- y) (if (<= t_0 2000000000.0) 1.0 x)))))
double code(double x, double y) {
double t_0 = (x - y) / (1.0 - y);
double tmp;
if (t_0 <= -4e-32) {
tmp = x;
} else if (t_0 <= 0.5) {
tmp = -y;
} else if (t_0 <= 2000000000.0) {
tmp = 1.0;
} else {
tmp = 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 = (x - y) / (1.0d0 - y)
if (t_0 <= (-4d-32)) then
tmp = x
else if (t_0 <= 0.5d0) then
tmp = -y
else if (t_0 <= 2000000000.0d0) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) / (1.0 - y);
double tmp;
if (t_0 <= -4e-32) {
tmp = x;
} else if (t_0 <= 0.5) {
tmp = -y;
} else if (t_0 <= 2000000000.0) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): t_0 = (x - y) / (1.0 - y) tmp = 0 if t_0 <= -4e-32: tmp = x elif t_0 <= 0.5: tmp = -y elif t_0 <= 2000000000.0: tmp = 1.0 else: tmp = x return tmp
function code(x, y) t_0 = Float64(Float64(x - y) / Float64(1.0 - y)) tmp = 0.0 if (t_0 <= -4e-32) tmp = x; elseif (t_0 <= 0.5) tmp = Float64(-y); elseif (t_0 <= 2000000000.0) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) / (1.0 - y); tmp = 0.0; if (t_0 <= -4e-32) tmp = x; elseif (t_0 <= 0.5) tmp = -y; elseif (t_0 <= 2000000000.0) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-32], x, If[LessEqual[t$95$0, 0.5], (-y), If[LessEqual[t$95$0, 2000000000.0], 1.0, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{1 - y}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-32}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_0 \leq 0.5:\\
\;\;\;\;-y\\
\mathbf{elif}\;t\_0 \leq 2000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < -4.00000000000000022e-32 or 2e9 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites66.6%
if -4.00000000000000022e-32 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < 0.5Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower--.f6498.8
Applied rewrites98.8%
Taylor expanded in x around 0
mul-1-negN/A
lift-neg.f6450.8
Applied rewrites50.8%
if 0.5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < 2e9Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites96.1%
(FPCore (x y) :precision binary64 (if (<= y -1.25e+29) 1.0 (if (<= y 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.25e+29) {
tmp = 1.0;
} else if (y <= 1.0) {
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 (y <= (-1.25d+29)) then
tmp = 1.0d0
else if (y <= 1.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.25e+29) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.25e+29: tmp = 1.0 elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.25e+29) tmp = 1.0; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.25e+29) tmp = 1.0; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.25e+29], 1.0, If[LessEqual[y, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+29}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.25e29 or 1 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites76.5%
if -1.25e29 < y < 1Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites71.0%
(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
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites39.4%
herbie shell --seed 2025115
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, C"
:precision binary64
(/ (- x y) (- 1.0 y)))