
(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 11 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
(let* ((t_0 (* 2.0 (+ y 1.0))))
(if (<= y -1.4e+15)
(- x (/ -1.0 y))
(if (<= y 8400000000000.0)
(/ (- t_0 (* 2.0 (* (- 1.0 x) y))) t_0)
(- x (/ (- x 1.0) y))))))
double code(double x, double y) {
double t_0 = 2.0 * (y + 1.0);
double tmp;
if (y <= -1.4e+15) {
tmp = x - (-1.0 / y);
} else if (y <= 8400000000000.0) {
tmp = (t_0 - (2.0 * ((1.0 - x) * y))) / t_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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 * (y + 1.0d0)
if (y <= (-1.4d+15)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 8400000000000.0d0) then
tmp = (t_0 - (2.0d0 * ((1.0d0 - x) * y))) / t_0
else
tmp = x - ((x - 1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 2.0 * (y + 1.0);
double tmp;
if (y <= -1.4e+15) {
tmp = x - (-1.0 / y);
} else if (y <= 8400000000000.0) {
tmp = (t_0 - (2.0 * ((1.0 - x) * y))) / t_0;
} else {
tmp = x - ((x - 1.0) / y);
}
return tmp;
}
def code(x, y): t_0 = 2.0 * (y + 1.0) tmp = 0 if y <= -1.4e+15: tmp = x - (-1.0 / y) elif y <= 8400000000000.0: tmp = (t_0 - (2.0 * ((1.0 - x) * y))) / t_0 else: tmp = x - ((x - 1.0) / y) return tmp
function code(x, y) t_0 = Float64(2.0 * Float64(y + 1.0)) tmp = 0.0 if (y <= -1.4e+15) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 8400000000000.0) tmp = Float64(Float64(t_0 - Float64(2.0 * Float64(Float64(1.0 - x) * y))) / t_0); else tmp = Float64(x - Float64(Float64(x - 1.0) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = 2.0 * (y + 1.0); tmp = 0.0; if (y <= -1.4e+15) tmp = x - (-1.0 / y); elseif (y <= 8400000000000.0) tmp = (t_0 - (2.0 * ((1.0 - x) * y))) / t_0; else tmp = x - ((x - 1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(2.0 * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.4e+15], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8400000000000.0], N[(N[(t$95$0 - N[(2.0 * N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(y + 1\right)\\
\mathbf{if}\;y \leq -1.4 \cdot 10^{+15}:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 8400000000000:\\
\;\;\;\;\frac{t\_0 - 2 \cdot \left(\left(1 - x\right) \cdot y\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x - 1}{y}\\
\end{array}
\end{array}
if y < -1.4e15Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around 0
Applied rewrites50.0%
if -1.4e15 < y < 8.4e12Initial program 66.2%
lift--.f64N/A
metadata-evalN/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
frac-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f6466.5
Applied rewrites66.5%
if 8.4e12 < y Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
(FPCore (x y)
:precision binary64
(if (<= y -420000000000.0)
(- x (/ -1.0 y))
(if (<= y 146000000.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 <= -420000000000.0) {
tmp = x - (-1.0 / y);
} else if (y <= 146000000.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 <= (-420000000000.0d0)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 146000000.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 <= -420000000000.0) {
tmp = x - (-1.0 / y);
} else if (y <= 146000000.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 <= -420000000000.0: tmp = x - (-1.0 / y) elif y <= 146000000.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 <= -420000000000.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 146000000.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 <= -420000000000.0) tmp = x - (-1.0 / y); elseif (y <= 146000000.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, -420000000000.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 146000000.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 -420000000000:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 146000000:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x - 1}{y}\\
\end{array}
\end{array}
if y < -4.2e11Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around 0
Applied rewrites50.0%
if -4.2e11 < y < 1.46e8Initial program 66.2%
if 1.46e8 < y Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- x (/ (- x 1.0) y))))
(if (<= y -330.0)
t_0
(if (<= y 56000.0) (- 1.0 (/ (* (- x) y) (+ y 1.0))) t_0))))
double code(double x, double y) {
double t_0 = x - ((x - 1.0) / y);
double tmp;
if (y <= -330.0) {
tmp = t_0;
} else if (y <= 56000.0) {
tmp = 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 - ((x - 1.0d0) / y)
if (y <= (-330.0d0)) then
tmp = t_0
else if (y <= 56000.0d0) then
tmp = 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 - ((x - 1.0) / y);
double tmp;
if (y <= -330.0) {
tmp = t_0;
} else if (y <= 56000.0) {
tmp = 1.0 - ((-x * y) / (y + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x - ((x - 1.0) / y) tmp = 0 if y <= -330.0: tmp = t_0 elif y <= 56000.0: tmp = 1.0 - ((-x * y) / (y + 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 <= -330.0) tmp = t_0; elseif (y <= 56000.0) tmp = Float64(1.0 - Float64(Float64(Float64(-x) * y) / Float64(y + 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 <= -330.0) tmp = t_0; elseif (y <= 56000.0) tmp = 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[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -330.0], t$95$0, If[LessEqual[y, 56000.0], N[(1.0 - N[(N[((-x) * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \frac{x - 1}{y}\\
\mathbf{if}\;y \leq -330:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 56000:\\
\;\;\;\;1 - \frac{\left(-x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -330 or 56000 < y Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
if -330 < y < 56000Initial program 66.2%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6463.5
Applied rewrites63.5%
(FPCore (x y) :precision binary64 (let* ((t_0 (- x (/ (- x 1.0) y)))) (if (<= y -1.0) t_0 (if (<= y 1.0) (fma (- x 1.0) y 1.0) t_0))))
double code(double x, double y) {
double t_0 = x - ((x - 1.0) / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = fma((x - 1.0), y, 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 <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = fma(Float64(x - 1.0), y, 1.0); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.0], N[(N[(x - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \frac{x - 1}{y}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\mathsf{fma}\left(x - 1, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
if -1 < y < 1Initial program 66.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6451.0
Applied rewrites51.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (- x (/ -1.0 y)))) (if (<= y -1.0) t_0 (if (<= y 0.83) (fma (- x 1.0) y 1.0) 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.83) {
tmp = fma((x - 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 <= -1.0) tmp = t_0; elseif (y <= 0.83) tmp = fma(Float64(x - 1.0), y, 1.0); else tmp = t_0; end return 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.83], N[(N[(x - 1.0), $MachinePrecision] * y + 1.0), $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.83:\\
\;\;\;\;\mathsf{fma}\left(x - 1, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 0.82999999999999996 < y Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around 0
Applied rewrites50.0%
if -1 < y < 0.82999999999999996Initial program 66.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6451.0
Applied rewrites51.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0))) (t_1 (- 1.0 (- x))))
(if (<= t_0 -1e+219)
(- x (/ x y))
(if (<= t_0 -1.5e+22)
(* y x)
(if (<= t_0 0.02)
t_1
(if (<= t_0 4e+95)
(- x (/ -1.0 y))
(if (<= t_0 1e+286) (* y x) t_1)))))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (y + 1.0);
double t_1 = 1.0 - -x;
double tmp;
if (t_0 <= -1e+219) {
tmp = x - (x / y);
} else if (t_0 <= -1.5e+22) {
tmp = y * x;
} else if (t_0 <= 0.02) {
tmp = t_1;
} else if (t_0 <= 4e+95) {
tmp = x - (-1.0 / y);
} else if (t_0 <= 1e+286) {
tmp = y * x;
} 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 - x) * y) / (y + 1.0d0)
t_1 = 1.0d0 - -x
if (t_0 <= (-1d+219)) then
tmp = x - (x / y)
else if (t_0 <= (-1.5d+22)) then
tmp = y * x
else if (t_0 <= 0.02d0) then
tmp = t_1
else if (t_0 <= 4d+95) then
tmp = x - ((-1.0d0) / y)
else if (t_0 <= 1d+286) then
tmp = y * x
else
tmp = t_1
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 - -x;
double tmp;
if (t_0 <= -1e+219) {
tmp = x - (x / y);
} else if (t_0 <= -1.5e+22) {
tmp = y * x;
} else if (t_0 <= 0.02) {
tmp = t_1;
} else if (t_0 <= 4e+95) {
tmp = x - (-1.0 / y);
} else if (t_0 <= 1e+286) {
tmp = y * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = ((1.0 - x) * y) / (y + 1.0) t_1 = 1.0 - -x tmp = 0 if t_0 <= -1e+219: tmp = x - (x / y) elif t_0 <= -1.5e+22: tmp = y * x elif t_0 <= 0.02: tmp = t_1 elif t_0 <= 4e+95: tmp = x - (-1.0 / y) elif t_0 <= 1e+286: tmp = y * x else: tmp = t_1 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(-x)) tmp = 0.0 if (t_0 <= -1e+219) tmp = Float64(x - Float64(x / y)); elseif (t_0 <= -1.5e+22) tmp = Float64(y * x); elseif (t_0 <= 0.02) tmp = t_1; elseif (t_0 <= 4e+95) tmp = Float64(x - Float64(-1.0 / y)); elseif (t_0 <= 1e+286) tmp = Float64(y * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (y + 1.0); t_1 = 1.0 - -x; tmp = 0.0; if (t_0 <= -1e+219) tmp = x - (x / y); elseif (t_0 <= -1.5e+22) tmp = y * x; elseif (t_0 <= 0.02) tmp = t_1; elseif (t_0 <= 4e+95) tmp = x - (-1.0 / y); elseif (t_0 <= 1e+286) tmp = y * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - (-x)), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+219], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1.5e+22], N[(y * x), $MachinePrecision], If[LessEqual[t$95$0, 0.02], t$95$1, If[LessEqual[t$95$0, 4e+95], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+286], N[(y * x), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
t_1 := 1 - \left(-x\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+219}:\\
\;\;\;\;x - \frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq -1.5 \cdot 10^{+22}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+95}:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;t\_0 \leq 10^{+286}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -9.99999999999999965e218Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around inf
lower-/.f6438.3
Applied rewrites38.3%
if -9.99999999999999965e218 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -1.5e22 or 4.00000000000000008e95 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.00000000000000003e286Initial program 66.2%
Taylor expanded in x around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f6450.9
Applied rewrites50.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6414.9
Applied rewrites14.9%
if -1.5e22 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.0200000000000000004 or 1.00000000000000003e286 < (/.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
lift--.f6427.7
Applied rewrites27.7%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6449.2
Applied rewrites49.2%
if 0.0200000000000000004 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 4.00000000000000008e95Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around 0
Applied rewrites50.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0)))
(t_1 (- 1.0 (- x)))
(t_2 (- x (/ x y))))
(if (<= t_0 -1e+219)
t_2
(if (<= t_0 -1.5e+22)
(* y x)
(if (<= t_0 0.02)
t_1
(if (<= t_0 4e+95) t_2 (if (<= t_0 1e+286) (* y x) t_1)))))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (y + 1.0);
double t_1 = 1.0 - -x;
double t_2 = x - (x / y);
double tmp;
if (t_0 <= -1e+219) {
tmp = t_2;
} else if (t_0 <= -1.5e+22) {
tmp = y * x;
} else if (t_0 <= 0.02) {
tmp = t_1;
} else if (t_0 <= 4e+95) {
tmp = t_2;
} else if (t_0 <= 1e+286) {
tmp = y * x;
} 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) :: t_2
real(8) :: tmp
t_0 = ((1.0d0 - x) * y) / (y + 1.0d0)
t_1 = 1.0d0 - -x
t_2 = x - (x / y)
if (t_0 <= (-1d+219)) then
tmp = t_2
else if (t_0 <= (-1.5d+22)) then
tmp = y * x
else if (t_0 <= 0.02d0) then
tmp = t_1
else if (t_0 <= 4d+95) then
tmp = t_2
else if (t_0 <= 1d+286) then
tmp = y * x
else
tmp = t_1
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 - -x;
double t_2 = x - (x / y);
double tmp;
if (t_0 <= -1e+219) {
tmp = t_2;
} else if (t_0 <= -1.5e+22) {
tmp = y * x;
} else if (t_0 <= 0.02) {
tmp = t_1;
} else if (t_0 <= 4e+95) {
tmp = t_2;
} else if (t_0 <= 1e+286) {
tmp = y * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = ((1.0 - x) * y) / (y + 1.0) t_1 = 1.0 - -x t_2 = x - (x / y) tmp = 0 if t_0 <= -1e+219: tmp = t_2 elif t_0 <= -1.5e+22: tmp = y * x elif t_0 <= 0.02: tmp = t_1 elif t_0 <= 4e+95: tmp = t_2 elif t_0 <= 1e+286: tmp = y * x else: tmp = t_1 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(-x)) t_2 = Float64(x - Float64(x / y)) tmp = 0.0 if (t_0 <= -1e+219) tmp = t_2; elseif (t_0 <= -1.5e+22) tmp = Float64(y * x); elseif (t_0 <= 0.02) tmp = t_1; elseif (t_0 <= 4e+95) tmp = t_2; elseif (t_0 <= 1e+286) tmp = Float64(y * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (y + 1.0); t_1 = 1.0 - -x; t_2 = x - (x / y); tmp = 0.0; if (t_0 <= -1e+219) tmp = t_2; elseif (t_0 <= -1.5e+22) tmp = y * x; elseif (t_0 <= 0.02) tmp = t_1; elseif (t_0 <= 4e+95) tmp = t_2; elseif (t_0 <= 1e+286) tmp = y * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - (-x)), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+219], t$95$2, If[LessEqual[t$95$0, -1.5e+22], N[(y * x), $MachinePrecision], If[LessEqual[t$95$0, 0.02], t$95$1, If[LessEqual[t$95$0, 4e+95], t$95$2, If[LessEqual[t$95$0, 1e+286], N[(y * x), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
t_1 := 1 - \left(-x\right)\\
t_2 := x - \frac{x}{y}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+219}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_0 \leq -1.5 \cdot 10^{+22}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+95}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_0 \leq 10^{+286}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -9.99999999999999965e218 or 0.0200000000000000004 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 4.00000000000000008e95Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around inf
lower-/.f6438.3
Applied rewrites38.3%
if -9.99999999999999965e218 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -1.5e22 or 4.00000000000000008e95 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.00000000000000003e286Initial program 66.2%
Taylor expanded in x around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f6450.9
Applied rewrites50.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6414.9
Applied rewrites14.9%
if -1.5e22 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.0200000000000000004 or 1.00000000000000003e286 < (/.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
lift--.f6427.7
Applied rewrites27.7%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6449.2
Applied rewrites49.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0))) (t_1 (- 1.0 (- x))))
(if (<= t_0 -1e+219)
t_1
(if (<= t_0 -1.5e+22)
(* y x)
(if (<= t_0 0.9999999999996938)
t_1
(if (<= t_0 2.0) (/ 1.0 y) (if (<= t_0 1e+286) (* y x) t_1)))))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (y + 1.0);
double t_1 = 1.0 - -x;
double tmp;
if (t_0 <= -1e+219) {
tmp = t_1;
} else if (t_0 <= -1.5e+22) {
tmp = y * x;
} else if (t_0 <= 0.9999999999996938) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = 1.0 / y;
} else if (t_0 <= 1e+286) {
tmp = y * x;
} 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 - x) * y) / (y + 1.0d0)
t_1 = 1.0d0 - -x
if (t_0 <= (-1d+219)) then
tmp = t_1
else if (t_0 <= (-1.5d+22)) then
tmp = y * x
else if (t_0 <= 0.9999999999996938d0) then
tmp = t_1
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 / y
else if (t_0 <= 1d+286) then
tmp = y * x
else
tmp = t_1
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 - -x;
double tmp;
if (t_0 <= -1e+219) {
tmp = t_1;
} else if (t_0 <= -1.5e+22) {
tmp = y * x;
} else if (t_0 <= 0.9999999999996938) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = 1.0 / y;
} else if (t_0 <= 1e+286) {
tmp = y * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = ((1.0 - x) * y) / (y + 1.0) t_1 = 1.0 - -x tmp = 0 if t_0 <= -1e+219: tmp = t_1 elif t_0 <= -1.5e+22: tmp = y * x elif t_0 <= 0.9999999999996938: tmp = t_1 elif t_0 <= 2.0: tmp = 1.0 / y elif t_0 <= 1e+286: tmp = y * x else: tmp = t_1 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(-x)) tmp = 0.0 if (t_0 <= -1e+219) tmp = t_1; elseif (t_0 <= -1.5e+22) tmp = Float64(y * x); elseif (t_0 <= 0.9999999999996938) tmp = t_1; elseif (t_0 <= 2.0) tmp = Float64(1.0 / y); elseif (t_0 <= 1e+286) tmp = Float64(y * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (y + 1.0); t_1 = 1.0 - -x; tmp = 0.0; if (t_0 <= -1e+219) tmp = t_1; elseif (t_0 <= -1.5e+22) tmp = y * x; elseif (t_0 <= 0.9999999999996938) tmp = t_1; elseif (t_0 <= 2.0) tmp = 1.0 / y; elseif (t_0 <= 1e+286) tmp = y * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - (-x)), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+219], t$95$1, If[LessEqual[t$95$0, -1.5e+22], N[(y * x), $MachinePrecision], If[LessEqual[t$95$0, 0.9999999999996938], t$95$1, If[LessEqual[t$95$0, 2.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[t$95$0, 1e+286], N[(y * x), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
t_1 := 1 - \left(-x\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+219}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -1.5 \cdot 10^{+22}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;t\_0 \leq 0.9999999999996938:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;t\_0 \leq 10^{+286}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -9.99999999999999965e218 or -1.5e22 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.9999999999996938 or 1.00000000000000003e286 < (/.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
lift--.f6427.7
Applied rewrites27.7%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6449.2
Applied rewrites49.2%
if -9.99999999999999965e218 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -1.5e22 or 2 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.00000000000000003e286Initial program 66.2%
Taylor expanded in x around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f6450.9
Applied rewrites50.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6414.9
Applied rewrites14.9%
if 0.9999999999996938 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 2Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around 0
lower-/.f6414.2
Applied rewrites14.2%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0)))) (if (<= t_0 -1e-302) (* y x) (if (<= t_0 2.0) (/ 1.0 y) (* y x)))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (y + 1.0);
double tmp;
if (t_0 <= -1e-302) {
tmp = y * x;
} else if (t_0 <= 2.0) {
tmp = 1.0 / y;
} else {
tmp = y * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 - x) * y) / (y + 1.0d0)
if (t_0 <= (-1d-302)) then
tmp = y * x
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 / y
else
tmp = y * 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 tmp;
if (t_0 <= -1e-302) {
tmp = y * x;
} else if (t_0 <= 2.0) {
tmp = 1.0 / y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): t_0 = ((1.0 - x) * y) / (y + 1.0) tmp = 0 if t_0 <= -1e-302: tmp = y * x elif t_0 <= 2.0: tmp = 1.0 / y else: tmp = y * x return tmp
function code(x, y) t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)) tmp = 0.0 if (t_0 <= -1e-302) tmp = Float64(y * x); elseif (t_0 <= 2.0) tmp = Float64(1.0 / y); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (y + 1.0); tmp = 0.0; if (t_0 <= -1e-302) tmp = y * x; elseif (t_0 <= 2.0) tmp = 1.0 / y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-302], N[(y * x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(1.0 / y), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-302}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -9.9999999999999996e-303 or 2 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 66.2%
Taylor expanded in x around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f6450.9
Applied rewrites50.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6414.9
Applied rewrites14.9%
if -9.9999999999999996e-303 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 2Initial program 66.2%
Taylor expanded in y around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around 0
lower-/.f6414.2
Applied rewrites14.2%
(FPCore (x y) :precision binary64 (* y x))
double code(double x, double y) {
return y * x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * x
end function
public static double code(double x, double y) {
return y * x;
}
def code(x, y): return y * x
function code(x, y) return Float64(y * x) end
function tmp = code(x, y) tmp = y * x; end
code[x_, y_] := N[(y * x), $MachinePrecision]
\begin{array}{l}
\\
y \cdot x
\end{array}
Initial program 66.2%
Taylor expanded in x around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f6450.9
Applied rewrites50.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6414.9
Applied rewrites14.9%
(FPCore (x y) :precision binary64 (- 1.0 1.0))
double code(double x, double y) {
return 1.0 - 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
end function
public static double code(double x, double y) {
return 1.0 - 1.0;
}
def code(x, y): return 1.0 - 1.0
function code(x, y) return Float64(1.0 - 1.0) end
function tmp = code(x, y) tmp = 1.0 - 1.0; end
code[x_, y_] := N[(1.0 - 1.0), $MachinePrecision]
\begin{array}{l}
\\
1 - 1
\end{array}
Initial program 66.2%
Taylor expanded in y around inf
lift--.f6427.7
Applied rewrites27.7%
Taylor expanded in x around 0
Applied rewrites3.1%
herbie shell --seed 2025140
(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))))