
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ y x) 1.0)))
(if (<= x -7.9e+146)
(/ (/ y x) t_0)
(if (<= x -2.5e-161)
(/ (/ (* y x) (pow (+ y x) 2.0)) t_0)
(/ (/ (fma (* x (/ x y)) -2.0 x) y) t_0)))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -7.9e+146) {
tmp = (y / x) / t_0;
} else if (x <= -2.5e-161) {
tmp = ((y * x) / pow((y + x), 2.0)) / t_0;
} else {
tmp = (fma((x * (x / y)), -2.0, x) / y) / t_0;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) + 1.0) tmp = 0.0 if (x <= -7.9e+146) tmp = Float64(Float64(y / x) / t_0); elseif (x <= -2.5e-161) tmp = Float64(Float64(Float64(y * x) / (Float64(y + x) ^ 2.0)) / t_0); else tmp = Float64(Float64(fma(Float64(x * Float64(x / y)), -2.0, x) / y) / t_0); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -7.9e+146], N[(N[(y / x), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, -2.5e-161], N[(N[(N[(y * x), $MachinePrecision] / N[Power[N[(y + x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] * -2.0 + x), $MachinePrecision] / y), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;x \leq -7.9 \cdot 10^{+146}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_0}\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-161}:\\
\;\;\;\;\frac{\frac{y \cdot x}{{\left(y + x\right)}^{2}}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x \cdot \frac{x}{y}, -2, x\right)}{y}}{t\_0}\\
\end{array}
\end{array}
if x < -7.8999999999999997e146Initial program 44.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6444.3
Applied rewrites44.3%
Taylor expanded in x around inf
lower-/.f6489.0
Applied rewrites89.0%
if -7.8999999999999997e146 < x < -2.5e-161Initial program 74.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.3
Applied rewrites83.3%
if -2.5e-161 < x Initial program 64.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6467.1
Applied rewrites67.1%
Taylor expanded in x around 0
lower-/.f6451.2
Applied rewrites51.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6451.0
Applied rewrites51.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ y x) 1.0)))
(if (<= x -7.8e+105)
(/ (/ y x) t_0)
(if (<= x -2.5e-161)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(/ (/ (fma (* x (/ x y)) -2.0 x) y) t_0)))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -7.8e+105) {
tmp = (y / x) / t_0;
} else if (x <= -2.5e-161) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (fma((x * (x / y)), -2.0, x) / y) / t_0;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) + 1.0) tmp = 0.0 if (x <= -7.8e+105) tmp = Float64(Float64(y / x) / t_0); elseif (x <= -2.5e-161) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(fma(Float64(x * Float64(x / y)), -2.0, x) / y) / t_0); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -7.8e+105], N[(N[(y / x), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, -2.5e-161], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] * -2.0 + x), $MachinePrecision] / y), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+105}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_0}\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-161}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x \cdot \frac{x}{y}, -2, x\right)}{y}}{t\_0}\\
\end{array}
\end{array}
if x < -7.79999999999999957e105Initial program 39.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6449.0
Applied rewrites49.0%
Taylor expanded in x around inf
lower-/.f6488.0
Applied rewrites88.0%
if -7.79999999999999957e105 < x < -2.5e-161Initial program 80.4%
if -2.5e-161 < x Initial program 64.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6467.1
Applied rewrites67.1%
Taylor expanded in x around 0
lower-/.f6451.2
Applied rewrites51.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6451.0
Applied rewrites51.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ y x) 1.0)))
(if (<= x -7.8e+105)
(/ (/ y x) t_0)
(if (<= x -3e-107)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(/ (/ x y) t_0)))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -7.8e+105) {
tmp = (y / x) / t_0;
} else if (x <= -3e-107) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (y + x) + 1.0d0
if (x <= (-7.8d+105)) then
tmp = (y / x) / t_0
else if (x <= (-3d-107)) then
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
else
tmp = (x / y) / t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -7.8e+105) {
tmp = (y / x) / t_0;
} else if (x <= -3e-107) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) + 1.0 tmp = 0 if x <= -7.8e+105: tmp = (y / x) / t_0 elif x <= -3e-107: tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)) else: tmp = (x / y) / t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) + 1.0) tmp = 0.0 if (x <= -7.8e+105) tmp = Float64(Float64(y / x) / t_0); elseif (x <= -3e-107) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(x / y) / t_0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) + 1.0;
tmp = 0.0;
if (x <= -7.8e+105)
tmp = (y / x) / t_0;
elseif (x <= -3e-107)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
else
tmp = (x / y) / t_0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -7.8e+105], N[(N[(y / x), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, -3e-107], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+105}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_0}\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-107}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{t\_0}\\
\end{array}
\end{array}
if x < -7.79999999999999957e105Initial program 39.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6449.0
Applied rewrites49.0%
Taylor expanded in x around inf
lower-/.f6488.0
Applied rewrites88.0%
if -7.79999999999999957e105 < x < -2.9999999999999997e-107Initial program 78.6%
if -2.9999999999999997e-107 < x Initial program 66.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6468.6
Applied rewrites68.6%
Taylor expanded in x around 0
lower-/.f6453.8
Applied rewrites53.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ y x) 1.0)))
(if (<= x -1.65e-34)
(/ (/ y x) t_0)
(if (<= x -3e-107)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ y 1.0)))
(/ (/ x y) t_0)))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -1.65e-34) {
tmp = (y / x) / t_0;
} else if (x <= -3e-107) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (y + x) + 1.0d0
if (x <= (-1.65d-34)) then
tmp = (y / x) / t_0
else if (x <= (-3d-107)) then
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0d0))
else
tmp = (x / y) / t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -1.65e-34) {
tmp = (y / x) / t_0;
} else if (x <= -3e-107) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) + 1.0 tmp = 0 if x <= -1.65e-34: tmp = (y / x) / t_0 elif x <= -3e-107: tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0)) else: tmp = (x / y) / t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) + 1.0) tmp = 0.0 if (x <= -1.65e-34) tmp = Float64(Float64(y / x) / t_0); elseif (x <= -3e-107) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(y + 1.0))); else tmp = Float64(Float64(x / y) / t_0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) + 1.0;
tmp = 0.0;
if (x <= -1.65e-34)
tmp = (y / x) / t_0;
elseif (x <= -3e-107)
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
else
tmp = (x / y) / t_0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.65e-34], N[(N[(y / x), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, -3e-107], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{-34}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_0}\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-107}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(y + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{t\_0}\\
\end{array}
\end{array}
if x < -1.64999999999999991e-34Initial program 54.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6462.5
Applied rewrites62.5%
Taylor expanded in x around inf
lower-/.f6476.2
Applied rewrites76.2%
if -1.64999999999999991e-34 < x < -2.9999999999999997e-107Initial program 83.7%
Taylor expanded in x around 0
Applied rewrites83.7%
if -2.9999999999999997e-107 < x Initial program 66.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6468.6
Applied rewrites68.6%
Taylor expanded in x around 0
lower-/.f6453.8
Applied rewrites53.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ y x) 1.0)))
(if (<= x -7.8e+105)
(/ (/ y x) t_0)
(if (<= x -7.2e-87)
(/ (* x y) (* (* (+ x y) x) (+ (+ x y) 1.0)))
(/ (/ x y) t_0)))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -7.8e+105) {
tmp = (y / x) / t_0;
} else if (x <= -7.2e-87) {
tmp = (x * y) / (((x + y) * x) * ((x + y) + 1.0));
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (y + x) + 1.0d0
if (x <= (-7.8d+105)) then
tmp = (y / x) / t_0
else if (x <= (-7.2d-87)) then
tmp = (x * y) / (((x + y) * x) * ((x + y) + 1.0d0))
else
tmp = (x / y) / t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -7.8e+105) {
tmp = (y / x) / t_0;
} else if (x <= -7.2e-87) {
tmp = (x * y) / (((x + y) * x) * ((x + y) + 1.0));
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) + 1.0 tmp = 0 if x <= -7.8e+105: tmp = (y / x) / t_0 elif x <= -7.2e-87: tmp = (x * y) / (((x + y) * x) * ((x + y) + 1.0)) else: tmp = (x / y) / t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) + 1.0) tmp = 0.0 if (x <= -7.8e+105) tmp = Float64(Float64(y / x) / t_0); elseif (x <= -7.2e-87) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * x) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(x / y) / t_0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) + 1.0;
tmp = 0.0;
if (x <= -7.8e+105)
tmp = (y / x) / t_0;
elseif (x <= -7.2e-87)
tmp = (x * y) / (((x + y) * x) * ((x + y) + 1.0));
else
tmp = (x / y) / t_0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -7.8e+105], N[(N[(y / x), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, -7.2e-87], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * x), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+105}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_0}\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{-87}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot x\right) \cdot \left(\left(x + y\right) + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{t\_0}\\
\end{array}
\end{array}
if x < -7.79999999999999957e105Initial program 39.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6449.0
Applied rewrites49.0%
Taylor expanded in x around inf
lower-/.f6488.0
Applied rewrites88.0%
if -7.79999999999999957e105 < x < -7.19999999999999986e-87Initial program 82.7%
Taylor expanded in x around inf
Applied rewrites69.5%
if -7.19999999999999986e-87 < x Initial program 66.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6468.1
Applied rewrites68.1%
Taylor expanded in x around 0
lower-/.f6453.2
Applied rewrites53.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y -2.7e+82) (/ (/ y x) x) (if (<= y 9e-54) (/ y (* (+ 1.0 x) x)) (/ (/ x y) (+ (+ y x) 1.0)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -2.7e+82) {
tmp = (y / x) / x;
} else if (y <= 9e-54) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = (x / y) / ((y + x) + 1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 <= (-2.7d+82)) then
tmp = (y / x) / x
else if (y <= 9d-54) then
tmp = y / ((1.0d0 + x) * x)
else
tmp = (x / y) / ((y + x) + 1.0d0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= -2.7e+82) {
tmp = (y / x) / x;
} else if (y <= 9e-54) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = (x / y) / ((y + x) + 1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= -2.7e+82: tmp = (y / x) / x elif y <= 9e-54: tmp = y / ((1.0 + x) * x) else: tmp = (x / y) / ((y + x) + 1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= -2.7e+82) tmp = Float64(Float64(y / x) / x); elseif (y <= 9e-54) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(Float64(x / y) / Float64(Float64(y + x) + 1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= -2.7e+82)
tmp = (y / x) / x;
elseif (y <= 9e-54)
tmp = y / ((1.0 + x) * x);
else
tmp = (x / y) / ((y + x) + 1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, -2.7e+82], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[y, 9e-54], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+82}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-54}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{\left(y + x\right) + 1}\\
\end{array}
\end{array}
if y < -2.6999999999999999e82Initial program 59.7%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6415.3
Applied rewrites15.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6425.6
Applied rewrites25.6%
if -2.6999999999999999e82 < y < 8.9999999999999997e-54Initial program 68.4%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6476.0
Applied rewrites76.0%
if 8.9999999999999997e-54 < y Initial program 60.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6463.0
Applied rewrites63.0%
Taylor expanded in x around 0
lower-/.f6470.9
Applied rewrites70.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y -2.7e+82) (/ (/ y x) x) (if (<= y 9e-54) (/ y (* (+ 1.0 x) x)) (/ (/ x y) (+ 1.0 y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -2.7e+82) {
tmp = (y / x) / x;
} else if (y <= 9e-54) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = (x / y) / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 <= (-2.7d+82)) then
tmp = (y / x) / x
else if (y <= 9d-54) then
tmp = y / ((1.0d0 + x) * x)
else
tmp = (x / y) / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= -2.7e+82) {
tmp = (y / x) / x;
} else if (y <= 9e-54) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = (x / y) / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= -2.7e+82: tmp = (y / x) / x elif y <= 9e-54: tmp = y / ((1.0 + x) * x) else: tmp = (x / y) / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= -2.7e+82) tmp = Float64(Float64(y / x) / x); elseif (y <= 9e-54) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(Float64(x / y) / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= -2.7e+82)
tmp = (y / x) / x;
elseif (y <= 9e-54)
tmp = y / ((1.0 + x) * x);
else
tmp = (x / y) / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, -2.7e+82], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[y, 9e-54], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+82}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-54}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{1 + y}\\
\end{array}
\end{array}
if y < -2.6999999999999999e82Initial program 59.7%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6415.3
Applied rewrites15.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6425.6
Applied rewrites25.6%
if -2.6999999999999999e82 < y < 8.9999999999999997e-54Initial program 68.4%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6476.0
Applied rewrites76.0%
if 8.9999999999999997e-54 < y Initial program 60.2%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6469.5
Applied rewrites69.5%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-+.f6470.5
Applied rewrites70.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.05e+33) (/ y (* x x)) (if (or (<= x -2.1e-91) (not (<= x 2.35e-303))) (/ x (* y y)) (/ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.05e+33) {
tmp = y / (x * x);
} else if ((x <= -2.1e-91) || !(x <= 2.35e-303)) {
tmp = x / (y * y);
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.05d+33)) then
tmp = y / (x * x)
else if ((x <= (-2.1d-91)) .or. (.not. (x <= 2.35d-303))) then
tmp = x / (y * y)
else
tmp = x / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.05e+33) {
tmp = y / (x * x);
} else if ((x <= -2.1e-91) || !(x <= 2.35e-303)) {
tmp = x / (y * y);
} else {
tmp = x / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.05e+33: tmp = y / (x * x) elif (x <= -2.1e-91) or not (x <= 2.35e-303): tmp = x / (y * y) else: tmp = x / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.05e+33) tmp = Float64(y / Float64(x * x)); elseif ((x <= -2.1e-91) || !(x <= 2.35e-303)) tmp = Float64(x / Float64(y * y)); else tmp = Float64(x / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.05e+33)
tmp = y / (x * x);
elseif ((x <= -2.1e-91) || ~((x <= 2.35e-303)))
tmp = x / (y * y);
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.05e+33], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -2.1e-91], N[Not[LessEqual[x, 2.35e-303]], $MachinePrecision]], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+33}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-91} \lor \neg \left(x \leq 2.35 \cdot 10^{-303}\right):\\
\;\;\;\;\frac{x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.05e33Initial program 45.3%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6470.7
Applied rewrites70.7%
if -1.05e33 < x < -2.0999999999999999e-91 or 2.3499999999999999e-303 < x Initial program 72.2%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6439.9
Applied rewrites39.9%
if -2.0999999999999999e-91 < x < 2.3499999999999999e-303Initial program 60.0%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6479.7
Applied rewrites79.7%
Taylor expanded in y around 0
Applied rewrites65.4%
Final simplification50.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 9e-54) (/ y (* (+ 1.0 x) x)) (if (<= y 8e+17) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 9e-54) {
tmp = y / ((1.0 + x) * x);
} else if (y <= 8e+17) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 <= 9d-54) then
tmp = y / ((1.0d0 + x) * x)
else if (y <= 8d+17) then
tmp = x / ((1.0d0 + y) * y)
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 9e-54) {
tmp = y / ((1.0 + x) * x);
} else if (y <= 8e+17) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 9e-54: tmp = y / ((1.0 + x) * x) elif y <= 8e+17: tmp = x / ((1.0 + y) * y) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 9e-54) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); elseif (y <= 8e+17) tmp = Float64(x / Float64(Float64(1.0 + y) * y)); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 9e-54)
tmp = y / ((1.0 + x) * x);
elseif (y <= 8e+17)
tmp = x / ((1.0 + y) * y);
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 9e-54], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+17], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-54}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+17}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < 8.9999999999999997e-54Initial program 66.2%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6460.3
Applied rewrites60.3%
if 8.9999999999999997e-54 < y < 8e17Initial program 92.5%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6464.9
Applied rewrites64.9%
if 8e17 < y Initial program 51.6%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6470.7
Applied rewrites70.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6472.0
Applied rewrites72.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (let* ((t_0 (+ (+ y x) 1.0))) (if (<= y 9e-54) (/ (/ y x) t_0) (/ (/ x y) t_0))))
assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (y <= 9e-54) {
tmp = (y / x) / t_0;
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (y + x) + 1.0d0
if (y <= 9d-54) then
tmp = (y / x) / t_0
else
tmp = (x / y) / t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (y <= 9e-54) {
tmp = (y / x) / t_0;
} else {
tmp = (x / y) / t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) + 1.0 tmp = 0 if y <= 9e-54: tmp = (y / x) / t_0 else: tmp = (x / y) / t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) + 1.0) tmp = 0.0 if (y <= 9e-54) tmp = Float64(Float64(y / x) / t_0); else tmp = Float64(Float64(x / y) / t_0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) + 1.0;
tmp = 0.0;
if (y <= 9e-54)
tmp = (y / x) / t_0;
else
tmp = (x / y) / t_0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[y, 9e-54], N[(N[(y / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;y \leq 9 \cdot 10^{-54}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{t\_0}\\
\end{array}
\end{array}
if y < 8.9999999999999997e-54Initial program 66.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9
Applied rewrites69.9%
Taylor expanded in x around inf
lower-/.f6463.3
Applied rewrites63.3%
if 8.9999999999999997e-54 < y Initial program 60.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6463.0
Applied rewrites63.0%
Taylor expanded in x around 0
lower-/.f6470.9
Applied rewrites70.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -5.6e+200) (/ (/ y x) x) (if (<= x -8.5e-107) (/ y (* (+ 1.0 x) x)) (/ x (* (+ 1.0 y) y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -5.6e+200) {
tmp = (y / x) / x;
} else if (x <= -8.5e-107) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-5.6d+200)) then
tmp = (y / x) / x
else if (x <= (-8.5d-107)) then
tmp = y / ((1.0d0 + x) * x)
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -5.6e+200) {
tmp = (y / x) / x;
} else if (x <= -8.5e-107) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -5.6e+200: tmp = (y / x) / x elif x <= -8.5e-107: tmp = y / ((1.0 + x) * x) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -5.6e+200) tmp = Float64(Float64(y / x) / x); elseif (x <= -8.5e-107) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -5.6e+200)
tmp = (y / x) / x;
elseif (x <= -8.5e-107)
tmp = y / ((1.0 + x) * x);
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -5.6e+200], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -8.5e-107], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{+200}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-107}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -5.59999999999999969e200Initial program 40.7%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6472.4
Applied rewrites72.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6492.9
Applied rewrites92.9%
if -5.59999999999999969e200 < x < -8.49999999999999956e-107Initial program 69.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6458.3
Applied rewrites58.3%
if -8.49999999999999956e-107 < x Initial program 66.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6454.1
Applied rewrites54.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -8.5e-107) (/ y (* (+ 1.0 x) x)) (/ x (* (+ 1.0 y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -8.5e-107) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-8.5d-107)) then
tmp = y / ((1.0d0 + x) * x)
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -8.5e-107) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -8.5e-107: tmp = y / ((1.0 + x) * x) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -8.5e-107) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -8.5e-107)
tmp = y / ((1.0 + x) * x);
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -8.5e-107], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-107}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -8.49999999999999956e-107Initial program 60.5%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
if -8.49999999999999956e-107 < x Initial program 66.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6454.1
Applied rewrites54.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -7.2e+17) (/ y (* x x)) (/ x (* (+ 1.0 y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7.2e+17) {
tmp = y / (x * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-7.2d+17)) then
tmp = y / (x * x)
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -7.2e+17) {
tmp = y / (x * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -7.2e+17: tmp = y / (x * x) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -7.2e+17) tmp = Float64(y / Float64(x * x)); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -7.2e+17)
tmp = y / (x * x);
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -7.2e+17], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{+17}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -7.2e17Initial program 46.4%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6468.7
Applied rewrites68.7%
if -7.2e17 < x Initial program 69.3%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.4
Applied rewrites53.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.0) (/ x y) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.0d0) then
tmp = x / y
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.0: tmp = x / y else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.0) tmp = Float64(x / y); else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.0)
tmp = x / y;
else
tmp = x / (y * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.0], N[(x / y), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if y < 1Initial program 68.2%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6439.5
Applied rewrites39.5%
Taylor expanded in y around 0
Applied rewrites25.7%
if 1 < y Initial program 51.5%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x y))
assert(x < y);
double code(double x, double y) {
return x / y;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
assert x < y;
public static double code(double x, double y) {
return x / y;
}
[x, y] = sort([x, y]) def code(x, y): return x / y
x, y = sort([x, y]) function code(x, y) return Float64(x / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y}
\end{array}
Initial program 64.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6446.0
Applied rewrites46.0%
Taylor expanded in y around 0
Applied rewrites24.1%
(FPCore (x y) :precision binary64 (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x)))))
double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (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 = ((x / ((y + 1.0d0) + x)) / (y + x)) / (1.0d0 / (y / (y + x)))
end function
public static double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
def code(x, y): return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)))
function code(x, y) return Float64(Float64(Float64(x / Float64(Float64(y + 1.0) + x)) / Float64(y + x)) / Float64(1.0 / Float64(y / Float64(y + x)))) end
function tmp = code(x, y) tmp = ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x))); end
code[x_, y_] := N[(N[(N[(x / N[(N[(y + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}}
\end{array}
herbie shell --seed 2025040
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
:alt
(! :herbie-platform default (/ (/ (/ x (+ (+ y 1) x)) (+ y x)) (/ 1 (/ y (+ y x)))))
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))