
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ (/ y (+ y x)) (- (+ y x) -1.0)) (/ x (+ y x))))
assert(x < y);
double code(double x, double y) {
return ((y / (y + x)) / ((y + x) - -1.0)) * (x / (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 = ((y / (y + x)) / ((y + x) - (-1.0d0))) * (x / (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return ((y / (y + x)) / ((y + x) - -1.0)) * (x / (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return ((y / (y + x)) / ((y + x) - -1.0)) * (x / (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(y / Float64(y + x)) / Float64(Float64(y + x) - -1.0)) * Float64(x / Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((y / (y + x)) / ((y + x) - -1.0)) * (x / (y + x));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{y + x}}{\left(y + x\right) - -1} \cdot \frac{x}{y + x}
\end{array}
Initial program 73.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6494.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval94.2
lift-+.f64N/A
Applied rewrites94.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6494.2
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -3.9e+101)
(* (/ 1.0 x) (/ y (+ y x)))
(if (<= x -3.5e-14)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(* (/ x (+ y x)) (/ y (* (+ 1.0 y) (+ y x)))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.9e+101) {
tmp = (1.0 / x) * (y / (y + x));
} else if (x <= -3.5e-14) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (x / (y + x)) * (y / ((1.0 + y) * (y + x)));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3.9d+101)) then
tmp = (1.0d0 / x) * (y / (y + x))
else if (x <= (-3.5d-14)) then
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
else
tmp = (x / (y + x)) * (y / ((1.0d0 + y) * (y + x)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -3.9e+101) {
tmp = (1.0 / x) * (y / (y + x));
} else if (x <= -3.5e-14) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (x / (y + x)) * (y / ((1.0 + y) * (y + x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -3.9e+101: tmp = (1.0 / x) * (y / (y + x)) elif x <= -3.5e-14: tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)) else: tmp = (x / (y + x)) * (y / ((1.0 + y) * (y + x))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3.9e+101) tmp = Float64(Float64(1.0 / x) * Float64(y / Float64(y + x))); elseif (x <= -3.5e-14) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(y / Float64(Float64(1.0 + y) * Float64(y + x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -3.9e+101)
tmp = (1.0 / x) * (y / (y + x));
elseif (x <= -3.5e-14)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
else
tmp = (x / (y + x)) * (y / ((1.0 + y) * (y + x)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -3.9e+101], N[(N[(1.0 / x), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.5e-14], 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[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(1.0 + y), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.9 \cdot 10^{+101}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{y}{y + x}\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-14}:\\
\;\;\;\;\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{x}{y + x} \cdot \frac{y}{\left(1 + y\right) \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if x < -3.9e101Initial program 59.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.4
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.4
lift-+.f64N/A
Applied rewrites87.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6486.0
Applied rewrites86.0%
if -3.9e101 < x < -3.5000000000000002e-14Initial program 91.7%
if -3.5000000000000002e-14 < x Initial program 75.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.9
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval95.9
lift-+.f64N/A
Applied rewrites95.9%
Taylor expanded in x around 0
lower-+.f6483.3
Applied rewrites83.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 2.8e-11)
(* (/ y (+ y x)) (/ x (* (- x -1.0) (+ y x))))
(if (<= y 7.6e+87)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(* (/ 1.0 (- (+ y x) -1.0)) (/ x (+ y x))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.8e-11) {
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
} else if (y <= 7.6e+87) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.8d-11) then
tmp = (y / (y + x)) * (x / ((x - (-1.0d0)) * (y + x)))
else if (y <= 7.6d+87) then
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
else
tmp = (1.0d0 / ((y + x) - (-1.0d0))) * (x / (y + x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.8e-11) {
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
} else if (y <= 7.6e+87) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.8e-11: tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x))) elif y <= 7.6e+87: tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)) else: tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.8e-11) tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(x - -1.0) * Float64(y + x)))); elseif (y <= 7.6e+87) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(1.0 / Float64(Float64(y + x) - -1.0)) * Float64(x / Float64(y + x))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.8e-11)
tmp = (y / (y + x)) * (x / ((x - -1.0) * (y + x)));
elseif (y <= 7.6e+87)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
else
tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.8e-11], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.6e+87], 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[(1.0 / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(x - -1\right) \cdot \left(y + x\right)}\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+87}:\\
\;\;\;\;\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{1}{\left(y + x\right) - -1} \cdot \frac{x}{y + x}\\
\end{array}
\end{array}
if y < 2.8e-11Initial program 75.0%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.1
Applied rewrites84.1%
if 2.8e-11 < y < 7.60000000000000022e87Initial program 72.6%
if 7.60000000000000022e87 < y Initial program 69.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.4
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval84.4
lift-+.f64N/A
Applied rewrites84.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.4
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites86.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 2e-153)
(* (/ 1.0 (+ 1.0 x)) (/ y (+ y x)))
(if (<= y 7.6e+87)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(* (/ 1.0 (- (+ y x) -1.0)) (/ x (+ y x))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2e-153) {
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
} else if (y <= 7.6e+87) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2d-153) then
tmp = (1.0d0 / (1.0d0 + x)) * (y / (y + x))
else if (y <= 7.6d+87) then
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
else
tmp = (1.0d0 / ((y + x) - (-1.0d0))) * (x / (y + x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2e-153) {
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
} else if (y <= 7.6e+87) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2e-153: tmp = (1.0 / (1.0 + x)) * (y / (y + x)) elif y <= 7.6e+87: tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)) else: tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2e-153) tmp = Float64(Float64(1.0 / Float64(1.0 + x)) * Float64(y / Float64(y + x))); elseif (y <= 7.6e+87) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(Float64(1.0 / Float64(Float64(y + x) - -1.0)) * Float64(x / Float64(y + x))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2e-153)
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
elseif (y <= 7.6e+87)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
else
tmp = (1.0 / ((y + x) - -1.0)) * (x / (y + x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2e-153], N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.6e+87], 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[(1.0 / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-153}:\\
\;\;\;\;\frac{1}{1 + x} \cdot \frac{y}{y + x}\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+87}:\\
\;\;\;\;\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{1}{\left(y + x\right) - -1} \cdot \frac{x}{y + x}\\
\end{array}
\end{array}
if y < 2.00000000000000008e-153Initial program 71.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval96.2
lift-+.f64N/A
Applied rewrites96.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6460.8
Applied rewrites60.8%
if 2.00000000000000008e-153 < y < 7.60000000000000022e87Initial program 82.7%
if 7.60000000000000022e87 < y Initial program 69.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.4
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval84.4
lift-+.f64N/A
Applied rewrites84.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.4
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites86.9%
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))) (t_1 (- (+ y x) -1.0))) (if (<= y 5.5e+122) (/ (* t_0 y) (* (+ y x) t_1)) (* (/ 1.0 t_1) t_0))))
assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 5.5e+122) {
tmp = (t_0 * y) / ((y + x) * t_1);
} else {
tmp = (1.0 / t_1) * t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (y + x)
t_1 = (y + x) - (-1.0d0)
if (y <= 5.5d+122) then
tmp = (t_0 * y) / ((y + x) * t_1)
else
tmp = (1.0d0 / t_1) * t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 5.5e+122) {
tmp = (t_0 * y) / ((y + x) * t_1);
} else {
tmp = (1.0 / t_1) * t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) t_1 = (y + x) - -1.0 tmp = 0 if y <= 5.5e+122: tmp = (t_0 * y) / ((y + x) * t_1) else: tmp = (1.0 / t_1) * t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) t_1 = Float64(Float64(y + x) - -1.0) tmp = 0.0 if (y <= 5.5e+122) tmp = Float64(Float64(t_0 * y) / Float64(Float64(y + x) * t_1)); else tmp = Float64(Float64(1.0 / t_1) * t_0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
t_1 = (y + x) - -1.0;
tmp = 0.0;
if (y <= 5.5e+122)
tmp = (t_0 * y) / ((y + x) * t_1);
else
tmp = (1.0 / t_1) * t_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]}, Block[{t$95$1 = N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, 5.5e+122], N[(N[(t$95$0 * y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
t_1 := \left(y + x\right) - -1\\
\mathbf{if}\;y \leq 5.5 \cdot 10^{+122}:\\
\;\;\;\;\frac{t\_0 \cdot y}{\left(y + x\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1} \cdot t\_0\\
\end{array}
\end{array}
if y < 5.4999999999999998e122Initial program 74.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.0
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval96.0
lift-+.f64N/A
Applied rewrites96.0%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites96.1%
if 5.4999999999999998e122 < y Initial program 68.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval85.2
lift-+.f64N/A
Applied rewrites85.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.2
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites87.9%
Final simplification94.7%
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))) (t_1 (- (+ y x) -1.0))) (if (<= y 5.5e+122) (* t_0 (/ y (* t_1 (+ y x)))) (* (/ 1.0 t_1) t_0))))
assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 5.5e+122) {
tmp = t_0 * (y / (t_1 * (y + x)));
} else {
tmp = (1.0 / t_1) * t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (y + x)
t_1 = (y + x) - (-1.0d0)
if (y <= 5.5d+122) then
tmp = t_0 * (y / (t_1 * (y + x)))
else
tmp = (1.0d0 / t_1) * t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double t_1 = (y + x) - -1.0;
double tmp;
if (y <= 5.5e+122) {
tmp = t_0 * (y / (t_1 * (y + x)));
} else {
tmp = (1.0 / t_1) * t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) t_1 = (y + x) - -1.0 tmp = 0 if y <= 5.5e+122: tmp = t_0 * (y / (t_1 * (y + x))) else: tmp = (1.0 / t_1) * t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) t_1 = Float64(Float64(y + x) - -1.0) tmp = 0.0 if (y <= 5.5e+122) tmp = Float64(t_0 * Float64(y / Float64(t_1 * Float64(y + x)))); else tmp = Float64(Float64(1.0 / t_1) * t_0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
t_1 = (y + x) - -1.0;
tmp = 0.0;
if (y <= 5.5e+122)
tmp = t_0 * (y / (t_1 * (y + x)));
else
tmp = (1.0 / t_1) * t_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]}, Block[{t$95$1 = N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, 5.5e+122], N[(t$95$0 * N[(y / N[(t$95$1 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
t_1 := \left(y + x\right) - -1\\
\mathbf{if}\;y \leq 5.5 \cdot 10^{+122}:\\
\;\;\;\;t\_0 \cdot \frac{y}{t\_1 \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1} \cdot t\_0\\
\end{array}
\end{array}
if y < 5.4999999999999998e122Initial program 74.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.0
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval96.0
lift-+.f64N/A
Applied rewrites96.0%
if 5.4999999999999998e122 < y Initial program 68.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval85.2
lift-+.f64N/A
Applied rewrites85.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.2
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites87.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ (/ x (+ y x)) (- (+ y x) -1.0)) (/ y (+ y x))))
assert(x < y);
double code(double x, double y) {
return ((x / (y + x)) / ((y + x) - -1.0)) * (y / (y + x));
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / (y + x)) / ((y + x) - (-1.0d0))) * (y / (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return ((x / (y + x)) / ((y + x) - -1.0)) * (y / (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return ((x / (y + x)) / ((y + x) - -1.0)) * (y / (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(x / Float64(y + x)) / Float64(Float64(y + x) - -1.0)) * Float64(y / Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((x / (y + x)) / ((y + x) - -1.0)) * (y / (y + x));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{x}{y + x}}{\left(y + x\right) - -1} \cdot \frac{y}{y + x}
\end{array}
Initial program 73.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6494.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval94.2
lift-+.f64N/A
Applied rewrites94.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 2e-153)
(* (/ 1.0 (+ 1.0 x)) (/ y (+ y x)))
(if (<= y 26.5)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ 1.0 x)))
(* (/ x (+ y x)) (/ 1.0 (+ 1.0 y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2e-153) {
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
} else if (y <= 26.5) {
tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + x));
} else {
tmp = (x / (y + x)) * (1.0 / (1.0 + y));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2d-153) then
tmp = (1.0d0 / (1.0d0 + x)) * (y / (y + x))
else if (y <= 26.5d0) then
tmp = (x * y) / (((x + y) * (x + y)) * (1.0d0 + x))
else
tmp = (x / (y + x)) * (1.0d0 / (1.0d0 + y))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2e-153) {
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
} else if (y <= 26.5) {
tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + x));
} else {
tmp = (x / (y + x)) * (1.0 / (1.0 + y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2e-153: tmp = (1.0 / (1.0 + x)) * (y / (y + x)) elif y <= 26.5: tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + x)) else: tmp = (x / (y + x)) * (1.0 / (1.0 + y)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2e-153) tmp = Float64(Float64(1.0 / Float64(1.0 + x)) * Float64(y / Float64(y + x))); elseif (y <= 26.5) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(1.0 + x))); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 / Float64(1.0 + y))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2e-153)
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
elseif (y <= 26.5)
tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + x));
else
tmp = (x / (y + x)) * (1.0 / (1.0 + y));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2e-153], N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 26.5], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-153}:\\
\;\;\;\;\frac{1}{1 + x} \cdot \frac{y}{y + x}\\
\mathbf{elif}\;y \leq 26.5:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \frac{1}{1 + y}\\
\end{array}
\end{array}
if y < 2.00000000000000008e-153Initial program 71.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval96.2
lift-+.f64N/A
Applied rewrites96.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6460.8
Applied rewrites60.8%
if 2.00000000000000008e-153 < y < 26.5Initial program 89.2%
Taylor expanded in y around 0
lower-+.f6489.2
Applied rewrites89.2%
if 26.5 < y Initial program 70.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.1
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.1
lift-+.f64N/A
Applied rewrites87.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6475.0
Applied rewrites75.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -5.2e+80)
(* (/ 1.0 x) (/ y (+ y x)))
(if (<= x -1.46e-52)
(/ (* x y) (* (* x x) (+ (+ x y) 1.0)))
(/ x (fma y y y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -5.2e+80) {
tmp = (1.0 / x) * (y / (y + x));
} else if (x <= -1.46e-52) {
tmp = (x * y) / ((x * x) * ((x + y) + 1.0));
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -5.2e+80) tmp = Float64(Float64(1.0 / x) * Float64(y / Float64(y + x))); elseif (x <= -1.46e-52) tmp = Float64(Float64(x * y) / Float64(Float64(x * x) * Float64(Float64(x + y) + 1.0))); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -5.2e+80], N[(N[(1.0 / x), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.46e-52], N[(N[(x * y), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+80}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{y}{y + x}\\
\mathbf{elif}\;x \leq -1.46 \cdot 10^{-52}:\\
\;\;\;\;\frac{x \cdot y}{\left(x \cdot x\right) \cdot \left(\left(x + y\right) + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -5.19999999999999963e80Initial program 58.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.8
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval87.8
lift-+.f64N/A
Applied rewrites87.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6484.7
Applied rewrites84.7%
if -5.19999999999999963e80 < x < -1.46000000000000003e-52Initial program 96.1%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6474.5
Applied rewrites74.5%
if -1.46000000000000003e-52 < x Initial program 75.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6461.2
Applied rewrites61.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.3e-79) (* (/ 1.0 (+ 1.0 x)) (/ y (+ y x))) (* (/ x (+ y x)) (/ 1.0 (+ 1.0 y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.3e-79) {
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
} else {
tmp = (x / (y + x)) * (1.0 / (1.0 + y));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.3d-79)) then
tmp = (1.0d0 / (1.0d0 + x)) * (y / (y + x))
else
tmp = (x / (y + x)) * (1.0d0 / (1.0d0 + y))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.3e-79) {
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
} else {
tmp = (x / (y + x)) * (1.0 / (1.0 + y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.3e-79: tmp = (1.0 / (1.0 + x)) * (y / (y + x)) else: tmp = (x / (y + x)) * (1.0 / (1.0 + y)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.3e-79) tmp = Float64(Float64(1.0 / Float64(1.0 + x)) * Float64(y / Float64(y + x))); else tmp = Float64(Float64(x / Float64(y + x)) * Float64(1.0 / Float64(1.0 + y))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.3e-79)
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
else
tmp = (x / (y + x)) * (1.0 / (1.0 + y));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.3e-79], N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-79}:\\
\;\;\;\;\frac{1}{1 + x} \cdot \frac{y}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + x} \cdot \frac{1}{1 + y}\\
\end{array}
\end{array}
if x < -1.29999999999999997e-79Initial program 70.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval91.2
lift-+.f64N/A
Applied rewrites91.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6476.4
Applied rewrites76.4%
if -1.29999999999999997e-79 < x Initial program 75.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.6
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval95.6
lift-+.f64N/A
Applied rewrites95.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6460.9
Applied rewrites60.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.3e-79) (* (/ 1.0 (+ 1.0 x)) (/ y (+ y x))) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.3e-79) {
tmp = (1.0 / (1.0 + x)) * (y / (y + x));
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.3e-79) tmp = Float64(Float64(1.0 / Float64(1.0 + x)) * Float64(y / Float64(y + x))); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.3e-79], N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-79}:\\
\;\;\;\;\frac{1}{1 + x} \cdot \frac{y}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -1.29999999999999997e-79Initial program 70.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.2
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
metadata-eval91.2
lift-+.f64N/A
Applied rewrites91.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6476.4
Applied rewrites76.4%
if -1.29999999999999997e-79 < x Initial program 75.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6461.1
Applied rewrites61.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.3e-79) (/ y (fma x x x)) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.3e-79) {
tmp = y / fma(x, x, x);
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.3e-79) tmp = Float64(y / fma(x, x, x)); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.3e-79], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-79}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -1.29999999999999997e-79Initial program 70.1%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6477.1
Applied rewrites77.1%
if -1.29999999999999997e-79 < x Initial program 75.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6461.1
Applied rewrites61.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.55e-6) (/ y (* x x)) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.55e-6) {
tmp = y / (x * x);
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.55e-6) tmp = Float64(y / Float64(x * x)); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.55e-6], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-6}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -1.55e-6Initial program 68.3%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6479.1
Applied rewrites79.1%
if -1.55e-6 < x Initial program 75.9%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6460.8
Applied rewrites60.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.55e-6) (/ y (* x x)) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.55e-6) {
tmp = y / (x * x);
} else {
tmp = x / (y * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.55d-6)) then
tmp = y / (x * x)
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.55e-6) {
tmp = y / (x * x);
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.55e-6: tmp = y / (x * x) else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.55e-6) tmp = Float64(y / Float64(x * x)); else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.55e-6)
tmp = y / (x * x);
else
tmp = x / (y * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.55e-6], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-6}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -1.55e-6Initial program 68.3%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6479.1
Applied rewrites79.1%
if -1.55e-6 < x Initial program 75.9%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6447.1
Applied rewrites47.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (* y y)))
assert(x < y);
double code(double x, double y) {
return x / (y * y);
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (y * y)
end function
assert x < y;
public static double code(double x, double y) {
return x / (y * y);
}
[x, y] = sort([x, y]) def code(x, y): return x / (y * y)
x, y = sort([x, y]) function code(x, y) return Float64(x / Float64(y * y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / (y * y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y \cdot y}
\end{array}
Initial program 73.7%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6438.9
Applied rewrites38.9%
(FPCore (x y) :precision binary64 (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x)))))
double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
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 + 1.0d0) + x)) / (y + x)) / (1.0d0 / (y / (y + x)))
end function
public static double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
def code(x, y): return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)))
function code(x, y) return Float64(Float64(Float64(x / Float64(Float64(y + 1.0) + x)) / Float64(y + x)) / Float64(1.0 / Float64(y / Float64(y + x)))) end
function tmp = code(x, y) tmp = ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x))); end
code[x_, y_] := N[(N[(N[(x / N[(N[(y + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}}
\end{array}
herbie shell --seed 2025017
(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))))