
(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 24 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 x) -1.0)) (/ y (+ y x))))
assert(x < y);
double code(double x, double y) {
return ((x / (y + x)) / ((y + x) - -1.0)) * (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 + x) - (-1.0d0))) * (y / (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return ((x / (y + x)) / ((y + x) - -1.0)) * (y / (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return ((x / (y + x)) / ((y + x) - -1.0)) * (y / (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(x / Float64(y + x)) / Float64(Float64(y + x) - -1.0)) * Float64(y / Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((x / (y + x)) / ((y + x) - -1.0)) * (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[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{x}{y + x}}{\left(y + x\right) - -1} \cdot \frac{y}{y + x}
\end{array}
Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (/ x (+ y x)) (* (/ (- x (- -1.0 y)) y) (+ y x))))
assert(x < y);
double code(double x, double y) {
return (x / (y + x)) / (((x - (-1.0 - y)) / 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)) / (((x - ((-1.0d0) - y)) / y) * (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return (x / (y + x)) / (((x - (-1.0 - y)) / y) * (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return (x / (y + x)) / (((x - (-1.0 - y)) / y) * (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(y + x)) / Float64(Float64(Float64(x - Float64(-1.0 - y)) / y) * Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / (y + x)) / (((x - (-1.0 - y)) / 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[(N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{x}{y + x}}{\frac{x - \left(-1 - y\right)}{y} \cdot \left(y + x\right)}
\end{array}
Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
add-flipN/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
metadata-evalN/A
sub-flipN/A
lower--.f6499.2
Applied rewrites99.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= y -1.95e+36)
(/ (* t_0 (/ y (- x -1.0))) (+ y x))
(if (<= y 1.6e+153)
(* t_0 (/ y (* (- (+ y x) -1.0) (+ y x))))
(/ t_0 (+ 1.0 y))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -1.95e+36) {
tmp = (t_0 * (y / (x - -1.0))) / (y + x);
} else if (y <= 1.6e+153) {
tmp = t_0 * (y / (((y + x) - -1.0) * (y + x)));
} else {
tmp = t_0 / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (y <= (-1.95d+36)) then
tmp = (t_0 * (y / (x - (-1.0d0)))) / (y + x)
else if (y <= 1.6d+153) then
tmp = t_0 * (y / (((y + x) - (-1.0d0)) * (y + x)))
else
tmp = t_0 / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -1.95e+36) {
tmp = (t_0 * (y / (x - -1.0))) / (y + x);
} else if (y <= 1.6e+153) {
tmp = t_0 * (y / (((y + x) - -1.0) * (y + x)));
} else {
tmp = t_0 / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if y <= -1.95e+36: tmp = (t_0 * (y / (x - -1.0))) / (y + x) elif y <= 1.6e+153: tmp = t_0 * (y / (((y + x) - -1.0) * (y + x))) else: tmp = t_0 / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (y <= -1.95e+36) tmp = Float64(Float64(t_0 * Float64(y / Float64(x - -1.0))) / Float64(y + x)); elseif (y <= 1.6e+153) tmp = Float64(t_0 * Float64(y / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(t_0 / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (y <= -1.95e+36)
tmp = (t_0 * (y / (x - -1.0))) / (y + x);
elseif (y <= 1.6e+153)
tmp = t_0 * (y / (((y + x) - -1.0) * (y + x)));
else
tmp = t_0 / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.95e+36], N[(N[(t$95$0 * N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6e+153], N[(t$95$0 * N[(y / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;y \leq -1.95 \cdot 10^{+36}:\\
\;\;\;\;\frac{t\_0 \cdot \frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+153}:\\
\;\;\;\;t\_0 \cdot \frac{y}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{1 + y}\\
\end{array}
\end{array}
if y < -1.9500000000000001e36Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
frac-timesN/A
Applied rewrites75.8%
if -1.9500000000000001e36 < y < 1.6000000000000001e153Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
if 1.6000000000000001e153 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.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 (<= y 7.8e-23)
(/ (* t_0 (/ y (- x -1.0))) (+ y x))
(if (<= y 1.6e+153)
(* (/ (/ y (* (- (+ y x) -1.0) (+ y x))) (+ y x)) x)
(/ t_0 (+ 1.0 y))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= 7.8e-23) {
tmp = (t_0 * (y / (x - -1.0))) / (y + x);
} else if (y <= 1.6e+153) {
tmp = ((y / (((y + x) - -1.0) * (y + x))) / (y + x)) * x;
} else {
tmp = t_0 / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (y <= 7.8d-23) then
tmp = (t_0 * (y / (x - (-1.0d0)))) / (y + x)
else if (y <= 1.6d+153) then
tmp = ((y / (((y + x) - (-1.0d0)) * (y + x))) / (y + x)) * x
else
tmp = t_0 / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= 7.8e-23) {
tmp = (t_0 * (y / (x - -1.0))) / (y + x);
} else if (y <= 1.6e+153) {
tmp = ((y / (((y + x) - -1.0) * (y + x))) / (y + x)) * x;
} else {
tmp = t_0 / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if y <= 7.8e-23: tmp = (t_0 * (y / (x - -1.0))) / (y + x) elif y <= 1.6e+153: tmp = ((y / (((y + x) - -1.0) * (y + x))) / (y + x)) * x else: tmp = t_0 / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (y <= 7.8e-23) tmp = Float64(Float64(t_0 * Float64(y / Float64(x - -1.0))) / Float64(y + x)); elseif (y <= 1.6e+153) tmp = Float64(Float64(Float64(y / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x))) / Float64(y + x)) * x); else tmp = Float64(t_0 / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (y <= 7.8e-23)
tmp = (t_0 * (y / (x - -1.0))) / (y + x);
elseif (y <= 1.6e+153)
tmp = ((y / (((y + x) - -1.0) * (y + x))) / (y + x)) * x;
else
tmp = t_0 / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 7.8e-23], N[(N[(t$95$0 * N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6e+153], N[(N[(N[(y / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(t$95$0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;y \leq 7.8 \cdot 10^{-23}:\\
\;\;\;\;\frac{t\_0 \cdot \frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{y}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}}{y + x} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{1 + y}\\
\end{array}
\end{array}
if y < 7.8e-23Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
frac-timesN/A
Applied rewrites75.8%
if 7.8e-23 < y < 1.6000000000000001e153Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
if 1.6000000000000001e153 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (+ y x) -1.0)))
(if (<= y 1.02e-29)
(/ (* (/ x (+ y x)) (/ y (- x -1.0))) (+ y x))
(if (<= y 3.1e+86)
(* (/ y (* t_0 (* (+ y x) (+ y x)))) x)
(/ (/ x y) (* (/ t_0 y) (+ y x)))))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) - -1.0;
double tmp;
if (y <= 1.02e-29) {
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
} else if (y <= 3.1e+86) {
tmp = (y / (t_0 * ((y + x) * (y + x)))) * x;
} else {
tmp = (x / y) / ((t_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 = (y + x) - (-1.0d0)
if (y <= 1.02d-29) then
tmp = ((x / (y + x)) * (y / (x - (-1.0d0)))) / (y + x)
else if (y <= 3.1d+86) then
tmp = (y / (t_0 * ((y + x) * (y + x)))) * x
else
tmp = (x / y) / ((t_0 / y) * (y + x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) - -1.0;
double tmp;
if (y <= 1.02e-29) {
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
} else if (y <= 3.1e+86) {
tmp = (y / (t_0 * ((y + x) * (y + x)))) * x;
} else {
tmp = (x / y) / ((t_0 / y) * (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) - -1.0 tmp = 0 if y <= 1.02e-29: tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x) elif y <= 3.1e+86: tmp = (y / (t_0 * ((y + x) * (y + x)))) * x else: tmp = (x / y) / ((t_0 / y) * (y + x)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) - -1.0) tmp = 0.0 if (y <= 1.02e-29) tmp = Float64(Float64(Float64(x / Float64(y + x)) * Float64(y / Float64(x - -1.0))) / Float64(y + x)); elseif (y <= 3.1e+86) tmp = Float64(Float64(y / Float64(t_0 * Float64(Float64(y + x) * Float64(y + x)))) * x); else tmp = Float64(Float64(x / y) / Float64(Float64(t_0 / y) * Float64(y + x))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) - -1.0;
tmp = 0.0;
if (y <= 1.02e-29)
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
elseif (y <= 3.1e+86)
tmp = (y / (t_0 * ((y + x) * (y + x)))) * x;
else
tmp = (x / y) / ((t_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[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, 1.02e-29], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+86], N[(N[(y / N[(t$95$0 * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(N[(t$95$0 / y), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) - -1\\
\mathbf{if}\;y \leq 1.02 \cdot 10^{-29}:\\
\;\;\;\;\frac{\frac{x}{y + x} \cdot \frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+86}:\\
\;\;\;\;\frac{y}{t\_0 \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{t\_0}{y} \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if y < 1.01999999999999994e-29Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
frac-timesN/A
Applied rewrites75.8%
if 1.01999999999999994e-29 < y < 3.1000000000000002e86Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.1%
if 3.1000000000000002e86 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-/.f6461.8
Applied rewrites61.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.02e-29)
(/ (* (/ x (+ y x)) (/ y (- x -1.0))) (+ y x))
(if (<= y 3.1e+86)
(* (/ y (* (* (+ y x) (+ y x)) (- x (- -1.0 y)))) x)
(/ (/ x y) (* (/ (- (+ y x) -1.0) y) (+ y x))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.02e-29) {
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
} else if (y <= 3.1e+86) {
tmp = (y / (((y + x) * (y + x)) * (x - (-1.0 - y)))) * x;
} else {
tmp = (x / y) / ((((y + 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 (y <= 1.02d-29) then
tmp = ((x / (y + x)) * (y / (x - (-1.0d0)))) / (y + x)
else if (y <= 3.1d+86) then
tmp = (y / (((y + x) * (y + x)) * (x - ((-1.0d0) - y)))) * x
else
tmp = (x / y) / ((((y + 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 (y <= 1.02e-29) {
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
} else if (y <= 3.1e+86) {
tmp = (y / (((y + x) * (y + x)) * (x - (-1.0 - y)))) * x;
} else {
tmp = (x / y) / ((((y + x) - -1.0) / y) * (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.02e-29: tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x) elif y <= 3.1e+86: tmp = (y / (((y + x) * (y + x)) * (x - (-1.0 - y)))) * x else: tmp = (x / y) / ((((y + x) - -1.0) / y) * (y + x)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.02e-29) tmp = Float64(Float64(Float64(x / Float64(y + x)) * Float64(y / Float64(x - -1.0))) / Float64(y + x)); elseif (y <= 3.1e+86) tmp = Float64(Float64(y / Float64(Float64(Float64(y + x) * Float64(y + x)) * Float64(x - Float64(-1.0 - y)))) * x); else tmp = Float64(Float64(x / y) / Float64(Float64(Float64(Float64(y + x) - -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 (y <= 1.02e-29)
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
elseif (y <= 3.1e+86)
tmp = (y / (((y + x) * (y + x)) * (x - (-1.0 - y)))) * x;
else
tmp = (x / y) / ((((y + 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[y, 1.02e-29], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+86], N[(N[(y / N[(N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] / y), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{-29}:\\
\;\;\;\;\frac{\frac{x}{y + x} \cdot \frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+86}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) \cdot \left(y + x\right)\right) \cdot \left(x - \left(-1 - y\right)\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{\left(y + x\right) - -1}{y} \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if y < 1.01999999999999994e-29Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
frac-timesN/A
Applied rewrites75.8%
if 1.01999999999999994e-29 < y < 3.1000000000000002e86Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Applied rewrites82.1%
if 3.1000000000000002e86 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-/.f6461.8
Applied rewrites61.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.5e-10) (/ (* (/ x (+ y x)) (/ y (- x -1.0))) (+ y x)) (/ (/ x y) (* (/ (- (+ y x) -1.0) y) (+ y x)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
} else {
tmp = (x / y) / ((((y + 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 (y <= 5.5d-10) then
tmp = ((x / (y + x)) * (y / (x - (-1.0d0)))) / (y + x)
else
tmp = (x / y) / ((((y + 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 (y <= 5.5e-10) {
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
} else {
tmp = (x / y) / ((((y + x) - -1.0) / y) * (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.5e-10: tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x) else: tmp = (x / y) / ((((y + x) - -1.0) / y) * (y + x)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.5e-10) tmp = Float64(Float64(Float64(x / Float64(y + x)) * Float64(y / Float64(x - -1.0))) / Float64(y + x)); else tmp = Float64(Float64(x / y) / Float64(Float64(Float64(Float64(y + x) - -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 (y <= 5.5e-10)
tmp = ((x / (y + x)) * (y / (x - -1.0))) / (y + x);
else
tmp = (x / y) / ((((y + 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[y, 5.5e-10], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] / y), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{x}{y + x} \cdot \frac{y}{x - -1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{\left(y + x\right) - -1}{y} \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if y < 5.4999999999999996e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
frac-timesN/A
Applied rewrites75.8%
if 5.4999999999999996e-10 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-/.f6461.8
Applied rewrites61.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 5.5e-10)
(/ y (* (* (+ y x) (/ (+ y x) x)) (- x -1.0)))
(if (<= y 3.2e+152)
(/ (* (/ x (* (+ y x) (+ y x))) y) (+ 1.0 y))
(/ (/ x (+ y x)) (+ 1.0 y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
} else if (y <= 3.2e+152) {
tmp = ((x / ((y + x) * (y + x))) * y) / (1.0 + y);
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.5d-10) then
tmp = y / (((y + x) * ((y + x) / x)) * (x - (-1.0d0)))
else if (y <= 3.2d+152) then
tmp = ((x / ((y + x) * (y + x))) * y) / (1.0d0 + y)
else
tmp = (x / (y + x)) / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
} else if (y <= 3.2e+152) {
tmp = ((x / ((y + x) * (y + x))) * y) / (1.0 + y);
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.5e-10: tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0)) elif y <= 3.2e+152: tmp = ((x / ((y + x) * (y + x))) * y) / (1.0 + y) else: tmp = (x / (y + x)) / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.5e-10) tmp = Float64(y / Float64(Float64(Float64(y + x) * Float64(Float64(y + x) / x)) * Float64(x - -1.0))); elseif (y <= 3.2e+152) tmp = Float64(Float64(Float64(x / Float64(Float64(y + x) * Float64(y + x))) * y) / Float64(1.0 + y)); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5.5e-10)
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
elseif (y <= 3.2e+152)
tmp = ((x / ((y + x) * (y + x))) * y) / (1.0 + y);
else
tmp = (x / (y + x)) / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 5.5e-10], N[(y / N[(N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+152], N[(N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) \cdot \frac{y + x}{x}\right) \cdot \left(x - -1\right)}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+152}:\\
\;\;\;\;\frac{\frac{x}{\left(y + x\right) \cdot \left(y + x\right)} \cdot y}{1 + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 5.4999999999999996e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
div-flipN/A
frac-timesN/A
*-lft-identityN/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites84.0%
if 5.4999999999999996e-10 < y < 3.20000000000000005e152Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around 0
lower-+.f6474.9
Applied rewrites74.9%
if 3.20000000000000005e152 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 5.5e-10)
(/ y (* (* (+ y x) (/ (+ y x) x)) (- x -1.0)))
(if (<= y 3.2e+152)
(* (/ x y) (/ y (* (- (+ y x) -1.0) (+ y x))))
(/ (/ x (+ y x)) (+ 1.0 y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
} else if (y <= 3.2e+152) {
tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.5d-10) then
tmp = y / (((y + x) * ((y + x) / x)) * (x - (-1.0d0)))
else if (y <= 3.2d+152) then
tmp = (x / y) * (y / (((y + x) - (-1.0d0)) * (y + x)))
else
tmp = (x / (y + x)) / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
} else if (y <= 3.2e+152) {
tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.5e-10: tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0)) elif y <= 3.2e+152: tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x))) else: tmp = (x / (y + x)) / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.5e-10) tmp = Float64(y / Float64(Float64(Float64(y + x) * Float64(Float64(y + x) / x)) * Float64(x - -1.0))); elseif (y <= 3.2e+152) tmp = Float64(Float64(x / y) * Float64(y / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5.5e-10)
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
elseif (y <= 3.2e+152)
tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x)));
else
tmp = (x / (y + x)) / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 5.5e-10], N[(y / N[(N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+152], N[(N[(x / y), $MachinePrecision] * N[(y / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) \cdot \frac{y + x}{x}\right) \cdot \left(x - -1\right)}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+152}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{y}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 5.4999999999999996e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
div-flipN/A
frac-timesN/A
*-lft-identityN/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites84.0%
if 5.4999999999999996e-10 < y < 3.20000000000000005e152Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
Taylor expanded in x around 0
lower-/.f6458.7
Applied rewrites58.7%
if 3.20000000000000005e152 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.5e-10) (/ y (* (* (+ y x) (/ (+ y x) x)) (- x -1.0))) (/ (/ x y) (* (/ (- (+ y x) -1.0) y) (+ y x)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
} else {
tmp = (x / y) / ((((y + 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 (y <= 5.5d-10) then
tmp = y / (((y + x) * ((y + x) / x)) * (x - (-1.0d0)))
else
tmp = (x / y) / ((((y + 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 (y <= 5.5e-10) {
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
} else {
tmp = (x / y) / ((((y + x) - -1.0) / y) * (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.5e-10: tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0)) else: tmp = (x / y) / ((((y + x) - -1.0) / y) * (y + x)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.5e-10) tmp = Float64(y / Float64(Float64(Float64(y + x) * Float64(Float64(y + x) / x)) * Float64(x - -1.0))); else tmp = Float64(Float64(x / y) / Float64(Float64(Float64(Float64(y + x) - -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 (y <= 5.5e-10)
tmp = y / (((y + x) * ((y + x) / x)) * (x - -1.0));
else
tmp = (x / y) / ((((y + 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[y, 5.5e-10], N[(y / N[(N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] / y), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) \cdot \frac{y + x}{x}\right) \cdot \left(x - -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{\left(y + x\right) - -1}{y} \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if y < 5.4999999999999996e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
div-flipN/A
frac-timesN/A
*-lft-identityN/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites84.0%
if 5.4999999999999996e-10 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-/.f6461.8
Applied rewrites61.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 5.5e-10)
(* (/ y (+ y x)) (/ x (* (- x -1.0) (+ y x))))
(if (<= y 3.2e+152)
(* (/ x y) (/ y (* (- (+ y x) -1.0) (+ y x))))
(/ (/ x (+ y x)) (+ 1.0 y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
} else if (y <= 3.2e+152) {
tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.5d-10) then
tmp = (y / (y + x)) * (x / ((x - (-1.0d0)) * (y + x)))
else if (y <= 3.2d+152) then
tmp = (x / y) * (y / (((y + x) - (-1.0d0)) * (y + x)))
else
tmp = (x / (y + x)) / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e-10) {
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
} else if (y <= 3.2e+152) {
tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.5e-10: tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x))) elif y <= 3.2e+152: tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x))) else: tmp = (x / (y + x)) / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.5e-10) tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(x - -1.0) * Float64(y + x)))); elseif (y <= 3.2e+152) tmp = Float64(Float64(x / y) * Float64(y / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5.5e-10)
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
elseif (y <= 3.2e+152)
tmp = (x / y) * (y / (((y + x) - -1.0) * (y + x)));
else
tmp = (x / (y + x)) / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 5.5e-10], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+152], N[(N[(x / y), $MachinePrecision] * N[(y / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(x - -1\right) \cdot \left(y + x\right)}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+152}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{y}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 5.4999999999999996e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f6476.6
Applied rewrites76.6%
if 5.4999999999999996e-10 < y < 3.20000000000000005e152Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
Taylor expanded in x around 0
lower-/.f6458.7
Applied rewrites58.7%
if 3.20000000000000005e152 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.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 -7.5e-9)
(* (/ t_0 (- (+ y x) -1.0)) (/ y x))
(/ (* t_0 y) (* (- y -1.0) (+ y x))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -7.5e-9) {
tmp = (t_0 / ((y + x) - -1.0)) * (y / x);
} else {
tmp = (t_0 * y) / ((y - -1.0) * (y + x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (x <= (-7.5d-9)) then
tmp = (t_0 / ((y + x) - (-1.0d0))) * (y / x)
else
tmp = (t_0 * y) / ((y - (-1.0d0)) * (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 <= -7.5e-9) {
tmp = (t_0 / ((y + x) - -1.0)) * (y / x);
} else {
tmp = (t_0 * y) / ((y - -1.0) * (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if x <= -7.5e-9: tmp = (t_0 / ((y + x) - -1.0)) * (y / x) else: tmp = (t_0 * y) / ((y - -1.0) * (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 <= -7.5e-9) tmp = Float64(Float64(t_0 / Float64(Float64(y + x) - -1.0)) * Float64(y / x)); else tmp = Float64(Float64(t_0 * y) / Float64(Float64(y - -1.0) * 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 <= -7.5e-9)
tmp = (t_0 / ((y + x) - -1.0)) * (y / x);
else
tmp = (t_0 * y) / ((y - -1.0) * (y + x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.5e-9], N[(N[(t$95$0 / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * y), $MachinePrecision] / N[(N[(y - -1.0), $MachinePrecision] * N[(y + x), $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 -7.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t\_0}{\left(y + x\right) - -1} \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot y}{\left(y - -1\right) \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if x < -7.49999999999999933e-9Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6461.6
Applied rewrites61.6%
if -7.49999999999999933e-9 < x Initial program 68.5%
Taylor expanded in x around 0
lower-+.f6458.2
Applied rewrites58.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
Applied rewrites75.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (+ y x) -1.0)))
(if (<= y 1.6e-162)
(/ (/ y x) t_0)
(if (<= y 4.6e-10)
(* y (/ x (* (- x -1.0) (* (+ y x) (+ y x)))))
(if (<= y 3.2e+152)
(* (/ x y) (/ y (* t_0 (+ y x))))
(/ (/ x (+ y x)) (+ 1.0 y)))))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) - -1.0;
double tmp;
if (y <= 1.6e-162) {
tmp = (y / x) / t_0;
} else if (y <= 4.6e-10) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else if (y <= 3.2e+152) {
tmp = (x / y) * (y / (t_0 * (y + x)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (y + x) - (-1.0d0)
if (y <= 1.6d-162) then
tmp = (y / x) / t_0
else if (y <= 4.6d-10) then
tmp = y * (x / ((x - (-1.0d0)) * ((y + x) * (y + x))))
else if (y <= 3.2d+152) then
tmp = (x / y) * (y / (t_0 * (y + x)))
else
tmp = (x / (y + x)) / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) - -1.0;
double tmp;
if (y <= 1.6e-162) {
tmp = (y / x) / t_0;
} else if (y <= 4.6e-10) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else if (y <= 3.2e+152) {
tmp = (x / y) * (y / (t_0 * (y + x)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) - -1.0 tmp = 0 if y <= 1.6e-162: tmp = (y / x) / t_0 elif y <= 4.6e-10: tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x)))) elif y <= 3.2e+152: tmp = (x / y) * (y / (t_0 * (y + x))) else: tmp = (x / (y + x)) / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) - -1.0) tmp = 0.0 if (y <= 1.6e-162) tmp = Float64(Float64(y / x) / t_0); elseif (y <= 4.6e-10) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x))))); elseif (y <= 3.2e+152) tmp = Float64(Float64(x / y) * Float64(y / Float64(t_0 * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) - -1.0;
tmp = 0.0;
if (y <= 1.6e-162)
tmp = (y / x) / t_0;
elseif (y <= 4.6e-10)
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
elseif (y <= 3.2e+152)
tmp = (x / y) * (y / (t_0 * (y + x)));
else
tmp = (x / (y + x)) / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, 1.6e-162], N[(N[(y / x), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[y, 4.6e-10], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+152], N[(N[(x / y), $MachinePrecision] * N[(y / N[(t$95$0 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) - -1\\
\mathbf{if}\;y \leq 1.6 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_0}\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-10}:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+152}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{y}{t\_0 \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 1.59999999999999988e-162Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 1.59999999999999988e-162 < y < 4.60000000000000014e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.6
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites75.6%
if 4.60000000000000014e-10 < y < 3.20000000000000005e152Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
Taylor expanded in x around 0
lower-/.f6458.7
Applied rewrites58.7%
if 3.20000000000000005e152 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ y x) (+ y x))) (t_1 (- (+ y x) -1.0)))
(if (<= y 1.6e-162)
(/ (/ y x) t_1)
(if (<= y 4.4e-10)
(* y (/ x (* (- x -1.0) t_0)))
(if (<= y 1.5e+118)
(* (/ y (* (- y -1.0) t_0)) x)
(* (/ (/ x (+ y x)) t_1) 1.0))))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) * (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 1.6e-162) {
tmp = (y / x) / t_1;
} else if (y <= 4.4e-10) {
tmp = y * (x / ((x - -1.0) * t_0));
} else if (y <= 1.5e+118) {
tmp = (y / ((y - -1.0) * t_0)) * x;
} else {
tmp = ((x / (y + x)) / t_1) * 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) :: t_1
real(8) :: tmp
t_0 = (y + x) * (y + x)
t_1 = (y + x) - (-1.0d0)
if (y <= 1.6d-162) then
tmp = (y / x) / t_1
else if (y <= 4.4d-10) then
tmp = y * (x / ((x - (-1.0d0)) * t_0))
else if (y <= 1.5d+118) then
tmp = (y / ((y - (-1.0d0)) * t_0)) * x
else
tmp = ((x / (y + x)) / t_1) * 1.0d0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) * (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 1.6e-162) {
tmp = (y / x) / t_1;
} else if (y <= 4.4e-10) {
tmp = y * (x / ((x - -1.0) * t_0));
} else if (y <= 1.5e+118) {
tmp = (y / ((y - -1.0) * t_0)) * x;
} else {
tmp = ((x / (y + x)) / t_1) * 1.0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) * (y + x) t_1 = (y + x) - -1.0 tmp = 0 if y <= 1.6e-162: tmp = (y / x) / t_1 elif y <= 4.4e-10: tmp = y * (x / ((x - -1.0) * t_0)) elif y <= 1.5e+118: tmp = (y / ((y - -1.0) * t_0)) * x else: tmp = ((x / (y + x)) / t_1) * 1.0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) * Float64(y + x)) t_1 = Float64(Float64(y + x) - -1.0) tmp = 0.0 if (y <= 1.6e-162) tmp = Float64(Float64(y / x) / t_1); elseif (y <= 4.4e-10) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * t_0))); elseif (y <= 1.5e+118) tmp = Float64(Float64(y / Float64(Float64(y - -1.0) * t_0)) * x); else tmp = Float64(Float64(Float64(x / Float64(y + x)) / t_1) * 1.0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) * (y + x);
t_1 = (y + x) - -1.0;
tmp = 0.0;
if (y <= 1.6e-162)
tmp = (y / x) / t_1;
elseif (y <= 4.4e-10)
tmp = y * (x / ((x - -1.0) * t_0));
elseif (y <= 1.5e+118)
tmp = (y / ((y - -1.0) * t_0)) * x;
else
tmp = ((x / (y + x)) / t_1) * 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[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, 1.6e-162], N[(N[(y / x), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[y, 4.4e-10], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e+118], N[(N[(y / N[(N[(y - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] * 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) \cdot \left(y + x\right)\\
t_1 := \left(y + x\right) - -1\\
\mathbf{if}\;y \leq 1.6 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_1}\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-10}:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot t\_0}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+118}:\\
\;\;\;\;\frac{y}{\left(y - -1\right) \cdot t\_0} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{t\_1} \cdot 1\\
\end{array}
\end{array}
if y < 1.59999999999999988e-162Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 1.59999999999999988e-162 < y < 4.3999999999999998e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.6
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites75.6%
if 4.3999999999999998e-10 < y < 1.5e118Initial program 68.5%
Taylor expanded in x around 0
lower-+.f6458.2
Applied rewrites58.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.4%
if 1.5e118 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ y x) (+ y x))) (t_1 (- (+ y x) -1.0)))
(if (<= y 1.95e-162)
(/ (/ y x) t_1)
(if (<= y 4.4e-10)
(* (/ y (* (- x -1.0) t_0)) x)
(if (<= y 1.5e+118)
(* (/ y (* (- y -1.0) t_0)) x)
(* (/ (/ x (+ y x)) t_1) 1.0))))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) * (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 1.95e-162) {
tmp = (y / x) / t_1;
} else if (y <= 4.4e-10) {
tmp = (y / ((x - -1.0) * t_0)) * x;
} else if (y <= 1.5e+118) {
tmp = (y / ((y - -1.0) * t_0)) * x;
} else {
tmp = ((x / (y + x)) / t_1) * 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) :: t_1
real(8) :: tmp
t_0 = (y + x) * (y + x)
t_1 = (y + x) - (-1.0d0)
if (y <= 1.95d-162) then
tmp = (y / x) / t_1
else if (y <= 4.4d-10) then
tmp = (y / ((x - (-1.0d0)) * t_0)) * x
else if (y <= 1.5d+118) then
tmp = (y / ((y - (-1.0d0)) * t_0)) * x
else
tmp = ((x / (y + x)) / t_1) * 1.0d0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) * (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 1.95e-162) {
tmp = (y / x) / t_1;
} else if (y <= 4.4e-10) {
tmp = (y / ((x - -1.0) * t_0)) * x;
} else if (y <= 1.5e+118) {
tmp = (y / ((y - -1.0) * t_0)) * x;
} else {
tmp = ((x / (y + x)) / t_1) * 1.0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) * (y + x) t_1 = (y + x) - -1.0 tmp = 0 if y <= 1.95e-162: tmp = (y / x) / t_1 elif y <= 4.4e-10: tmp = (y / ((x - -1.0) * t_0)) * x elif y <= 1.5e+118: tmp = (y / ((y - -1.0) * t_0)) * x else: tmp = ((x / (y + x)) / t_1) * 1.0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) * Float64(y + x)) t_1 = Float64(Float64(y + x) - -1.0) tmp = 0.0 if (y <= 1.95e-162) tmp = Float64(Float64(y / x) / t_1); elseif (y <= 4.4e-10) tmp = Float64(Float64(y / Float64(Float64(x - -1.0) * t_0)) * x); elseif (y <= 1.5e+118) tmp = Float64(Float64(y / Float64(Float64(y - -1.0) * t_0)) * x); else tmp = Float64(Float64(Float64(x / Float64(y + x)) / t_1) * 1.0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) * (y + x);
t_1 = (y + x) - -1.0;
tmp = 0.0;
if (y <= 1.95e-162)
tmp = (y / x) / t_1;
elseif (y <= 4.4e-10)
tmp = (y / ((x - -1.0) * t_0)) * x;
elseif (y <= 1.5e+118)
tmp = (y / ((y - -1.0) * t_0)) * x;
else
tmp = ((x / (y + x)) / t_1) * 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[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, 1.95e-162], N[(N[(y / x), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[y, 4.4e-10], N[(N[(y / N[(N[(x - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 1.5e+118], N[(N[(y / N[(N[(y - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] * 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) \cdot \left(y + x\right)\\
t_1 := \left(y + x\right) - -1\\
\mathbf{if}\;y \leq 1.95 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{y}{x}}{t\_1}\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{\left(x - -1\right) \cdot t\_0} \cdot x\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+118}:\\
\;\;\;\;\frac{y}{\left(y - -1\right) \cdot t\_0} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{t\_1} \cdot 1\\
\end{array}
\end{array}
if y < 1.95e-162Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 1.95e-162 < y < 4.3999999999999998e-10Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.1%
if 4.3999999999999998e-10 < y < 1.5e118Initial program 68.5%
Taylor expanded in x around 0
lower-+.f6458.2
Applied rewrites58.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.4%
if 1.5e118 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.95e-162)
(/ (/ y x) (- (+ y x) -1.0))
(if (<= y 7.5e-9)
(* (/ y (* (- x -1.0) (* (+ y x) (+ y x)))) x)
(if (<= y 3.2e+152)
(/ x (fma x (+ 2.0 (* 3.0 y)) (* y (+ 1.0 y))))
(/ (/ x (+ y x)) (+ 1.0 y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.95e-162) {
tmp = (y / x) / ((y + x) - -1.0);
} else if (y <= 7.5e-9) {
tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x;
} else if (y <= 3.2e+152) {
tmp = x / fma(x, (2.0 + (3.0 * y)), (y * (1.0 + y)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.95e-162) tmp = Float64(Float64(y / x) / Float64(Float64(y + x) - -1.0)); elseif (y <= 7.5e-9) tmp = Float64(Float64(y / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x)))) * x); elseif (y <= 3.2e+152) tmp = Float64(x / fma(x, Float64(2.0 + Float64(3.0 * y)), Float64(y * Float64(1.0 + y)))); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.95e-162], N[(N[(y / x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e-9], N[(N[(y / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 3.2e+152], N[(x / N[(x * N[(2.0 + N[(3.0 * y), $MachinePrecision]), $MachinePrecision] + N[(y * N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{y}{x}}{\left(y + x\right) - -1}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{y}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+152}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(x, 2 + 3 \cdot y, y \cdot \left(1 + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 1.95e-162Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 1.95e-162 < y < 7.49999999999999933e-9Initial program 68.5%
Taylor expanded in y around 0
lower-+.f6458.5
Applied rewrites58.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.1%
if 7.49999999999999933e-9 < y < 3.20000000000000005e152Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
div-flipN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
Applied rewrites84.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6452.0
Applied rewrites52.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
if 3.20000000000000005e152 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 3.1e-50)
(/ (/ y x) (- (+ y x) -1.0))
(if (<= y 3.2e+152)
(/ x (fma x (+ 2.0 (* 3.0 y)) (* y (+ 1.0 y))))
(/ (/ x (+ y x)) (+ 1.0 y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.1e-50) {
tmp = (y / x) / ((y + x) - -1.0);
} else if (y <= 3.2e+152) {
tmp = x / fma(x, (2.0 + (3.0 * y)), (y * (1.0 + y)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.1e-50) tmp = Float64(Float64(y / x) / Float64(Float64(y + x) - -1.0)); elseif (y <= 3.2e+152) tmp = Float64(x / fma(x, Float64(2.0 + Float64(3.0 * y)), Float64(y * Float64(1.0 + y)))); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.1e-50], N[(N[(y / x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+152], N[(x / N[(x * N[(2.0 + N[(3.0 * y), $MachinePrecision]), $MachinePrecision] + N[(y * N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.1 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{y}{x}}{\left(y + x\right) - -1}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+152}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(x, 2 + 3 \cdot y, y \cdot \left(1 + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 3.1000000000000002e-50Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 3.1000000000000002e-50 < y < 3.20000000000000005e152Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
div-flipN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
Applied rewrites84.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6452.0
Applied rewrites52.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
if 3.20000000000000005e152 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 3.1e-50)
(/ (/ y x) (- (+ y x) -1.0))
(if (<= y 3.2e+152)
(/ x (fma x (* 3.0 y) (* y (+ 1.0 y))))
(/ (/ x (+ y x)) (+ 1.0 y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.1e-50) {
tmp = (y / x) / ((y + x) - -1.0);
} else if (y <= 3.2e+152) {
tmp = x / fma(x, (3.0 * y), (y * (1.0 + y)));
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.1e-50) tmp = Float64(Float64(y / x) / Float64(Float64(y + x) - -1.0)); elseif (y <= 3.2e+152) tmp = Float64(x / fma(x, Float64(3.0 * y), Float64(y * Float64(1.0 + y)))); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.1e-50], N[(N[(y / x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+152], N[(x / N[(x * N[(3.0 * y), $MachinePrecision] + N[(y * N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.1 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{y}{x}}{\left(y + x\right) - -1}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+152}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(x, 3 \cdot y, y \cdot \left(1 + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 3.1000000000000002e-50Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 3.1000000000000002e-50 < y < 3.20000000000000005e152Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
div-flipN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
Applied rewrites84.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6452.0
Applied rewrites52.0%
Taylor expanded in y around inf
lower-*.f6451.6
Applied rewrites51.6%
if 3.20000000000000005e152 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 3.1e-50) (/ (/ y x) (- (+ y x) -1.0)) (/ (/ x (+ y x)) (+ 1.0 y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.1e-50) {
tmp = (y / x) / ((y + x) - -1.0);
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.1d-50) then
tmp = (y / x) / ((y + x) - (-1.0d0))
else
tmp = (x / (y + x)) / (1.0d0 + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 3.1e-50) {
tmp = (y / x) / ((y + x) - -1.0);
} else {
tmp = (x / (y + x)) / (1.0 + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 3.1e-50: tmp = (y / x) / ((y + x) - -1.0) else: tmp = (x / (y + x)) / (1.0 + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.1e-50) tmp = Float64(Float64(y / x) / Float64(Float64(y + x) - -1.0)); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(1.0 + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 3.1e-50)
tmp = (y / x) / ((y + x) - -1.0);
else
tmp = (x / (y + x)) / (1.0 + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.1e-50], N[(N[(y / x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.1 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{y}{x}}{\left(y + x\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{1 + y}\\
\end{array}
\end{array}
if y < 3.1000000000000002e-50Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 3.1000000000000002e-50 < y Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
pow2N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
frac-timesN/A
div-flipN/A
lift-/.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
lower-+.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 3.2e-50) (/ (/ y x) (- (+ y x) -1.0)) (/ (/ x (- y -1.0)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.2e-50) {
tmp = (y / x) / ((y + x) - -1.0);
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.2d-50) then
tmp = (y / x) / ((y + x) - (-1.0d0))
else
tmp = (x / (y - (-1.0d0))) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 3.2e-50) {
tmp = (y / x) / ((y + x) - -1.0);
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 3.2e-50: tmp = (y / x) / ((y + x) - -1.0) else: tmp = (x / (y - -1.0)) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.2e-50) tmp = Float64(Float64(y / x) / Float64(Float64(y + x) - -1.0)); else tmp = Float64(Float64(x / Float64(y - -1.0)) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 3.2e-50)
tmp = (y / x) / ((y + x) - -1.0);
else
tmp = (x / (y - -1.0)) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.2e-50], N[(N[(y / x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{y}{x}}{\left(y + x\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y}\\
\end{array}
\end{array}
if y < 3.2e-50Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.6
Applied rewrites87.6%
Taylor expanded in x around inf
lower-/.f6451.2
Applied rewrites51.2%
if 3.2e-50 < y Initial program 68.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.4
Applied rewrites48.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6449.8
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6449.8
Applied rewrites49.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 3.2e-50) (/ y (* x (+ 1.0 x))) (/ (/ x (- y -1.0)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.2e-50) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.2d-50) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (x / (y - (-1.0d0))) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 3.2e-50) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 3.2e-50: tmp = y / (x * (1.0 + x)) else: tmp = (x / (y - -1.0)) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.2e-50) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / Float64(y - -1.0)) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 3.2e-50)
tmp = y / (x * (1.0 + x));
else
tmp = (x / (y - -1.0)) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.2e-50], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{-50}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y}\\
\end{array}
\end{array}
if y < 3.2e-50Initial program 68.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
if 3.2e-50 < y Initial program 68.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.4
Applied rewrites48.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6449.8
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6449.8
Applied rewrites49.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.8e-149) (/ y (* x (+ 1.0 x))) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.8e-149) {
tmp = y / (x * (1.0 + x));
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.8e-149) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.8e-149], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-149}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -1.8000000000000001e-149Initial program 68.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
if -1.8000000000000001e-149 < x Initial program 68.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.4
Applied rewrites48.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.4
Applied rewrites48.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (fma y y y)))
assert(x < y);
double code(double x, double y) {
return x / fma(y, y, y);
}
x, y = sort([x, y]) function code(x, y) return Float64(x / fma(y, y, y)) end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{\mathsf{fma}\left(y, y, y\right)}
\end{array}
Initial program 68.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.4
Applied rewrites48.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.4
Applied rewrites48.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (* 2.0 x)))
assert(x < y);
double code(double x, double y) {
return x / (2.0 * 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 / (2.0d0 * x)
end function
assert x < y;
public static double code(double x, double y) {
return x / (2.0 * x);
}
[x, y] = sort([x, y]) def code(x, y): return x / (2.0 * x)
x, y = sort([x, y]) function code(x, y) return Float64(x / Float64(2.0 * x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / (2.0 * x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(2.0 * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{2 \cdot x}
\end{array}
Initial program 68.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.4
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
div-flipN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
Applied rewrites84.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6452.0
Applied rewrites52.0%
Taylor expanded in y around 0
lower-*.f643.5
Applied rewrites3.5%
herbie shell --seed 2025148
(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))))