
(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 10 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 (* (/ x (- x -1.0)) (- (/ x y) -1.0)))
double code(double x, double y) {
return (x / (x - -1.0)) * ((x / 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 = (x / (x - (-1.0d0))) * ((x / y) - (-1.0d0))
end function
public static double code(double x, double y) {
return (x / (x - -1.0)) * ((x / y) - -1.0);
}
def code(x, y): return (x / (x - -1.0)) * ((x / y) - -1.0)
function code(x, y) return Float64(Float64(x / Float64(x - -1.0)) * Float64(Float64(x / y) - -1.0)) end
function tmp = code(x, y) tmp = (x / (x - -1.0)) * ((x / y) - -1.0); end
code[x_, y_] := N[(N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x - -1} \cdot \left(\frac{x}{y} - -1\right)
\end{array}
Initial program 88.5%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.9
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.9
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (/ 1.0 (/ y x))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 2e+261) (/ (fma (/ x y) x x) (- x -1.0)) t_1))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = 1.0 / (y / x);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= 2e+261) {
tmp = fma((x / y), x, x) / (x - -1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(1.0 / Float64(y / x)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= 2e+261) tmp = Float64(fma(Float64(x / y), x, x) / Float64(x - -1.0)); else tmp = t_1; 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]}, Block[{t$95$1 = N[(1.0 / N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 2e+261], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := \frac{1}{\frac{y}{x}}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+261}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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 1.9999999999999999e261 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.5%
lift-/.f64N/A
div-flipN/A
lower-special-/.f64N/A
lower-special-/.f6488.3
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval88.3
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6488.3
Applied rewrites88.3%
Taylor expanded in x around inf
lower-/.f6438.6
Applied rewrites38.6%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.9999999999999999e261Initial program 88.5%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6488.5
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval88.5
Applied rewrites88.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ y x) (/ 1.0 y))))
(if (<= x -1.25e+16)
t_0
(if (<= x 4e+15) (* (/ (+ y x) (fma y x y)) x) t_0))))
double code(double x, double y) {
double t_0 = (y + x) * (1.0 / y);
double tmp;
if (x <= -1.25e+16) {
tmp = t_0;
} else if (x <= 4e+15) {
tmp = ((y + x) / fma(y, x, y)) * x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(y + x) * Float64(1.0 / y)) tmp = 0.0 if (x <= -1.25e+16) tmp = t_0; elseif (x <= 4e+15) tmp = Float64(Float64(Float64(y + x) / fma(y, x, y)) * x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.25e+16], t$95$0, If[LessEqual[x, 4e+15], N[(N[(N[(y + x), $MachinePrecision] / N[(y * x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y + x\right) \cdot \frac{1}{y}\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+15}:\\
\;\;\;\;\frac{y + x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.25e16 or 4e15 < x Initial program 88.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
add-to-fractionN/A
frac-timesN/A
associate-/l*N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
add-flipN/A
*-lft-identityN/A
add-flip-revN/A
lower-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
*-lft-identityN/A
lower-fma.f6476.5
Applied rewrites76.5%
Taylor expanded in x around inf
lower-/.f6449.4
Applied rewrites49.4%
if -1.25e16 < x < 4e15Initial program 88.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
add-to-fractionN/A
associate-/l/N/A
lower-/.f64N/A
add-flipN/A
*-lft-identityN/A
add-flip-revN/A
lower-+.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
*-lft-identityN/A
lower-fma.f6487.7
Applied rewrites87.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (+ y x) (/ 1.0 y)))) (if (<= x -1.0) t_0 (if (<= x 0.85) (fma (- (/ x y) x) x x) t_0))))
double code(double x, double y) {
double t_0 = (y + x) * (1.0 / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 0.85) {
tmp = fma(((x / y) - x), x, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(y + x) * Float64(1.0 / y)) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 0.85) tmp = fma(Float64(Float64(x / y) - x), x, x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 0.85], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y + x\right) \cdot \frac{1}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.85:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 0.849999999999999978 < x Initial program 88.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
add-to-fractionN/A
frac-timesN/A
associate-/l*N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
add-flipN/A
*-lft-identityN/A
add-flip-revN/A
lower-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
*-lft-identityN/A
lower-fma.f6476.5
Applied rewrites76.5%
Taylor expanded in x around inf
lower-/.f6449.4
Applied rewrites49.4%
if -1 < x < 0.849999999999999978Initial program 88.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6457.6
Applied rewrites57.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6457.6
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
metadata-evalN/A
add-flipN/A
distribute-lft-neg-outN/A
*-lft-identityN/A
remove-double-negN/A
lower--.f6457.6
Applied rewrites57.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (+ y x) (/ 1.0 y)))) (if (<= x -14500.0) t_0 (if (<= x 140000000.0) (/ x (- x -1.0)) t_0))))
double code(double x, double y) {
double t_0 = (y + x) * (1.0 / y);
double tmp;
if (x <= -14500.0) {
tmp = t_0;
} else if (x <= 140000000.0) {
tmp = x / (x - -1.0);
} 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 = (y + x) * (1.0d0 / y)
if (x <= (-14500.0d0)) then
tmp = t_0
else if (x <= 140000000.0d0) then
tmp = x / (x - (-1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y + x) * (1.0 / y);
double tmp;
if (x <= -14500.0) {
tmp = t_0;
} else if (x <= 140000000.0) {
tmp = x / (x - -1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y + x) * (1.0 / y) tmp = 0 if x <= -14500.0: tmp = t_0 elif x <= 140000000.0: tmp = x / (x - -1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y + x) * Float64(1.0 / y)) tmp = 0.0 if (x <= -14500.0) tmp = t_0; elseif (x <= 140000000.0) tmp = Float64(x / Float64(x - -1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y + x) * (1.0 / y); tmp = 0.0; if (x <= -14500.0) tmp = t_0; elseif (x <= 140000000.0) tmp = x / (x - -1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -14500.0], t$95$0, If[LessEqual[x, 140000000.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y + x\right) \cdot \frac{1}{y}\\
\mathbf{if}\;x \leq -14500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 140000000:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -14500 or 1.4e8 < x Initial program 88.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
add-to-fractionN/A
frac-timesN/A
associate-/l*N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
add-flipN/A
*-lft-identityN/A
add-flip-revN/A
lower-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
*-lft-identityN/A
lower-fma.f6476.5
Applied rewrites76.5%
Taylor expanded in x around inf
lower-/.f6449.4
Applied rewrites49.4%
if -14500 < x < 1.4e8Initial program 88.5%
Taylor expanded in y around inf
lower-/.f64N/A
lower-+.f6450.8
Applied rewrites50.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f6450.8
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (/ 1.0 (/ y x)))) (if (<= t_0 -50000.0) t_1 (if (<= t_0 2.0) (/ x (- x -1.0)) t_1))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = 1.0 / (y / x);
double tmp;
if (t_0 <= -50000.0) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = x / (x - -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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
t_1 = 1.0d0 / (y / x)
if (t_0 <= (-50000.0d0)) then
tmp = t_1
else if (t_0 <= 2.0d0) then
tmp = x / (x - (-1.0d0))
else
tmp = t_1
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 t_1 = 1.0 / (y / x);
double tmp;
if (t_0 <= -50000.0) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) t_1 = 1.0 / (y / x) tmp = 0 if t_0 <= -50000.0: tmp = t_1 elif t_0 <= 2.0: tmp = x / (x - -1.0) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(1.0 / Float64(y / x)) tmp = 0.0 if (t_0 <= -50000.0) tmp = t_1; elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); t_1 = 1.0 / (y / x); tmp = 0.0; if (t_0 <= -50000.0) tmp = t_1; elseif (t_0 <= 2.0) tmp = x / (x - -1.0); else tmp = t_1; 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]}, Block[{t$95$1 = N[(1.0 / N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50000.0], t$95$1, If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := \frac{1}{\frac{y}{x}}\\
\mathbf{if}\;t\_0 \leq -50000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e4 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.5%
lift-/.f64N/A
div-flipN/A
lower-special-/.f64N/A
lower-special-/.f6488.3
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval88.3
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6488.3
Applied rewrites88.3%
Taylor expanded in x around inf
lower-/.f6438.6
Applied rewrites38.6%
if -5e4 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 88.5%
Taylor expanded in y around inf
lower-/.f64N/A
lower-+.f6450.8
Applied rewrites50.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f6450.8
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (- x -1.0)))) (if (<= y -5e-310) t_0 (if (<= y 4.5e+36) (* y (/ x y)) t_0))))
double code(double x, double y) {
double t_0 = x / (x - -1.0);
double tmp;
if (y <= -5e-310) {
tmp = t_0;
} else if (y <= 4.5e+36) {
tmp = y * (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 / (x - (-1.0d0))
if (y <= (-5d-310)) then
tmp = t_0
else if (y <= 4.5d+36) then
tmp = y * (x / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x - -1.0);
double tmp;
if (y <= -5e-310) {
tmp = t_0;
} else if (y <= 4.5e+36) {
tmp = y * (x / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x - -1.0) tmp = 0 if y <= -5e-310: tmp = t_0 elif y <= 4.5e+36: tmp = y * (x / y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x - -1.0)) tmp = 0.0 if (y <= -5e-310) tmp = t_0; elseif (y <= 4.5e+36) tmp = Float64(y * Float64(x / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x - -1.0); tmp = 0.0; if (y <= -5e-310) tmp = t_0; elseif (y <= 4.5e+36) tmp = y * (x / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e-310], t$95$0, If[LessEqual[y, 4.5e+36], N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x - -1}\\
\mathbf{if}\;y \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+36}:\\
\;\;\;\;y \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.999999999999985e-310 or 4.49999999999999997e36 < y Initial program 88.5%
Taylor expanded in y around inf
lower-/.f64N/A
lower-+.f6450.8
Applied rewrites50.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f6450.8
Applied rewrites50.8%
if -4.999999999999985e-310 < y < 4.49999999999999997e36Initial program 88.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
add-to-fractionN/A
frac-timesN/A
associate-/l*N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
add-flipN/A
*-lft-identityN/A
add-flip-revN/A
lower-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
*-lft-identityN/A
lower-fma.f6476.5
Applied rewrites76.5%
Taylor expanded in x around inf
lower-/.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites14.1%
Taylor expanded in x around 0
lower-/.f6433.5
Applied rewrites33.5%
(FPCore (x y) :precision binary64 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) 5e-11) x (- 1.0 (/ 1.0 x))))
double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 5e-11) {
tmp = x;
} else {
tmp = 1.0 - (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) :: tmp
if (((x * ((x / y) + 1.0d0)) / (x + 1.0d0)) <= 5d-11) then
tmp = x
else
tmp = 1.0d0 - (1.0d0 / x)
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)) <= 5e-11) {
tmp = x;
} else {
tmp = 1.0 - (1.0 / x);
}
return tmp;
}
def code(x, y): tmp = 0 if ((x * ((x / y) + 1.0)) / (x + 1.0)) <= 5e-11: tmp = x else: tmp = 1.0 - (1.0 / x) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= 5e-11) tmp = x; else tmp = Float64(1.0 - Float64(1.0 / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 5e-11) tmp = x; else tmp = 1.0 - (1.0 / x); 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], 5e-11], x, N[(1.0 - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.00000000000000018e-11Initial program 88.5%
Taylor expanded in x around 0
Applied rewrites39.5%
if 5.00000000000000018e-11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.5%
Taylor expanded in y around inf
lower-/.f64N/A
lower-+.f6450.8
Applied rewrites50.8%
Taylor expanded in x around inf
lower--.f64N/A
lower-/.f6413.4
Applied rewrites13.4%
(FPCore (x y) :precision binary64 (/ x (- x -1.0)))
double code(double x, double y) {
return x / (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 - (-1.0d0))
end function
public static double code(double x, double y) {
return x / (x - -1.0);
}
def code(x, y): return x / (x - -1.0)
function code(x, y) return Float64(x / Float64(x - -1.0)) end
function tmp = code(x, y) tmp = x / (x - -1.0); end
code[x_, y_] := N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x - -1}
\end{array}
Initial program 88.5%
Taylor expanded in y around inf
lower-/.f64N/A
lower-+.f6450.8
Applied rewrites50.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f6450.8
Applied rewrites50.8%
(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 88.5%
Taylor expanded in x around 0
Applied rewrites39.5%
herbie shell --seed 2025150
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))