
(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}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (* (/ x (+ y x)) (/ y (+ (+ y x) 1.0))) (+ y x)))
assert(x < y);
double code(double x, double y) {
return ((x / (y + x)) * (y / ((y + x) + 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 = ((x / (y + x)) * (y / ((y + x) + 1.0d0))) / (y + x)
end function
assert x < y;
public static double code(double x, double y) {
return ((x / (y + x)) * (y / ((y + x) + 1.0))) / (y + x);
}
[x, y] = sort([x, y]) def code(x, y): return ((x / (y + x)) * (y / ((y + x) + 1.0))) / (y + x)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(x / Float64(y + x)) * Float64(y / Float64(Float64(y + x) + 1.0))) / Float64(y + x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((x / (y + x)) * (y / ((y + x) + 1.0))) / (y + x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{x}{y + x} \cdot \frac{y}{\left(y + x\right) + 1}}{y + x}
\end{array}
Initial program 69.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.3
Applied rewrites88.3%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.3
Applied rewrites88.3%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f6499.8
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (+ y x) 1.0)))
(if (<= y 2.8e-259)
(* (/ 1.0 (+ y x)) (/ y t_0))
(if (<= y 1.1e-161)
(/ x y)
(if (<= y 2.3e+102)
(/ (* x y) (* (+ y x) (* (+ y x) t_0)))
(* (/ (/ x (+ y x)) (+ y x)) 1.0))))))assert(x < y);
double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (y <= 2.8e-259) {
tmp = (1.0 / (y + x)) * (y / t_0);
} else if (y <= 1.1e-161) {
tmp = x / y;
} else if (y <= 2.3e+102) {
tmp = (x * y) / ((y + x) * ((y + x) * t_0));
} else {
tmp = ((x / (y + x)) / (y + x)) * 1.0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (y + x) + 1.0d0
if (y <= 2.8d-259) then
tmp = (1.0d0 / (y + x)) * (y / t_0)
else if (y <= 1.1d-161) then
tmp = x / y
else if (y <= 2.3d+102) then
tmp = (x * y) / ((y + x) * ((y + x) * t_0))
else
tmp = ((x / (y + x)) / (y + x)) * 1.0d0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y + x) + 1.0;
double tmp;
if (y <= 2.8e-259) {
tmp = (1.0 / (y + x)) * (y / t_0);
} else if (y <= 1.1e-161) {
tmp = x / y;
} else if (y <= 2.3e+102) {
tmp = (x * y) / ((y + x) * ((y + x) * t_0));
} else {
tmp = ((x / (y + x)) / (y + x)) * 1.0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y + x) + 1.0 tmp = 0 if y <= 2.8e-259: tmp = (1.0 / (y + x)) * (y / t_0) elif y <= 1.1e-161: tmp = x / y elif y <= 2.3e+102: tmp = (x * y) / ((y + x) * ((y + x) * t_0)) else: tmp = ((x / (y + x)) / (y + x)) * 1.0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y + x) + 1.0) tmp = 0.0 if (y <= 2.8e-259) tmp = Float64(Float64(1.0 / Float64(y + x)) * Float64(y / t_0)); elseif (y <= 1.1e-161) tmp = Float64(x / y); elseif (y <= 2.3e+102) tmp = Float64(Float64(x * y) / Float64(Float64(y + x) * Float64(Float64(y + x) * t_0))); else tmp = Float64(Float64(Float64(x / Float64(y + x)) / Float64(y + x)) * 1.0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (y + x) + 1.0;
tmp = 0.0;
if (y <= 2.8e-259)
tmp = (1.0 / (y + x)) * (y / t_0);
elseif (y <= 1.1e-161)
tmp = x / y;
elseif (y <= 2.3e+102)
tmp = (x * y) / ((y + x) * ((y + x) * t_0));
else
tmp = ((x / (y + x)) / (y + x)) * 1.0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[y, 2.8e-259], N[(N[(1.0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-161], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.3e+102], N[(N[(x * y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(y + x\right) + 1\\
\mathbf{if}\;y \leq 2.8 \cdot 10^{-259}:\\
\;\;\;\;\frac{1}{y + x} \cdot \frac{y}{t\_0}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-161}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+102}:\\
\;\;\;\;\frac{x \cdot y}{\left(y + x\right) \cdot \left(\left(y + x\right) \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{y + x} \cdot 1\\
\end{array}
\end{array}
if y < 2.8e-259Initial program 69.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6489.4
Applied rewrites89.4%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites53.1%
if 2.8e-259 < y < 1.10000000000000001e-161Initial program 62.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6466.4
Applied rewrites66.4%
Taylor expanded in x around 0
frac-timesN/A
unpow2N/A
+-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f6424.1
Applied rewrites24.1%
Taylor expanded in y around 0
Applied rewrites24.1%
if 1.10000000000000001e-161 < y < 2.2999999999999999e102Initial program 87.9%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.9
Applied rewrites87.9%
if 2.2999999999999999e102 < y Initial program 54.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.6
Applied rewrites88.6%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.6
Applied rewrites88.6%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites84.6%
Final simplification62.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 2.8e-259)
(* (/ 1.0 (+ y x)) (/ y (+ (+ y x) 1.0)))
(if (<= y 1.1e-161)
(/ x y)
(if (<= y 2.3e+102)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(* (/ (/ x (+ y x)) (+ y x)) 1.0)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.8e-259) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else if (y <= 1.1e-161) {
tmp = x / y;
} else if (y <= 2.3e+102) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = ((x / (y + x)) / (y + x)) * 1.0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.8d-259) then
tmp = (1.0d0 / (y + x)) * (y / ((y + x) + 1.0d0))
else if (y <= 1.1d-161) then
tmp = x / y
else if (y <= 2.3d+102) then
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
else
tmp = ((x / (y + x)) / (y + x)) * 1.0d0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.8e-259) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else if (y <= 1.1e-161) {
tmp = x / y;
} else if (y <= 2.3e+102) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = ((x / (y + x)) / (y + x)) * 1.0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.8e-259: tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0)) elif y <= 1.1e-161: tmp = x / y elif y <= 2.3e+102: tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)) else: tmp = ((x / (y + x)) / (y + x)) * 1.0 return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.8e-259) tmp = Float64(Float64(1.0 / Float64(y + x)) * Float64(y / Float64(Float64(y + x) + 1.0))); elseif (y <= 1.1e-161) tmp = Float64(x / y); elseif (y <= 2.3e+102) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(Float64(x / Float64(y + x)) / Float64(y + x)) * 1.0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.8e-259)
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
elseif (y <= 1.1e-161)
tmp = x / y;
elseif (y <= 2.3e+102)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
else
tmp = ((x / (y + x)) / (y + x)) * 1.0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.8e-259], N[(N[(1.0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-161], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.3e+102], 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], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{-259}:\\
\;\;\;\;\frac{1}{y + x} \cdot \frac{y}{\left(y + x\right) + 1}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-161}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+102}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{y + x} \cdot 1\\
\end{array}
\end{array}
if y < 2.8e-259Initial program 69.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.4
Applied rewrites89.4%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6489.4
Applied rewrites89.4%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites53.1%
if 2.8e-259 < y < 1.10000000000000001e-161Initial program 62.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6466.4
Applied rewrites66.4%
Taylor expanded in x around 0
frac-timesN/A
unpow2N/A
+-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f6424.1
Applied rewrites24.1%
Taylor expanded in y around 0
Applied rewrites24.1%
if 1.10000000000000001e-161 < y < 2.2999999999999999e102Initial program 87.9%
if 2.2999999999999999e102 < y Initial program 54.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.6
Applied rewrites88.6%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.6
Applied rewrites88.6%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites84.6%
Final simplification62.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ (+ y x) 1.0))))
(if (<= x -5.7e+155)
(* (/ 1.0 (+ y x)) t_0)
(if (<= x -2.15e-159)
(* (/ x (* (+ y x) (+ y x))) t_0)
(/ x (* (+ 1.0 y) y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / ((y + x) + 1.0);
double tmp;
if (x <= -5.7e+155) {
tmp = (1.0 / (y + x)) * t_0;
} else if (x <= -2.15e-159) {
tmp = (x / ((y + x) * (y + x))) * t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / ((y + x) + 1.0d0)
if (x <= (-5.7d+155)) then
tmp = (1.0d0 / (y + x)) * t_0
else if (x <= (-2.15d-159)) then
tmp = (x / ((y + x) * (y + x))) * t_0
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 t_0 = y / ((y + x) + 1.0);
double tmp;
if (x <= -5.7e+155) {
tmp = (1.0 / (y + x)) * t_0;
} else if (x <= -2.15e-159) {
tmp = (x / ((y + x) * (y + x))) * t_0;
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / ((y + x) + 1.0) tmp = 0 if x <= -5.7e+155: tmp = (1.0 / (y + x)) * t_0 elif x <= -2.15e-159: tmp = (x / ((y + x) * (y + x))) * t_0 else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(Float64(y + x) + 1.0)) tmp = 0.0 if (x <= -5.7e+155) tmp = Float64(Float64(1.0 / Float64(y + x)) * t_0); elseif (x <= -2.15e-159) tmp = Float64(Float64(x / Float64(Float64(y + x) * Float64(y + x))) * t_0); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / ((y + x) + 1.0);
tmp = 0.0;
if (x <= -5.7e+155)
tmp = (1.0 / (y + x)) * t_0;
elseif (x <= -2.15e-159)
tmp = (x / ((y + x) * (y + x))) * t_0;
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_] := Block[{t$95$0 = N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.7e+155], N[(N[(1.0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, -2.15e-159], N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{\left(y + x\right) + 1}\\
\mathbf{if}\;x \leq -5.7 \cdot 10^{+155}:\\
\;\;\;\;\frac{1}{y + x} \cdot t\_0\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-159}:\\
\;\;\;\;\frac{x}{\left(y + x\right) \cdot \left(y + x\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -5.6999999999999996e155Initial program 56.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.0
Applied rewrites84.0%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6484.0
Applied rewrites84.0%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites81.6%
if -5.6999999999999996e155 < x < -2.15e-159Initial program 73.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6497.1
Applied rewrites97.1%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6497.1
Applied rewrites97.1%
if -2.15e-159 < x Initial program 69.5%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6456.2
Applied rewrites56.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -0.095)
(* (/ 1.0 (+ y x)) (/ y (+ (+ y x) 1.0)))
(if (<= x -2.15e-159)
(* (/ x (* (+ y x) (+ y x))) (/ y (+ y 1.0)))
(/ x (* (+ 1.0 y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -0.095) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else if (x <= -2.15e-159) {
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.095d0)) then
tmp = (1.0d0 / (y + x)) * (y / ((y + x) + 1.0d0))
else if (x <= (-2.15d-159)) then
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0d0))
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -0.095) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else if (x <= -2.15e-159) {
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -0.095: tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0)) elif x <= -2.15e-159: tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0)) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -0.095) tmp = Float64(Float64(1.0 / Float64(y + x)) * Float64(y / Float64(Float64(y + x) + 1.0))); elseif (x <= -2.15e-159) tmp = Float64(Float64(x / Float64(Float64(y + x) * Float64(y + x))) * Float64(y / Float64(y + 1.0))); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -0.095)
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
elseif (x <= -2.15e-159)
tmp = (x / ((y + x) * (y + x))) * (y / (y + 1.0));
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -0.095], N[(N[(1.0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.15e-159], N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.095:\\
\;\;\;\;\frac{1}{y + x} \cdot \frac{y}{\left(y + x\right) + 1}\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-159}:\\
\;\;\;\;\frac{x}{\left(y + x\right) \cdot \left(y + x\right)} \cdot \frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -0.095000000000000001Initial program 59.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.6
Applied rewrites88.6%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.6
Applied rewrites88.6%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites71.7%
if -0.095000000000000001 < x < -2.15e-159Initial program 81.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutative99.2
Applied rewrites99.2%
if -2.15e-159 < x Initial program 69.5%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6456.2
Applied rewrites56.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= x -5.4e+155)
(* (/ t_0 (+ y x)) (/ y x))
(/ (* t_0 y) (* (+ (+ y x) 1.0) (+ y x))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -5.4e+155) {
tmp = (t_0 / (y + x)) * (y / x);
} else {
tmp = (t_0 * y) / (((y + x) + 1.0) * (y + x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (x <= (-5.4d+155)) then
tmp = (t_0 / (y + x)) * (y / x)
else
tmp = (t_0 * y) / (((y + x) + 1.0d0) * (y + x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -5.4e+155) {
tmp = (t_0 / (y + x)) * (y / x);
} else {
tmp = (t_0 * y) / (((y + x) + 1.0) * (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if x <= -5.4e+155: tmp = (t_0 / (y + x)) * (y / x) else: tmp = (t_0 * y) / (((y + x) + 1.0) * (y + x)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (x <= -5.4e+155) tmp = Float64(Float64(t_0 / Float64(y + x)) * Float64(y / x)); else tmp = Float64(Float64(t_0 * y) / Float64(Float64(Float64(y + x) + 1.0) * Float64(y + x))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (x <= -5.4e+155)
tmp = (t_0 / (y + x)) * (y / x);
else
tmp = (t_0 * y) / (((y + x) + 1.0) * (y + x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.4e+155], N[(N[(t$95$0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * y), $MachinePrecision] / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;x \leq -5.4 \cdot 10^{+155}:\\
\;\;\;\;\frac{t\_0}{y + x} \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot y}{\left(\left(y + x\right) + 1\right) \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if x < -5.39999999999999987e155Initial program 56.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.0
Applied rewrites84.0%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6484.0
Applied rewrites84.0%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites87.7%
if -5.39999999999999987e155 < x Initial program 70.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.9
Applied rewrites88.9%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.9
Applied rewrites88.9%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f6496.3
Applied rewrites96.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= x -5.4e+155)
(* (/ t_0 (+ y x)) (/ y x))
(* t_0 (/ y (* (+ (+ y x) 1.0) (+ y x)))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -5.4e+155) {
tmp = (t_0 / (y + x)) * (y / x);
} else {
tmp = t_0 * (y / (((y + x) + 1.0) * (y + x)));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (x <= (-5.4d+155)) then
tmp = (t_0 / (y + x)) * (y / x)
else
tmp = t_0 * (y / (((y + x) + 1.0d0) * (y + x)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (x <= -5.4e+155) {
tmp = (t_0 / (y + x)) * (y / x);
} else {
tmp = t_0 * (y / (((y + x) + 1.0) * (y + x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if x <= -5.4e+155: tmp = (t_0 / (y + x)) * (y / x) else: tmp = t_0 * (y / (((y + x) + 1.0) * (y + x))) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (x <= -5.4e+155) tmp = Float64(Float64(t_0 / Float64(y + x)) * Float64(y / x)); else tmp = Float64(t_0 * Float64(y / Float64(Float64(Float64(y + x) + 1.0) * Float64(y + x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (x <= -5.4e+155)
tmp = (t_0 / (y + x)) * (y / x);
else
tmp = t_0 * (y / (((y + x) + 1.0) * (y + x)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.4e+155], N[(N[(t$95$0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(y / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;x \leq -5.4 \cdot 10^{+155}:\\
\;\;\;\;\frac{t\_0}{y + x} \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if x < -5.39999999999999987e155Initial program 56.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.0
Applied rewrites84.0%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6484.0
Applied rewrites84.0%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites87.7%
if -5.39999999999999987e155 < x Initial program 70.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.9
Applied rewrites88.9%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.9
Applied rewrites88.9%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
frac-timesN/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= y 1.25e+130)
(* t_0 (/ y (* (+ (+ y x) 1.0) (+ y x))))
(* (/ t_0 (+ y x)) 1.0))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= 1.25e+130) {
tmp = t_0 * (y / (((y + x) + 1.0) * (y + x)));
} else {
tmp = (t_0 / (y + x)) * 1.0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (y <= 1.25d+130) then
tmp = t_0 * (y / (((y + x) + 1.0d0) * (y + x)))
else
tmp = (t_0 / (y + x)) * 1.0d0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= 1.25e+130) {
tmp = t_0 * (y / (((y + x) + 1.0) * (y + x)));
} else {
tmp = (t_0 / (y + x)) * 1.0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if y <= 1.25e+130: tmp = t_0 * (y / (((y + x) + 1.0) * (y + x))) else: tmp = (t_0 / (y + x)) * 1.0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (y <= 1.25e+130) tmp = Float64(t_0 * Float64(y / Float64(Float64(Float64(y + x) + 1.0) * Float64(y + x)))); else tmp = Float64(Float64(t_0 / Float64(y + x)) * 1.0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (y <= 1.25e+130)
tmp = t_0 * (y / (((y + x) + 1.0) * (y + x)));
else
tmp = (t_0 / (y + x)) * 1.0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.25e+130], N[(t$95$0 * N[(y / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;y \leq 1.25 \cdot 10^{+130}:\\
\;\;\;\;t\_0 \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{y + x} \cdot 1\\
\end{array}
\end{array}
if y < 1.2499999999999999e130Initial program 70.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.7
Applied rewrites88.7%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.7
Applied rewrites88.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
frac-timesN/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.7%
if 1.2499999999999999e130 < y Initial program 60.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.7
Applied rewrites86.7%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6486.7
Applied rewrites86.7%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites85.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ (/ x (+ y x)) (+ y x)) (/ y (+ (+ y x) 1.0))))
assert(x < y);
double code(double x, double y) {
return ((x / (y + x)) / (y + x)) * (y / ((y + x) + 1.0));
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / (y + x)) / (y + x)) * (y / ((y + x) + 1.0d0))
end function
assert x < y;
public static double code(double x, double y) {
return ((x / (y + x)) / (y + x)) * (y / ((y + x) + 1.0));
}
[x, y] = sort([x, y]) def code(x, y): return ((x / (y + x)) / (y + x)) * (y / ((y + x) + 1.0))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(x / Float64(y + x)) / Float64(y + x)) * Float64(y / Float64(Float64(y + x) + 1.0))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((x / (y + x)) / (y + x)) * (y / ((y + x) + 1.0));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{x}{y + x}}{y + x} \cdot \frac{y}{\left(y + x\right) + 1}
\end{array}
Initial program 69.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.3
Applied rewrites88.3%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.3
Applied rewrites88.3%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -0.085)
(* (/ 1.0 (+ y x)) (/ y (+ (+ y x) 1.0)))
(if (<= x -3.3e-159)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ y 1.0)))
(/ x (* (+ 1.0 y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -0.085) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else if (x <= -3.3e-159) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.085d0)) then
tmp = (1.0d0 / (y + x)) * (y / ((y + x) + 1.0d0))
else if (x <= (-3.3d-159)) then
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0d0))
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -0.085) {
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
} else if (x <= -3.3e-159) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -0.085: tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0)) elif x <= -3.3e-159: tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0)) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -0.085) tmp = Float64(Float64(1.0 / Float64(y + x)) * Float64(y / Float64(Float64(y + x) + 1.0))); elseif (x <= -3.3e-159) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(y + 1.0))); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -0.085)
tmp = (1.0 / (y + x)) * (y / ((y + x) + 1.0));
elseif (x <= -3.3e-159)
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -0.085], N[(N[(1.0 / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.3e-159], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.085:\\
\;\;\;\;\frac{1}{y + x} \cdot \frac{y}{\left(y + x\right) + 1}\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-159}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(y + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -0.0850000000000000061Initial program 59.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.6
Applied rewrites88.6%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6488.6
Applied rewrites88.6%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites71.7%
if -0.0850000000000000061 < x < -3.3000000000000002e-159Initial program 81.4%
Taylor expanded in x around 0
Applied rewrites81.4%
if -3.3000000000000002e-159 < x Initial program 69.5%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6456.2
Applied rewrites56.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -5.6e+24)
(/ (/ y x) x)
(if (<= x -3.3e-159)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ y 1.0)))
(/ x (* (+ 1.0 y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -5.6e+24) {
tmp = (y / x) / x;
} else if (x <= -3.3e-159) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-5.6d+24)) then
tmp = (y / x) / x
else if (x <= (-3.3d-159)) then
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0d0))
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -5.6e+24) {
tmp = (y / x) / x;
} else if (x <= -3.3e-159) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -5.6e+24: tmp = (y / x) / x elif x <= -3.3e-159: tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0)) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -5.6e+24) tmp = Float64(Float64(y / x) / x); elseif (x <= -3.3e-159) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(y + 1.0))); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -5.6e+24)
tmp = (y / x) / x;
elseif (x <= -3.3e-159)
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -5.6e+24], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -3.3e-159], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{+24}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-159}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(y + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -5.6000000000000003e24Initial program 55.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.7
Applied rewrites87.7%
Taylor expanded in x around inf
frac-timesN/A
unpow2N/A
+-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-/.f64N/A
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.7
Applied rewrites73.7%
if -5.6000000000000003e24 < x < -3.3000000000000002e-159Initial program 83.4%
Taylor expanded in x around 0
Applied rewrites79.2%
if -3.3000000000000002e-159 < x Initial program 69.5%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6456.2
Applied rewrites56.2%
Final simplification64.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.35e-64)
(/ y (* (+ 1.0 x) x))
(if (<= y 1.5e+15)
(/ x (fma y 1.0 (* y y)))
(* (/ (/ x (+ y x)) (+ y x)) 1.0))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.35e-64) {
tmp = y / ((1.0 + x) * x);
} else if (y <= 1.5e+15) {
tmp = x / fma(y, 1.0, (y * y));
} else {
tmp = ((x / (y + x)) / (y + x)) * 1.0;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.35e-64) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); elseif (y <= 1.5e+15) tmp = Float64(x / fma(y, 1.0, Float64(y * y))); else tmp = Float64(Float64(Float64(x / Float64(y + x)) / Float64(y + x)) * 1.0); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.35e-64], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e+15], N[(x / N[(y * 1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{-64}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, 1, y \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{y + x} \cdot 1\\
\end{array}
\end{array}
if y < 1.34999999999999993e-64Initial program 69.9%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6458.4
Applied rewrites58.4%
if 1.34999999999999993e-64 < y < 1.5e15Initial program 85.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
frac-timesN/A
unpow2N/A
+-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f6432.7
Applied rewrites32.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-inN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6432.7
Applied rewrites32.7%
if 1.5e15 < y Initial program 64.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6491.5
Applied rewrites91.5%
lift-+.f64N/A
+-commutativeN/A
lower-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6491.5
Applied rewrites91.5%
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites79.3%
Final simplification63.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -7.5e+24) (/ y (* x x)) (if (or (<= x -4.2e-204) (not (<= x 5.6e-187))) (/ x (* y y)) (/ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7.5e+24) {
tmp = y / (x * x);
} else if ((x <= -4.2e-204) || !(x <= 5.6e-187)) {
tmp = x / (y * y);
} else {
tmp = 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 <= (-7.5d+24)) then
tmp = y / (x * x)
else if ((x <= (-4.2d-204)) .or. (.not. (x <= 5.6d-187))) then
tmp = x / (y * y)
else
tmp = x / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -7.5e+24) {
tmp = y / (x * x);
} else if ((x <= -4.2e-204) || !(x <= 5.6e-187)) {
tmp = x / (y * y);
} else {
tmp = x / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -7.5e+24: tmp = y / (x * x) elif (x <= -4.2e-204) or not (x <= 5.6e-187): tmp = x / (y * y) else: tmp = x / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -7.5e+24) tmp = Float64(y / Float64(x * x)); elseif ((x <= -4.2e-204) || !(x <= 5.6e-187)) tmp = Float64(x / Float64(y * y)); else tmp = Float64(x / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -7.5e+24)
tmp = y / (x * x);
elseif ((x <= -4.2e-204) || ~((x <= 5.6e-187)))
tmp = x / (y * y);
else
tmp = 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, -7.5e+24], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -4.2e-204], N[Not[LessEqual[x, 5.6e-187]], $MachinePrecision]], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+24}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{-204} \lor \neg \left(x \leq 5.6 \cdot 10^{-187}\right):\\
\;\;\;\;\frac{x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -7.50000000000000014e24Initial program 55.6%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
if -7.50000000000000014e24 < x < -4.20000000000000018e-204 or 5.6e-187 < x Initial program 78.0%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6444.2
Applied rewrites44.2%
if -4.20000000000000018e-204 < x < 5.6e-187Initial program 51.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6465.9
Applied rewrites65.9%
Taylor expanded in x around 0
frac-timesN/A
unpow2N/A
+-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f6483.6
Applied rewrites83.6%
Taylor expanded in y around 0
Applied rewrites76.6%
Final simplification55.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.35e-64) (/ y (* (+ 1.0 x) x)) (if (<= y 1e+47) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.35e-64) {
tmp = y / ((1.0 + x) * x);
} else if (y <= 1e+47) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.35d-64) then
tmp = y / ((1.0d0 + x) * x)
else if (y <= 1d+47) then
tmp = x / ((1.0d0 + y) * y)
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.35e-64) {
tmp = y / ((1.0 + x) * x);
} else if (y <= 1e+47) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.35e-64: tmp = y / ((1.0 + x) * x) elif y <= 1e+47: tmp = x / ((1.0 + y) * y) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.35e-64) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); elseif (y <= 1e+47) tmp = Float64(x / Float64(Float64(1.0 + y) * y)); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.35e-64)
tmp = y / ((1.0 + x) * x);
elseif (y <= 1e+47)
tmp = x / ((1.0 + y) * y);
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.35e-64], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+47], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{-64}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{elif}\;y \leq 10^{+47}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < 1.34999999999999993e-64Initial program 69.9%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6458.4
Applied rewrites58.4%
if 1.34999999999999993e-64 < y < 1e47Initial program 86.2%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6439.9
Applied rewrites39.9%
if 1e47 < y Initial program 61.4%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6482.5
Applied rewrites82.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.6
Applied rewrites81.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.35e-64) (/ y (* (+ 1.0 x) x)) (/ x (* (+ 1.0 y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.35e-64) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.35d-64) then
tmp = y / ((1.0d0 + x) * x)
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.35e-64) {
tmp = y / ((1.0 + x) * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.35e-64: tmp = y / ((1.0 + x) * x) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.35e-64) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.35e-64)
tmp = y / ((1.0 + x) * x);
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.35e-64], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{-64}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if y < 1.34999999999999993e-64Initial program 69.9%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6458.4
Applied rewrites58.4%
if 1.34999999999999993e-64 < y Initial program 67.3%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6472.4
Applied rewrites72.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -7.5e+24) (/ y (* x x)) (/ x (* (+ 1.0 y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7.5e+24) {
tmp = y / (x * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-7.5d+24)) then
tmp = y / (x * x)
else
tmp = x / ((1.0d0 + y) * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -7.5e+24) {
tmp = y / (x * x);
} else {
tmp = x / ((1.0 + y) * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -7.5e+24: tmp = y / (x * x) else: tmp = x / ((1.0 + y) * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -7.5e+24) tmp = Float64(y / Float64(x * x)); else tmp = Float64(x / Float64(Float64(1.0 + y) * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -7.5e+24)
tmp = y / (x * x);
else
tmp = x / ((1.0 + y) * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -7.5e+24], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+24}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\end{array}
\end{array}
if x < -7.50000000000000014e24Initial program 55.6%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.3
Applied rewrites75.3%
if -7.50000000000000014e24 < x Initial program 72.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6459.3
Applied rewrites59.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.0) (/ x y) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.0d0) then
tmp = x / y
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = x / y;
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.0: tmp = x / y else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.0) tmp = Float64(x / y); else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.0)
tmp = x / y;
else
tmp = x / (y * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.0], N[(x / y), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if y < 1Initial program 70.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6486.8
Applied rewrites86.8%
Taylor expanded in x around 0
frac-timesN/A
unpow2N/A
+-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f6439.6
Applied rewrites39.6%
Taylor expanded in y around 0
Applied rewrites25.4%
if 1 < y Initial program 64.7%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6478.2
Applied rewrites78.2%
Final simplification41.3%
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.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f6488.3
Applied rewrites88.3%
Taylor expanded in x around 0
frac-timesN/A
unpow2N/A
+-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f6451.2
Applied rewrites51.2%
Taylor expanded in y around 0
Applied rewrites26.4%
Final simplification26.4%
herbie shell --seed 2025085
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
:alt
(! :herbie-platform default (/ (/ (/ x (+ (+ y 1) x)) (+ y x)) (/ 1 (/ y (+ y x)))))
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))