
(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 (* (/ x (+ y x)) (/ (/ y (+ 1.0 (+ y x))) (+ y x))))
assert(x < y);
double code(double x, double y) {
return (x / (y + x)) * ((y / (1.0 + (y + x))) / (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 = (x / (y + x)) * ((y / (1.0d0 + (y + x))) / (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return (x / (y + x)) * ((y / (1.0 + (y + x))) / (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return (x / (y + x)) * ((y / (1.0 + (y + x))) / (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(y + x)) * Float64(Float64(y / Float64(1.0 + Float64(y + x))) / Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / (y + x)) * ((y / (1.0 + (y + x))) / (y + x));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(N[(y / N[(1.0 + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y + x} \cdot \frac{\frac{y}{1 + \left(y + x\right)}}{y + x}
\end{array}
Initial program 69.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.75e-119)
(* 1.0 (/ (/ y (+ 1.0 (+ y x))) (+ y x)))
(if (<= y 5e+136)
(/ (* x 1.0) (* (+ y x) (+ (+ 1.0 x) y)))
(* (/ x (+ y x)) (pow (+ 1.0 y) -1.0)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.75e-119) {
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
} else if (y <= 5e+136) {
tmp = (x * 1.0) / ((y + x) * ((1.0 + x) + y));
} else {
tmp = (x / (y + x)) * pow((1.0 + y), -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 <= 1.75d-119) then
tmp = 1.0d0 * ((y / (1.0d0 + (y + x))) / (y + x))
else if (y <= 5d+136) then
tmp = (x * 1.0d0) / ((y + x) * ((1.0d0 + x) + y))
else
tmp = (x / (y + x)) * ((1.0d0 + y) ** (-1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.75e-119) {
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
} else if (y <= 5e+136) {
tmp = (x * 1.0) / ((y + x) * ((1.0 + x) + y));
} else {
tmp = (x / (y + x)) * Math.pow((1.0 + y), -1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.75e-119: tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x)) elif y <= 5e+136: tmp = (x * 1.0) / ((y + x) * ((1.0 + x) + y)) else: tmp = (x / (y + x)) * math.pow((1.0 + y), -1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.75e-119) tmp = Float64(1.0 * Float64(Float64(y / Float64(1.0 + Float64(y + x))) / Float64(y + x))); elseif (y <= 5e+136) tmp = Float64(Float64(x * 1.0) / Float64(Float64(y + x) * Float64(Float64(1.0 + x) + y))); else tmp = Float64(Float64(x / Float64(y + x)) * (Float64(1.0 + y) ^ -1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.75e-119)
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
elseif (y <= 5e+136)
tmp = (x * 1.0) / ((y + x) * ((1.0 + x) + y));
else
tmp = (x / (y + x)) * ((1.0 + y) ^ -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, 1.75e-119], N[(1.0 * N[(N[(y / N[(1.0 + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+136], N[(N[(x * 1.0), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[Power[N[(1.0 + y), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.75 \cdot 10^{-119}:\\
\;\;\;\;1 \cdot \frac{\frac{y}{1 + \left(y + x\right)}}{y + x}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+136}:\\
\;\;\;\;\frac{x \cdot 1}{\left(y + x\right) \cdot \left(\left(1 + x\right) + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot {\left(1 + y\right)}^{-1}\\
\end{array}
\end{array}
if y < 1.75e-119Initial program 68.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites62.2%
if 1.75e-119 < y < 5.0000000000000002e136Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6489.3
Applied rewrites96.8%
Taylor expanded in x around 0
Applied rewrites76.9%
if 5.0000000000000002e136 < y Initial program 56.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6484.3
Applied rewrites84.3%
Final simplification68.5%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.75e-119)
(/ y (fma x x x))
(if (<= y 5e+136)
(/ (* x 1.0) (* (+ y x) (+ (+ 1.0 x) y)))
(* (/ x (+ y x)) (pow (+ 1.0 y) -1.0)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.75e-119) {
tmp = y / fma(x, x, x);
} else if (y <= 5e+136) {
tmp = (x * 1.0) / ((y + x) * ((1.0 + x) + y));
} else {
tmp = (x / (y + x)) * pow((1.0 + y), -1.0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.75e-119) tmp = Float64(y / fma(x, x, x)); elseif (y <= 5e+136) tmp = Float64(Float64(x * 1.0) / Float64(Float64(y + x) * Float64(Float64(1.0 + x) + y))); else tmp = Float64(Float64(x / Float64(y + x)) * (Float64(1.0 + y) ^ -1.0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.75e-119], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+136], N[(N[(x * 1.0), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[Power[N[(1.0 + y), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.75 \cdot 10^{-119}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+136}:\\
\;\;\;\;\frac{x \cdot 1}{\left(y + x\right) \cdot \left(\left(1 + x\right) + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot {\left(1 + y\right)}^{-1}\\
\end{array}
\end{array}
if y < 1.75e-119Initial program 68.4%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6459.7
Applied rewrites59.7%
if 1.75e-119 < y < 5.0000000000000002e136Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6489.3
Applied rewrites96.8%
Taylor expanded in x around 0
Applied rewrites76.9%
if 5.0000000000000002e136 < y Initial program 56.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6484.3
Applied rewrites84.3%
Final simplification66.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.75e-119)
(/ y (fma x x x))
(if (<= y 5e+136)
(/ (* x 1.0) (* (+ y x) (+ (+ 1.0 x) y)))
(* (/ x (+ y x)) (pow y -1.0)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.75e-119) {
tmp = y / fma(x, x, x);
} else if (y <= 5e+136) {
tmp = (x * 1.0) / ((y + x) * ((1.0 + x) + y));
} else {
tmp = (x / (y + x)) * pow(y, -1.0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.75e-119) tmp = Float64(y / fma(x, x, x)); elseif (y <= 5e+136) tmp = Float64(Float64(x * 1.0) / Float64(Float64(y + x) * Float64(Float64(1.0 + x) + y))); else tmp = Float64(Float64(x / Float64(y + x)) * (y ^ -1.0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.75e-119], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+136], N[(N[(x * 1.0), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[Power[y, -1.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.75 \cdot 10^{-119}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+136}:\\
\;\;\;\;\frac{x \cdot 1}{\left(y + x\right) \cdot \left(\left(1 + x\right) + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot {y}^{-1}\\
\end{array}
\end{array}
if y < 1.75e-119Initial program 68.4%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6459.7
Applied rewrites59.7%
if 1.75e-119 < y < 5.0000000000000002e136Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6489.3
Applied rewrites96.8%
Taylor expanded in x around 0
Applied rewrites76.9%
if 5.0000000000000002e136 < y Initial program 56.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
lower-/.f6484.3
Applied rewrites84.3%
Final simplification66.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -4.2e+90)
(* 1.0 (/ (/ y (+ 1.0 (+ y x))) (+ y x)))
(if (<= x -2.15e-116)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(/ (/ x (+ 1.0 y)) y))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -4.2e+90) {
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
} else if (x <= -2.15e-116) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + 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 <= (-4.2d+90)) then
tmp = 1.0d0 * ((y / (1.0d0 + (y + x))) / (y + x))
else if (x <= (-2.15d-116)) then
tmp = (x * y) / (((x + y) * (x + y)) * ((x + 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 <= -4.2e+90) {
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
} else if (x <= -2.15e-116) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + 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 <= -4.2e+90: tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x)) elif x <= -2.15e-116: tmp = (x * y) / (((x + y) * (x + y)) * ((x + 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 <= -4.2e+90) tmp = Float64(1.0 * Float64(Float64(y / Float64(1.0 + Float64(y + x))) / Float64(y + x))); elseif (x <= -2.15e-116) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(x / 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 <= -4.2e+90)
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
elseif (x <= -2.15e-116)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + 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, -4.2e+90], N[(1.0 * N[(N[(y / N[(1.0 + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.15e-116], 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 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+90}:\\
\;\;\;\;1 \cdot \frac{\frac{y}{1 + \left(y + x\right)}}{y + x}\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-116}:\\
\;\;\;\;\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}{1 + y}}{y}\\
\end{array}
\end{array}
if x < -4.19999999999999961e90Initial program 58.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites89.3%
if -4.19999999999999961e90 < x < -2.1499999999999999e-116Initial program 81.2%
if -2.1499999999999999e-116 < x Initial program 69.8%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6458.3
Applied rewrites58.3%
Applied rewrites58.3%
Final simplification66.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ 1.0 x) y)))
(if (<= y 5e+136)
(/ (* x (/ y (+ y x))) (* (+ y x) t_0))
(/ (* x (/ 1.0 t_0)) (+ x y)))))assert(x < y);
double code(double x, double y) {
double t_0 = (1.0 + x) + y;
double tmp;
if (y <= 5e+136) {
tmp = (x * (y / (y + x))) / ((y + x) * t_0);
} else {
tmp = (x * (1.0 / t_0)) / (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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 + x) + y
if (y <= 5d+136) then
tmp = (x * (y / (y + x))) / ((y + x) * t_0)
else
tmp = (x * (1.0d0 / t_0)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (1.0 + x) + y;
double tmp;
if (y <= 5e+136) {
tmp = (x * (y / (y + x))) / ((y + x) * t_0);
} else {
tmp = (x * (1.0 / t_0)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (1.0 + x) + y tmp = 0 if y <= 5e+136: tmp = (x * (y / (y + x))) / ((y + x) * t_0) else: tmp = (x * (1.0 / t_0)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(1.0 + x) + y) tmp = 0.0 if (y <= 5e+136) tmp = Float64(Float64(x * Float64(y / Float64(y + x))) / Float64(Float64(y + x) * t_0)); else tmp = Float64(Float64(x * Float64(1.0 / t_0)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (1.0 + x) + y;
tmp = 0.0;
if (y <= 5e+136)
tmp = (x * (y / (y + x))) / ((y + x) * t_0);
else
tmp = (x * (1.0 / t_0)) / (x + 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[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[y, 5e+136], N[(N[(x * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(1 + x\right) + y\\
\mathbf{if}\;y \leq 5 \cdot 10^{+136}:\\
\;\;\;\;\frac{x \cdot \frac{y}{y + x}}{\left(y + x\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{1}{t\_0}}{x + y}\\
\end{array}
\end{array}
if y < 5.0000000000000002e136Initial program 71.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6477.2
Applied rewrites96.5%
if 5.0000000000000002e136 < y Initial program 56.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6456.9
Applied rewrites87.7%
Taylor expanded in x around 0
Applied rewrites87.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f6484.7
Applied rewrites84.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5e+136) (* (/ y (+ y x)) (/ x (* (+ 1.0 (+ y x)) (+ y x)))) (/ (* x (/ 1.0 (+ (+ 1.0 x) y))) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5e+136) {
tmp = (y / (y + x)) * (x / ((1.0 + (y + x)) * (y + x)));
} else {
tmp = (x * (1.0 / ((1.0 + x) + y))) / (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 (y <= 5d+136) then
tmp = (y / (y + x)) * (x / ((1.0d0 + (y + x)) * (y + x)))
else
tmp = (x * (1.0d0 / ((1.0d0 + x) + y))) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5e+136) {
tmp = (y / (y + x)) * (x / ((1.0 + (y + x)) * (y + x)));
} else {
tmp = (x * (1.0 / ((1.0 + x) + y))) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5e+136: tmp = (y / (y + x)) * (x / ((1.0 + (y + x)) * (y + x))) else: tmp = (x * (1.0 / ((1.0 + x) + y))) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5e+136) tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(1.0 + Float64(y + x)) * Float64(y + x)))); else tmp = Float64(Float64(x * Float64(1.0 / Float64(Float64(1.0 + x) + y))) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5e+136)
tmp = (y / (y + x)) * (x / ((1.0 + (y + x)) * (y + x)));
else
tmp = (x * (1.0 / ((1.0 + x) + y))) / (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[y, 5e+136], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(1.0 + N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 / N[(N[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+136}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(1 + \left(y + x\right)\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{1}{\left(1 + x\right) + y}}{x + y}\\
\end{array}
\end{array}
if y < 5.0000000000000002e136Initial program 71.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.5
lift-+.f64N/A
+-commutativeN/A
lower-+.f6496.5
lift-+.f64N/A
+-commutativeN/A
lower-+.f6496.5
lift-+.f64N/A
+-commutativeN/A
lower-+.f6496.5
Applied rewrites96.5%
if 5.0000000000000002e136 < y Initial program 56.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6456.9
Applied rewrites87.7%
Taylor expanded in x around 0
Applied rewrites87.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f6484.7
Applied rewrites84.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ 1.0 x) y)))
(if (<= x 7e-279)
(* y (/ (/ x (+ y x)) (* (+ y x) t_0)))
(/ (* x (/ 1.0 t_0)) (+ x y)))))assert(x < y);
double code(double x, double y) {
double t_0 = (1.0 + x) + y;
double tmp;
if (x <= 7e-279) {
tmp = y * ((x / (y + x)) / ((y + x) * t_0));
} else {
tmp = (x * (1.0 / t_0)) / (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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 + x) + y
if (x <= 7d-279) then
tmp = y * ((x / (y + x)) / ((y + x) * t_0))
else
tmp = (x * (1.0d0 / t_0)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (1.0 + x) + y;
double tmp;
if (x <= 7e-279) {
tmp = y * ((x / (y + x)) / ((y + x) * t_0));
} else {
tmp = (x * (1.0 / t_0)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (1.0 + x) + y tmp = 0 if x <= 7e-279: tmp = y * ((x / (y + x)) / ((y + x) * t_0)) else: tmp = (x * (1.0 / t_0)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(1.0 + x) + y) tmp = 0.0 if (x <= 7e-279) tmp = Float64(y * Float64(Float64(x / Float64(y + x)) / Float64(Float64(y + x) * t_0))); else tmp = Float64(Float64(x * Float64(1.0 / t_0)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (1.0 + x) + y;
tmp = 0.0;
if (x <= 7e-279)
tmp = y * ((x / (y + x)) / ((y + x) * t_0));
else
tmp = (x * (1.0 / t_0)) / (x + 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[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[x, 7e-279], N[(y * N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(1 + x\right) + y\\
\mathbf{if}\;x \leq 7 \cdot 10^{-279}:\\
\;\;\;\;y \cdot \frac{\frac{x}{y + x}}{\left(y + x\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{1}{t\_0}}{x + y}\\
\end{array}
\end{array}
if x < 7.00000000000000019e-279Initial program 67.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6495.3
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f6495.3
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f6495.3
Applied rewrites95.3%
if 7.00000000000000019e-279 < x Initial program 71.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6476.1
Applied rewrites94.8%
Taylor expanded in x around 0
Applied rewrites65.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f6447.6
Applied rewrites47.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ 1.0 x) y)))
(if (<= y 1.75e-119)
(* 1.0 (/ (/ y (+ 1.0 (+ y x))) (+ y x)))
(if (<= y 5e+136)
(/ (* x 1.0) (* (+ y x) t_0))
(/ (* x (/ 1.0 t_0)) (+ x y))))))assert(x < y);
double code(double x, double y) {
double t_0 = (1.0 + x) + y;
double tmp;
if (y <= 1.75e-119) {
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
} else if (y <= 5e+136) {
tmp = (x * 1.0) / ((y + x) * t_0);
} else {
tmp = (x * (1.0 / t_0)) / (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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 + x) + y
if (y <= 1.75d-119) then
tmp = 1.0d0 * ((y / (1.0d0 + (y + x))) / (y + x))
else if (y <= 5d+136) then
tmp = (x * 1.0d0) / ((y + x) * t_0)
else
tmp = (x * (1.0d0 / t_0)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (1.0 + x) + y;
double tmp;
if (y <= 1.75e-119) {
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
} else if (y <= 5e+136) {
tmp = (x * 1.0) / ((y + x) * t_0);
} else {
tmp = (x * (1.0 / t_0)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (1.0 + x) + y tmp = 0 if y <= 1.75e-119: tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x)) elif y <= 5e+136: tmp = (x * 1.0) / ((y + x) * t_0) else: tmp = (x * (1.0 / t_0)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(1.0 + x) + y) tmp = 0.0 if (y <= 1.75e-119) tmp = Float64(1.0 * Float64(Float64(y / Float64(1.0 + Float64(y + x))) / Float64(y + x))); elseif (y <= 5e+136) tmp = Float64(Float64(x * 1.0) / Float64(Float64(y + x) * t_0)); else tmp = Float64(Float64(x * Float64(1.0 / t_0)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (1.0 + x) + y;
tmp = 0.0;
if (y <= 1.75e-119)
tmp = 1.0 * ((y / (1.0 + (y + x))) / (y + x));
elseif (y <= 5e+136)
tmp = (x * 1.0) / ((y + x) * t_0);
else
tmp = (x * (1.0 / t_0)) / (x + 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[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[y, 1.75e-119], N[(1.0 * N[(N[(y / N[(1.0 + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+136], N[(N[(x * 1.0), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(1 + x\right) + y\\
\mathbf{if}\;y \leq 1.75 \cdot 10^{-119}:\\
\;\;\;\;1 \cdot \frac{\frac{y}{1 + \left(y + x\right)}}{y + x}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+136}:\\
\;\;\;\;\frac{x \cdot 1}{\left(y + x\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{1}{t\_0}}{x + y}\\
\end{array}
\end{array}
if y < 1.75e-119Initial program 68.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites62.2%
if 1.75e-119 < y < 5.0000000000000002e136Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6489.3
Applied rewrites96.8%
Taylor expanded in x around 0
Applied rewrites76.9%
if 5.0000000000000002e136 < y Initial program 56.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f6456.9
Applied rewrites87.7%
Taylor expanded in x around 0
Applied rewrites87.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f6484.7
Applied rewrites84.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.12e-110) (/ y (fma x x x)) (if (<= y 7e+90) (/ x (fma y y y)) (/ (/ x y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.12e-110) {
tmp = y / fma(x, x, x);
} else if (y <= 7e+90) {
tmp = x / fma(y, y, y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.12e-110) tmp = Float64(y / fma(x, x, x)); elseif (y <= 7e+90) tmp = Float64(x / fma(y, y, y)); else tmp = Float64(Float64(x / y) / y); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.12e-110], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e+90], N[(x / N[(y * y + 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.12 \cdot 10^{-110}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+90}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < 1.11999999999999998e-110Initial program 68.4%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6459.7
Applied rewrites59.7%
if 1.11999999999999998e-110 < y < 6.9999999999999997e90Initial program 89.8%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6462.6
Applied rewrites62.6%
if 6.9999999999999997e90 < y Initial program 52.0%
Taylor expanded in y around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.7
Applied rewrites74.7%
Final simplification63.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.12e-110) (/ y (fma x x x)) (/ (/ x (+ 1.0 y)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.12e-110) {
tmp = y / fma(x, x, x);
} else {
tmp = (x / (1.0 + y)) / y;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.12e-110) tmp = Float64(y / fma(x, x, x)); else tmp = Float64(Float64(x / 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_] := If[LessEqual[y, 1.12e-110], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{-110}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y}\\
\end{array}
\end{array}
if y < 1.11999999999999998e-110Initial program 68.4%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6459.7
Applied rewrites59.7%
if 1.11999999999999998e-110 < y Initial program 71.1%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6468.7
Applied rewrites68.7%
Applied rewrites68.6%
Final simplification63.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.12e-110) (/ y (fma x x x)) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.12e-110) {
tmp = y / fma(x, x, x);
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.12e-110) tmp = Float64(y / fma(x, x, x)); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.12e-110], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{-110}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if y < 1.11999999999999998e-110Initial program 68.4%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6459.7
Applied rewrites59.7%
if 1.11999999999999998e-110 < y Initial program 71.1%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6468.7
Applied rewrites68.7%
Final simplification63.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.02e+18) (/ y (* x x)) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.02e+18) {
tmp = y / (x * x);
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.02e+18) tmp = Float64(y / Float64(x * x)); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.02e+18], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+18}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -1.02e18Initial program 63.2%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
Applied rewrites75.8%
if -1.02e18 < x Initial program 71.0%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6458.9
Applied rewrites58.9%
Final simplification62.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.02e+18) (/ y (* x x)) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.02e+18) {
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 (x <= (-1.02d+18)) 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 (x <= -1.02e+18) {
tmp = y / (x * x);
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.02e+18: tmp = y / (x * x) else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.02e+18) tmp = Float64(y / Float64(x * 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 (x <= -1.02e+18)
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[x, -1.02e+18], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+18}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -1.02e18Initial program 63.2%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
Applied rewrites75.8%
if -1.02e18 < x Initial program 71.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6440.1
Applied rewrites40.1%
Final simplification47.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (* y y)))
assert(x < y);
double code(double x, double y) {
return x / (y * 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 * y)
end function
assert x < y;
public static double code(double x, double y) {
return x / (y * y);
}
[x, y] = sort([x, y]) def code(x, y): return x / (y * y)
x, y = sort([x, y]) function code(x, y) return Float64(x / Float64(y * y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / (y * y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y \cdot y}
\end{array}
Initial program 69.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6436.4
Applied rewrites36.4%
(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 2024363
(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))))