
(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 16 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 (if (<= x -1.2e+94) (/ (/ y x) (+ 1.0 x)) (* x (/ (/ y (+ y x)) (* (+ (+ y x) 1.0) (+ y x))))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.2e+94) {
tmp = (y / x) / (1.0 + x);
} else {
tmp = x * ((y / (y + x)) / (((y + x) + 1.0) * (y + x)));
}
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.2d+94)) then
tmp = (y / x) / (1.0d0 + x)
else
tmp = x * ((y / (y + x)) / (((y + x) + 1.0d0) * (y + x)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.2e+94) {
tmp = (y / x) / (1.0 + x);
} else {
tmp = x * ((y / (y + x)) / (((y + x) + 1.0) * (y + x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.2e+94: tmp = (y / x) / (1.0 + x) else: tmp = x * ((y / (y + x)) / (((y + x) + 1.0) * (y + x))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.2e+94) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); else tmp = Float64(x * Float64(Float64(y / Float64(y + x)) / Float64(Float64(Float64(y + x) + 1.0) * Float64(y + x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.2e+94)
tmp = (y / x) / (1.0 + x);
else
tmp = x * ((y / (y + x)) / (((y + x) + 1.0) * (y + x)));
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.2e+94], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{y}{y + x}}{\left(\left(y + x\right) + 1\right) \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if x < -1.19999999999999991e94Initial program 53.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6491.1
Applied rewrites91.1%
if -1.19999999999999991e94 < x Initial program 72.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/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-+.f6485.3
Applied rewrites85.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
+-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6485.4
Applied rewrites85.4%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f6492.9
Applied rewrites92.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.2e+94)
(/ (/ y x) (+ 1.0 x))
(if (<= x -6.2e-15)
(* x (/ y (* (+ y x) (* (+ y x) (+ (+ y x) 1.0)))))
(* x (/ (/ y (+ y x)) (* (+ y 1.0) (+ y x)))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.2e+94) {
tmp = (y / x) / (1.0 + x);
} else if (x <= -6.2e-15) {
tmp = x * (y / ((y + x) * ((y + x) * ((y + x) + 1.0))));
} else {
tmp = x * ((y / (y + x)) / ((y + 1.0) * (y + x)));
}
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.2d+94)) then
tmp = (y / x) / (1.0d0 + x)
else if (x <= (-6.2d-15)) then
tmp = x * (y / ((y + x) * ((y + x) * ((y + x) + 1.0d0))))
else
tmp = x * ((y / (y + x)) / ((y + 1.0d0) * (y + x)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.2e+94) {
tmp = (y / x) / (1.0 + x);
} else if (x <= -6.2e-15) {
tmp = x * (y / ((y + x) * ((y + x) * ((y + x) + 1.0))));
} else {
tmp = x * ((y / (y + x)) / ((y + 1.0) * (y + x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.2e+94: tmp = (y / x) / (1.0 + x) elif x <= -6.2e-15: tmp = x * (y / ((y + x) * ((y + x) * ((y + x) + 1.0)))) else: tmp = x * ((y / (y + x)) / ((y + 1.0) * (y + x))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.2e+94) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); elseif (x <= -6.2e-15) tmp = Float64(x * Float64(y / Float64(Float64(y + x) * Float64(Float64(y + x) * Float64(Float64(y + x) + 1.0))))); else tmp = Float64(x * Float64(Float64(y / Float64(y + x)) / Float64(Float64(y + 1.0) * Float64(y + x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.2e+94)
tmp = (y / x) / (1.0 + x);
elseif (x <= -6.2e-15)
tmp = x * (y / ((y + x) * ((y + x) * ((y + x) + 1.0))));
else
tmp = x * ((y / (y + x)) / ((y + 1.0) * (y + x)));
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.2e+94], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6.2e-15], N[(x * N[(y / N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(N[(y + 1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-15}:\\
\;\;\;\;x \cdot \frac{y}{\left(y + x\right) \cdot \left(\left(y + x\right) \cdot \left(\left(y + x\right) + 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{y}{y + x}}{\left(y + 1\right) \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if x < -1.19999999999999991e94Initial program 53.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6491.1
Applied rewrites91.1%
if -1.19999999999999991e94 < x < -6.1999999999999998e-15Initial program 81.5%
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-+.f6496.8
Applied rewrites96.8%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
+-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6496.8
Applied rewrites96.8%
if -6.1999999999999998e-15 < x Initial program 71.0%
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-+.f6483.2
Applied rewrites83.2%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
+-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6483.2
Applied rewrites83.2%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f6491.6
Applied rewrites91.6%
Taylor expanded in x around 0
Applied rewrites86.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.2e+94)
(/ (/ y x) (+ 1.0 x))
(if (<= x -1e-162)
(* x (/ y (* (+ y x) (* (+ y x) (+ (+ y x) 1.0)))))
(/ x (fma y 1.0 (* y y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.2e+94) {
tmp = (y / x) / (1.0 + x);
} else if (x <= -1e-162) {
tmp = x * (y / ((y + x) * ((y + x) * ((y + x) + 1.0))));
} else {
tmp = x / fma(y, 1.0, (y * y));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.2e+94) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); elseif (x <= -1e-162) tmp = Float64(x * Float64(y / Float64(Float64(y + x) * Float64(Float64(y + x) * Float64(Float64(y + x) + 1.0))))); else tmp = Float64(x / fma(y, 1.0, Float64(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.2e+94], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-162], N[(x * N[(y / N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * 1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-162}:\\
\;\;\;\;x \cdot \frac{y}{\left(y + x\right) \cdot \left(\left(y + x\right) \cdot \left(\left(y + x\right) + 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, 1, y \cdot y\right)}\\
\end{array}
\end{array}
if x < -1.19999999999999991e94Initial program 53.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6491.1
Applied rewrites91.1%
if -1.19999999999999991e94 < x < -9.99999999999999954e-163Initial program 87.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-+.f6498.0
Applied rewrites98.0%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
+-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6498.0
Applied rewrites98.0%
if -9.99999999999999954e-163 < x Initial program 66.0%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.1
Applied rewrites53.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-inN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6453.1
Applied rewrites53.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.1e+94)
(/ (/ y x) (+ 1.0 x))
(if (<= x -7.5e-159)
(* x (/ y (* (+ y x) (* (+ y x) (+ x 1.0)))))
(/ x (fma y 1.0 (* y y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.1e+94) {
tmp = (y / x) / (1.0 + x);
} else if (x <= -7.5e-159) {
tmp = x * (y / ((y + x) * ((y + x) * (x + 1.0))));
} else {
tmp = x / fma(y, 1.0, (y * y));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.1e+94) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); elseif (x <= -7.5e-159) tmp = Float64(x * Float64(y / Float64(Float64(y + x) * Float64(Float64(y + x) * Float64(x + 1.0))))); else tmp = Float64(x / fma(y, 1.0, Float64(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.1e+94], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -7.5e-159], N[(x * N[(y / N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * 1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{elif}\;x \leq -7.5 \cdot 10^{-159}:\\
\;\;\;\;x \cdot \frac{y}{\left(y + x\right) \cdot \left(\left(y + x\right) \cdot \left(x + 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, 1, y \cdot y\right)}\\
\end{array}
\end{array}
if x < -1.10000000000000006e94Initial program 53.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6491.1
Applied rewrites91.1%
if -1.10000000000000006e94 < x < -7.5e-159Initial program 87.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-+.f6498.0
Applied rewrites98.0%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
+-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6498.0
Applied rewrites98.0%
Taylor expanded in x around inf
Applied rewrites79.9%
if -7.5e-159 < x Initial program 66.0%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.1
Applied rewrites53.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-inN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6453.1
Applied rewrites53.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.1e+94)
(/ (/ y x) (+ 1.0 x))
(if (<= x -3.2e-86)
(* x (/ y (* (+ y x) (* (+ 1.0 x) x))))
(/ x (fma y 1.0 (* y y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.1e+94) {
tmp = (y / x) / (1.0 + x);
} else if (x <= -3.2e-86) {
tmp = x * (y / ((y + x) * ((1.0 + x) * x)));
} else {
tmp = x / fma(y, 1.0, (y * y));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.1e+94) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); elseif (x <= -3.2e-86) tmp = Float64(x * Float64(y / Float64(Float64(y + x) * Float64(Float64(1.0 + x) * x)))); else tmp = Float64(x / fma(y, 1.0, Float64(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.1e+94], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.2e-86], N[(x * N[(y / N[(N[(y + x), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * 1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;x \cdot \frac{y}{\left(y + x\right) \cdot \left(\left(1 + x\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, 1, y \cdot y\right)}\\
\end{array}
\end{array}
if x < -1.10000000000000006e94Initial program 53.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6491.1
Applied rewrites91.1%
if -1.10000000000000006e94 < x < -3.20000000000000006e-86Initial program 87.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-+.f6497.8
Applied rewrites97.8%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
+-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f6497.9
Applied rewrites97.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-+.f6463.0
Applied rewrites63.0%
if -3.20000000000000006e-86 < x Initial program 67.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.6
Applied rewrites53.6%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-inN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ y (* x x))
(if (<= x -6e-114)
(/ (fma (- x) y y) x)
(if (<= x 2.8e-184) (/ x y) (/ x (* y y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = y / (x * x);
} else if (x <= -6e-114) {
tmp = fma(-x, y, y) / x;
} else if (x <= 2.8e-184) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(y / Float64(x * x)); elseif (x <= -6e-114) tmp = Float64(fma(Float64(-x), y, y) / x); elseif (x <= 2.8e-184) tmp = Float64(x / y); else tmp = Float64(x / Float64(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.0], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6e-114], N[(N[((-x) * y + y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 2.8e-184], N[(x / y), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-114}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x, y, y\right)}{x}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-184}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -1Initial program 61.7%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
if -1 < x < -6.0000000000000003e-114Initial program 94.0%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6449.5
Applied rewrites49.5%
Taylor expanded in x around 0
Applied rewrites48.6%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6449.5
Applied rewrites49.5%
if -6.0000000000000003e-114 < x < 2.7999999999999998e-184Initial program 63.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in y around 0
Applied rewrites76.4%
if 2.7999999999999998e-184 < x Initial program 68.8%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6431.0
Applied rewrites31.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ y (* x x))
(if (<= x -6e-114)
(fma -1.0 y (/ y x))
(if (<= x 2.8e-184) (/ x y) (/ x (* y y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = y / (x * x);
} else if (x <= -6e-114) {
tmp = fma(-1.0, y, (y / x));
} else if (x <= 2.8e-184) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(y / Float64(x * x)); elseif (x <= -6e-114) tmp = fma(-1.0, y, Float64(y / x)); elseif (x <= 2.8e-184) tmp = Float64(x / y); else tmp = Float64(x / Float64(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.0], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6e-114], N[(-1.0 * y + N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e-184], N[(x / y), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-114}:\\
\;\;\;\;\mathsf{fma}\left(-1, y, \frac{y}{x}\right)\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-184}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -1Initial program 61.7%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
if -1 < x < -6.0000000000000003e-114Initial program 94.0%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6449.5
Applied rewrites49.5%
Taylor expanded in x around 0
Applied rewrites48.6%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6449.5
Applied rewrites49.5%
Taylor expanded in x around inf
lower-fma.f64N/A
lower-/.f6449.5
Applied rewrites49.5%
if -6.0000000000000003e-114 < x < 2.7999999999999998e-184Initial program 63.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in y around 0
Applied rewrites76.4%
if 2.7999999999999998e-184 < x Initial program 68.8%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6431.0
Applied rewrites31.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.0) (/ y (* x x)) (if (<= x -6e-114) (/ y x) (if (<= x 2.8e-184) (/ x y) (/ x (* y y))))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = y / (x * x);
} else if (x <= -6e-114) {
tmp = y / x;
} else if (x <= 2.8e-184) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = y / (x * x)
else if (x <= (-6d-114)) then
tmp = y / x
else if (x <= 2.8d-184) then
tmp = x / y
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = y / (x * x);
} else if (x <= -6e-114) {
tmp = y / x;
} else if (x <= 2.8e-184) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.0: tmp = y / (x * x) elif x <= -6e-114: tmp = y / x elif x <= 2.8e-184: tmp = x / y else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(y / Float64(x * x)); elseif (x <= -6e-114) tmp = Float64(y / x); elseif (x <= 2.8e-184) tmp = Float64(x / y); else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.0)
tmp = y / (x * x);
elseif (x <= -6e-114)
tmp = y / x;
elseif (x <= 2.8e-184)
tmp = x / y;
else
tmp = x / (y * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.0], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6e-114], N[(y / x), $MachinePrecision], If[LessEqual[x, 2.8e-184], N[(x / y), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-114}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-184}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -1Initial program 61.7%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
if -1 < x < -6.0000000000000003e-114Initial program 94.0%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6449.5
Applied rewrites49.5%
Taylor expanded in x around 0
Applied rewrites48.6%
if -6.0000000000000003e-114 < x < 2.7999999999999998e-184Initial program 63.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in y around 0
Applied rewrites76.4%
if 2.7999999999999998e-184 < x Initial program 68.8%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6431.0
Applied rewrites31.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.0) (/ y (* x x)) (if (<= x -3.2e-86) (/ (fma (- x) y y) x) (/ x (* (+ 1.0 y) y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = y / (x * x);
} else if (x <= -3.2e-86) {
tmp = fma(-x, y, y) / x;
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(y / Float64(x * x)); elseif (x <= -3.2e-86) tmp = Float64(fma(Float64(-x), y, y) / x); 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_] := If[LessEqual[x, -1.0], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.2e-86], N[(N[((-x) * y + y), $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 -1:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x, y, y\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -1Initial program 61.7%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
if -1 < x < -3.20000000000000006e-86Initial program 96.3%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
Taylor expanded in x around 0
Applied rewrites48.2%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6449.4
Applied rewrites49.4%
if -3.20000000000000006e-86 < x Initial program 67.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.6
Applied rewrites53.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -3.2e-86) (/ (/ y x) (+ 1.0 x)) (/ x (fma y 1.0 (* y y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.2e-86) {
tmp = (y / x) / (1.0 + x);
} else {
tmp = x / fma(y, 1.0, (y * y));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3.2e-86) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); else tmp = Float64(x / fma(y, 1.0, Float64(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, -3.2e-86], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * 1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, 1, y \cdot y\right)}\\
\end{array}
\end{array}
if x < -3.20000000000000006e-86Initial program 72.5%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6467.2
Applied rewrites67.2%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f6468.8
Applied rewrites68.8%
if -3.20000000000000006e-86 < x Initial program 67.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.6
Applied rewrites53.6%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-inN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 4.3e-145) (/ y x) (if (<= y 1.0) (/ x y) (/ x (* y y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.3e-145) {
tmp = y / x;
} else if (y <= 1.0) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.3d-145) then
tmp = y / x
else if (y <= 1.0d0) then
tmp = x / y
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4.3e-145) {
tmp = y / x;
} else if (y <= 1.0) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.3e-145: tmp = y / x elif y <= 1.0: tmp = x / y else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.3e-145) tmp = Float64(y / x); elseif (y <= 1.0) tmp = Float64(x / y); else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4.3e-145)
tmp = y / x;
elseif (y <= 1.0)
tmp = x / y;
else
tmp = x / (y * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 4.3e-145], N[(y / x), $MachinePrecision], If[LessEqual[y, 1.0], N[(x / y), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{-145}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if y < 4.2999999999999999e-145Initial program 66.7%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6458.8
Applied rewrites58.8%
Taylor expanded in x around 0
Applied rewrites40.9%
if 4.2999999999999999e-145 < y < 1Initial program 89.8%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6437.9
Applied rewrites37.9%
Taylor expanded in y around 0
Applied rewrites37.6%
if 1 < y Initial program 68.8%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6472.4
Applied rewrites72.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -3.2e-86) (/ y (* (+ 1.0 x) x)) (/ x (fma y 1.0 (* y y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.2e-86) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / fma(y, 1.0, (y * y));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3.2e-86) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(x / fma(y, 1.0, Float64(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, -3.2e-86], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * 1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, 1, y \cdot y\right)}\\
\end{array}
\end{array}
if x < -3.20000000000000006e-86Initial program 72.5%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6467.2
Applied rewrites67.2%
if -3.20000000000000006e-86 < x Initial program 67.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.6
Applied rewrites53.6%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-inN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -3.2e-86) (/ y (* (+ 1.0 x) x)) (/ x (* (+ 1.0 y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.2e-86) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3.2d-86)) then
tmp = y / ((1.0d0 + x) * x)
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -3.2e-86) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -3.2e-86: tmp = y / ((1.0 + x) * x) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3.2e-86) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -3.2e-86)
tmp = y / ((1.0 + x) * x);
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -3.2e-86], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -3.20000000000000006e-86Initial program 72.5%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6467.2
Applied rewrites67.2%
if -3.20000000000000006e-86 < x Initial program 67.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.6
Applied rewrites53.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -6e-114) (/ y x) (/ x y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -6e-114) {
tmp = y / x;
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-6d-114)) then
tmp = y / x
else
tmp = x / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -6e-114) {
tmp = y / x;
} else {
tmp = x / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -6e-114: tmp = y / x else: tmp = x / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -6e-114) tmp = Float64(y / x); else tmp = Float64(x / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -6e-114)
tmp = y / x;
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -6e-114], N[(y / x), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-114}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -6.0000000000000003e-114Initial program 72.7%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6466.6
Applied rewrites66.6%
Taylor expanded in x around 0
Applied rewrites36.6%
if -6.0000000000000003e-114 < x Initial program 66.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6453.7
Applied rewrites53.7%
Taylor expanded in y around 0
Applied rewrites34.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x y))
assert(x < y);
double code(double x, double y) {
return x / y;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
assert x < y;
public static double code(double x, double y) {
return x / y;
}
[x, y] = sort([x, y]) def code(x, y): return x / y
x, y = sort([x, y]) function code(x, y) return Float64(x / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y}
\end{array}
Initial program 69.3%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6445.4
Applied rewrites45.4%
Taylor expanded in y around 0
Applied rewrites22.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (- y))
assert(x < y);
double code(double x, double y) {
return -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 = -y
end function
assert x < y;
public static double code(double x, double y) {
return -y;
}
[x, y] = sort([x, y]) def code(x, y): return -y
x, y = sort([x, y]) function code(x, y) return Float64(-y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = -y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := (-y)
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
-y
\end{array}
Initial program 69.3%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6452.1
Applied rewrites52.1%
Taylor expanded in x around 0
Applied rewrites30.0%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6416.0
Applied rewrites16.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f643.8
Applied rewrites3.8%
(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 2025051
(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))))