
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (/ y (+ x y)) (* (/ (+ x y) x) (- x (- -1.0 y)))))
assert(x < y);
double code(double x, double y) {
return (y / (x + y)) / (((x + y) / x) * (x - (-1.0 - y)));
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / (x + y)) / (((x + y) / x) * (x - ((-1.0d0) - y)))
end function
assert x < y;
public static double code(double x, double y) {
return (y / (x + y)) / (((x + y) / x) * (x - (-1.0 - y)));
}
[x, y] = sort([x, y]) def code(x, y): return (y / (x + y)) / (((x + y) / x) * (x - (-1.0 - y)))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(y / Float64(x + y)) / Float64(Float64(Float64(x + y) / x) * Float64(x - Float64(-1.0 - y)))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (y / (x + y)) / (((x + y) / x) * (x - (-1.0 - y)));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] / x), $MachinePrecision] * N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{x + y}}{\frac{x + y}{x} \cdot \left(x - \left(-1 - y\right)\right)}
\end{array}
Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- x (- -1.0 y))) (t_1 (/ y (+ x y))))
(if (<= x -2.35e+166)
(/ t_1 (* (/ (+ x y) x) (- x -1.0)))
(if (<= x 5.5e-90)
(/ (* t_1 x) (* t_0 (+ x y)))
(/ (* 1.0 (/ x t_0)) (+ x y))))))assert(x < y);
double code(double x, double y) {
double t_0 = x - (-1.0 - y);
double t_1 = y / (x + y);
double tmp;
if (x <= -2.35e+166) {
tmp = t_1 / (((x + y) / x) * (x - -1.0));
} else if (x <= 5.5e-90) {
tmp = (t_1 * x) / (t_0 * (x + y));
} else {
tmp = (1.0 * (x / t_0)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x - ((-1.0d0) - y)
t_1 = y / (x + y)
if (x <= (-2.35d+166)) then
tmp = t_1 / (((x + y) / x) * (x - (-1.0d0)))
else if (x <= 5.5d-90) then
tmp = (t_1 * x) / (t_0 * (x + y))
else
tmp = (1.0d0 * (x / t_0)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x - (-1.0 - y);
double t_1 = y / (x + y);
double tmp;
if (x <= -2.35e+166) {
tmp = t_1 / (((x + y) / x) * (x - -1.0));
} else if (x <= 5.5e-90) {
tmp = (t_1 * x) / (t_0 * (x + y));
} else {
tmp = (1.0 * (x / t_0)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x - (-1.0 - y) t_1 = y / (x + y) tmp = 0 if x <= -2.35e+166: tmp = t_1 / (((x + y) / x) * (x - -1.0)) elif x <= 5.5e-90: tmp = (t_1 * x) / (t_0 * (x + y)) else: tmp = (1.0 * (x / t_0)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x - Float64(-1.0 - y)) t_1 = Float64(y / Float64(x + y)) tmp = 0.0 if (x <= -2.35e+166) tmp = Float64(t_1 / Float64(Float64(Float64(x + y) / x) * Float64(x - -1.0))); elseif (x <= 5.5e-90) tmp = Float64(Float64(t_1 * x) / Float64(t_0 * Float64(x + y))); else tmp = Float64(Float64(1.0 * Float64(x / t_0)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x - (-1.0 - y);
t_1 = y / (x + y);
tmp = 0.0;
if (x <= -2.35e+166)
tmp = t_1 / (((x + y) / x) * (x - -1.0));
elseif (x <= 5.5e-90)
tmp = (t_1 * x) / (t_0 * (x + y));
else
tmp = (1.0 * (x / t_0)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.35e+166], N[(t$95$1 / N[(N[(N[(x + y), $MachinePrecision] / x), $MachinePrecision] * N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-90], N[(N[(t$95$1 * x), $MachinePrecision] / N[(t$95$0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * N[(x / t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := x - \left(-1 - y\right)\\
t_1 := \frac{y}{x + y}\\
\mathbf{if}\;x \leq -2.35 \cdot 10^{+166}:\\
\;\;\;\;\frac{t\_1}{\frac{x + y}{x} \cdot \left(x - -1\right)}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-90}:\\
\;\;\;\;\frac{t\_1 \cdot x}{t\_0 \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \frac{x}{t\_0}}{x + y}\\
\end{array}
\end{array}
if x < -2.35e166Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
Applied rewrites76.5%
if -2.35e166 < x < 5.5000000000000003e-90Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-*r/N/A
Applied rewrites93.7%
if 5.5000000000000003e-90 < x Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-/r*N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites51.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 230000.0) (/ (/ y (+ x y)) (* (/ (+ x y) x) (- x -1.0))) (/ (* 1.0 (/ x (- x (- -1.0 y)))) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 230000.0) {
tmp = (y / (x + y)) / (((x + y) / x) * (x - -1.0));
} else {
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 230000.0d0) then
tmp = (y / (x + y)) / (((x + y) / x) * (x - (-1.0d0)))
else
tmp = (1.0d0 * (x / (x - ((-1.0d0) - y)))) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 230000.0) {
tmp = (y / (x + y)) / (((x + y) / x) * (x - -1.0));
} else {
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 230000.0: tmp = (y / (x + y)) / (((x + y) / x) * (x - -1.0)) else: tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 230000.0) tmp = Float64(Float64(y / Float64(x + y)) / Float64(Float64(Float64(x + y) / x) * Float64(x - -1.0))); else tmp = Float64(Float64(1.0 * Float64(x / Float64(x - Float64(-1.0 - y)))) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 230000.0)
tmp = (y / (x + y)) / (((x + y) / x) * (x - -1.0));
else
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 230000.0], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] / x), $MachinePrecision] * N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * N[(x / N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 230000:\\
\;\;\;\;\frac{\frac{y}{x + y}}{\frac{x + y}{x} \cdot \left(x - -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \frac{x}{x - \left(-1 - y\right)}}{x + y}\\
\end{array}
\end{array}
if y < 2.3e5Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
Applied rewrites76.5%
if 2.3e5 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-/r*N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites51.5%
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))))
(if (<= x -2.5e-5)
(/ t_0 (+ 1.0 x))
(if (<= x 5.5e-90)
(/ (* t_0 x) (* (- y -1.0) (+ x y)))
(/ (* 1.0 (/ x (- x (- -1.0 y)))) (+ x y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (x <= -2.5e-5) {
tmp = t_0 / (1.0 + x);
} else if (x <= 5.5e-90) {
tmp = (t_0 * x) / ((y - -1.0) * (x + y));
} else {
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y / (x + y)
if (x <= (-2.5d-5)) then
tmp = t_0 / (1.0d0 + x)
else if (x <= 5.5d-90) then
tmp = (t_0 * x) / ((y - (-1.0d0)) * (x + y))
else
tmp = (1.0d0 * (x / (x - ((-1.0d0) - y)))) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (x <= -2.5e-5) {
tmp = t_0 / (1.0 + x);
} else if (x <= 5.5e-90) {
tmp = (t_0 * x) / ((y - -1.0) * (x + y));
} else {
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (x + y) tmp = 0 if x <= -2.5e-5: tmp = t_0 / (1.0 + x) elif x <= 5.5e-90: tmp = (t_0 * x) / ((y - -1.0) * (x + y)) else: tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(x + y)) tmp = 0.0 if (x <= -2.5e-5) tmp = Float64(t_0 / Float64(1.0 + x)); elseif (x <= 5.5e-90) tmp = Float64(Float64(t_0 * x) / Float64(Float64(y - -1.0) * Float64(x + y))); else tmp = Float64(Float64(1.0 * Float64(x / Float64(x - Float64(-1.0 - y)))) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (x + y);
tmp = 0.0;
if (x <= -2.5e-5)
tmp = t_0 / (1.0 + x);
elseif (x <= 5.5e-90)
tmp = (t_0 * x) / ((y - -1.0) * (x + y));
else
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.5e-5], N[(t$95$0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-90], N[(N[(t$95$0 * x), $MachinePrecision] / N[(N[(y - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * N[(x / N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;x \leq -2.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0}{1 + x}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-90}:\\
\;\;\;\;\frac{t\_0 \cdot x}{\left(y - -1\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \frac{x}{x - \left(-1 - y\right)}}{x + y}\\
\end{array}
\end{array}
if x < -2.50000000000000012e-5Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
lower-+.f6451.3
Applied rewrites51.3%
if -2.50000000000000012e-5 < x < 5.5000000000000003e-90Initial program 69.1%
Taylor expanded in x around 0
lower-+.f6458.7
Applied rewrites58.7%
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
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites75.8%
if 5.5000000000000003e-90 < x Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-/r*N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites51.5%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 3.6e-167)
(/ (/ y (+ x y)) (+ 1.0 x))
(if (<= y 3500.0)
(* (/ y (* (+ 1.0 x) (* (+ y x) (+ y x)))) x)
(/ (* 1.0 (/ x (- x (- -1.0 y)))) (+ x y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.6e-167) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 3500.0) {
tmp = (y / ((1.0 + x) * ((y + x) * (y + x)))) * x;
} else {
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.6d-167) then
tmp = (y / (x + y)) / (1.0d0 + x)
else if (y <= 3500.0d0) then
tmp = (y / ((1.0d0 + x) * ((y + x) * (y + x)))) * x
else
tmp = (1.0d0 * (x / (x - ((-1.0d0) - y)))) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 3.6e-167) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 3500.0) {
tmp = (y / ((1.0 + x) * ((y + x) * (y + x)))) * x;
} else {
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 3.6e-167: tmp = (y / (x + y)) / (1.0 + x) elif y <= 3500.0: tmp = (y / ((1.0 + x) * ((y + x) * (y + x)))) * x else: tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.6e-167) tmp = Float64(Float64(y / Float64(x + y)) / Float64(1.0 + x)); elseif (y <= 3500.0) tmp = Float64(Float64(y / Float64(Float64(1.0 + x) * Float64(Float64(y + x) * Float64(y + x)))) * x); else tmp = Float64(Float64(1.0 * Float64(x / Float64(x - Float64(-1.0 - y)))) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 3.6e-167)
tmp = (y / (x + y)) / (1.0 + x);
elseif (y <= 3500.0)
tmp = (y / ((1.0 + x) * ((y + x) * (y + x)))) * x;
else
tmp = (1.0 * (x / (x - (-1.0 - y)))) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.6e-167], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3500.0], N[(N[(y / N[(N[(1.0 + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(1.0 * N[(x / N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{-167}:\\
\;\;\;\;\frac{\frac{y}{x + y}}{1 + x}\\
\mathbf{elif}\;y \leq 3500:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \frac{x}{x - \left(-1 - y\right)}}{x + y}\\
\end{array}
\end{array}
if y < 3.6000000000000001e-167Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
lower-+.f6451.3
Applied rewrites51.3%
if 3.6000000000000001e-167 < y < 3500Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.8%
Taylor expanded in y around 0
lower-+.f6472.1
Applied rewrites72.1%
if 3500 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-/r*N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites51.5%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- x (- -1.0 y))))
(if (<= y 4.4e-195)
(/ (/ y (+ x y)) (+ 1.0 x))
(if (<= y 1.8e+156)
(/ (* 1.0 x) (* t_0 (+ x y)))
(/ (* 1.0 (/ x t_0)) (+ x y))))))assert(x < y);
double code(double x, double y) {
double t_0 = x - (-1.0 - y);
double tmp;
if (y <= 4.4e-195) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / (t_0 * (x + y));
} else {
tmp = (1.0 * (x / t_0)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x - ((-1.0d0) - y)
if (y <= 4.4d-195) then
tmp = (y / (x + y)) / (1.0d0 + x)
else if (y <= 1.8d+156) then
tmp = (1.0d0 * x) / (t_0 * (x + y))
else
tmp = (1.0d0 * (x / t_0)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x - (-1.0 - y);
double tmp;
if (y <= 4.4e-195) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / (t_0 * (x + y));
} else {
tmp = (1.0 * (x / t_0)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x - (-1.0 - y) tmp = 0 if y <= 4.4e-195: tmp = (y / (x + y)) / (1.0 + x) elif y <= 1.8e+156: tmp = (1.0 * x) / (t_0 * (x + y)) else: tmp = (1.0 * (x / t_0)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x - Float64(-1.0 - y)) tmp = 0.0 if (y <= 4.4e-195) tmp = Float64(Float64(y / Float64(x + y)) / Float64(1.0 + x)); elseif (y <= 1.8e+156) tmp = Float64(Float64(1.0 * x) / Float64(t_0 * Float64(x + y))); else tmp = Float64(Float64(1.0 * Float64(x / t_0)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x - (-1.0 - y);
tmp = 0.0;
if (y <= 4.4e-195)
tmp = (y / (x + y)) / (1.0 + x);
elseif (y <= 1.8e+156)
tmp = (1.0 * x) / (t_0 * (x + y));
else
tmp = (1.0 * (x / t_0)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 4.4e-195], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+156], N[(N[(1.0 * x), $MachinePrecision] / N[(t$95$0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * N[(x / t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := x - \left(-1 - y\right)\\
\mathbf{if}\;y \leq 4.4 \cdot 10^{-195}:\\
\;\;\;\;\frac{\frac{y}{x + y}}{1 + x}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+156}:\\
\;\;\;\;\frac{1 \cdot x}{t\_0 \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \frac{x}{t\_0}}{x + y}\\
\end{array}
\end{array}
if y < 4.40000000000000011e-195Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
lower-+.f6451.3
Applied rewrites51.3%
if 4.40000000000000011e-195 < y < 1.79999999999999989e156Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-*r/N/A
Applied rewrites65.9%
if 1.79999999999999989e156 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-/r*N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites51.5%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- x (- -1.0 y))))
(if (<= y 4.4e-195)
(/ (/ y (+ x y)) (+ 1.0 x))
(if (<= y 1.8e+156)
(/ (* 1.0 x) (* t_0 (+ x y)))
(* (/ 1.0 t_0) (/ x (+ x y)))))))assert(x < y);
double code(double x, double y) {
double t_0 = x - (-1.0 - y);
double tmp;
if (y <= 4.4e-195) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / (t_0 * (x + y));
} else {
tmp = (1.0 / t_0) * (x / (x + y));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x - ((-1.0d0) - y)
if (y <= 4.4d-195) then
tmp = (y / (x + y)) / (1.0d0 + x)
else if (y <= 1.8d+156) then
tmp = (1.0d0 * x) / (t_0 * (x + y))
else
tmp = (1.0d0 / t_0) * (x / (x + y))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x - (-1.0 - y);
double tmp;
if (y <= 4.4e-195) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / (t_0 * (x + y));
} else {
tmp = (1.0 / t_0) * (x / (x + y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x - (-1.0 - y) tmp = 0 if y <= 4.4e-195: tmp = (y / (x + y)) / (1.0 + x) elif y <= 1.8e+156: tmp = (1.0 * x) / (t_0 * (x + y)) else: tmp = (1.0 / t_0) * (x / (x + y)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x - Float64(-1.0 - y)) tmp = 0.0 if (y <= 4.4e-195) tmp = Float64(Float64(y / Float64(x + y)) / Float64(1.0 + x)); elseif (y <= 1.8e+156) tmp = Float64(Float64(1.0 * x) / Float64(t_0 * Float64(x + y))); else tmp = Float64(Float64(1.0 / t_0) * Float64(x / Float64(x + y))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x - (-1.0 - y);
tmp = 0.0;
if (y <= 4.4e-195)
tmp = (y / (x + y)) / (1.0 + x);
elseif (y <= 1.8e+156)
tmp = (1.0 * x) / (t_0 * (x + y));
else
tmp = (1.0 / t_0) * (x / (x + y));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 4.4e-195], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+156], N[(N[(1.0 * x), $MachinePrecision] / N[(t$95$0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := x - \left(-1 - y\right)\\
\mathbf{if}\;y \leq 4.4 \cdot 10^{-195}:\\
\;\;\;\;\frac{\frac{y}{x + y}}{1 + x}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+156}:\\
\;\;\;\;\frac{1 \cdot x}{t\_0 \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0} \cdot \frac{x}{x + y}\\
\end{array}
\end{array}
if y < 4.40000000000000011e-195Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
lower-+.f6451.3
Applied rewrites51.3%
if 4.40000000000000011e-195 < y < 1.79999999999999989e156Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-*r/N/A
Applied rewrites65.9%
if 1.79999999999999989e156 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
associate-/r*N/A
mult-flipN/A
lift-/.f64N/A
div-flipN/A
lower-*.f64N/A
Applied rewrites51.5%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 4.4e-195)
(/ (/ y (+ x y)) (+ 1.0 x))
(if (<= y 1.8e+156)
(/ (* 1.0 x) (* (- x (- -1.0 y)) (+ x y)))
(/ (/ x y) (- y -1.0)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.4e-195) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / ((x - (-1.0 - y)) * (x + y));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.4d-195) then
tmp = (y / (x + y)) / (1.0d0 + x)
else if (y <= 1.8d+156) then
tmp = (1.0d0 * x) / ((x - ((-1.0d0) - y)) * (x + y))
else
tmp = (x / y) / (y - (-1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4.4e-195) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / ((x - (-1.0 - y)) * (x + y));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.4e-195: tmp = (y / (x + y)) / (1.0 + x) elif y <= 1.8e+156: tmp = (1.0 * x) / ((x - (-1.0 - y)) * (x + y)) else: tmp = (x / y) / (y - -1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.4e-195) tmp = Float64(Float64(y / Float64(x + y)) / Float64(1.0 + x)); elseif (y <= 1.8e+156) tmp = Float64(Float64(1.0 * x) / Float64(Float64(x - Float64(-1.0 - y)) * Float64(x + y))); else tmp = Float64(Float64(x / y) / Float64(y - -1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4.4e-195)
tmp = (y / (x + y)) / (1.0 + x);
elseif (y <= 1.8e+156)
tmp = (1.0 * x) / ((x - (-1.0 - y)) * (x + y));
else
tmp = (x / y) / (y - -1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 4.4e-195], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+156], N[(N[(1.0 * x), $MachinePrecision] / N[(N[(x - N[(-1.0 - y), $MachinePrecision]), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{-195}:\\
\;\;\;\;\frac{\frac{y}{x + y}}{1 + x}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+156}:\\
\;\;\;\;\frac{1 \cdot x}{\left(x - \left(-1 - y\right)\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y - -1}\\
\end{array}
\end{array}
if y < 4.40000000000000011e-195Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
lower-+.f6451.3
Applied rewrites51.3%
if 4.40000000000000011e-195 < y < 1.79999999999999989e156Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites50.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
div-flipN/A
associate-*r/N/A
Applied rewrites65.9%
if 1.79999999999999989e156 < y Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.1
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.1
Applied rewrites50.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 2.45e-83)
(/ (/ y (+ x y)) (+ 1.0 x))
(if (<= y 1.8e+156)
(/ (* 1.0 x) (* (- y -1.0) (+ x y)))
(/ (/ x y) (- y -1.0)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.45e-83) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / ((y - -1.0) * (x + y));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.45d-83) then
tmp = (y / (x + y)) / (1.0d0 + x)
else if (y <= 1.8d+156) then
tmp = (1.0d0 * x) / ((y - (-1.0d0)) * (x + y))
else
tmp = (x / y) / (y - (-1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.45e-83) {
tmp = (y / (x + y)) / (1.0 + x);
} else if (y <= 1.8e+156) {
tmp = (1.0 * x) / ((y - -1.0) * (x + y));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.45e-83: tmp = (y / (x + y)) / (1.0 + x) elif y <= 1.8e+156: tmp = (1.0 * x) / ((y - -1.0) * (x + y)) else: tmp = (x / y) / (y - -1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.45e-83) tmp = Float64(Float64(y / Float64(x + y)) / Float64(1.0 + x)); elseif (y <= 1.8e+156) tmp = Float64(Float64(1.0 * x) / Float64(Float64(y - -1.0) * Float64(x + y))); else tmp = Float64(Float64(x / y) / Float64(y - -1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.45e-83)
tmp = (y / (x + y)) / (1.0 + x);
elseif (y <= 1.8e+156)
tmp = (1.0 * x) / ((y - -1.0) * (x + y));
else
tmp = (x / y) / (y - -1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.45e-83], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+156], N[(N[(1.0 * x), $MachinePrecision] / N[(N[(y - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.45 \cdot 10^{-83}:\\
\;\;\;\;\frac{\frac{y}{x + y}}{1 + x}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+156}:\\
\;\;\;\;\frac{1 \cdot x}{\left(y - -1\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y - -1}\\
\end{array}
\end{array}
if y < 2.45e-83Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
lower-+.f6451.3
Applied rewrites51.3%
if 2.45e-83 < y < 1.79999999999999989e156Initial program 69.1%
Taylor expanded in x around 0
lower-+.f6458.7
Applied rewrites58.7%
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
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites75.8%
Taylor expanded in x around 0
Applied rewrites51.8%
if 1.79999999999999989e156 < y Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.1
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.1
Applied rewrites50.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.5e-83) (/ (/ y (+ x y)) (+ 1.0 x)) (/ (/ x y) (- y -1.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-83) {
tmp = (y / (x + y)) / (1.0 + x);
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.5d-83) then
tmp = (y / (x + y)) / (1.0d0 + x)
else
tmp = (x / y) / (y - (-1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e-83) {
tmp = (y / (x + y)) / (1.0 + x);
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.5e-83: tmp = (y / (x + y)) / (1.0 + x) else: tmp = (x / y) / (y - -1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.5e-83) tmp = Float64(Float64(y / Float64(x + y)) / Float64(1.0 + x)); else tmp = Float64(Float64(x / y) / Float64(y - -1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5.5e-83)
tmp = (y / (x + y)) / (1.0 + x);
else
tmp = (x / y) / (y - -1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 5.5e-83], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-83}:\\
\;\;\;\;\frac{\frac{y}{x + y}}{1 + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y - -1}\\
\end{array}
\end{array}
if y < 5.49999999999999964e-83Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval93.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-+l+N/A
metadata-evalN/A
sub-flipN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around 0
lower-+.f6451.3
Applied rewrites51.3%
if 5.49999999999999964e-83 < y Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.1
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.1
Applied rewrites50.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 3.8e-67) (/ y (* x (+ 1.0 x))) (/ (/ x y) (- y -1.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.8e-67) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.8d-67) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (x / y) / (y - (-1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 3.8e-67) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 3.8e-67: tmp = y / (x * (1.0 + x)) else: tmp = (x / y) / (y - -1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.8e-67) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / y) / Float64(y - -1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 3.8e-67)
tmp = y / (x * (1.0 + x));
else
tmp = (x / y) / (y - -1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.8e-67], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{-67}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y - -1}\\
\end{array}
\end{array}
if y < 3.79999999999999988e-67Initial program 69.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.5
Applied rewrites49.5%
if 3.79999999999999988e-67 < y Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.1
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.1
Applied rewrites50.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 3.8e-67) (/ y (* x (+ 1.0 x))) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.8e-67) {
tmp = y / (x * (1.0 + x));
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.8e-67) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.8e-67], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{-67}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if y < 3.79999999999999988e-67Initial program 69.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.5
Applied rewrites49.5%
if 3.79999999999999988e-67 < y Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.7
Applied rewrites48.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (fma y y y)))
assert(x < y);
double code(double x, double y) {
return x / fma(y, y, y);
}
x, y = sort([x, y]) function code(x, y) return Float64(x / fma(y, y, y)) end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{\mathsf{fma}\left(y, y, y\right)}
\end{array}
Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.7
Applied rewrites48.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ 1.0 (/ y x)))
assert(x < y);
double code(double x, double y) {
return 1.0 / (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 = 1.0d0 / (y / x)
end function
assert x < y;
public static double code(double x, double y) {
return 1.0 / (y / x);
}
[x, y] = sort([x, y]) def code(x, y): return 1.0 / (y / x)
x, y = sort([x, y]) function code(x, y) return Float64(1.0 / Float64(y / x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = 1.0 / (y / x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(1.0 / N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{\frac{y}{x}}
\end{array}
Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in y around 0
lower-/.f6426.7
Applied rewrites26.7%
lift-/.f64N/A
div-flipN/A
lower-/.f64N/A
lower-/.f6427.2
Applied rewrites27.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x y))
assert(x < y);
double code(double x, double y) {
return x / y;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
assert x < y;
public static double code(double x, double y) {
return x / y;
}
[x, y] = sort([x, y]) def code(x, y): return x / y
x, y = sort([x, y]) function code(x, y) return Float64(x / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y}
\end{array}
Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in y around 0
lower-/.f6426.7
Applied rewrites26.7%
herbie shell --seed 2025156
(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))))