
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
(FPCore (x y)
:precision binary64
(if (<= y -8.7e+14)
(- x (/ -1.0 y))
(if (<= y 2200000000.0)
(/ (- (- y -1.0) (* y (- 1.0 x))) (- y -1.0))
(- x (/ (- x 1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -8.7e+14) {
tmp = x - (-1.0 / y);
} else if (y <= 2200000000.0) {
tmp = ((y - -1.0) - (y * (1.0 - x))) / (y - -1.0);
} else {
tmp = x - ((x - 1.0) / 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) :: tmp
if (y <= (-8.7d+14)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 2200000000.0d0) then
tmp = ((y - (-1.0d0)) - (y * (1.0d0 - x))) / (y - (-1.0d0))
else
tmp = x - ((x - 1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8.7e+14) {
tmp = x - (-1.0 / y);
} else if (y <= 2200000000.0) {
tmp = ((y - -1.0) - (y * (1.0 - x))) / (y - -1.0);
} else {
tmp = x - ((x - 1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.7e+14: tmp = x - (-1.0 / y) elif y <= 2200000000.0: tmp = ((y - -1.0) - (y * (1.0 - x))) / (y - -1.0) else: tmp = x - ((x - 1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -8.7e+14) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 2200000000.0) tmp = Float64(Float64(Float64(y - -1.0) - Float64(y * Float64(1.0 - x))) / Float64(y - -1.0)); else tmp = Float64(x - Float64(Float64(x - 1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8.7e+14) tmp = x - (-1.0 / y); elseif (y <= 2200000000.0) tmp = ((y - -1.0) - (y * (1.0 - x))) / (y - -1.0); else tmp = x - ((x - 1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8.7e+14], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2200000000.0], N[(N[(N[(y - -1.0), $MachinePrecision] - N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.7 \cdot 10^{+14}:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 2200000000:\\
\;\;\;\;\frac{\left(y - -1\right) - y \cdot \left(1 - x\right)}{y - -1}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x - 1}{y}\\
\end{array}
\end{array}
if y < -8.7e14Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -8.7e14 < y < 2.2e9Initial program 66.2%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lower-/.f64N/A
*-lft-identityN/A
lower--.f6466.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval66.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval66.7
Applied rewrites66.7%
if 2.2e9 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
(FPCore (x y)
:precision binary64
(if (<= y -15800000000.0)
(- x (/ -1.0 y))
(if (<= y 230000000.0)
(fma (* (- x 1.0) y) (/ -1.0 (- -1.0 y)) 1.0)
(- x (/ (- x 1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -15800000000.0) {
tmp = x - (-1.0 / y);
} else if (y <= 230000000.0) {
tmp = fma(((x - 1.0) * y), (-1.0 / (-1.0 - y)), 1.0);
} else {
tmp = x - ((x - 1.0) / y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -15800000000.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 230000000.0) tmp = fma(Float64(Float64(x - 1.0) * y), Float64(-1.0 / Float64(-1.0 - y)), 1.0); else tmp = Float64(x - Float64(Float64(x - 1.0) / y)); end return tmp end
code[x_, y_] := If[LessEqual[y, -15800000000.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 230000000.0], N[(N[(N[(x - 1.0), $MachinePrecision] * y), $MachinePrecision] * N[(-1.0 / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -15800000000:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 230000000:\\
\;\;\;\;\mathsf{fma}\left(\left(x - 1\right) \cdot y, \frac{-1}{-1 - y}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x - 1}{y}\\
\end{array}
\end{array}
if y < -1.58e10Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -1.58e10 < y < 2.3e8Initial program 66.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
lower--.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval66.2
Applied rewrites66.2%
if 2.3e8 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
(FPCore (x y)
:precision binary64
(if (<= y -15800000000.0)
(- x (/ -1.0 y))
(if (<= y 200000000.0)
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0)))
(- x (/ (- x 1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -15800000000.0) {
tmp = x - (-1.0 / y);
} else if (y <= 200000000.0) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = x - ((x - 1.0) / 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) :: tmp
if (y <= (-15800000000.0d0)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 200000000.0d0) then
tmp = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
else
tmp = x - ((x - 1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -15800000000.0) {
tmp = x - (-1.0 / y);
} else if (y <= 200000000.0) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = x - ((x - 1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -15800000000.0: tmp = x - (-1.0 / y) elif y <= 200000000.0: tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)) else: tmp = x - ((x - 1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -15800000000.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 200000000.0) tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))); else tmp = Float64(x - Float64(Float64(x - 1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -15800000000.0) tmp = x - (-1.0 / y); elseif (y <= 200000000.0) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); else tmp = x - ((x - 1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -15800000000.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 200000000.0], N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -15800000000:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 200000000:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x - 1}{y}\\
\end{array}
\end{array}
if y < -1.58e10Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -1.58e10 < y < 2e8Initial program 66.2%
if 2e8 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
(FPCore (x y)
:precision binary64
(if (<= y -15800000000.0)
(- x (/ -1.0 y))
(if (<= y 200000000.0)
(fma (- x 1.0) (/ y (- y -1.0)) 1.0)
(- x (/ (- x 1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -15800000000.0) {
tmp = x - (-1.0 / y);
} else if (y <= 200000000.0) {
tmp = fma((x - 1.0), (y / (y - -1.0)), 1.0);
} else {
tmp = x - ((x - 1.0) / y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -15800000000.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 200000000.0) tmp = fma(Float64(x - 1.0), Float64(y / Float64(y - -1.0)), 1.0); else tmp = Float64(x - Float64(Float64(x - 1.0) / y)); end return tmp end
code[x_, y_] := If[LessEqual[y, -15800000000.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 200000000.0], N[(N[(x - 1.0), $MachinePrecision] * N[(y / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -15800000000:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 200000000:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \frac{y}{y - -1}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x - 1}{y}\\
\end{array}
\end{array}
if y < -1.58e10Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -1.58e10 < y < 2e8Initial program 66.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6477.3
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval77.3
Applied rewrites77.3%
if 2e8 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
(FPCore (x y) :precision binary64 (if (<= y -1.0) (- x (/ -1.0 y)) (if (<= y 1.0) (- 1.0 (* y (- 1.0 x))) (- x (/ (- x 1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 - (y * (1.0 - x));
} else {
tmp = x - ((x - 1.0) / 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) :: tmp
if (y <= (-1.0d0)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 1.0d0) then
tmp = 1.0d0 - (y * (1.0d0 - x))
else
tmp = x - ((x - 1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 - (y * (1.0 - x));
} else {
tmp = x - ((x - 1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x - (-1.0 / y) elif y <= 1.0: tmp = 1.0 - (y * (1.0 - x)) else: tmp = x - ((x - 1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(y * Float64(1.0 - x))); else tmp = Float64(x - Float64(Float64(x - 1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x - (-1.0 / y); elseif (y <= 1.0) tmp = 1.0 - (y * (1.0 - x)); else tmp = x - ((x - 1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - y \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x - 1}{y}\\
\end{array}
\end{array}
if y < -1Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -1 < y < 1Initial program 66.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6451.4
Applied rewrites51.4%
if 1 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
(FPCore (x y) :precision binary64 (let* ((t_0 (- x (/ -1.0 y)))) (if (<= y -1.0) t_0 (if (<= y 0.82) (- 1.0 (* y (- 1.0 x))) t_0))))
double code(double x, double y) {
double t_0 = x - (-1.0 / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 0.82) {
tmp = 1.0 - (y * (1.0 - x));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x - ((-1.0d0) / y)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 0.82d0) then
tmp = 1.0d0 - (y * (1.0d0 - x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x - (-1.0 / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 0.82) {
tmp = 1.0 - (y * (1.0 - x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x - (-1.0 / y) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 0.82: tmp = 1.0 - (y * (1.0 - x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x - Float64(-1.0 / y)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 0.82) tmp = Float64(1.0 - Float64(y * Float64(1.0 - x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x - (-1.0 / y); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 0.82) tmp = 1.0 - (y * (1.0 - x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 0.82], N[(1.0 - N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \frac{-1}{y}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.82:\\
\;\;\;\;1 - y \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 0.819999999999999951 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -1 < y < 0.819999999999999951Initial program 66.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6451.4
Applied rewrites51.4%
(FPCore (x y) :precision binary64 (let* ((t_0 (- x (/ -1.0 y)))) (if (<= y -2.1e+16) t_0 (if (<= y 560000.0) (/ 1.0 (- y -1.0)) t_0))))
double code(double x, double y) {
double t_0 = x - (-1.0 / y);
double tmp;
if (y <= -2.1e+16) {
tmp = t_0;
} else if (y <= 560000.0) {
tmp = 1.0 / (y - -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 = x - ((-1.0d0) / y)
if (y <= (-2.1d+16)) then
tmp = t_0
else if (y <= 560000.0d0) then
tmp = 1.0d0 / (y - (-1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x - (-1.0 / y);
double tmp;
if (y <= -2.1e+16) {
tmp = t_0;
} else if (y <= 560000.0) {
tmp = 1.0 / (y - -1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x - (-1.0 / y) tmp = 0 if y <= -2.1e+16: tmp = t_0 elif y <= 560000.0: tmp = 1.0 / (y - -1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x - Float64(-1.0 / y)) tmp = 0.0 if (y <= -2.1e+16) tmp = t_0; elseif (y <= 560000.0) tmp = Float64(1.0 / Float64(y - -1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x - (-1.0 / y); tmp = 0.0; if (y <= -2.1e+16) tmp = t_0; elseif (y <= 560000.0) tmp = 1.0 / (y - -1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.1e+16], t$95$0, If[LessEqual[y, 560000.0], N[(1.0 / N[(y - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \frac{-1}{y}\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 560000:\\
\;\;\;\;\frac{1}{y - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.1e16 or 5.6e5 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -2.1e16 < y < 5.6e5Initial program 66.2%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lower-/.f64N/A
*-lft-identityN/A
lower--.f6466.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval66.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval66.7
Applied rewrites66.7%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.3
Applied rewrites51.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6451.3
Applied rewrites51.3%
(FPCore (x y) :precision binary64 (let* ((t_0 (- x (/ -1.0 y)))) (if (<= y -1.0) t_0 (if (<= y 8.8e-23) (- 1.0 y) t_0))))
double code(double x, double y) {
double t_0 = x - (-1.0 / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 8.8e-23) {
tmp = 1.0 - y;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x - ((-1.0d0) / y)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 8.8d-23) then
tmp = 1.0d0 - y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x - (-1.0 / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 8.8e-23) {
tmp = 1.0 - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x - (-1.0 / y) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 8.8e-23: tmp = 1.0 - y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x - Float64(-1.0 / y)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 8.8e-23) tmp = Float64(1.0 - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x - (-1.0 / y); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 8.8e-23) tmp = 1.0 - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 8.8e-23], N[(1.0 - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \frac{-1}{y}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{-23}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 8.7999999999999998e-23 < y Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites49.6%
if -1 < y < 8.7999999999999998e-23Initial program 66.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6451.4
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites38.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0)))) (t_1 (- 1.0 (- 1.0 x))))
(if (<= t_0 -2000000.0)
t_1
(if (<= t_0 0.001) (/ 1.0 y) (if (<= t_0 2.0) (- 1.0 y) t_1)))))
double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double t_1 = 1.0 - (1.0 - x);
double tmp;
if (t_0 <= -2000000.0) {
tmp = t_1;
} else if (t_0 <= 0.001) {
tmp = 1.0 / y;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
t_1 = 1.0d0 - (1.0d0 - x)
if (t_0 <= (-2000000.0d0)) then
tmp = t_1
else if (t_0 <= 0.001d0) then
tmp = 1.0d0 / y
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 - y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double t_1 = 1.0 - (1.0 - x);
double tmp;
if (t_0 <= -2000000.0) {
tmp = t_1;
} else if (t_0 <= 0.001) {
tmp = 1.0 / y;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)) t_1 = 1.0 - (1.0 - x) tmp = 0 if t_0 <= -2000000.0: tmp = t_1 elif t_0 <= 0.001: tmp = 1.0 / y elif t_0 <= 2.0: tmp = 1.0 - y else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) t_1 = Float64(1.0 - Float64(1.0 - x)) tmp = 0.0 if (t_0 <= -2000000.0) tmp = t_1; elseif (t_0 <= 0.001) tmp = Float64(1.0 / y); elseif (t_0 <= 2.0) tmp = Float64(1.0 - y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)); t_1 = 1.0 - (1.0 - x); tmp = 0.0; if (t_0 <= -2000000.0) tmp = t_1; elseif (t_0 <= 0.001) tmp = 1.0 / y; elseif (t_0 <= 2.0) tmp = 1.0 - y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2000000.0], t$95$1, If[LessEqual[t$95$0, 0.001], N[(1.0 / y), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(1.0 - y), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
t_1 := 1 - \left(1 - x\right)\\
\mathbf{if}\;t\_0 \leq -2000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.001:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < -2e6 or 2 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) Initial program 66.2%
Taylor expanded in y around inf
lower--.f6426.8
Applied rewrites26.8%
if -2e6 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 1e-3Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
lower-/.f6414.8
Applied rewrites14.8%
if 1e-3 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 2Initial program 66.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6451.4
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites38.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0)))) (t_1 (- 1.0 (- x))))
(if (<= t_0 -2000000.0)
t_1
(if (<= t_0 0.001) (/ 1.0 y) (if (<= t_0 2.0) (- 1.0 y) t_1)))))
double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double t_1 = 1.0 - -x;
double tmp;
if (t_0 <= -2000000.0) {
tmp = t_1;
} else if (t_0 <= 0.001) {
tmp = 1.0 / y;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
t_1 = 1.0d0 - -x
if (t_0 <= (-2000000.0d0)) then
tmp = t_1
else if (t_0 <= 0.001d0) then
tmp = 1.0d0 / y
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 - y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double t_1 = 1.0 - -x;
double tmp;
if (t_0 <= -2000000.0) {
tmp = t_1;
} else if (t_0 <= 0.001) {
tmp = 1.0 / y;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)) t_1 = 1.0 - -x tmp = 0 if t_0 <= -2000000.0: tmp = t_1 elif t_0 <= 0.001: tmp = 1.0 / y elif t_0 <= 2.0: tmp = 1.0 - y else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) t_1 = Float64(1.0 - Float64(-x)) tmp = 0.0 if (t_0 <= -2000000.0) tmp = t_1; elseif (t_0 <= 0.001) tmp = Float64(1.0 / y); elseif (t_0 <= 2.0) tmp = Float64(1.0 - y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)); t_1 = 1.0 - -x; tmp = 0.0; if (t_0 <= -2000000.0) tmp = t_1; elseif (t_0 <= 0.001) tmp = 1.0 / y; elseif (t_0 <= 2.0) tmp = 1.0 - y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - (-x)), $MachinePrecision]}, If[LessEqual[t$95$0, -2000000.0], t$95$1, If[LessEqual[t$95$0, 0.001], N[(1.0 / y), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(1.0 - y), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
t_1 := 1 - \left(-x\right)\\
\mathbf{if}\;t\_0 \leq -2000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.001:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < -2e6 or 2 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) Initial program 66.2%
Taylor expanded in y around inf
lower--.f6426.8
Applied rewrites26.8%
Taylor expanded in x around inf
lower-*.f6449.4
Applied rewrites49.4%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6449.4
Applied rewrites49.4%
if -2e6 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 1e-3Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
lower-/.f6414.8
Applied rewrites14.8%
if 1e-3 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 2Initial program 66.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6451.4
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites38.6%
(FPCore (x y) :precision binary64 (if (<= (/ (* (- 1.0 x) y) (+ y 1.0)) 5e-14) (- 1.0 y) (/ 1.0 y)))
double code(double x, double y) {
double tmp;
if ((((1.0 - x) * y) / (y + 1.0)) <= 5e-14) {
tmp = 1.0 - y;
} else {
tmp = 1.0 / 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) :: tmp
if ((((1.0d0 - x) * y) / (y + 1.0d0)) <= 5d-14) then
tmp = 1.0d0 - y
else
tmp = 1.0d0 / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((((1.0 - x) * y) / (y + 1.0)) <= 5e-14) {
tmp = 1.0 - y;
} else {
tmp = 1.0 / y;
}
return tmp;
}
def code(x, y): tmp = 0 if (((1.0 - x) * y) / (y + 1.0)) <= 5e-14: tmp = 1.0 - y else: tmp = 1.0 / y return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)) <= 5e-14) tmp = Float64(1.0 - y); else tmp = Float64(1.0 / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((((1.0 - x) * y) / (y + 1.0)) <= 5e-14) tmp = 1.0 - y; else tmp = 1.0 / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], 5e-14], N[(1.0 - y), $MachinePrecision], N[(1.0 / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\left(1 - x\right) \cdot y}{y + 1} \leq 5 \cdot 10^{-14}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 5.0000000000000002e-14Initial program 66.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6451.4
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites38.6%
if 5.0000000000000002e-14 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 66.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
lower-/.f6414.8
Applied rewrites14.8%
(FPCore (x y) :precision binary64 (- 1.0 y))
double code(double x, double y) {
return 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 = 1.0d0 - y
end function
public static double code(double x, double y) {
return 1.0 - y;
}
def code(x, y): return 1.0 - y
function code(x, y) return Float64(1.0 - y) end
function tmp = code(x, y) tmp = 1.0 - y; end
code[x_, y_] := N[(1.0 - y), $MachinePrecision]
\begin{array}{l}
\\
1 - y
\end{array}
Initial program 66.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6451.4
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites38.6%
herbie shell --seed 2025151
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))