
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
Herbie found 18 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 (+ y x)) (/ -1.0 (- (- -1.0 x) y)))))
assert(x < y);
double code(double x, double y) {
return (x / (y + x)) * ((y / (y + x)) * (-1.0 / ((-1.0 - 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 + x)) * ((y / (y + x)) * ((-1.0d0) / (((-1.0d0) - x) - y)))
end function
assert x < y;
public static double code(double x, double y) {
return (x / (y + x)) * ((y / (y + x)) * (-1.0 / ((-1.0 - x) - y)));
}
[x, y] = sort([x, y]) def code(x, y): return (x / (y + x)) * ((y / (y + x)) * (-1.0 / ((-1.0 - x) - y)))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(y + x)) * Float64(Float64(y / Float64(y + x)) * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / (y + x)) * ((y / (y + x)) * (-1.0 / ((-1.0 - x) - y)));
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[(y + x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y + x} \cdot \left(\frac{y}{y + x} \cdot \frac{-1}{\left(-1 - x\right) - y}\right)
\end{array}
Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1e-38) (/ (/ (* (/ y (+ x y)) x) (- x -1.0)) (+ x y)) (/ (/ (* (/ y (- y (- -1.0 x))) x) (+ y x)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1e-38) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else {
tmp = (((y / (y - (-1.0 - x))) * x) / (y + x)) / (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 (y <= 1d-38) then
tmp = (((y / (x + y)) * x) / (x - (-1.0d0))) / (x + y)
else
tmp = (((y / (y - ((-1.0d0) - x))) * x) / (y + x)) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1e-38) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else {
tmp = (((y / (y - (-1.0 - x))) * x) / (y + x)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1e-38: tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y) else: tmp = (((y / (y - (-1.0 - x))) * x) / (y + x)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1e-38) tmp = Float64(Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(x - -1.0)) / Float64(x + y)); else tmp = Float64(Float64(Float64(Float64(y / Float64(y - Float64(-1.0 - x))) * x) / Float64(y + x)) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1e-38)
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
else
tmp = (((y / (y - (-1.0 - x))) * x) / (y + x)) / (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[y, 1e-38], N[(N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{-38}:\\
\;\;\;\;\frac{\frac{\frac{y}{x + y} \cdot x}{x - -1}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{y}{y - \left(-1 - x\right)} \cdot x}{y + x}}{y + x}\\
\end{array}
\end{array}
if y < 9.9999999999999996e-39Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
frac-timesN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
Applied rewrites74.5%
if 9.9999999999999996e-39 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y -5e-157)
(/ (/ (* (/ y (+ x y)) x) (- x -1.0)) (+ x y))
(if (<= y 4e+163)
(* (/ y (+ y x)) (/ x (* (- y (- -1.0 x)) (+ y x))))
(* (/ x (+ y x)) (* 1.0 (/ -1.0 (- (- -1.0 x) y)))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -5e-157) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else if (y <= 4e+163) {
tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x)));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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) :: tmp
if (y <= (-5d-157)) then
tmp = (((y / (x + y)) * x) / (x - (-1.0d0))) / (x + y)
else if (y <= 4d+163) then
tmp = (y / (y + x)) * (x / ((y - ((-1.0d0) - x)) * (y + x)))
else
tmp = (x / (y + x)) * (1.0d0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= -5e-157) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else if (y <= 4e+163) {
tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x)));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= -5e-157: tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y) elif y <= 4e+163: tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x))) else: tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= -5e-157) tmp = Float64(Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(x - -1.0)) / Float64(x + y)); elseif (y <= 4e+163) tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(y - Float64(-1.0 - x)) * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= -5e-157)
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
elseif (y <= 4e+163)
tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x)));
else
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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_] := If[LessEqual[y, -5e-157], N[(N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+163], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-157}:\\
\;\;\;\;\frac{\frac{\frac{y}{x + y} \cdot x}{x - -1}}{x + y}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+163}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(y - \left(-1 - x\right)\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \left(1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < -5.0000000000000002e-157Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
frac-timesN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
Applied rewrites74.5%
if -5.0000000000000002e-157 < y < 3.9999999999999998e163Initial program 69.5%
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-*.f6493.8
Applied rewrites93.8%
if 3.9999999999999998e163 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites52.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= y -1.05e+89)
(* (/ (/ y (+ y x)) (+ y x)) (/ x (- x -1.0)))
(if (<= y 4e+163)
(* (/ y (* (- y (- -1.0 x)) (+ y x))) t_0)
(* t_0 (* 1.0 (/ -1.0 (- (- -1.0 x) y))))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -1.05e+89) {
tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0));
} else if (y <= 4e+163) {
tmp = (y / ((y - (-1.0 - x)) * (y + x))) * t_0;
} else {
tmp = t_0 * (1.0 * (-1.0 / ((-1.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 = x / (y + x)
if (y <= (-1.05d+89)) then
tmp = ((y / (y + x)) / (y + x)) * (x / (x - (-1.0d0)))
else if (y <= 4d+163) then
tmp = (y / ((y - ((-1.0d0) - x)) * (y + x))) * t_0
else
tmp = t_0 * (1.0d0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -1.05e+89) {
tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0));
} else if (y <= 4e+163) {
tmp = (y / ((y - (-1.0 - x)) * (y + x))) * t_0;
} else {
tmp = t_0 * (1.0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if y <= -1.05e+89: tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0)) elif y <= 4e+163: tmp = (y / ((y - (-1.0 - x)) * (y + x))) * t_0 else: tmp = t_0 * (1.0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (y <= -1.05e+89) tmp = Float64(Float64(Float64(y / Float64(y + x)) / Float64(y + x)) * Float64(x / Float64(x - -1.0))); elseif (y <= 4e+163) tmp = Float64(Float64(y / Float64(Float64(y - Float64(-1.0 - x)) * Float64(y + x))) * t_0); else tmp = Float64(t_0 * Float64(1.0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (y <= -1.05e+89)
tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0));
elseif (y <= 4e+163)
tmp = (y / ((y - (-1.0 - x)) * (y + x))) * t_0;
else
tmp = t_0 * (1.0 * (-1.0 / ((-1.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[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.05e+89], N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+163], N[(N[(y / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[(1.0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{+89}:\\
\;\;\;\;\frac{\frac{y}{y + x}}{y + x} \cdot \frac{x}{x - -1}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+163}:\\
\;\;\;\;\frac{y}{\left(y - \left(-1 - x\right)\right) \cdot \left(y + x\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < -1.04999999999999993e89Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites74.4%
if -1.04999999999999993e89 < y < 3.9999999999999998e163Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.8%
if 3.9999999999999998e163 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites52.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 2e-17)
(/ (/ (* (/ y (+ x y)) x) (- x -1.0)) (+ x y))
(if (<= y 9e+71)
(* (/ x (* (- y (- -1.0 x)) (* (+ y x) (+ y x)))) y)
(* (/ x (+ y x)) (* 1.0 (/ -1.0 (- (- -1.0 x) y)))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2e-17) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else if (y <= 9e+71) {
tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y;
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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) :: tmp
if (y <= 2d-17) then
tmp = (((y / (x + y)) * x) / (x - (-1.0d0))) / (x + y)
else if (y <= 9d+71) then
tmp = (x / ((y - ((-1.0d0) - x)) * ((y + x) * (y + x)))) * y
else
tmp = (x / (y + x)) * (1.0d0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2e-17) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else if (y <= 9e+71) {
tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y;
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2e-17: tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y) elif y <= 9e+71: tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y else: tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2e-17) tmp = Float64(Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(x - -1.0)) / Float64(x + y)); elseif (y <= 9e+71) tmp = Float64(Float64(x / Float64(Float64(y - Float64(-1.0 - x)) * Float64(Float64(y + x) * Float64(y + x)))) * y); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2e-17)
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
elseif (y <= 9e+71)
tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y;
else
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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_] := If[LessEqual[y, 2e-17], N[(N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9e+71], N[(N[(x / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{\frac{y}{x + y} \cdot x}{x - -1}}{x + y}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+71}:\\
\;\;\;\;\frac{x}{\left(y - \left(-1 - x\right)\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \left(1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < 2.00000000000000014e-17Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
frac-timesN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
Applied rewrites74.5%
if 2.00000000000000014e-17 < y < 9.00000000000000087e71Initial program 69.5%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.8%
if 9.00000000000000087e71 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites52.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y -8e-157)
(/ (/ y (- x -1.0)) (+ y x))
(if (<= y 1.9e-5)
(* (/ y (+ y x)) (/ x (* (- x -1.0) (+ y x))))
(* (/ x (+ y x)) (* 1.0 (/ -1.0 (- (- -1.0 x) y)))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -8e-157) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 1.9e-5) {
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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) :: tmp
if (y <= (-8d-157)) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else if (y <= 1.9d-5) then
tmp = (y / (y + x)) * (x / ((x - (-1.0d0)) * (y + x)))
else
tmp = (x / (y + x)) * (1.0d0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= -8e-157) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 1.9e-5) {
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= -8e-157: tmp = (y / (x - -1.0)) / (y + x) elif y <= 1.9e-5: tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x))) else: tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= -8e-157) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); elseif (y <= 1.9e-5) tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(x - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= -8e-157)
tmp = (y / (x - -1.0)) / (y + x);
elseif (y <= 1.9e-5)
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
else
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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_] := If[LessEqual[y, -8e-157], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.9e-5], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{-157}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(x - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \left(1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < -7.99999999999999955e-157Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6450.4
Applied rewrites50.4%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6450.4
Applied rewrites50.4%
if -7.99999999999999955e-157 < y < 1.9000000000000001e-5Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6475.4
Applied rewrites75.4%
if 1.9000000000000001e-5 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites52.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.9e-5) (/ (/ (* (/ y (+ x y)) x) (- x -1.0)) (+ x y)) (* (/ x (+ y x)) (* 1.0 (/ -1.0 (- (- -1.0 x) y))))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.9e-5) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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) :: tmp
if (y <= 1.9d-5) then
tmp = (((y / (x + y)) * x) / (x - (-1.0d0))) / (x + y)
else
tmp = (x / (y + x)) * (1.0d0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.9e-5) {
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.9e-5: tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y) else: tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.9e-5) tmp = Float64(Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(x - -1.0)) / Float64(x + y)); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.9e-5)
tmp = (((y / (x + y)) * x) / (x - -1.0)) / (x + y);
else
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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_] := If[LessEqual[y, 1.9e-5], N[(N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{\frac{y}{x + y} \cdot x}{x - -1}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \left(1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < 1.9000000000000001e-5Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
frac-timesN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
Applied rewrites74.5%
if 1.9000000000000001e-5 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites52.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.9e-5) (* (/ (/ y (+ y x)) (+ y x)) (/ x (- x -1.0))) (* (/ x (+ y x)) (* 1.0 (/ -1.0 (- (- -1.0 x) y))))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.9e-5) {
tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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) :: tmp
if (y <= 1.9d-5) then
tmp = ((y / (y + x)) / (y + x)) * (x / (x - (-1.0d0)))
else
tmp = (x / (y + x)) * (1.0d0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.9e-5) {
tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.9e-5: tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0)) else: tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.9e-5) tmp = Float64(Float64(Float64(y / Float64(y + x)) / Float64(y + x)) * Float64(x / Float64(x - -1.0))); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.9e-5)
tmp = ((y / (y + x)) / (y + x)) * (x / (x - -1.0));
else
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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_] := If[LessEqual[y, 1.9e-5], N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{y}{y + x}}{y + x} \cdot \frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \left(1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < 1.9000000000000001e-5Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites74.4%
if 1.9000000000000001e-5 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites52.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 4.2e-177)
(/ (/ y (+ 1.0 x)) (* (+ 1.0 (/ y x)) x))
(if (<= y 1.9e-5)
(* y (/ x (* (- x -1.0) (* (+ y x) (+ y x)))))
(* (/ x (+ y x)) (* 1.0 (/ -1.0 (- (- -1.0 x) y)))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.2e-177) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else if (y <= 1.9e-5) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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) :: tmp
if (y <= 4.2d-177) then
tmp = (y / (1.0d0 + x)) / ((1.0d0 + (y / x)) * x)
else if (y <= 1.9d-5) then
tmp = y * (x / ((x - (-1.0d0)) * ((y + x) * (y + x))))
else
tmp = (x / (y + x)) * (1.0d0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4.2e-177) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else if (y <= 1.9e-5) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.2e-177: tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x) elif y <= 1.9e-5: tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x)))) else: tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.2e-177) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(Float64(1.0 + Float64(y / x)) * x)); elseif (y <= 1.9e-5) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x))))); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4.2e-177)
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
elseif (y <= 1.9e-5)
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
else
tmp = (x / (y + x)) * (1.0 * (-1.0 / ((-1.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_] := If[LessEqual[y, 4.2e-177], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.9e-5], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{-177}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{\left(1 + \frac{y}{x}\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \left(1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < 4.20000000000000002e-177Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6450.4
Applied rewrites50.4%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6462.5
Applied rewrites62.5%
if 4.20000000000000002e-177 < y < 1.9000000000000001e-5Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.1
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.1
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites75.1%
if 1.9000000000000001e-5 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites52.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 4.2e-177)
(/ (/ y (+ 1.0 x)) (* (+ 1.0 (/ y x)) x))
(if (<= y 1.9e-5)
(* y (/ x (* (- x -1.0) (* (+ y x) (+ y x)))))
(/ (/ x (- y -1.0)) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.2e-177) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else if (y <= 1.9e-5) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (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 (y <= 4.2d-177) then
tmp = (y / (1.0d0 + x)) / ((1.0d0 + (y / x)) * x)
else if (y <= 1.9d-5) then
tmp = y * (x / ((x - (-1.0d0)) * ((y + x) * (y + x))))
else
tmp = (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 (y <= 4.2e-177) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else if (y <= 1.9e-5) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.2e-177: tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x) elif y <= 1.9e-5: tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x)))) else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.2e-177) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(Float64(1.0 + Float64(y / x)) * x)); elseif (y <= 1.9e-5) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x))))); else tmp = Float64(Float64(x / 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 (y <= 4.2e-177)
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
elseif (y <= 1.9e-5)
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
else
tmp = (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[y, 4.2e-177], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.9e-5], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{-177}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{\left(1 + \frac{y}{x}\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if y < 4.20000000000000002e-177Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6450.4
Applied rewrites50.4%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6462.5
Applied rewrites62.5%
if 4.20000000000000002e-177 < y < 1.9000000000000001e-5Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.1
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.1
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites75.1%
if 1.9000000000000001e-5 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.4
Applied rewrites51.4%
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6451.4
Applied rewrites51.4%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 4.2e-177)
(/ (/ y (+ 1.0 x)) (* (+ 1.0 (/ y x)) x))
(if (<= y 1.9e-5)
(* (/ y (* (- x -1.0) (* (+ y x) (+ y x)))) x)
(/ (/ x (- y -1.0)) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.2e-177) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else if (y <= 1.9e-5) {
tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x;
} else {
tmp = (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 (y <= 4.2d-177) then
tmp = (y / (1.0d0 + x)) / ((1.0d0 + (y / x)) * x)
else if (y <= 1.9d-5) then
tmp = (y / ((x - (-1.0d0)) * ((y + x) * (y + x)))) * x
else
tmp = (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 (y <= 4.2e-177) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else if (y <= 1.9e-5) {
tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x;
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.2e-177: tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x) elif y <= 1.9e-5: tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.2e-177) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(Float64(1.0 + Float64(y / x)) * x)); elseif (y <= 1.9e-5) tmp = Float64(Float64(y / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x)))) * x); else tmp = Float64(Float64(x / 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 (y <= 4.2e-177)
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
elseif (y <= 1.9e-5)
tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x;
else
tmp = (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[y, 4.2e-177], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.9e-5], N[(N[(y / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{-177}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{\left(1 + \frac{y}{x}\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if y < 4.20000000000000002e-177Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6450.4
Applied rewrites50.4%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6462.5
Applied rewrites62.5%
if 4.20000000000000002e-177 < y < 1.9000000000000001e-5Initial program 69.5%
Taylor expanded in y around 0
lower-+.f6458.8
Applied rewrites58.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.9%
if 1.9000000000000001e-5 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.4
Applied rewrites51.4%
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6451.4
Applied rewrites51.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.02e-85) (/ (/ y (+ 1.0 x)) (* (+ 1.0 (/ y x)) x)) (/ (/ x (- y -1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.02e-85) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else {
tmp = (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 (y <= 1.02d-85) then
tmp = (y / (1.0d0 + x)) / ((1.0d0 + (y / x)) * x)
else
tmp = (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 (y <= 1.02e-85) {
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.02e-85: tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x) else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.02e-85) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(Float64(1.0 + Float64(y / x)) * x)); else tmp = Float64(Float64(x / 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 (y <= 1.02e-85)
tmp = (y / (1.0 + x)) / ((1.0 + (y / x)) * x);
else
tmp = (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[y, 1.02e-85], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{-85}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{\left(1 + \frac{y}{x}\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if y < 1.02000000000000001e-85Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6450.4
Applied rewrites50.4%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6462.5
Applied rewrites62.5%
if 1.02000000000000001e-85 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.4
Applied rewrites51.4%
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6451.4
Applied rewrites51.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.02e-85) (/ (/ y (- x -1.0)) (+ y x)) (/ (/ x (- y -1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.02e-85) {
tmp = (y / (x - -1.0)) / (y + x);
} else {
tmp = (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 (y <= 1.02d-85) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else
tmp = (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 (y <= 1.02e-85) {
tmp = (y / (x - -1.0)) / (y + x);
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.02e-85: tmp = (y / (x - -1.0)) / (y + x) else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.02e-85) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); else tmp = Float64(Float64(x / 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 (y <= 1.02e-85)
tmp = (y / (x - -1.0)) / (y + x);
else
tmp = (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[y, 1.02e-85], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{-85}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if y < 1.02000000000000001e-85Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6450.4
Applied rewrites50.4%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6450.4
Applied rewrites50.4%
if 1.02000000000000001e-85 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.4
Applied rewrites51.4%
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6451.4
Applied rewrites51.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.02e-85) (/ y (* x (+ 1.0 x))) (/ (/ x (- y -1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.02e-85) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (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 (y <= 1.02d-85) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (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 (y <= 1.02e-85) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.02e-85: tmp = y / (x * (1.0 + x)) else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.02e-85) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / 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 (y <= 1.02e-85)
tmp = y / (x * (1.0 + x));
else
tmp = (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[y, 1.02e-85], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{-85}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if y < 1.02000000000000001e-85Initial program 69.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.8
Applied rewrites48.8%
if 1.02000000000000001e-85 < y Initial program 69.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6451.4
Applied rewrites51.4%
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6451.4
Applied rewrites51.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.02e-85) (/ y (* x (+ 1.0 x))) (/ (/ x (- y -1.0)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.02e-85) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.02d-85) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (x / (y - (-1.0d0))) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.02e-85) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.02e-85: tmp = y / (x * (1.0 + x)) else: tmp = (x / (y - -1.0)) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.02e-85) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / Float64(y - -1.0)) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.02e-85)
tmp = y / (x * (1.0 + x));
else
tmp = (x / (y - -1.0)) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.02e-85], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{-85}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y}\\
\end{array}
\end{array}
if y < 1.02000000000000001e-85Initial program 69.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.8
Applied rewrites48.8%
if 1.02000000000000001e-85 < y Initial program 69.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.8
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.02e-85) (/ y (* x (+ 1.0 x))) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.02e-85) {
tmp = y / (x * (1.0 + 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.02e-85) tmp = Float64(y / Float64(x * Float64(1.0 + 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.02e-85], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $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.02 \cdot 10^{-85}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if y < 1.02000000000000001e-85Initial program 69.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.8
Applied rewrites48.8%
if 1.02000000000000001e-85 < y Initial program 69.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6449.4
Applied rewrites49.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (fma y y y)))
assert(x < y);
double code(double x, double y) {
return x / fma(y, y, y);
}
x, y = sort([x, y]) function code(x, y) return Float64(x / fma(y, 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 + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{\mathsf{fma}\left(y, y, y\right)}
\end{array}
Initial program 69.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6449.4
Applied rewrites49.4%
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.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6449.4
Applied rewrites49.4%
Taylor expanded in y around 0
lower-/.f6426.1
Applied rewrites26.1%
herbie shell --seed 2025159
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))