
(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 13 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) 1.0)) (/ x (+ x y))) (+ x y)))
assert(x < y);
double code(double x, double y) {
return ((y / ((x + y) + 1.0)) * (x / (x + y))) / (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 = ((y / ((x + y) + 1.0d0)) * (x / (x + y))) / (x + y)
end function
assert x < y;
public static double code(double x, double y) {
return ((y / ((x + y) + 1.0)) * (x / (x + y))) / (x + y);
}
[x, y] = sort([x, y]) def code(x, y): return ((y / ((x + y) + 1.0)) * (x / (x + y))) / (x + y)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(y / Float64(Float64(x + y) + 1.0)) * Float64(x / Float64(x + y))) / Float64(x + y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((y / ((x + y) + 1.0)) * (x / (x + y))) / (x + y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(y / N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{\left(x + y\right) + 1} \cdot \frac{x}{x + y}}{x + y}
\end{array}
Initial program 69.2%
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ x y) 1.0)))
(if (<= x -1.45e+124)
(/ (* (/ y t_0) 1.0) (+ x y))
(if (<= x -75.0)
(* (/ x (* (* (+ x y) (+ x y)) t_0)) y)
(/ (* (/ y (+ 1.0 y)) (/ x (+ x y))) (+ x y))))))assert(x < y);
double code(double x, double y) {
double t_0 = (x + y) + 1.0;
double tmp;
if (x <= -1.45e+124) {
tmp = ((y / t_0) * 1.0) / (x + y);
} else if (x <= -75.0) {
tmp = (x / (((x + y) * (x + y)) * t_0)) * y;
} else {
tmp = ((y / (1.0 + y)) * (x / (x + 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 = (x + y) + 1.0d0
if (x <= (-1.45d+124)) then
tmp = ((y / t_0) * 1.0d0) / (x + y)
else if (x <= (-75.0d0)) then
tmp = (x / (((x + y) * (x + y)) * t_0)) * y
else
tmp = ((y / (1.0d0 + y)) * (x / (x + y))) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (x + y) + 1.0;
double tmp;
if (x <= -1.45e+124) {
tmp = ((y / t_0) * 1.0) / (x + y);
} else if (x <= -75.0) {
tmp = (x / (((x + y) * (x + y)) * t_0)) * y;
} else {
tmp = ((y / (1.0 + y)) * (x / (x + y))) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (x + y) + 1.0 tmp = 0 if x <= -1.45e+124: tmp = ((y / t_0) * 1.0) / (x + y) elif x <= -75.0: tmp = (x / (((x + y) * (x + y)) * t_0)) * y else: tmp = ((y / (1.0 + y)) * (x / (x + y))) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(x + y) + 1.0) tmp = 0.0 if (x <= -1.45e+124) tmp = Float64(Float64(Float64(y / t_0) * 1.0) / Float64(x + y)); elseif (x <= -75.0) tmp = Float64(Float64(x / Float64(Float64(Float64(x + y) * Float64(x + y)) * t_0)) * y); else tmp = Float64(Float64(Float64(y / Float64(1.0 + y)) * Float64(x / Float64(x + y))) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (x + y) + 1.0;
tmp = 0.0;
if (x <= -1.45e+124)
tmp = ((y / t_0) * 1.0) / (x + y);
elseif (x <= -75.0)
tmp = (x / (((x + y) * (x + y)) * t_0)) * y;
else
tmp = ((y / (1.0 + y)) * (x / (x + 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[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.45e+124], N[(N[(N[(y / t$95$0), $MachinePrecision] * 1.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -75.0], N[(N[(x / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(x + y\right) + 1\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{+124}:\\
\;\;\;\;\frac{\frac{y}{t\_0} \cdot 1}{x + y}\\
\mathbf{elif}\;x \leq -75:\\
\;\;\;\;\frac{x}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot t\_0} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{1 + y} \cdot \frac{x}{x + y}}{x + y}\\
\end{array}
\end{array}
if x < -1.45000000000000011e124Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites51.9%
if -1.45000000000000011e124 < x < -75Initial program 69.2%
Applied rewrites81.7%
if -75 < x Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.85e+151) (* (/ y (+ x y)) (/ x (* (+ (+ x y) 1.0) (+ x y)))) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.85e+151) {
tmp = (y / (x + y)) * (x / (((x + y) + 1.0) * (x + y)));
} else {
tmp = (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 <= 1.85d+151) then
tmp = (y / (x + y)) * (x / (((x + y) + 1.0d0) * (x + y)))
else
tmp = (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 <= 1.85e+151) {
tmp = (y / (x + y)) * (x / (((x + y) + 1.0) * (x + y)));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.85e+151: tmp = (y / (x + y)) * (x / (((x + y) + 1.0) * (x + y))) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.85e+151) tmp = Float64(Float64(y / Float64(x + y)) * Float64(x / Float64(Float64(Float64(x + y) + 1.0) * Float64(x + y)))); else tmp = Float64(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 <= 1.85e+151)
tmp = (y / (x + y)) * (x / (((x + y) + 1.0) * (x + y)));
else
tmp = (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, 1.85e+151], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{+151}:\\
\;\;\;\;\frac{y}{x + y} \cdot \frac{x}{\left(\left(x + y\right) + 1\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 1.8499999999999999e151Initial program 69.2%
Applied rewrites93.6%
if 1.8499999999999999e151 < y Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.4%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.45e+124)
(/ (* (/ y (+ (+ x y) 1.0)) 1.0) (+ x y))
(if (<= x -75.0)
(* (/ x (* (* (+ x y) (+ x y)) (+ 1.0 x))) y)
(/ (* (/ y (+ 1.0 y)) (/ x (+ x y))) (+ x y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.45e+124) {
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
} else if (x <= -75.0) {
tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y;
} else {
tmp = ((y / (1.0 + y)) * (x / (x + 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 (x <= (-1.45d+124)) then
tmp = ((y / ((x + y) + 1.0d0)) * 1.0d0) / (x + y)
else if (x <= (-75.0d0)) then
tmp = (x / (((x + y) * (x + y)) * (1.0d0 + x))) * y
else
tmp = ((y / (1.0d0 + y)) * (x / (x + y))) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.45e+124) {
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
} else if (x <= -75.0) {
tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y;
} else {
tmp = ((y / (1.0 + y)) * (x / (x + y))) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.45e+124: tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y) elif x <= -75.0: tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y else: tmp = ((y / (1.0 + y)) * (x / (x + y))) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.45e+124) tmp = Float64(Float64(Float64(y / Float64(Float64(x + y) + 1.0)) * 1.0) / Float64(x + y)); elseif (x <= -75.0) tmp = Float64(Float64(x / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(1.0 + x))) * y); else tmp = Float64(Float64(Float64(y / Float64(1.0 + y)) * Float64(x / Float64(x + y))) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.45e+124)
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
elseif (x <= -75.0)
tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y;
else
tmp = ((y / (1.0 + y)) * (x / (x + 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[x, -1.45e+124], N[(N[(N[(y / N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -75.0], N[(N[(x / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+124}:\\
\;\;\;\;\frac{\frac{y}{\left(x + y\right) + 1} \cdot 1}{x + y}\\
\mathbf{elif}\;x \leq -75:\\
\;\;\;\;\frac{x}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(1 + x\right)} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{1 + y} \cdot \frac{x}{x + y}}{x + y}\\
\end{array}
\end{array}
if x < -1.45000000000000011e124Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites51.9%
if -1.45000000000000011e124 < x < -75Initial program 69.2%
Applied rewrites81.7%
Taylor expanded in y around 0
Applied rewrites75.2%
if -75 < x Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 9.2e-197)
(/ (* (/ y (+ (+ x y) 1.0)) 1.0) (+ x y))
(if (<= y 1.25)
(* (/ x (* (* (+ x y) (+ x y)) (+ 1.0 x))) y)
(/ (/ x (+ 1.0 y)) (+ x y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 9.2e-197) {
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
} else if (y <= 1.25) {
tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y;
} else {
tmp = (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 <= 9.2d-197) then
tmp = ((y / ((x + y) + 1.0d0)) * 1.0d0) / (x + y)
else if (y <= 1.25d0) then
tmp = (x / (((x + y) * (x + y)) * (1.0d0 + x))) * y
else
tmp = (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 <= 9.2e-197) {
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
} else if (y <= 1.25) {
tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y;
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 9.2e-197: tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y) elif y <= 1.25: tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 9.2e-197) tmp = Float64(Float64(Float64(y / Float64(Float64(x + y) + 1.0)) * 1.0) / Float64(x + y)); elseif (y <= 1.25) tmp = Float64(Float64(x / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(1.0 + x))) * y); else tmp = Float64(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 <= 9.2e-197)
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
elseif (y <= 1.25)
tmp = (x / (((x + y) * (x + y)) * (1.0 + x))) * y;
else
tmp = (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, 9.2e-197], N[(N[(N[(y / N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25], N[(N[(x / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.2 \cdot 10^{-197}:\\
\;\;\;\;\frac{\frac{y}{\left(x + y\right) + 1} \cdot 1}{x + y}\\
\mathbf{elif}\;y \leq 1.25:\\
\;\;\;\;\frac{x}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(1 + x\right)} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 9.2000000000000002e-197Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites51.9%
if 9.2000000000000002e-197 < y < 1.25Initial program 69.2%
Applied rewrites81.7%
Taylor expanded in y around 0
Applied rewrites75.2%
if 1.25 < y Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.6e-50) (/ (* (/ y (+ (+ x y) 1.0)) 1.0) (+ x y)) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.6e-50) {
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
} else {
tmp = (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 <= 5.6d-50) then
tmp = ((y / ((x + y) + 1.0d0)) * 1.0d0) / (x + y)
else
tmp = (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 <= 5.6e-50) {
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.6e-50: tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.6e-50) tmp = Float64(Float64(Float64(y / Float64(Float64(x + y) + 1.0)) * 1.0) / Float64(x + y)); else tmp = Float64(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 <= 5.6e-50)
tmp = ((y / ((x + y) + 1.0)) * 1.0) / (x + y);
else
tmp = (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, 5.6e-50], N[(N[(N[(y / N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{y}{\left(x + y\right) + 1} \cdot 1}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 5.5999999999999996e-50Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites51.9%
if 5.5999999999999996e-50 < y Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.6e-50) (/ (/ y (+ 1.0 x)) (+ x y)) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.6e-50) {
tmp = (y / (1.0 + x)) / (x + y);
} else {
tmp = (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 <= 5.6d-50) then
tmp = (y / (1.0d0 + x)) / (x + y)
else
tmp = (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 <= 5.6e-50) {
tmp = (y / (1.0 + x)) / (x + y);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.6e-50: tmp = (y / (1.0 + x)) / (x + y) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.6e-50) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(x + y)); else tmp = Float64(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 <= 5.6e-50)
tmp = (y / (1.0 + x)) / (x + y);
else
tmp = (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, 5.6e-50], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 5.5999999999999996e-50Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites51.1%
if 5.5999999999999996e-50 < y Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.6e-50) (/ y (* x (+ 1.0 x))) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.6e-50) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (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 <= 5.6d-50) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (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 <= 5.6e-50) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.6e-50: tmp = y / (x * (1.0 + x)) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.6e-50) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(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 <= 5.6e-50)
tmp = y / (x * (1.0 + x));
else
tmp = (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, 5.6e-50], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 5.5999999999999996e-50Initial program 69.2%
Taylor expanded in y around 0
Applied rewrites49.4%
if 5.5999999999999996e-50 < y Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.6e-50) (/ y (* x (+ 1.0 x))) (/ (/ x (+ 1.0 y)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.6e-50) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (1.0 + y)) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.6d-50) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (x / (1.0d0 + y)) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5.6e-50) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (1.0 + y)) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.6e-50: tmp = y / (x * (1.0 + x)) else: tmp = (x / (1.0 + y)) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.6e-50) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5.6e-50)
tmp = y / (x * (1.0 + x));
else
tmp = (x / (1.0 + y)) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 5.6e-50], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{y}\\
\end{array}
\end{array}
if y < 5.5999999999999996e-50Initial program 69.2%
Taylor expanded in y around 0
Applied rewrites49.4%
if 5.5999999999999996e-50 < y Initial program 69.2%
Taylor expanded in x around 0
Applied rewrites48.5%
Applied rewrites49.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.6e-50) (/ y (* x (+ 1.0 x))) (/ x (* y (+ 1.0 y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.6e-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 <= 5.6d-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 <= 5.6e-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 <= 5.6e-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 <= 5.6e-50) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(x / Float64(y * 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.6e-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, 5.6e-50], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(1 + y\right)}\\
\end{array}
\end{array}
if y < 5.5999999999999996e-50Initial program 69.2%
Taylor expanded in y around 0
Applied rewrites49.4%
if 5.5999999999999996e-50 < y Initial program 69.2%
Taylor expanded in x around 0
Applied rewrites48.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -2.8e+104) (/ (/ y x) y) (/ x (* y (+ 1.0 y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -2.8e+104) {
tmp = (y / x) / y;
} 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 (x <= (-2.8d+104)) then
tmp = (y / x) / y
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 (x <= -2.8e+104) {
tmp = (y / x) / y;
} else {
tmp = x / (y * (1.0 + y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -2.8e+104: tmp = (y / x) / y else: tmp = x / (y * (1.0 + y)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -2.8e+104) tmp = Float64(Float64(y / x) / y); else tmp = Float64(x / Float64(y * Float64(1.0 + y))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -2.8e+104)
tmp = (y / x) / y;
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[x, -2.8e+104], N[(N[(y / x), $MachinePrecision] / y), $MachinePrecision], N[(x / N[(y * N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{+104}:\\
\;\;\;\;\frac{\frac{y}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(1 + y\right)}\\
\end{array}
\end{array}
if x < -2.8e104Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites38.6%
Taylor expanded in x around 0
Applied rewrites14.4%
if -2.8e104 < x Initial program 69.2%
Taylor expanded in x around 0
Applied rewrites48.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -2.8e+104) (/ (/ y x) y) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -2.8e+104) {
tmp = (y / x) / y;
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -2.8e+104) tmp = Float64(Float64(y / x) / y); 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, -2.8e+104], N[(N[(y / x), $MachinePrecision] / y), $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 -2.8 \cdot 10^{+104}:\\
\;\;\;\;\frac{\frac{y}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -2.8e104Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites38.6%
Taylor expanded in x around 0
Applied rewrites14.4%
if -2.8e104 < x Initial program 69.2%
Taylor expanded in x around 0
Applied rewrites48.5%
Applied rewrites48.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (/ y x) y))
assert(x < y);
double code(double x, double y) {
return (y / 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 = (y / x) / y
end function
assert x < y;
public static double code(double x, double y) {
return (y / x) / y;
}
[x, y] = sort([x, y]) def code(x, y): return (y / x) / y
x, y = sort([x, y]) function code(x, y) return Float64(Float64(y / x) / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (y / x) / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(y / x), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{x}}{y}
\end{array}
Initial program 69.2%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites38.6%
Taylor expanded in x around 0
Applied rewrites14.4%
herbie shell --seed 2025153
(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))))