
(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 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (* (/ x (+ y x)) (/ y (+ (+ 1.0 x) y))) (+ y x)))
assert(x < y);
double code(double x, double y) {
return ((x / (y + x)) * (y / ((1.0 + x) + y))) / (y + x);
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / (y + x)) * (y / ((1.0d0 + x) + y))) / (y + x)
end function
assert x < y;
public static double code(double x, double y) {
return ((x / (y + x)) * (y / ((1.0 + x) + y))) / (y + x);
}
[x, y] = sort([x, y]) def code(x, y): return ((x / (y + x)) * (y / ((1.0 + x) + y))) / (y + x)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(x / Float64(y + x)) * Float64(y / Float64(Float64(1.0 + x) + y))) / Float64(y + x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((x / (y + x)) * (y / ((1.0 + x) + y))) / (y + x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{x}{y + x} \cdot \frac{y}{\left(1 + x\right) + y}}{y + x}
\end{array}
Initial program 69.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.8
Applied rewrites87.8%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ x (+ y x)) (/ (/ y (+ (+ 1.0 x) y)) (+ y x))))
assert(x < y);
double code(double x, double y) {
return (x / (y + x)) * ((y / ((1.0 + x) + y)) / (y + x));
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (y + x)) * ((y / ((1.0d0 + x) + y)) / (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return (x / (y + x)) * ((y / ((1.0 + x) + y)) / (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return (x / (y + x)) * ((y / ((1.0 + x) + y)) / (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(y + x)) * Float64(Float64(y / Float64(Float64(1.0 + x) + y)) / Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / (y + x)) * ((y / ((1.0 + x) + y)) / (y + x));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(N[(y / N[(N[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y + x} \cdot \frac{\frac{y}{\left(1 + x\right) + y}}{y + x}
\end{array}
Initial program 69.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.8
Applied rewrites87.8%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
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
lift-/.f64N/A
lift-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f6499.8
Applied rewrites99.8%
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 (<= x -2e+25)
(/ (* t_0 (/ y (+ x y))) (+ y x))
(/ (* t_0 y) (* (+ y x) (+ (+ 1.0 x) y))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -2e+25) {
tmp = (t_0 * (y / (x + y))) / (y + x);
} else {
tmp = (t_0 * y) / ((y + x) * ((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 (x <= (-2d+25)) then
tmp = (t_0 * (y / (x + y))) / (y + x)
else
tmp = (t_0 * y) / ((y + x) * ((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 (x <= -2e+25) {
tmp = (t_0 * (y / (x + y))) / (y + x);
} else {
tmp = (t_0 * y) / ((y + x) * ((1.0 + x) + y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if x <= -2e+25: tmp = (t_0 * (y / (x + y))) / (y + x) else: tmp = (t_0 * y) / ((y + x) * ((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 (x <= -2e+25) tmp = Float64(Float64(t_0 * Float64(y / Float64(x + y))) / Float64(y + x)); else tmp = Float64(Float64(t_0 * y) / Float64(Float64(y + x) * 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 (x <= -2e+25)
tmp = (t_0 * (y / (x + y))) / (y + x);
else
tmp = (t_0 * y) / ((y + x) * ((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[x, -2e+25], N[(N[(t$95$0 * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\frac{t\_0 \cdot \frac{y}{x + y}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot y}{\left(y + x\right) \cdot \left(\left(1 + x\right) + y\right)}\\
\end{array}
\end{array}
if x < -2.00000000000000018e25Initial program 66.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.7
Applied rewrites88.7%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites99.8%
if -2.00000000000000018e25 < x Initial program 71.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.2
Applied rewrites87.2%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
frac-timesN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
Applied rewrites97.3%
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 (<= x -1.0)
(/ (* t_0 (/ y (+ x y))) (+ y x))
(/ (* t_0 (/ y (+ 1.0 y))) (+ y x)))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -1.0) {
tmp = (t_0 * (y / (x + y))) / (y + x);
} else {
tmp = (t_0 * (y / (1.0 + y))) / (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) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (x <= (-1.0d0)) then
tmp = (t_0 * (y / (x + y))) / (y + x)
else
tmp = (t_0 * (y / (1.0d0 + y))) / (y + x)
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 (x <= -1.0) {
tmp = (t_0 * (y / (x + y))) / (y + x);
} else {
tmp = (t_0 * (y / (1.0 + y))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if x <= -1.0: tmp = (t_0 * (y / (x + y))) / (y + x) else: tmp = (t_0 * (y / (1.0 + y))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(t_0 * Float64(y / Float64(x + y))) / Float64(y + x)); else tmp = Float64(Float64(t_0 * Float64(y / Float64(1.0 + y))) / Float64(y + x)); 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 (x <= -1.0)
tmp = (t_0 * (y / (x + y))) / (y + x);
else
tmp = (t_0 * (y / (1.0 + y))) / (y + x);
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[x, -1.0], N[(N[(t$95$0 * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{t\_0 \cdot \frac{y}{x + y}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \frac{y}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -1Initial program 67.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
Applied rewrites89.4%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites98.6%
if -1 < x Initial program 70.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.5
Applied rewrites86.5%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites98.6%
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 (<= x -1.05e-60)
(* (/ t_0 (+ y x)) (/ y (+ x 1.0)))
(/ (* t_0 (/ y (+ 1.0 y))) (+ y x)))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -1.05e-60) {
tmp = (t_0 / (y + x)) * (y / (x + 1.0));
} else {
tmp = (t_0 * (y / (1.0 + y))) / (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) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (x <= (-1.05d-60)) then
tmp = (t_0 / (y + x)) * (y / (x + 1.0d0))
else
tmp = (t_0 * (y / (1.0d0 + y))) / (y + x)
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 (x <= -1.05e-60) {
tmp = (t_0 / (y + x)) * (y / (x + 1.0));
} else {
tmp = (t_0 * (y / (1.0 + y))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if x <= -1.05e-60: tmp = (t_0 / (y + x)) * (y / (x + 1.0)) else: tmp = (t_0 * (y / (1.0 + y))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (x <= -1.05e-60) tmp = Float64(Float64(t_0 / Float64(y + x)) * Float64(y / Float64(x + 1.0))); else tmp = Float64(Float64(t_0 * Float64(y / Float64(1.0 + y))) / Float64(y + x)); 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 (x <= -1.05e-60)
tmp = (t_0 / (y + x)) * (y / (x + 1.0));
else
tmp = (t_0 * (y / (1.0 + y))) / (y + x);
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[x, -1.05e-60], N[(N[(t$95$0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{-60}:\\
\;\;\;\;\frac{t\_0}{y + x} \cdot \frac{y}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \frac{y}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -1.04999999999999996e-60Initial 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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6490.8
Applied rewrites90.8%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites90.8%
if -1.04999999999999996e-60 < x Initial program 67.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.7
Applied rewrites84.7%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.3%
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 (<= x -1.7e-228)
(* (/ t_0 (+ y x)) (/ y (+ x 1.0)))
(* (/ t_0 y) (/ y (+ (+ y x) 1.0))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -1.7e-228) {
tmp = (t_0 / (y + x)) * (y / (x + 1.0));
} else {
tmp = (t_0 / y) * (y / ((y + x) + 1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (x <= (-1.7d-228)) then
tmp = (t_0 / (y + x)) * (y / (x + 1.0d0))
else
tmp = (t_0 / y) * (y / ((y + x) + 1.0d0))
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 (x <= -1.7e-228) {
tmp = (t_0 / (y + x)) * (y / (x + 1.0));
} else {
tmp = (t_0 / y) * (y / ((y + x) + 1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if x <= -1.7e-228: tmp = (t_0 / (y + x)) * (y / (x + 1.0)) else: tmp = (t_0 / y) * (y / ((y + x) + 1.0)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (x <= -1.7e-228) tmp = Float64(Float64(t_0 / Float64(y + x)) * Float64(y / Float64(x + 1.0))); else tmp = Float64(Float64(t_0 / y) * Float64(y / Float64(Float64(y + x) + 1.0))); 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 (x <= -1.7e-228)
tmp = (t_0 / (y + x)) * (y / (x + 1.0));
else
tmp = (t_0 / y) * (y / ((y + x) + 1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7e-228], N[(N[(t$95$0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / y), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{-228}:\\
\;\;\;\;\frac{t\_0}{y + x} \cdot \frac{y}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{y} \cdot \frac{y}{\left(y + x\right) + 1}\\
\end{array}
\end{array}
if x < -1.69999999999999995e-228Initial program 70.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.3
Applied rewrites89.3%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites90.2%
if -1.69999999999999995e-228 < x Initial program 67.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.5
Applied rewrites84.5%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites95.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.15)
(* (/ (/ x (+ y x)) (+ y x)) (/ y x))
(if (<= x -1.3e-164)
(* (/ x (* (+ y x) (+ y x))) (/ y (+ y 1.0)))
(/ (/ x (+ 1.0 y)) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.15) {
tmp = ((x / (y + x)) / (y + x)) * (y / x);
} else if (x <= -1.3e-164) {
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0));
} else {
tmp = (x / (1.0 + y)) / (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.15d0)) then
tmp = ((x / (y + x)) / (y + x)) * (y / x)
else if (x <= (-1.3d-164)) then
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0d0))
else
tmp = (x / (1.0d0 + y)) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.15) {
tmp = ((x / (y + x)) / (y + x)) * (y / x);
} else if (x <= -1.3e-164) {
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0));
} else {
tmp = (x / (1.0 + y)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.15: tmp = ((x / (y + x)) / (y + x)) * (y / x) elif x <= -1.3e-164: tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0)) else: tmp = (x / (1.0 + y)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.15) tmp = Float64(Float64(Float64(x / Float64(y + x)) / Float64(y + x)) * Float64(y / x)); elseif (x <= -1.3e-164) tmp = Float64(Float64(x / Float64(Float64(y + x) * Float64(y + x))) * Float64(y / Float64(y + 1.0))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / 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.15)
tmp = ((x / (y + x)) / (y + x)) * (y / x);
elseif (x <= -1.3e-164)
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0));
else
tmp = (x / (1.0 + y)) / (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.15], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.3e-164], N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15:\\
\;\;\;\;\frac{\frac{x}{y + x}}{y + x} \cdot \frac{y}{x}\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{-164}:\\
\;\;\;\;\frac{x}{\left(y + x\right) \cdot \left(y + x\right)} \cdot \frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -1.1499999999999999Initial program 67.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
Applied rewrites89.4%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites90.5%
if -1.1499999999999999 < x < -1.3000000000000001e-164Initial program 80.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
Taylor expanded in x around 0
+-commutative96.3
Applied rewrites96.3%
if -1.3000000000000001e-164 < x Initial program 65.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6480.9
Applied rewrites80.9%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6491.2
Applied rewrites91.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -90000000000000.0)
(* (/ (/ x (+ y x)) (+ y x)) (/ y x))
(if (<= x -2.8e-108)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ x 1.0)))
(/ (/ x (+ 1.0 y)) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -90000000000000.0) {
tmp = ((x / (y + x)) / (y + x)) * (y / x);
} else if (x <= -2.8e-108) {
tmp = (x * y) / (((x + y) * (x + y)) * (x + 1.0));
} else {
tmp = (x / (1.0 + y)) / (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 <= (-90000000000000.0d0)) then
tmp = ((x / (y + x)) / (y + x)) * (y / x)
else if (x <= (-2.8d-108)) then
tmp = (x * y) / (((x + y) * (x + y)) * (x + 1.0d0))
else
tmp = (x / (1.0d0 + y)) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -90000000000000.0) {
tmp = ((x / (y + x)) / (y + x)) * (y / x);
} else if (x <= -2.8e-108) {
tmp = (x * y) / (((x + y) * (x + y)) * (x + 1.0));
} else {
tmp = (x / (1.0 + y)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -90000000000000.0: tmp = ((x / (y + x)) / (y + x)) * (y / x) elif x <= -2.8e-108: tmp = (x * y) / (((x + y) * (x + y)) * (x + 1.0)) else: tmp = (x / (1.0 + y)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -90000000000000.0) tmp = Float64(Float64(Float64(x / Float64(y + x)) / Float64(y + x)) * Float64(y / x)); elseif (x <= -2.8e-108) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(x + 1.0))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -90000000000000.0)
tmp = ((x / (y + x)) / (y + x)) * (y / x);
elseif (x <= -2.8e-108)
tmp = (x * y) / (((x + y) * (x + y)) * (x + 1.0));
else
tmp = (x / (1.0 + y)) / (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, -90000000000000.0], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.8e-108], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -90000000000000:\\
\;\;\;\;\frac{\frac{x}{y + x}}{y + x} \cdot \frac{y}{x}\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-108}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -9e13Initial program 66.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.0
Applied rewrites89.0%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites91.7%
if -9e13 < x < -2.8e-108Initial program 86.7%
Taylor expanded in x around inf
Applied rewrites74.2%
if -2.8e-108 < x Initial program 65.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6482.9
Applied rewrites82.9%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -105000000.0)
(* (/ (/ x (+ y x)) (+ y x)) (/ y x))
(if (<= x -1.2e-91)
(* (/ 1.0 (+ y x)) (/ y (+ (+ y x) 1.0)))
(/ (/ x (+ 1.0 y)) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -105000000.0) {
tmp = ((x / (y + x)) / (y + x)) * (y / x);
} else if (x <= -1.2e-91) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else {
tmp = (x / (1.0 + y)) / (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 <= (-105000000.0d0)) then
tmp = ((x / (y + x)) / (y + x)) * (y / x)
else if (x <= (-1.2d-91)) then
tmp = (1.0d0 / (y + x)) * (y / ((y + x) + 1.0d0))
else
tmp = (x / (1.0d0 + y)) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -105000000.0) {
tmp = ((x / (y + x)) / (y + x)) * (y / x);
} else if (x <= -1.2e-91) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else {
tmp = (x / (1.0 + y)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -105000000.0: tmp = ((x / (y + x)) / (y + x)) * (y / x) elif x <= -1.2e-91: tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0)) else: tmp = (x / (1.0 + y)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -105000000.0) tmp = Float64(Float64(Float64(x / Float64(y + x)) / Float64(y + x)) * Float64(y / x)); elseif (x <= -1.2e-91) tmp = Float64(Float64(1.0 / Float64(y + x)) * Float64(y / Float64(Float64(y + x) + 1.0))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -105000000.0)
tmp = ((x / (y + x)) / (y + x)) * (y / x);
elseif (x <= -1.2e-91)
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
else
tmp = (x / (1.0 + y)) / (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, -105000000.0], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.2e-91], N[(N[(1.0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -105000000:\\
\;\;\;\;\frac{\frac{x}{y + x}}{y + x} \cdot \frac{y}{x}\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-91}:\\
\;\;\;\;\frac{1}{y + x} \cdot \frac{y}{\left(y + x\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -1.05e8Initial program 67.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.2
Applied rewrites89.2%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites91.5%
if -1.05e8 < x < -1.20000000000000005e-91Initial program 88.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.5
Applied rewrites99.5%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites64.4%
if -1.20000000000000005e-91 < x Initial program 66.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.6
Applied rewrites83.6%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.26e+20) (/ (/ y x) (+ y x)) (if (<= x -1.8e-71) (/ y (* (+ 1.0 x) x)) (/ (/ x (+ 1.0 y)) (+ y x)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.26e+20) {
tmp = (y / x) / (y + x);
} else if (x <= -1.8e-71) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = (x / (1.0 + y)) / (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.26d+20)) then
tmp = (y / x) / (y + x)
else if (x <= (-1.8d-71)) then
tmp = y / ((1.0d0 + x) * x)
else
tmp = (x / (1.0d0 + y)) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.26e+20) {
tmp = (y / x) / (y + x);
} else if (x <= -1.8e-71) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = (x / (1.0 + y)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.26e+20: tmp = (y / x) / (y + x) elif x <= -1.8e-71: tmp = y / ((1.0 + x) * x) else: tmp = (x / (1.0 + y)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.26e+20) tmp = Float64(Float64(y / x) / Float64(y + x)); elseif (x <= -1.8e-71) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(Float64(x / Float64(1.0 + y)) / 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.26e+20)
tmp = (y / x) / (y + x);
elseif (x <= -1.8e-71)
tmp = y / ((1.0 + x) * x);
else
tmp = (x / (1.0 + y)) / (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.26e+20], N[(N[(y / x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.8e-71], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.26 \cdot 10^{+20}:\\
\;\;\;\;\frac{\frac{y}{x}}{y + x}\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-71}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -1.26e20Initial program 66.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.8
Applied rewrites88.8%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6486.3
Applied rewrites86.3%
if -1.26e20 < x < -1.8e-71Initial program 90.5%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6466.4
Applied rewrites66.4%
if -1.8e-71 < x Initial program 66.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.3
Applied rewrites84.3%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6483.7
Applied rewrites83.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.2e-91) (* (/ 1.0 (+ y x)) (/ y (+ (+ y x) 1.0))) (/ (/ x (+ 1.0 y)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.2e-91) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else {
tmp = (x / (1.0 + y)) / (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-91)) then
tmp = (1.0d0 / (y + x)) * (y / ((y + x) + 1.0d0))
else
tmp = (x / (1.0d0 + y)) / (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-91) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else {
tmp = (x / (1.0 + y)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.2e-91: tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0)) else: tmp = (x / (1.0 + y)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.2e-91) tmp = Float64(Float64(1.0 / Float64(y + x)) * Float64(y / Float64(Float64(y + x) + 1.0))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / 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-91)
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
else
tmp = (x / (1.0 + y)) / (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-91], N[(N[(1.0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-91}:\\
\;\;\;\;\frac{1}{y + x} \cdot \frac{y}{\left(y + x\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -1.20000000000000005e-91Initial program 71.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6491.3
Applied rewrites91.3%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites81.5%
if -1.20000000000000005e-91 < x Initial program 66.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.6
Applied rewrites83.6%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.2e-91) (/ (/ y (+ 1.0 x)) (+ y x)) (/ (/ x (+ 1.0 y)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.2e-91) {
tmp = (y / (1.0 + x)) / (y + x);
} else {
tmp = (x / (1.0 + y)) / (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-91)) then
tmp = (y / (1.0d0 + x)) / (y + x)
else
tmp = (x / (1.0d0 + y)) / (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-91) {
tmp = (y / (1.0 + x)) / (y + x);
} else {
tmp = (x / (1.0 + y)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.2e-91: tmp = (y / (1.0 + x)) / (y + x) else: tmp = (x / (1.0 + y)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.2e-91) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(y + x)); else tmp = Float64(Float64(x / Float64(1.0 + y)) / 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-91)
tmp = (y / (1.0 + x)) / (y + x);
else
tmp = (x / (1.0 + y)) / (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-91], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-91}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y + x}\\
\end{array}
\end{array}
if x < -1.20000000000000005e-91Initial program 71.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6491.3
Applied rewrites91.3%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lift-+.f6481.3
Applied rewrites81.3%
if -1.20000000000000005e-91 < x Initial program 66.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.6
Applied rewrites83.6%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.26e+20) (/ (/ y x) (+ y x)) (if (<= x -1.8e-71) (/ y (* (+ 1.0 x) x)) (/ x (* (+ 1.0 y) y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.26e+20) {
tmp = (y / x) / (y + x);
} else if (x <= -1.8e-71) {
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 <= (-1.26d+20)) then
tmp = (y / x) / (y + x)
else if (x <= (-1.8d-71)) 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 <= -1.26e+20) {
tmp = (y / x) / (y + x);
} else if (x <= -1.8e-71) {
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 <= -1.26e+20: tmp = (y / x) / (y + x) elif x <= -1.8e-71: 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 <= -1.26e+20) tmp = Float64(Float64(y / x) / Float64(y + x)); elseif (x <= -1.8e-71) 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 <= -1.26e+20)
tmp = (y / x) / (y + x);
elseif (x <= -1.8e-71)
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, -1.26e+20], N[(N[(y / x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.8e-71], 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 -1.26 \cdot 10^{+20}:\\
\;\;\;\;\frac{\frac{y}{x}}{y + x}\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-71}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -1.26e20Initial program 66.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.8
Applied rewrites88.8%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
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
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6486.3
Applied rewrites86.3%
if -1.26e20 < x < -1.8e-71Initial program 90.5%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6466.4
Applied rewrites66.4%
if -1.8e-71 < x Initial program 66.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6480.8
Applied rewrites80.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1e+28) (/ (/ y x) x) (if (<= x -1.8e-71) (/ y (* (+ 1.0 x) x)) (/ x (* (+ 1.0 y) y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1e+28) {
tmp = (y / x) / x;
} else if (x <= -1.8e-71) {
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 <= (-1d+28)) then
tmp = (y / x) / x
else if (x <= (-1.8d-71)) 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 <= -1e+28) {
tmp = (y / x) / x;
} else if (x <= -1.8e-71) {
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 <= -1e+28: tmp = (y / x) / x elif x <= -1.8e-71: 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 <= -1e+28) tmp = Float64(Float64(y / x) / x); elseif (x <= -1.8e-71) 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 <= -1e+28)
tmp = (y / x) / x;
elseif (x <= -1.8e-71)
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, -1e+28], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -1.8e-71], 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 -1 \cdot 10^{+28}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-71}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -9.99999999999999958e27Initial program 65.8%
Taylor expanded in x around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around inf
Applied rewrites81.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6486.4
Applied rewrites86.4%
if -9.99999999999999958e27 < x < -1.8e-71Initial program 90.5%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6466.5
Applied rewrites66.5%
if -1.8e-71 < x Initial program 66.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6480.8
Applied rewrites80.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.15) (/ (/ y x) x) (/ x (* (+ 1.0 y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.15) {
tmp = (y / x) / x;
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.15d0)) then
tmp = (y / x) / x
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.15) {
tmp = (y / x) / x;
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.15: tmp = (y / x) / x else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.15) tmp = Float64(Float64(y / x) / x); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.15)
tmp = (y / x) / x;
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.15], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -1.1499999999999999Initial program 67.9%
Taylor expanded in x around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in x around inf
Applied rewrites79.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6484.2
Applied rewrites84.2%
if -1.1499999999999999 < x Initial program 70.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6474.4
Applied rewrites74.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -4.6e-12) (/ (/ y x) x) (/ (/ x y) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -4.6e-12) {
tmp = (y / x) / x;
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-4.6d-12)) then
tmp = (y / x) / x
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -4.6e-12) {
tmp = (y / x) / x;
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -4.6e-12: tmp = (y / x) / x else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -4.6e-12) tmp = Float64(Float64(y / x) / x); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -4.6e-12)
tmp = (y / x) / x;
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -4.6e-12], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -4.59999999999999979e-12Initial program 68.6%
Taylor expanded in x around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6473.2
Applied rewrites73.2%
Taylor expanded in x around inf
Applied rewrites77.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6482.1
Applied rewrites82.1%
if -4.59999999999999979e-12 < x Initial program 69.6%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6455.0
Applied rewrites55.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 7e+26) (/ y (* x x)) (/ (/ x y) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 7e+26) {
tmp = y / (x * x);
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7d+26) then
tmp = y / (x * x)
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 7e+26) {
tmp = y / (x * x);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 7e+26: tmp = y / (x * x) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 7e+26) tmp = Float64(y / Float64(x * x)); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 7e+26)
tmp = y / (x * x);
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 7e+26], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+26}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < 6.9999999999999998e26Initial program 70.8%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6451.3
Applied rewrites51.3%
if 6.9999999999999998e26 < y Initial program 66.6%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6481.1
Applied rewrites81.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -4.6e-12) (/ y (* x x)) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -4.6e-12) {
tmp = y / (x * x);
} else {
tmp = x / (y * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-4.6d-12)) then
tmp = y / (x * x)
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -4.6e-12) {
tmp = y / (x * x);
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -4.6e-12: tmp = y / (x * x) else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -4.6e-12) tmp = Float64(y / Float64(x * x)); else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -4.6e-12)
tmp = y / (x * x);
else
tmp = x / (y * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -4.6e-12], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -4.59999999999999979e-12Initial program 68.6%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6477.8
Applied rewrites77.8%
if -4.59999999999999979e-12 < x Initial program 69.6%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6452.3
Applied rewrites52.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (* y y)))
assert(x < y);
double code(double x, double y) {
return x / (y * y);
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (y * y)
end function
assert x < y;
public static double code(double x, double y) {
return x / (y * y);
}
[x, y] = sort([x, y]) def code(x, y): return x / (y * y)
x, y = sort([x, y]) function code(x, y) return Float64(x / Float64(y * y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / (y * y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y \cdot y}
\end{array}
Initial program 69.1%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6435.8
Applied rewrites35.8%
herbie shell --seed 2025114
(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))))