
(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}
Herbie found 13 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 (+ (+ y x) 1.0))))
(if (<= x -1.4e+149)
(* (/ (fma (/ y x) -2.0 1.0) x) t_0)
(if (<= x -5e-159)
(* (/ x (pow (+ y x) 2.0)) t_0)
(/ x (* (+ 1.0 y) y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / ((y + x) + 1.0);
double tmp;
if (x <= -1.4e+149) {
tmp = (fma((y / x), -2.0, 1.0) / x) * t_0;
} else if (x <= -5e-159) {
tmp = (x / pow((y + x), 2.0)) * t_0;
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(Float64(y + x) + 1.0)) tmp = 0.0 if (x <= -1.4e+149) tmp = Float64(Float64(fma(Float64(y / x), -2.0, 1.0) / x) * t_0); elseif (x <= -5e-159) tmp = Float64(Float64(x / (Float64(y + x) ^ 2.0)) * t_0); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); 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[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e+149], N[(N[(N[(N[(y / x), $MachinePrecision] * -2.0 + 1.0), $MachinePrecision] / x), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, -5e-159], N[(N[(x / N[Power[N[(y + x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{\left(y + x\right) + 1}\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+149}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{x}, -2, 1\right)}{x} \cdot t\_0\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-159}:\\
\;\;\;\;\frac{x}{{\left(y + x\right)}^{2}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -1.4e149Initial program 63.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6485.1
Applied rewrites85.1%
Taylor expanded in x around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6492.8
Applied rewrites92.8%
if -1.4e149 < x < -5.00000000000000032e-159Initial program 77.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6497.5
Applied rewrites97.5%
if -5.00000000000000032e-159 < x Initial program 64.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.3
Applied rewrites87.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ (+ y x) 1.0))))
(if (<= x -1.4e+149)
(* (pow x -1.0) t_0)
(if (<= x -5e-159)
(* (/ x (pow (+ y x) 2.0)) t_0)
(/ x (* (+ 1.0 y) y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / ((y + x) + 1.0);
double tmp;
if (x <= -1.4e+149) {
tmp = pow(x, -1.0) * t_0;
} else if (x <= -5e-159) {
tmp = (x / pow((y + x), 2.0)) * t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / ((y + x) + 1.0d0)
if (x <= (-1.4d+149)) then
tmp = (x ** (-1.0d0)) * t_0
else if (x <= (-5d-159)) then
tmp = (x / ((y + x) ** 2.0d0)) * t_0
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 t_0 = y / ((y + x) + 1.0);
double tmp;
if (x <= -1.4e+149) {
tmp = Math.pow(x, -1.0) * t_0;
} else if (x <= -5e-159) {
tmp = (x / Math.pow((y + x), 2.0)) * t_0;
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / ((y + x) + 1.0) tmp = 0 if x <= -1.4e+149: tmp = math.pow(x, -1.0) * t_0 elif x <= -5e-159: tmp = (x / math.pow((y + x), 2.0)) * t_0 else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(Float64(y + x) + 1.0)) tmp = 0.0 if (x <= -1.4e+149) tmp = Float64((x ^ -1.0) * t_0); elseif (x <= -5e-159) tmp = Float64(Float64(x / (Float64(y + x) ^ 2.0)) * t_0); 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)
t_0 = y / ((y + x) + 1.0);
tmp = 0.0;
if (x <= -1.4e+149)
tmp = (x ^ -1.0) * t_0;
elseif (x <= -5e-159)
tmp = (x / ((y + x) ^ 2.0)) * t_0;
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_] := Block[{t$95$0 = N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e+149], N[(N[Power[x, -1.0], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, -5e-159], N[(N[(x / N[Power[N[(y + x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{\left(y + x\right) + 1}\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+149}:\\
\;\;\;\;{x}^{-1} \cdot t\_0\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-159}:\\
\;\;\;\;\frac{x}{{\left(y + x\right)}^{2}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -1.4e149Initial program 63.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6485.1
Applied rewrites85.1%
Taylor expanded in x around inf
inv-powN/A
lower-pow.f6492.4
Applied rewrites92.4%
if -1.4e149 < x < -5.00000000000000032e-159Initial program 77.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6497.5
Applied rewrites97.5%
if -5.00000000000000032e-159 < x Initial program 64.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.3
Applied rewrites87.3%
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.18e+79)
(* (pow x -1.0) (/ y t_0))
(if (<= x -5e-159)
(* x (/ y (* t_0 (pow (+ y x) 2.0))))
(/ x (* (+ 1.0 y) y))))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (x <= -1.18e+79) {
tmp = pow(x, -1.0) * (y / t_0);
} else if (x <= -5e-159) {
tmp = x * (y / (t_0 * pow((y + x), 2.0)));
} 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) :: t_0
real(8) :: tmp
t_0 = (y + x) + 1.0d0
if (x <= (-1.18d+79)) then
tmp = (x ** (-1.0d0)) * (y / t_0)
else if (x <= (-5d-159)) then
tmp = x * (y / (t_0 * ((y + x) ** 2.0d0)))
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 t_0 = (y + x) + 1.0;
double tmp;
if (x <= -1.18e+79) {
tmp = Math.pow(x, -1.0) * (y / t_0);
} else if (x <= -5e-159) {
tmp = x * (y / (t_0 * Math.pow((y + x), 2.0)));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) + 1.0 tmp = 0 if x <= -1.18e+79: tmp = math.pow(x, -1.0) * (y / t_0) elif x <= -5e-159: tmp = x * (y / (t_0 * math.pow((y + x), 2.0))) else: tmp = x / ((1.0 + y) * y) 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.18e+79) tmp = Float64((x ^ -1.0) * Float64(y / t_0)); elseif (x <= -5e-159) tmp = Float64(x * Float64(y / Float64(t_0 * (Float64(y + x) ^ 2.0)))); 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)
t_0 = (y + x) + 1.0;
tmp = 0.0;
if (x <= -1.18e+79)
tmp = (x ^ -1.0) * (y / t_0);
elseif (x <= -5e-159)
tmp = x * (y / (t_0 * ((y + x) ^ 2.0)));
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_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.18e+79], N[(N[Power[x, -1.0], $MachinePrecision] * N[(y / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-159], N[(x * N[(y / N[(t$95$0 * N[Power[N[(y + x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;x \leq -1.18 \cdot 10^{+79}:\\
\;\;\;\;{x}^{-1} \cdot \frac{y}{t\_0}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-159}:\\
\;\;\;\;x \cdot \frac{y}{t\_0 \cdot {\left(y + x\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -1.18e79Initial program 61.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.7
Applied rewrites87.7%
Taylor expanded in x around inf
inv-powN/A
lower-pow.f6489.0
Applied rewrites89.0%
if -1.18e79 < x < -5.00000000000000032e-159Initial program 83.4%
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-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f6493.8
Applied rewrites93.8%
if -5.00000000000000032e-159 < x Initial program 64.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.3
Applied rewrites87.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -3.1e-5)
(* (pow x -1.0) (/ y (+ (+ y x) 1.0)))
(if (<= x -5e-159)
(* (/ x (pow (+ y x) 2.0)) (/ y (+ y 1.0)))
(/ x (* (+ 1.0 y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.1e-5) {
tmp = pow(x, -1.0) * (y / ((y + x) + 1.0));
} else if (x <= -5e-159) {
tmp = (x / pow((y + x), 2.0)) * (y / (y + 1.0));
} 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 <= (-3.1d-5)) then
tmp = (x ** (-1.0d0)) * (y / ((y + x) + 1.0d0))
else if (x <= (-5d-159)) then
tmp = (x / ((y + x) ** 2.0d0)) * (y / (y + 1.0d0))
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 <= -3.1e-5) {
tmp = Math.pow(x, -1.0) * (y / ((y + x) + 1.0));
} else if (x <= -5e-159) {
tmp = (x / Math.pow((y + x), 2.0)) * (y / (y + 1.0));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -3.1e-5: tmp = math.pow(x, -1.0) * (y / ((y + x) + 1.0)) elif x <= -5e-159: tmp = (x / math.pow((y + x), 2.0)) * (y / (y + 1.0)) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3.1e-5) tmp = Float64((x ^ -1.0) * Float64(y / Float64(Float64(y + x) + 1.0))); elseif (x <= -5e-159) tmp = Float64(Float64(x / (Float64(y + x) ^ 2.0)) * Float64(y / Float64(y + 1.0))); 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 <= -3.1e-5)
tmp = (x ^ -1.0) * (y / ((y + x) + 1.0));
elseif (x <= -5e-159)
tmp = (x / ((y + x) ^ 2.0)) * (y / (y + 1.0));
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, -3.1e-5], N[(N[Power[x, -1.0], $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-159], N[(N[(x / N[Power[N[(y + x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + 1.0), $MachinePrecision]), $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 -3.1 \cdot 10^{-5}:\\
\;\;\;\;{x}^{-1} \cdot \frac{y}{\left(y + x\right) + 1}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-159}:\\
\;\;\;\;\frac{x}{{\left(y + x\right)}^{2}} \cdot \frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -3.10000000000000014e-5Initial program 68.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6490.0
Applied rewrites90.0%
Taylor expanded in x around inf
inv-powN/A
lower-pow.f6485.0
Applied rewrites85.0%
if -3.10000000000000014e-5 < x < -5.00000000000000032e-159Initial program 80.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites98.5%
if -5.00000000000000032e-159 < x Initial program 64.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.3
Applied rewrites87.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.35e-131)
(/ (/ y (+ 1.0 x)) x)
(if (<= y 140000000000.0)
(/ x (* (+ 1.0 y) y))
(if (<= y 1.4e+164) (* (/ x (pow (+ y x) 2.0)) 1.0) (/ (/ x y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.35e-131) {
tmp = (y / (1.0 + x)) / x;
} else if (y <= 140000000000.0) {
tmp = x / ((1.0 + y) * y);
} else if (y <= 1.4e+164) {
tmp = (x / pow((y + x), 2.0)) * 1.0;
} 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.35d-131) then
tmp = (y / (1.0d0 + x)) / x
else if (y <= 140000000000.0d0) then
tmp = x / ((1.0d0 + y) * y)
else if (y <= 1.4d+164) then
tmp = (x / ((y + x) ** 2.0d0)) * 1.0d0
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.35e-131) {
tmp = (y / (1.0 + x)) / x;
} else if (y <= 140000000000.0) {
tmp = x / ((1.0 + y) * y);
} else if (y <= 1.4e+164) {
tmp = (x / Math.pow((y + x), 2.0)) * 1.0;
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.35e-131: tmp = (y / (1.0 + x)) / x elif y <= 140000000000.0: tmp = x / ((1.0 + y) * y) elif y <= 1.4e+164: tmp = (x / math.pow((y + x), 2.0)) * 1.0 else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.35e-131) tmp = Float64(Float64(y / Float64(1.0 + x)) / x); elseif (y <= 140000000000.0) tmp = Float64(x / Float64(Float64(1.0 + y) * y)); elseif (y <= 1.4e+164) tmp = Float64(Float64(x / (Float64(y + x) ^ 2.0)) * 1.0); 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 <= 1.35e-131)
tmp = (y / (1.0 + x)) / x;
elseif (y <= 140000000000.0)
tmp = x / ((1.0 + y) * y);
elseif (y <= 1.4e+164)
tmp = (x / ((y + x) ^ 2.0)) * 1.0;
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.35e-131], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[y, 140000000000.0], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e+164], N[(N[(x / N[Power[N[(y + x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{-131}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{x}\\
\mathbf{elif}\;y \leq 140000000000:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+164}:\\
\;\;\;\;\frac{x}{{\left(y + x\right)}^{2}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < 1.35000000000000011e-131Initial program 63.9%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6485.3
Applied rewrites85.3%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6488.4
Applied rewrites88.4%
if 1.35000000000000011e-131 < y < 1.4e11Initial program 85.0%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6458.3
Applied rewrites58.3%
if 1.4e11 < y < 1.4000000000000001e164Initial program 72.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.3
Applied rewrites93.3%
Taylor expanded in y around inf
Applied rewrites85.6%
if 1.4000000000000001e164 < y Initial program 63.5%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6486.4
Applied rewrites86.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.1
Applied rewrites94.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y -4.5e-10)
(/ (/ y x) x)
(if (<= y 1.35e-131)
(/ y (* (+ 1.0 x) x))
(if (<= y 1.4e+164) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -4.5e-10) {
tmp = (y / x) / x;
} else if (y <= 1.35e-131) {
tmp = y / ((1.0 + x) * x);
} else if (y <= 1.4e+164) {
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 <= (-4.5d-10)) then
tmp = (y / x) / x
else if (y <= 1.35d-131) then
tmp = y / ((1.0d0 + x) * x)
else if (y <= 1.4d+164) 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 <= -4.5e-10) {
tmp = (y / x) / x;
} else if (y <= 1.35e-131) {
tmp = y / ((1.0 + x) * x);
} else if (y <= 1.4e+164) {
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 <= -4.5e-10: tmp = (y / x) / x elif y <= 1.35e-131: tmp = y / ((1.0 + x) * x) elif y <= 1.4e+164: 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 <= -4.5e-10) tmp = Float64(Float64(y / x) / x); elseif (y <= 1.35e-131) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); elseif (y <= 1.4e+164) 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 <= -4.5e-10)
tmp = (y / x) / x;
elseif (y <= 1.35e-131)
tmp = y / ((1.0 + x) * x);
elseif (y <= 1.4e+164)
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, -4.5e-10], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[y, 1.35e-131], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e+164], 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 -4.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-131}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+164}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < -4.5e-10Initial program 32.4%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6476.4
Applied rewrites76.4%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6496.2
Applied rewrites96.2%
Taylor expanded in x around inf
Applied rewrites96.1%
if -4.5e-10 < y < 1.35000000000000011e-131Initial program 69.9%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6486.9
Applied rewrites86.9%
if 1.35000000000000011e-131 < y < 1.4000000000000001e164Initial program 77.8%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6468.1
Applied rewrites68.1%
if 1.4000000000000001e164 < y Initial program 63.5%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6486.4
Applied rewrites86.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.1
Applied rewrites94.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.35e-131) (/ (/ y (+ 1.0 x)) x) (if (<= y 1.4e+164) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.35e-131) {
tmp = (y / (1.0 + x)) / x;
} else if (y <= 1.4e+164) {
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 <= 1.35d-131) then
tmp = (y / (1.0d0 + x)) / x
else if (y <= 1.4d+164) 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 <= 1.35e-131) {
tmp = (y / (1.0 + x)) / x;
} else if (y <= 1.4e+164) {
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 <= 1.35e-131: tmp = (y / (1.0 + x)) / x elif y <= 1.4e+164: 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 <= 1.35e-131) tmp = Float64(Float64(y / Float64(1.0 + x)) / x); elseif (y <= 1.4e+164) 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 <= 1.35e-131)
tmp = (y / (1.0 + x)) / x;
elseif (y <= 1.4e+164)
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, 1.35e-131], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[y, 1.4e+164], 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 1.35 \cdot 10^{-131}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{x}\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+164}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < 1.35000000000000011e-131Initial program 63.9%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6485.3
Applied rewrites85.3%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6488.4
Applied rewrites88.4%
if 1.35000000000000011e-131 < y < 1.4000000000000001e164Initial program 77.8%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6468.1
Applied rewrites68.1%
if 1.4000000000000001e164 < y Initial program 63.5%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6486.4
Applied rewrites86.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.1
Applied rewrites94.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -7900000.0) (/ (/ y x) x) (/ x (* (+ 1.0 y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7900000.0) {
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 <= (-7900000.0d0)) 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 <= -7900000.0) {
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 <= -7900000.0: 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 <= -7900000.0) tmp = Float64(Float64(y / 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 <= -7900000.0)
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, -7900000.0], N[(N[(y / x), $MachinePrecision] / x), $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 -7900000:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -7.9e6Initial program 67.3%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6481.0
Applied rewrites81.0%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6485.3
Applied rewrites85.3%
Taylor expanded in x around inf
Applied rewrites84.9%
if -7.9e6 < x Initial program 70.0%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6474.3
Applied rewrites74.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y -3.2e-201)
(/ (/ y x) x)
(if (<= y 1.05e-144)
(/ y x)
(if (<= y 850000.0) (/ y (* x x)) (/ (/ x y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -3.2e-201) {
tmp = (y / x) / x;
} else if (y <= 1.05e-144) {
tmp = y / x;
} else if (y <= 850000.0) {
tmp = y / (x * x);
} 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 <= (-3.2d-201)) then
tmp = (y / x) / x
else if (y <= 1.05d-144) then
tmp = y / x
else if (y <= 850000.0d0) then
tmp = y / (x * x)
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 <= -3.2e-201) {
tmp = (y / x) / x;
} else if (y <= 1.05e-144) {
tmp = y / x;
} else if (y <= 850000.0) {
tmp = y / (x * x);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= -3.2e-201: tmp = (y / x) / x elif y <= 1.05e-144: tmp = y / x elif y <= 850000.0: tmp = y / (x * x) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= -3.2e-201) tmp = Float64(Float64(y / x) / x); elseif (y <= 1.05e-144) tmp = Float64(y / x); elseif (y <= 850000.0) tmp = Float64(y / Float64(x * x)); 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 <= -3.2e-201)
tmp = (y / x) / x;
elseif (y <= 1.05e-144)
tmp = y / x;
elseif (y <= 850000.0)
tmp = y / (x * x);
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, -3.2e-201], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[y, 1.05e-144], N[(y / x), $MachinePrecision], If[LessEqual[y, 850000.0], N[(y / N[(x * x), $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 -3.2 \cdot 10^{-201}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-144}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{elif}\;y \leq 850000:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < -3.2000000000000001e-201Initial program 70.7%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6489.7
Applied rewrites89.7%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6497.3
Applied rewrites97.3%
Taylor expanded in x around inf
Applied rewrites82.8%
if -3.2000000000000001e-201 < y < 1.0500000000000001e-144Initial program 58.7%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6483.8
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites72.1%
if 1.0500000000000001e-144 < y < 8.5e5Initial program 83.5%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6434.4
Applied rewrites34.4%
if 8.5e5 < y Initial program 68.2%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6480.3
Applied rewrites80.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6484.9
Applied rewrites84.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (* x x))))
(if (<= y -3.4e-201)
t_0
(if (<= y 1.05e-144) (/ y x) (if (<= y 850000.0) t_0 (/ (/ x y) y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (x * x);
double tmp;
if (y <= -3.4e-201) {
tmp = t_0;
} else if (y <= 1.05e-144) {
tmp = y / x;
} else if (y <= 850000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / (x * x)
if (y <= (-3.4d-201)) then
tmp = t_0
else if (y <= 1.05d-144) then
tmp = y / x
else if (y <= 850000.0d0) then
tmp = t_0
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (x * x);
double tmp;
if (y <= -3.4e-201) {
tmp = t_0;
} else if (y <= 1.05e-144) {
tmp = y / x;
} else if (y <= 850000.0) {
tmp = t_0;
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (x * x) tmp = 0 if y <= -3.4e-201: tmp = t_0 elif y <= 1.05e-144: tmp = y / x elif y <= 850000.0: tmp = t_0 else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(x * x)) tmp = 0.0 if (y <= -3.4e-201) tmp = t_0; elseif (y <= 1.05e-144) tmp = Float64(y / x); elseif (y <= 850000.0) tmp = t_0; else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (x * x);
tmp = 0.0;
if (y <= -3.4e-201)
tmp = t_0;
elseif (y <= 1.05e-144)
tmp = y / x;
elseif (y <= 850000.0)
tmp = t_0;
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_] := Block[{t$95$0 = N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.4e-201], t$95$0, If[LessEqual[y, 1.05e-144], N[(y / x), $MachinePrecision], If[LessEqual[y, 850000.0], t$95$0, N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{x \cdot x}\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{-201}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-144}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{elif}\;y \leq 850000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < -3.39999999999999985e-201 or 1.0500000000000001e-144 < y < 8.5e5Initial program 76.9%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6455.3
Applied rewrites55.3%
if -3.39999999999999985e-201 < y < 1.0500000000000001e-144Initial program 58.7%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6483.8
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites72.1%
if 8.5e5 < y Initial program 68.2%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6480.3
Applied rewrites80.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6484.9
Applied rewrites84.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (* x x))))
(if (<= y -3.4e-201)
t_0
(if (<= y 1.05e-144) (/ y x) (if (<= y 850000.0) t_0 (/ x (* y y)))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (x * x);
double tmp;
if (y <= -3.4e-201) {
tmp = t_0;
} else if (y <= 1.05e-144) {
tmp = y / x;
} else if (y <= 850000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / (x * x)
if (y <= (-3.4d-201)) then
tmp = t_0
else if (y <= 1.05d-144) then
tmp = y / x
else if (y <= 850000.0d0) then
tmp = t_0
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (x * x);
double tmp;
if (y <= -3.4e-201) {
tmp = t_0;
} else if (y <= 1.05e-144) {
tmp = y / x;
} else if (y <= 850000.0) {
tmp = t_0;
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (x * x) tmp = 0 if y <= -3.4e-201: tmp = t_0 elif y <= 1.05e-144: tmp = y / x elif y <= 850000.0: tmp = t_0 else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(x * x)) tmp = 0.0 if (y <= -3.4e-201) tmp = t_0; elseif (y <= 1.05e-144) tmp = Float64(y / x); elseif (y <= 850000.0) tmp = t_0; else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (x * x);
tmp = 0.0;
if (y <= -3.4e-201)
tmp = t_0;
elseif (y <= 1.05e-144)
tmp = y / x;
elseif (y <= 850000.0)
tmp = t_0;
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_] := Block[{t$95$0 = N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.4e-201], t$95$0, If[LessEqual[y, 1.05e-144], N[(y / x), $MachinePrecision], If[LessEqual[y, 850000.0], t$95$0, N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{x \cdot x}\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{-201}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-144}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{elif}\;y \leq 850000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if y < -3.39999999999999985e-201 or 1.0500000000000001e-144 < y < 8.5e5Initial program 76.9%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6455.3
Applied rewrites55.3%
if -3.39999999999999985e-201 < y < 1.0500000000000001e-144Initial program 58.7%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6483.8
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites72.1%
if 8.5e5 < y Initial program 68.2%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6480.3
Applied rewrites80.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 8.5e-26) (/ y x) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 8.5e-26) {
tmp = y / x;
} 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 <= 8.5d-26) then
tmp = y / x
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 <= 8.5e-26) {
tmp = y / x;
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 8.5e-26: tmp = y / x else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 8.5e-26) tmp = Float64(y / x); 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 <= 8.5e-26)
tmp = y / x;
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, 8.5e-26], N[(y / x), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-26}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if y < 8.50000000000000004e-26Initial program 67.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6476.8
Applied rewrites76.8%
Taylor expanded in x around 0
Applied rewrites47.2%
if 8.50000000000000004e-26 < y Initial program 70.1%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.1
Applied rewrites75.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ y x))
assert(x < y);
double code(double x, double y) {
return y / x;
}
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 = y / x
end function
assert x < y;
public static double code(double x, double y) {
return y / x;
}
[x, y] = sort([x, y]) def code(x, y): return y / x
x, y = sort([x, y]) function code(x, y) return Float64(y / x) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = y / x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(y / x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{y}{x}
\end{array}
Initial program 68.9%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6449.2
Applied rewrites49.2%
Taylor expanded in x around 0
Applied rewrites26.5%
herbie shell --seed 2025101
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))