
(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}
Sampling outcomes in binary64 precision:
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 (if (or (<= x -1.5e+39) (not (<= x 1.85e+15))) (+ (/ x y) 1.0) (/ (fma (/ x y) x x) (- x -1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.5e+39) || !(x <= 1.85e+15)) {
tmp = (x / y) + 1.0;
} else {
tmp = fma((x / y), x, x) / (x - -1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((x <= -1.5e+39) || !(x <= 1.85e+15)) tmp = Float64(Float64(x / y) + 1.0); else tmp = Float64(fma(Float64(x / y), x, x) / Float64(x - -1.0)); end return tmp end
code[x_, y_] := If[Or[LessEqual[x, -1.5e+39], N[Not[LessEqual[x, 1.85e+15]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+39} \lor \neg \left(x \leq 1.85 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\
\end{array}
\end{array}
if x < -1.5e39 or 1.85e15 < x Initial program 73.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites63.3%
Taylor expanded in x around inf
lift-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
if -1.5e39 < x < 1.85e15Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
lift-/.f6499.9
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6499.9
Applied rewrites99.9%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -100000.0)
(/ x y)
(if (<= t_0 2e-5) x (if (<= t_0 2.0) (/ x 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 <= -100000.0) {
tmp = x / y;
} else if (t_0 <= 2e-5) {
tmp = x;
} else if (t_0 <= 2.0) {
tmp = x / 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 <= (-100000.0d0)) then
tmp = x / y
else if (t_0 <= 2d-5) then
tmp = x
else if (t_0 <= 2.0d0) then
tmp = x / 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 <= -100000.0) {
tmp = x / y;
} else if (t_0 <= 2e-5) {
tmp = x;
} else if (t_0 <= 2.0) {
tmp = x / 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 <= -100000.0: tmp = x / y elif t_0 <= 2e-5: tmp = x elif t_0 <= 2.0: tmp = x / 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 <= -100000.0) tmp = Float64(x / y); elseif (t_0 <= 2e-5) tmp = x; elseif (t_0 <= 2.0) tmp = Float64(x / 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 <= -100000.0) tmp = x / y; elseif (t_0 <= 2e-5) tmp = x; elseif (t_0 <= 2.0) tmp = x / 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, -100000.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 2e-5], x, If[LessEqual[t$95$0, 2.0], N[(x / 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 -100000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{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))) < -1e5 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 70.3%
Taylor expanded in x around inf
lift-/.f6484.9
Applied rewrites84.9%
if -1e5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2.00000000000000016e-5Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites85.8%
if 2.00000000000000016e-5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites98.6%
Taylor expanded in x around 0
Applied rewrites95.5%
(FPCore (x y) :precision binary64 (if (or (<= x -1.7e-12) (not (<= x 2.95e-6))) (+ (/ x y) (/ x (- x -1.0))) (fma x (/ x (fma y x y)) x)))
double code(double x, double y) {
double tmp;
if ((x <= -1.7e-12) || !(x <= 2.95e-6)) {
tmp = (x / y) + (x / (x - -1.0));
} else {
tmp = fma(x, (x / fma(y, x, y)), x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((x <= -1.7e-12) || !(x <= 2.95e-6)) tmp = Float64(Float64(x / y) + Float64(x / Float64(x - -1.0))); else tmp = fma(x, Float64(x / fma(y, x, y)), x); end return tmp end
code[x_, y_] := If[Or[LessEqual[x, -1.7e-12], N[Not[LessEqual[x, 2.95e-6]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-12} \lor \neg \left(x \leq 2.95 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{x}{y} + \frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{\mathsf{fma}\left(y, x, y\right)}, x\right)\\
\end{array}
\end{array}
if x < -1.7e-12 or 2.95000000000000013e-6 < x Initial program 76.7%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites67.2%
Taylor expanded in x around inf
lift-/.f6499.2
Applied rewrites99.2%
if -1.7e-12 < x < 2.95000000000000013e-6Initial program 99.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites93.3%
Taylor expanded in x around 0
Applied rewrites93.3%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-/l*N/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lift-fma.f6499.8
Applied rewrites99.8%
Final simplification99.5%
(FPCore (x y) :precision binary64 (if (or (<= x -125000.0) (not (<= x 2200000.0))) (+ (/ x y) 1.0) (fma x (/ x (fma y x y)) x)))
double code(double x, double y) {
double tmp;
if ((x <= -125000.0) || !(x <= 2200000.0)) {
tmp = (x / y) + 1.0;
} else {
tmp = fma(x, (x / fma(y, x, y)), x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((x <= -125000.0) || !(x <= 2200000.0)) tmp = Float64(Float64(x / y) + 1.0); else tmp = fma(x, Float64(x / fma(y, x, y)), x); end return tmp end
code[x_, y_] := If[Or[LessEqual[x, -125000.0], N[Not[LessEqual[x, 2200000.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -125000 \lor \neg \left(x \leq 2200000\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{\mathsf{fma}\left(y, x, y\right)}, x\right)\\
\end{array}
\end{array}
if x < -125000 or 2.2e6 < x Initial program 76.0%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites66.2%
Taylor expanded in x around inf
lift-/.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites99.2%
if -125000 < x < 2.2e6Initial program 99.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites93.5%
Taylor expanded in x around 0
Applied rewrites92.4%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-/l*N/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lift-fma.f6498.8
Applied rewrites98.8%
Final simplification99.0%
(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(x * Float64(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[(x * N[(N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{x}{y} - -1}{x - -1}
\end{array}
Initial program 88.2%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-/.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-/.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6499.8
Applied rewrites99.8%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (+ (/ x y) 1.0) (+ (/ (* x x) y) x)))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (x / y) + 1.0;
} else {
tmp = ((x * x) / y) + 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 <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (x / y) + 1.0d0
else
tmp = ((x * x) / y) + x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (x / y) + 1.0;
} else {
tmp = ((x * x) / y) + x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = (x / y) + 1.0 else: tmp = ((x * x) / y) + x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(Float64(x / y) + 1.0); else tmp = Float64(Float64(Float64(x * x) / y) + x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = (x / y) + 1.0; else tmp = ((x * x) / y) + x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y} + x\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 76.2%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites66.5%
Taylor expanded in x around inf
lift-/.f6499.2
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites98.8%
if -1 < x < 1Initial program 99.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites93.5%
Taylor expanded in x around 0
Applied rewrites92.4%
Taylor expanded in x around 0
Applied rewrites92.1%
Final simplification95.4%
(FPCore (x y) :precision binary64 (if (or (<= x -26000000.0) (not (<= x 2050.0))) (+ (/ x y) 1.0) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -26000000.0) || !(x <= 2050.0)) {
tmp = (x / y) + 1.0;
} else {
tmp = x / (x + 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 <= (-26000000.0d0)) .or. (.not. (x <= 2050.0d0))) then
tmp = (x / y) + 1.0d0
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -26000000.0) || !(x <= 2050.0)) {
tmp = (x / y) + 1.0;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -26000000.0) or not (x <= 2050.0): tmp = (x / y) + 1.0 else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -26000000.0) || !(x <= 2050.0)) tmp = Float64(Float64(x / y) + 1.0); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -26000000.0) || ~((x <= 2050.0))) tmp = (x / y) + 1.0; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -26000000.0], N[Not[LessEqual[x, 2050.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -26000000 \lor \neg \left(x \leq 2050\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -2.6e7 or 2050 < x Initial program 76.0%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites66.2%
Taylor expanded in x around inf
lift-/.f6499.2
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites99.2%
if -2.6e7 < x < 2050Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Final simplification88.8%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.085))) (+ (/ x y) 1.0) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.085)) {
tmp = (x / y) + 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) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 0.085d0))) then
tmp = (x / y) + 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.085)) {
tmp = (x / y) + 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.085): tmp = (x / y) + 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.085)) tmp = Float64(Float64(x / y) + 1.0); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.085))) tmp = (x / y) + 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.085]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.085\right):\\
\;\;\;\;\frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 0.0850000000000000061 < x Initial program 76.2%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-lft-inN/A
+-commutativeN/A
div-addN/A
associate-*r/N/A
unpow2N/A
associate-/r*N/A
*-rgt-identityN/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites66.5%
Taylor expanded in x around inf
lift-/.f6499.2
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites98.8%
if -1 < x < 0.0850000000000000061Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites77.5%
Final simplification88.0%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.82))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.82)) {
tmp = x / y;
} 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) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 0.82d0))) then
tmp = x / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.82)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.82): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.82)) tmp = Float64(x / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.82))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.82]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.82\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 0.819999999999999951 < x Initial program 76.2%
Taylor expanded in x around inf
lift-/.f6469.1
Applied rewrites69.1%
if -1 < x < 0.819999999999999951Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites77.5%
Final simplification73.4%
(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.2%
Taylor expanded in x around 0
Applied rewrites41.0%
(FPCore (x y) :precision binary64 (* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0))))
double code(double x, double y) {
return (x / 1.0) * (((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 / 1.0d0) * (((x / y) + 1.0d0) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
def code(x, y): return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0))
function code(x, y) return Float64(Float64(x / 1.0) * Float64(Float64(Float64(x / y) + 1.0) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = (x / 1.0) * (((x / y) + 1.0) / (x + 1.0)); end
code[x_, y_] := N[(N[(x / 1.0), $MachinePrecision] * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1} \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
herbie shell --seed 2025064
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))