
(FPCore (x y) :precision binary64 (- 1 (/ (* (- 1 x) y) (+ y 1))))
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 - N[(N[(N[(1 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1 (/ (* (- 1 x) y) (+ y 1))))
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 - N[(N[(N[(1 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1 y))))
(if (<= y -132000000000000)
t_0
(if (<= y 60000) (- 1 (/ (* (- 1 x) y) (+ y 1))) t_0))))double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -1.32e+14) {
tmp = t_0;
} else if (y <= 60000.0) {
tmp = 1.0 - (((1.0 - x) * y) / (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 <= (-1.32d+14)) then
tmp = t_0
else if (y <= 60000.0d0) then
tmp = 1.0d0 - (((1.0d0 - x) * y) / (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 <= -1.32e+14) {
tmp = t_0;
} else if (y <= 60000.0) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x + (1.0 / y) tmp = 0 if y <= -1.32e+14: tmp = t_0 elif y <= 60000.0: tmp = 1.0 - (((1.0 - x) * y) / (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 <= -1.32e+14) tmp = t_0; elseif (y <= 60000.0) tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / 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 <= -1.32e+14) tmp = t_0; elseif (y <= 60000.0) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(1 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -132000000000000], t$95$0, If[LessEqual[y, 60000], N[(1 - N[(N[(N[(1 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
\mathbf{if}\;y \leq -132000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 60000:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.32e14 or 6e4 < y Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
Taylor expanded in x around 0
lower-/.f6450.2%
Applied rewrites50.2%
if -1.32e14 < y < 6e4Initial program 65.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (- x (/ (- x 1) y)))) (if (<= y -21) t_0 (if (<= y 1) (+ 1 (* y (- x 1))) t_0))))
double code(double x, double y) {
double t_0 = x - ((x - 1.0) / y);
double tmp;
if (y <= -21.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = 1.0 + (y * (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 = x - ((x - 1.0d0) / y)
if (y <= (-21.0d0)) then
tmp = t_0
else if (y <= 1.0d0) then
tmp = 1.0d0 + (y * (x - 1.0d0))
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) / y);
double tmp;
if (y <= -21.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = 1.0 + (y * (x - 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x - ((x - 1.0) / y) tmp = 0 if y <= -21.0: tmp = t_0 elif y <= 1.0: tmp = 1.0 + (y * (x - 1.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x - Float64(Float64(x - 1.0) / y)) tmp = 0.0 if (y <= -21.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(1.0 + Float64(y * Float64(x - 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x - ((x - 1.0) / y); tmp = 0.0; if (y <= -21.0) tmp = t_0; elseif (y <= 1.0) tmp = 1.0 + (y * (x - 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(N[(x - 1), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -21], t$95$0, If[LessEqual[y, 1], N[(1 + N[(y * N[(x - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x - \frac{x - 1}{y}\\
\mathbf{if}\;y \leq -21:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 + y \cdot \left(x - 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -21 or 1 < y Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
lift-/.f6450.0%
Applied rewrites50.0%
if -21 < y < 1Initial program 65.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6451.2%
Applied rewrites51.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1 y))))
(if (<= y -7032821178101767/576460752303423488)
t_0
(if (<= y 5224175567749775/36028797018963968)
(+ 1 (* y (- x 1)))
t_0))))double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -0.0122) {
tmp = t_0;
} else if (y <= 0.145) {
tmp = 1.0 + (y * (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 = x + (1.0d0 / y)
if (y <= (-0.0122d0)) then
tmp = t_0
else if (y <= 0.145d0) then
tmp = 1.0d0 + (y * (x - 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 <= -0.0122) {
tmp = t_0;
} else if (y <= 0.145) {
tmp = 1.0 + (y * (x - 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x + (1.0 / y) tmp = 0 if y <= -0.0122: tmp = t_0 elif y <= 0.145: tmp = 1.0 + (y * (x - 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 <= -0.0122) tmp = t_0; elseif (y <= 0.145) tmp = Float64(1.0 + Float64(y * Float64(x - 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 <= -0.0122) tmp = t_0; elseif (y <= 0.145) tmp = 1.0 + (y * (x - 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(1 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7032821178101767/576460752303423488], t$95$0, If[LessEqual[y, 5224175567749775/36028797018963968], N[(1 + N[(y * N[(x - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
\mathbf{if}\;y \leq \frac{-7032821178101767}{576460752303423488}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq \frac{5224175567749775}{36028797018963968}:\\
\;\;\;\;1 + y \cdot \left(x - 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -0.012200000000000001 or 0.14499999999999999 < y Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
Taylor expanded in x around 0
lower-/.f6450.2%
Applied rewrites50.2%
if -0.012200000000000001 < y < 0.14499999999999999Initial program 65.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6451.2%
Applied rewrites51.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1 x) y) (+ y 1))) (t_1 (- 1 (- 1 x))))
(if (<= t_0 -2000000)
t_1
(if (<= t_0 3602879701896397/18014398509481984)
(+ 1 (* y -1))
(if (<= t_0 2)
(/ 1 y)
(if (<=
t_0
100000000000000003284156248920492607898701256635961169551231342625874700689878799554400131562772741268394950478432243557864849063421149184)
t_1
(if (<=
t_0
49999999999999998477451758974159751046482403622374605607421237630054847441436856676344327287652542857018591204612420567252946440591689353040126624759541451965054047394820266694175773042474003475163007869396334450282260856832)
(* x y)
(- 1 (- x)))))))))double code(double x, double y) {
double t_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.2) {
tmp = 1.0 + (y * -1.0);
} else if (t_0 <= 2.0) {
tmp = 1.0 / y;
} else if (t_0 <= 1e+137) {
tmp = t_1;
} else if (t_0 <= 5e+223) {
tmp = x * y;
} else {
tmp = 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((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.2d0) then
tmp = 1.0d0 + (y * (-1.0d0))
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 / y
else if (t_0 <= 1d+137) then
tmp = t_1
else if (t_0 <= 5d+223) then
tmp = x * y
else
tmp = 1.0d0 - -x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_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.2) {
tmp = 1.0 + (y * -1.0);
} else if (t_0 <= 2.0) {
tmp = 1.0 / y;
} else if (t_0 <= 1e+137) {
tmp = t_1;
} else if (t_0 <= 5e+223) {
tmp = x * y;
} else {
tmp = 1.0 - -x;
}
return tmp;
}
def code(x, y): t_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.2: tmp = 1.0 + (y * -1.0) elif t_0 <= 2.0: tmp = 1.0 / y elif t_0 <= 1e+137: tmp = t_1 elif t_0 <= 5e+223: tmp = x * y else: tmp = 1.0 - -x return tmp
function code(x, y) t_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.2) tmp = Float64(1.0 + Float64(y * -1.0)); elseif (t_0 <= 2.0) tmp = Float64(1.0 / y); elseif (t_0 <= 1e+137) tmp = t_1; elseif (t_0 <= 5e+223) tmp = Float64(x * y); else tmp = Float64(1.0 - Float64(-x)); end return tmp end
function tmp_2 = code(x, y) t_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.2) tmp = 1.0 + (y * -1.0); elseif (t_0 <= 2.0) tmp = 1.0 / y; elseif (t_0 <= 1e+137) tmp = t_1; elseif (t_0 <= 5e+223) tmp = x * y; else tmp = 1.0 - -x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1 - N[(1 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2000000], t$95$1, If[LessEqual[t$95$0, 3602879701896397/18014398509481984], N[(1 + N[(y * -1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2], N[(1 / y), $MachinePrecision], If[LessEqual[t$95$0, 100000000000000003284156248920492607898701256635961169551231342625874700689878799554400131562772741268394950478432243557864849063421149184], t$95$1, If[LessEqual[t$95$0, 49999999999999998477451758974159751046482403622374605607421237630054847441436856676344327287652542857018591204612420567252946440591689353040126624759541451965054047394820266694175773042474003475163007869396334450282260856832], N[(x * y), $MachinePrecision], N[(1 - (-x)), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \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 \frac{3602879701896397}{18014398509481984}:\\
\;\;\;\;1 + y \cdot -1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;t\_0 \leq 100000000000000003284156248920492607898701256635961169551231342625874700689878799554400131562772741268394950478432243557864849063421149184:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 49999999999999998477451758974159751046482403622374605607421237630054847441436856676344327287652542857018591204612420567252946440591689353040126624759541451965054047394820266694175773042474003475163007869396334450282260856832:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 - \left(-x\right)\\
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -2e6 or 2 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1e137Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
if -2e6 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.20000000000000001Initial program 65.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6451.2%
Applied rewrites51.2%
Taylor expanded in x around 0
Applied rewrites38.8%
if 0.20000000000000001 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 2Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
lift-/.f6450.0%
Applied rewrites50.0%
Taylor expanded in x around 0
lower-/.f6413.9%
Applied rewrites13.9%
if 1e137 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 4.9999999999999998e223Initial program 65.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6438.9%
Applied rewrites38.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.0%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6451.0%
Applied rewrites51.0%
Taylor expanded in y around 0
lower-*.f6414.9%
Applied rewrites14.9%
if 4.9999999999999998e223 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in x around inf
lower-*.f6450.3%
Applied rewrites50.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6450.3%
Applied rewrites50.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1 (- 1 x))))
(if (<= y -7032821178101767/576460752303423488)
t_0
(if (<= y 5224175567749775/36028797018963968)
(+ 1 (* y (- x 1)))
t_0))))double code(double x, double y) {
double t_0 = 1.0 - (1.0 - x);
double tmp;
if (y <= -0.0122) {
tmp = t_0;
} else if (y <= 0.145) {
tmp = 1.0 + (y * (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 = 1.0d0 - (1.0d0 - x)
if (y <= (-0.0122d0)) then
tmp = t_0
else if (y <= 0.145d0) then
tmp = 1.0d0 + (y * (x - 1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (1.0 - x);
double tmp;
if (y <= -0.0122) {
tmp = t_0;
} else if (y <= 0.145) {
tmp = 1.0 + (y * (x - 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (1.0 - x) tmp = 0 if y <= -0.0122: tmp = t_0 elif y <= 0.145: tmp = 1.0 + (y * (x - 1.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(1.0 - x)) tmp = 0.0 if (y <= -0.0122) tmp = t_0; elseif (y <= 0.145) tmp = Float64(1.0 + Float64(y * Float64(x - 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (1.0 - x); tmp = 0.0; if (y <= -0.0122) tmp = t_0; elseif (y <= 0.145) tmp = 1.0 + (y * (x - 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1 - N[(1 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7032821178101767/576460752303423488], t$95$0, If[LessEqual[y, 5224175567749775/36028797018963968], N[(1 + N[(y * N[(x - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 1 - \left(1 - x\right)\\
\mathbf{if}\;y \leq \frac{-7032821178101767}{576460752303423488}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq \frac{5224175567749775}{36028797018963968}:\\
\;\;\;\;1 + y \cdot \left(x - 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -0.012200000000000001 or 0.14499999999999999 < y Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
if -0.012200000000000001 < y < 0.14499999999999999Initial program 65.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6451.2%
Applied rewrites51.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1 x) y) (+ y 1))) (t_1 (- 1 (- 1 x))))
(if (<= t_0 -2000000)
t_1
(if (<= t_0 3602879701896397/18014398509481984)
(+ 1 (* y -1))
(if (<=
t_0
100000000000000003284156248920492607898701256635961169551231342625874700689878799554400131562772741268394950478432243557864849063421149184)
t_1
(if (<=
t_0
49999999999999998477451758974159751046482403622374605607421237630054847441436856676344327287652542857018591204612420567252946440591689353040126624759541451965054047394820266694175773042474003475163007869396334450282260856832)
(* x y)
(- 1 (- x))))))))double code(double x, double y) {
double t_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.2) {
tmp = 1.0 + (y * -1.0);
} else if (t_0 <= 1e+137) {
tmp = t_1;
} else if (t_0 <= 5e+223) {
tmp = x * y;
} else {
tmp = 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((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.2d0) then
tmp = 1.0d0 + (y * (-1.0d0))
else if (t_0 <= 1d+137) then
tmp = t_1
else if (t_0 <= 5d+223) then
tmp = x * y
else
tmp = 1.0d0 - -x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_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.2) {
tmp = 1.0 + (y * -1.0);
} else if (t_0 <= 1e+137) {
tmp = t_1;
} else if (t_0 <= 5e+223) {
tmp = x * y;
} else {
tmp = 1.0 - -x;
}
return tmp;
}
def code(x, y): t_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.2: tmp = 1.0 + (y * -1.0) elif t_0 <= 1e+137: tmp = t_1 elif t_0 <= 5e+223: tmp = x * y else: tmp = 1.0 - -x return tmp
function code(x, y) t_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.2) tmp = Float64(1.0 + Float64(y * -1.0)); elseif (t_0 <= 1e+137) tmp = t_1; elseif (t_0 <= 5e+223) tmp = Float64(x * y); else tmp = Float64(1.0 - Float64(-x)); end return tmp end
function tmp_2 = code(x, y) t_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.2) tmp = 1.0 + (y * -1.0); elseif (t_0 <= 1e+137) tmp = t_1; elseif (t_0 <= 5e+223) tmp = x * y; else tmp = 1.0 - -x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1 - N[(1 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2000000], t$95$1, If[LessEqual[t$95$0, 3602879701896397/18014398509481984], N[(1 + N[(y * -1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 100000000000000003284156248920492607898701256635961169551231342625874700689878799554400131562772741268394950478432243557864849063421149184], t$95$1, If[LessEqual[t$95$0, 49999999999999998477451758974159751046482403622374605607421237630054847441436856676344327287652542857018591204612420567252946440591689353040126624759541451965054047394820266694175773042474003475163007869396334450282260856832], N[(x * y), $MachinePrecision], N[(1 - (-x)), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \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 \frac{3602879701896397}{18014398509481984}:\\
\;\;\;\;1 + y \cdot -1\\
\mathbf{elif}\;t\_0 \leq 100000000000000003284156248920492607898701256635961169551231342625874700689878799554400131562772741268394950478432243557864849063421149184:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 49999999999999998477451758974159751046482403622374605607421237630054847441436856676344327287652542857018591204612420567252946440591689353040126624759541451965054047394820266694175773042474003475163007869396334450282260856832:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 - \left(-x\right)\\
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -2e6 or 0.20000000000000001 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1e137Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
if -2e6 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.20000000000000001Initial program 65.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6451.2%
Applied rewrites51.2%
Taylor expanded in x around 0
Applied rewrites38.8%
if 1e137 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 4.9999999999999998e223Initial program 65.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6438.9%
Applied rewrites38.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.0%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6451.0%
Applied rewrites51.0%
Taylor expanded in y around 0
lower-*.f6414.9%
Applied rewrites14.9%
if 4.9999999999999998e223 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in x around inf
lower-*.f6450.3%
Applied rewrites50.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6450.3%
Applied rewrites50.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1 (- 1 x))))
(if (<= y -7378697629483821/9223372036854775808)
t_0
(if (<=
y
-6224982717398119/29642774844752946028434172162224104410437116074403984394101141506025761187823616)
(* x y)
(if (<= y 6530219459687219/2251799813685248) 1 t_0)))))double code(double x, double y) {
double t_0 = 1.0 - (1.0 - x);
double tmp;
if (y <= -0.0008) {
tmp = t_0;
} else if (y <= -2.1e-64) {
tmp = x * y;
} else if (y <= 2.9) {
tmp = 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 = 1.0d0 - (1.0d0 - x)
if (y <= (-0.0008d0)) then
tmp = t_0
else if (y <= (-2.1d-64)) then
tmp = x * y
else if (y <= 2.9d0) then
tmp = 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (1.0 - x);
double tmp;
if (y <= -0.0008) {
tmp = t_0;
} else if (y <= -2.1e-64) {
tmp = x * y;
} else if (y <= 2.9) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (1.0 - x) tmp = 0 if y <= -0.0008: tmp = t_0 elif y <= -2.1e-64: tmp = x * y elif y <= 2.9: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(1.0 - x)) tmp = 0.0 if (y <= -0.0008) tmp = t_0; elseif (y <= -2.1e-64) tmp = Float64(x * y); elseif (y <= 2.9) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (1.0 - x); tmp = 0.0; if (y <= -0.0008) tmp = t_0; elseif (y <= -2.1e-64) tmp = x * y; elseif (y <= 2.9) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1 - N[(1 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7378697629483821/9223372036854775808], t$95$0, If[LessEqual[y, -6224982717398119/29642774844752946028434172162224104410437116074403984394101141506025761187823616], N[(x * y), $MachinePrecision], If[LessEqual[y, 6530219459687219/2251799813685248], 1, t$95$0]]]]
\begin{array}{l}
t_0 := 1 - \left(1 - x\right)\\
\mathbf{if}\;y \leq \frac{-7378697629483821}{9223372036854775808}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq \frac{-6224982717398119}{29642774844752946028434172162224104410437116074403984394101141506025761187823616}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq \frac{6530219459687219}{2251799813685248}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -8.0000000000000004e-4 or 2.8999999999999999 < y Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
if -8.0000000000000004e-4 < y < -2.1000000000000001e-64Initial program 65.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6438.9%
Applied rewrites38.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.0%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6451.0%
Applied rewrites51.0%
Taylor expanded in y around 0
lower-*.f6414.9%
Applied rewrites14.9%
if -2.1000000000000001e-64 < y < 2.8999999999999999Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
lift-/.f6450.0%
Applied rewrites50.0%
Taylor expanded in y around 0
Applied rewrites39.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1 (- x))))
(if (<= y -8715097876569077/79228162514264337593543950336)
t_0
(if (<=
y
-6224982717398119/29642774844752946028434172162224104410437116074403984394101141506025761187823616)
(* x y)
(if (<= y 5440166188265831/1208925819614629174706176) 1 t_0)))))double code(double x, double y) {
double t_0 = 1.0 - -x;
double tmp;
if (y <= -1.1e-13) {
tmp = t_0;
} else if (y <= -2.1e-64) {
tmp = x * y;
} else if (y <= 4.5e-9) {
tmp = 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 = 1.0d0 - -x
if (y <= (-1.1d-13)) then
tmp = t_0
else if (y <= (-2.1d-64)) then
tmp = x * y
else if (y <= 4.5d-9) then
tmp = 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - -x;
double tmp;
if (y <= -1.1e-13) {
tmp = t_0;
} else if (y <= -2.1e-64) {
tmp = x * y;
} else if (y <= 4.5e-9) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - -x tmp = 0 if y <= -1.1e-13: tmp = t_0 elif y <= -2.1e-64: tmp = x * y elif y <= 4.5e-9: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(-x)) tmp = 0.0 if (y <= -1.1e-13) tmp = t_0; elseif (y <= -2.1e-64) tmp = Float64(x * y); elseif (y <= 4.5e-9) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - -x; tmp = 0.0; if (y <= -1.1e-13) tmp = t_0; elseif (y <= -2.1e-64) tmp = x * y; elseif (y <= 4.5e-9) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1 - (-x)), $MachinePrecision]}, If[LessEqual[y, -8715097876569077/79228162514264337593543950336], t$95$0, If[LessEqual[y, -6224982717398119/29642774844752946028434172162224104410437116074403984394101141506025761187823616], N[(x * y), $MachinePrecision], If[LessEqual[y, 5440166188265831/1208925819614629174706176], 1, t$95$0]]]]
\begin{array}{l}
t_0 := 1 - \left(-x\right)\\
\mathbf{if}\;y \leq \frac{-8715097876569077}{79228162514264337593543950336}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq \frac{-6224982717398119}{29642774844752946028434172162224104410437116074403984394101141506025761187823616}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq \frac{5440166188265831}{1208925819614629174706176}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.1e-13 or 4.4999999999999998e-9 < y Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in x around inf
lower-*.f6450.3%
Applied rewrites50.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6450.3%
Applied rewrites50.3%
if -1.1e-13 < y < -2.1000000000000001e-64Initial program 65.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6438.9%
Applied rewrites38.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.0%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6451.0%
Applied rewrites51.0%
Taylor expanded in y around 0
lower-*.f6414.9%
Applied rewrites14.9%
if -2.1000000000000001e-64 < y < 4.4999999999999998e-9Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
lift-/.f6450.0%
Applied rewrites50.0%
Taylor expanded in y around 0
Applied rewrites39.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (- 1 (/ (* (- 1 x) y) (+ y 1))))) (if (<= t_0 0) (* x y) (if (<= t_0 2) 1 (* x y)))))
double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = x * y;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = x * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
if (t_0 <= 0.0d0) then
tmp = x * y
else if (t_0 <= 2.0d0) then
tmp = 1.0d0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = x * y;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)) tmp = 0 if t_0 <= 0.0: tmp = x * y elif t_0 <= 2.0: tmp = 1.0 else: tmp = x * y return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(x * y); elseif (t_0 <= 2.0) tmp = 1.0; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = x * y; elseif (t_0 <= 2.0) tmp = 1.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1 - N[(N[(N[(1 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0], N[(x * y), $MachinePrecision], If[LessEqual[t$95$0, 2], 1, N[(x * y), $MachinePrecision]]]]
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 0.0 or 2 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) Initial program 65.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6438.9%
Applied rewrites38.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.0%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6451.0%
Applied rewrites51.0%
Taylor expanded in y around 0
lower-*.f6414.9%
Applied rewrites14.9%
if 0.0 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 2Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
lift-/.f6450.0%
Applied rewrites50.0%
Taylor expanded in y around 0
Applied rewrites39.0%
(FPCore (x y) :precision binary64 1)
double code(double x, double y) {
return 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1
1
Initial program 65.9%
Taylor expanded in y around inf
lower--.f6428.2%
Applied rewrites28.2%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6450.0%
Applied rewrites50.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
lift-/.f6450.0%
Applied rewrites50.0%
Taylor expanded in y around 0
Applied rewrites39.0%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
(- 1 (/ (* (- 1 x) y) (+ y 1))))