
(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 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (* (/ (/ y (+ x y)) (- (+ x y) -1.0)) x) (+ x y)))
assert(x < y);
double code(double x, double y) {
return (((y / (x + y)) / ((x + y) - -1.0)) * x) / (x + y);
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (((y / (x + y)) / ((x + y) - (-1.0d0))) * x) / (x + y)
end function
assert x < y;
public static double code(double x, double y) {
return (((y / (x + y)) / ((x + y) - -1.0)) * x) / (x + y);
}
[x, y] = sort([x, y]) def code(x, y): return (((y / (x + y)) / ((x + y) - -1.0)) * x) / (x + y)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(Float64(y / Float64(x + y)) / Float64(Float64(x + y) - -1.0)) * x) / Float64(x + y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (((y / (x + y)) / ((x + y) - -1.0)) * x) / (x + y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{\frac{y}{x + y}}{\left(x + y\right) - -1} \cdot x}{x + y}
\end{array}
Initial program 66.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.4
Applied rewrites91.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites91.4%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f6499.7
Applied rewrites99.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.4e+154)
(* (/ y (+ y x)) (/ 1.0 x))
(if (<= x 2.4e+107)
(/ (* (/ y (+ x y)) x) (* (- (+ x y) -1.0) (+ x y)))
(/ (/ (- x (* x (/ (fma 3.0 x 1.0) y))) y) y))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.4e+154) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= 2.4e+107) {
tmp = ((y / (x + y)) * x) / (((x + y) - -1.0) * (x + y));
} else {
tmp = ((x - (x * (fma(3.0, x, 1.0) / y))) / y) / y;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.4e+154) tmp = Float64(Float64(y / Float64(y + x)) * Float64(1.0 / x)); elseif (x <= 2.4e+107) tmp = Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(Float64(Float64(x + y) - -1.0) * Float64(x + y))); else tmp = Float64(Float64(Float64(x - Float64(x * Float64(fma(3.0, x, 1.0) / 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.4e+154], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4e+107], N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x - N[(x * N[(N[(3.0 * x + 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+154}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+107}:\\
\;\;\;\;\frac{\frac{y}{x + y} \cdot x}{\left(\left(x + y\right) - -1\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x - x \cdot \frac{\mathsf{fma}\left(3, x, 1\right)}{y}}{y}}{y}\\
\end{array}
\end{array}
if x < -1.4e154Initial program 52.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
Taylor expanded in x around inf
lower-/.f6475.8
Applied rewrites75.8%
if -1.4e154 < x < 2.4000000000000001e107Initial program 71.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites97.7%
if 2.4000000000000001e107 < x Initial program 57.8%
Taylor expanded in y around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites25.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (+ x y) -1.0)))
(if (<= x -1.4e+154)
(* (/ y (+ y x)) (/ 1.0 x))
(if (<= x 4.7e+20)
(/ (* (/ y (+ x y)) x) (* t_0 (+ x y)))
(* (/ 1.0 (+ x y)) (/ x t_0))))))assert(x < y);
double code(double x, double y) {
double t_0 = (x + y) - -1.0;
double tmp;
if (x <= -1.4e+154) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= 4.7e+20) {
tmp = ((y / (x + y)) * x) / (t_0 * (x + y));
} else {
tmp = (1.0 / (x + y)) * (x / 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) :: tmp
t_0 = (x + y) - (-1.0d0)
if (x <= (-1.4d+154)) then
tmp = (y / (y + x)) * (1.0d0 / x)
else if (x <= 4.7d+20) then
tmp = ((y / (x + y)) * x) / (t_0 * (x + y))
else
tmp = (1.0d0 / (x + y)) * (x / t_0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (x + y) - -1.0;
double tmp;
if (x <= -1.4e+154) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= 4.7e+20) {
tmp = ((y / (x + y)) * x) / (t_0 * (x + y));
} else {
tmp = (1.0 / (x + y)) * (x / t_0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (x + y) - -1.0 tmp = 0 if x <= -1.4e+154: tmp = (y / (y + x)) * (1.0 / x) elif x <= 4.7e+20: tmp = ((y / (x + y)) * x) / (t_0 * (x + y)) else: tmp = (1.0 / (x + y)) * (x / t_0) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(x + y) - -1.0) tmp = 0.0 if (x <= -1.4e+154) tmp = Float64(Float64(y / Float64(y + x)) * Float64(1.0 / x)); elseif (x <= 4.7e+20) tmp = Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(t_0 * Float64(x + y))); else tmp = Float64(Float64(1.0 / Float64(x + y)) * Float64(x / t_0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (x + y) - -1.0;
tmp = 0.0;
if (x <= -1.4e+154)
tmp = (y / (y + x)) * (1.0 / x);
elseif (x <= 4.7e+20)
tmp = ((y / (x + y)) * x) / (t_0 * (x + y));
else
tmp = (1.0 / (x + y)) * (x / 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[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[x, -1.4e+154], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e+20], N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(t$95$0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(x + y\right) - -1\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+154}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{+20}:\\
\;\;\;\;\frac{\frac{y}{x + y} \cdot x}{t\_0 \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + y} \cdot \frac{x}{t\_0}\\
\end{array}
\end{array}
if x < -1.4e154Initial program 52.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
Taylor expanded in x around inf
lower-/.f6475.8
Applied rewrites75.8%
if -1.4e154 < x < 4.7e20Initial program 70.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites99.2%
if 4.7e20 < x Initial program 61.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.9
Applied rewrites77.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites33.8%
Final simplification80.7%
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))))
(if (<= x -1.4e+154)
(* t_0 (/ 1.0 x))
(if (<= x 4.7e+20)
(* t_0 (/ x (* (- (+ y x) -1.0) (+ y x))))
(* (/ 1.0 (+ x y)) (/ x (- (+ x y) -1.0)))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (y + x);
double tmp;
if (x <= -1.4e+154) {
tmp = t_0 * (1.0 / x);
} else if (x <= 4.7e+20) {
tmp = t_0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y / (y + x)
if (x <= (-1.4d+154)) then
tmp = t_0 * (1.0d0 / x)
else if (x <= 4.7d+20) then
tmp = t_0 * (x / (((y + x) - (-1.0d0)) * (y + x)))
else
tmp = (1.0d0 / (x + y)) * (x / ((x + y) - (-1.0d0)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (y + x);
double tmp;
if (x <= -1.4e+154) {
tmp = t_0 * (1.0 / x);
} else if (x <= 4.7e+20) {
tmp = t_0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (y + x) tmp = 0 if x <= -1.4e+154: tmp = t_0 * (1.0 / x) elif x <= 4.7e+20: tmp = t_0 * (x / (((y + x) - -1.0) * (y + x))) else: tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(y + x)) tmp = 0.0 if (x <= -1.4e+154) tmp = Float64(t_0 * Float64(1.0 / x)); elseif (x <= 4.7e+20) tmp = Float64(t_0 * Float64(x / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(1.0 / Float64(x + y)) * Float64(x / Float64(Float64(x + y) - -1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (y + x);
tmp = 0.0;
if (x <= -1.4e+154)
tmp = t_0 * (1.0 / x);
elseif (x <= 4.7e+20)
tmp = t_0 * (x / (((y + x) - -1.0) * (y + x)));
else
tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e+154], N[(t$95$0 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e+20], N[(t$95$0 * N[(x / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{y + x}\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+154}:\\
\;\;\;\;t\_0 \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{+20}:\\
\;\;\;\;t\_0 \cdot \frac{x}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + y} \cdot \frac{x}{\left(x + y\right) - -1}\\
\end{array}
\end{array}
if x < -1.4e154Initial program 52.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
Taylor expanded in x around inf
lower-/.f6475.8
Applied rewrites75.8%
if -1.4e154 < x < 4.7e20Initial program 70.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
if 4.7e20 < x Initial program 61.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.9
Applied rewrites77.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites33.8%
Final simplification80.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ x y))))
(if (<= y 6.8e+113)
(/ (* t_0 x) (* (- (+ x y) -1.0) (+ x y)))
(* (/ t_0 (+ x y)) (/ x (+ 1.0 y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (y <= 6.8e+113) {
tmp = (t_0 * x) / (((x + y) - -1.0) * (x + y));
} else {
tmp = (t_0 / (x + y)) * (x / (1.0 + y));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y / (x + y)
if (y <= 6.8d+113) then
tmp = (t_0 * x) / (((x + y) - (-1.0d0)) * (x + y))
else
tmp = (t_0 / (x + y)) * (x / (1.0d0 + y))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (y <= 6.8e+113) {
tmp = (t_0 * x) / (((x + y) - -1.0) * (x + y));
} else {
tmp = (t_0 / (x + y)) * (x / (1.0 + y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (x + y) tmp = 0 if y <= 6.8e+113: tmp = (t_0 * x) / (((x + y) - -1.0) * (x + y)) else: tmp = (t_0 / (x + y)) * (x / (1.0 + y)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(x + y)) tmp = 0.0 if (y <= 6.8e+113) tmp = Float64(Float64(t_0 * x) / Float64(Float64(Float64(x + y) - -1.0) * Float64(x + y))); else tmp = Float64(Float64(t_0 / Float64(x + y)) * Float64(x / Float64(1.0 + y))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (x + y);
tmp = 0.0;
if (y <= 6.8e+113)
tmp = (t_0 * x) / (((x + y) - -1.0) * (x + y));
else
tmp = (t_0 / (x + y)) * (x / (1.0 + y));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 6.8e+113], N[(N[(t$95$0 * x), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;y \leq 6.8 \cdot 10^{+113}:\\
\;\;\;\;\frac{t\_0 \cdot x}{\left(\left(x + y\right) - -1\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x + y} \cdot \frac{x}{1 + y}\\
\end{array}
\end{array}
if y < 6.80000000000000038e113Initial program 71.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.8
Applied rewrites95.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
Applied rewrites95.9%
if 6.80000000000000038e113 < y Initial program 45.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6468.6
Applied rewrites68.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6488.5
Applied rewrites88.5%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -6e+98)
(* (/ y (+ y x)) (/ 1.0 x))
(if (<= x -1.1e-146)
(/ (* x y) (* (+ y x) (* (- (+ y x) -1.0) (+ y x))))
(* (/ 1.0 y) (/ x (- (+ x y) -1.0))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -6e+98) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= -1.1e-146) {
tmp = (x * y) / ((y + x) * (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-6d+98)) then
tmp = (y / (y + x)) * (1.0d0 / x)
else if (x <= (-1.1d-146)) then
tmp = (x * y) / ((y + x) * (((y + x) - (-1.0d0)) * (y + x)))
else
tmp = (1.0d0 / y) * (x / ((x + y) - (-1.0d0)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -6e+98) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= -1.1e-146) {
tmp = (x * y) / ((y + x) * (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -6e+98: tmp = (y / (y + x)) * (1.0 / x) elif x <= -1.1e-146: tmp = (x * y) / ((y + x) * (((y + x) - -1.0) * (y + x))) else: tmp = (1.0 / y) * (x / ((x + y) - -1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -6e+98) tmp = Float64(Float64(y / Float64(y + x)) * Float64(1.0 / x)); elseif (x <= -1.1e-146) tmp = Float64(Float64(x * y) / Float64(Float64(y + x) * Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(1.0 / y) * Float64(x / Float64(Float64(x + y) - -1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -6e+98)
tmp = (y / (y + x)) * (1.0 / x);
elseif (x <= -1.1e-146)
tmp = (x * y) / ((y + x) * (((y + x) - -1.0) * (y + x)));
else
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -6e+98], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.1e-146], N[(N[(x * y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{+98}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-146}:\\
\;\;\;\;\frac{x \cdot y}{\left(y + x\right) \cdot \left(\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{x}{\left(x + y\right) - -1}\\
\end{array}
\end{array}
if x < -6.0000000000000003e98Initial program 38.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
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.2
Applied rewrites80.2%
Taylor expanded in x around inf
lower-/.f6472.2
Applied rewrites72.2%
if -6.0000000000000003e98 < x < -1.1e-146Initial program 89.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6489.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-eval89.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6489.6
Applied rewrites89.6%
if -1.1e-146 < x Initial program 67.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
lower-/.f6459.1
Applied rewrites59.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -6e+98)
(* (/ y (+ y x)) (/ 1.0 x))
(if (<= x -1.1e-146)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
(* (/ 1.0 y) (/ x (- (+ x y) -1.0))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -6e+98) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= -1.1e-146) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-6d+98)) then
tmp = (y / (y + x)) * (1.0d0 / x)
else if (x <= (-1.1d-146)) then
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
else
tmp = (1.0d0 / y) * (x / ((x + y) - (-1.0d0)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -6e+98) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= -1.1e-146) {
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
} else {
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -6e+98: tmp = (y / (y + x)) * (1.0 / x) elif x <= -1.1e-146: tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)) else: tmp = (1.0 / y) * (x / ((x + y) - -1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -6e+98) tmp = Float64(Float64(y / Float64(y + x)) * Float64(1.0 / x)); elseif (x <= -1.1e-146) 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 / y) * Float64(x / Float64(Float64(x + y) - -1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -6e+98)
tmp = (y / (y + x)) * (1.0 / x);
elseif (x <= -1.1e-146)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
else
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -6e+98], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.1e-146], 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 / y), $MachinePrecision] * N[(x / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{+98}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-146}:\\
\;\;\;\;\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}{y} \cdot \frac{x}{\left(x + y\right) - -1}\\
\end{array}
\end{array}
if x < -6.0000000000000003e98Initial program 38.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
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.2
Applied rewrites80.2%
Taylor expanded in x around inf
lower-/.f6472.2
Applied rewrites72.2%
if -6.0000000000000003e98 < x < -1.1e-146Initial program 89.6%
if -1.1e-146 < x Initial program 67.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
lower-/.f6459.1
Applied rewrites59.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (+ x y) -1.0)))
(if (<= x -5.5e+102)
(* (/ y (+ y x)) (/ 1.0 x))
(if (<= x -1.6e-159)
(* y (/ x (* t_0 (* (fma 2.0 y x) x))))
(* (/ 1.0 y) (/ x t_0))))))assert(x < y);
double code(double x, double y) {
double t_0 = (x + y) - -1.0;
double tmp;
if (x <= -5.5e+102) {
tmp = (y / (y + x)) * (1.0 / x);
} else if (x <= -1.6e-159) {
tmp = y * (x / (t_0 * (fma(2.0, y, x) * x)));
} else {
tmp = (1.0 / y) * (x / t_0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(x + y) - -1.0) tmp = 0.0 if (x <= -5.5e+102) tmp = Float64(Float64(y / Float64(y + x)) * Float64(1.0 / x)); elseif (x <= -1.6e-159) tmp = Float64(y * Float64(x / Float64(t_0 * Float64(fma(2.0, y, x) * x)))); else tmp = Float64(Float64(1.0 / y) * Float64(x / t_0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[x, -5.5e+102], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.6e-159], N[(y * N[(x / N[(t$95$0 * N[(N[(2.0 * y + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(x + y\right) - -1\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{+102}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{-159}:\\
\;\;\;\;y \cdot \frac{x}{t\_0 \cdot \left(\mathsf{fma}\left(2, y, x\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{x}{t\_0}\\
\end{array}
\end{array}
if x < -5.49999999999999981e102Initial program 37.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6479.2
Applied rewrites79.2%
Taylor expanded in x around inf
lower-/.f6473.3
Applied rewrites73.3%
if -5.49999999999999981e102 < x < -1.6e-159Initial program 86.4%
Taylor expanded in y around 0
+-commutativeN/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6460.6
Applied rewrites60.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6469.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.8
lift-+.f64N/A
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-+.f6469.8
Applied rewrites69.8%
if -1.6e-159 < x Initial program 67.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
lower-/.f6459.4
Applied rewrites59.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ (/ y (+ x y)) (+ x y)) (/ x (- (+ x y) -1.0))))
assert(x < y);
double code(double x, double y) {
return ((y / (x + y)) / (x + y)) * (x / ((x + y) - -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 = ((y / (x + y)) / (x + y)) * (x / ((x + y) - (-1.0d0)))
end function
assert x < y;
public static double code(double x, double y) {
return ((y / (x + y)) / (x + y)) * (x / ((x + y) - -1.0));
}
[x, y] = sort([x, y]) def code(x, y): return ((y / (x + y)) / (x + y)) * (x / ((x + y) - -1.0))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(y / Float64(x + y)) / Float64(x + y)) * Float64(x / Float64(Float64(x + y) - -1.0))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((y / (x + y)) / (x + y)) * (x / ((x + y) - -1.0));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{x + y}}{x + y} \cdot \frac{x}{\left(x + y\right) - -1}
\end{array}
Initial program 66.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.4
Applied rewrites91.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 9e-149)
(* (/ y (+ y x)) (/ 1.0 (+ 1.0 x)))
(if (<= y 1.85e+131)
(* 1.0 (/ x (* (- (+ y x) -1.0) (+ y x))))
(* (/ 1.0 (+ x y)) (/ x (- (+ x y) -1.0))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 9e-149) {
tmp = (y / (y + x)) * (1.0 / (1.0 + x));
} else if (y <= 1.85e+131) {
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 9d-149) then
tmp = (y / (y + x)) * (1.0d0 / (1.0d0 + x))
else if (y <= 1.85d+131) then
tmp = 1.0d0 * (x / (((y + x) - (-1.0d0)) * (y + x)))
else
tmp = (1.0d0 / (x + y)) * (x / ((x + y) - (-1.0d0)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 9e-149) {
tmp = (y / (y + x)) * (1.0 / (1.0 + x));
} else if (y <= 1.85e+131) {
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 9e-149: tmp = (y / (y + x)) * (1.0 / (1.0 + x)) elif y <= 1.85e+131: tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x))) else: tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 9e-149) tmp = Float64(Float64(y / Float64(y + x)) * Float64(1.0 / Float64(1.0 + x))); elseif (y <= 1.85e+131) tmp = Float64(1.0 * Float64(x / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(1.0 / Float64(x + y)) * Float64(x / Float64(Float64(x + y) - -1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 9e-149)
tmp = (y / (y + x)) * (1.0 / (1.0 + x));
elseif (y <= 1.85e+131)
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
else
tmp = (1.0 / (x + y)) * (x / ((x + y) - -1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 9e-149], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e+131], N[(1.0 * N[(x / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-149}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{1}{1 + x}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+131}:\\
\;\;\;\;1 \cdot \frac{x}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + y} \cdot \frac{x}{\left(x + y\right) - -1}\\
\end{array}
\end{array}
if y < 8.9999999999999996e-149Initial program 68.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6494.4
Applied rewrites94.4%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6457.2
Applied rewrites57.2%
if 8.9999999999999996e-149 < y < 1.84999999999999998e131Initial program 76.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites65.4%
if 1.84999999999999998e131 < y Initial program 46.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites86.0%
Final simplification63.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 9e-149)
(* (/ y (+ y x)) (/ 1.0 (+ 1.0 x)))
(if (<= y 1.85e+131)
(* 1.0 (/ x (* (- (+ y x) -1.0) (+ y x))))
(* (/ 1.0 y) (/ x (- (+ x y) -1.0))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 9e-149) {
tmp = (y / (y + x)) * (1.0 / (1.0 + x));
} else if (y <= 1.85e+131) {
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 9d-149) then
tmp = (y / (y + x)) * (1.0d0 / (1.0d0 + x))
else if (y <= 1.85d+131) then
tmp = 1.0d0 * (x / (((y + x) - (-1.0d0)) * (y + x)))
else
tmp = (1.0d0 / y) * (x / ((x + y) - (-1.0d0)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 9e-149) {
tmp = (y / (y + x)) * (1.0 / (1.0 + x));
} else if (y <= 1.85e+131) {
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 9e-149: tmp = (y / (y + x)) * (1.0 / (1.0 + x)) elif y <= 1.85e+131: tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x))) else: tmp = (1.0 / y) * (x / ((x + y) - -1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 9e-149) tmp = Float64(Float64(y / Float64(y + x)) * Float64(1.0 / Float64(1.0 + x))); elseif (y <= 1.85e+131) tmp = Float64(1.0 * Float64(x / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(1.0 / y) * Float64(x / Float64(Float64(x + y) - -1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 9e-149)
tmp = (y / (y + x)) * (1.0 / (1.0 + x));
elseif (y <= 1.85e+131)
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
else
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 9e-149], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e+131], N[(1.0 * N[(x / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-149}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{1}{1 + x}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+131}:\\
\;\;\;\;1 \cdot \frac{x}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{x}{\left(x + y\right) - -1}\\
\end{array}
\end{array}
if y < 8.9999999999999996e-149Initial program 68.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6494.4
Applied rewrites94.4%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6457.2
Applied rewrites57.2%
if 8.9999999999999996e-149 < y < 1.84999999999999998e131Initial program 76.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites65.4%
if 1.84999999999999998e131 < y Initial program 46.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f6485.6
Applied rewrites85.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 9e-149)
(/ y (fma x x x))
(if (<= y 1.85e+131)
(* 1.0 (/ x (* (- (+ y x) -1.0) (+ y x))))
(* (/ 1.0 y) (/ x (- (+ x y) -1.0))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 9e-149) {
tmp = y / fma(x, x, x);
} else if (y <= 1.85e+131) {
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / y) * (x / ((x + y) - -1.0));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 9e-149) tmp = Float64(y / fma(x, x, x)); elseif (y <= 1.85e+131) tmp = Float64(1.0 * Float64(x / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(1.0 / y) * Float64(x / Float64(Float64(x + y) - -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, 9e-149], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e+131], N[(1.0 * N[(x / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x / N[(N[(x + y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-149}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+131}:\\
\;\;\;\;1 \cdot \frac{x}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{x}{\left(x + y\right) - -1}\\
\end{array}
\end{array}
if y < 8.9999999999999996e-149Initial program 68.6%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6456.5
Applied rewrites56.5%
if 8.9999999999999996e-149 < y < 1.84999999999999998e131Initial program 76.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites65.4%
if 1.84999999999999998e131 < y Initial program 46.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f6485.6
Applied rewrites85.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 9e-149)
(/ y (fma x x x))
(if (<= y 1.85e+131)
(* 1.0 (/ x (* (- (+ y x) -1.0) (+ y x))))
(* (/ 1.0 y) (/ x y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 9e-149) {
tmp = y / fma(x, x, x);
} else if (y <= 1.85e+131) {
tmp = 1.0 * (x / (((y + x) - -1.0) * (y + x)));
} else {
tmp = (1.0 / y) * (x / y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 9e-149) tmp = Float64(y / fma(x, x, x)); elseif (y <= 1.85e+131) tmp = Float64(1.0 * Float64(x / Float64(Float64(Float64(y + x) - -1.0) * Float64(y + x)))); else tmp = Float64(Float64(1.0 / y) * Float64(x / y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 9e-149], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e+131], N[(1.0 * N[(x / N[(N[(N[(y + x), $MachinePrecision] - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-149}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+131}:\\
\;\;\;\;1 \cdot \frac{x}{\left(\left(y + x\right) - -1\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 8.9999999999999996e-149Initial program 68.6%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6456.5
Applied rewrites56.5%
if 8.9999999999999996e-149 < y < 1.84999999999999998e131Initial program 76.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites65.4%
if 1.84999999999999998e131 < y Initial program 46.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
metadata-evalN/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f6485.6
Applied rewrites85.6%
Taylor expanded in y around inf
lower-/.f6485.4
Applied rewrites85.4%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -2e+150)
(/ (/ y x) x)
(if (<= x -3e-74)
(/ y (fma x x x))
(if (<= x 2.25e+86) (/ x (fma y y y)) (/ (/ x y) y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -2e+150) {
tmp = (y / x) / x;
} else if (x <= -3e-74) {
tmp = y / fma(x, x, x);
} else if (x <= 2.25e+86) {
tmp = x / fma(y, y, y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -2e+150) tmp = Float64(Float64(y / x) / x); elseif (x <= -3e-74) tmp = Float64(y / fma(x, x, x)); elseif (x <= 2.25e+86) tmp = Float64(x / fma(y, y, y)); else tmp = Float64(Float64(x / 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, -2e+150], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -3e-74], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.25e+86], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+150}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-74}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+86}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -1.99999999999999996e150Initial program 54.2%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6475.9
Applied rewrites75.9%
if -1.99999999999999996e150 < x < -3.00000000000000007e-74Initial program 69.1%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6464.1
Applied rewrites64.1%
if -3.00000000000000007e-74 < x < 2.24999999999999996e86Initial program 72.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6471.8
Applied rewrites71.8%
if 2.24999999999999996e86 < x Initial program 57.4%
Taylor expanded in y around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6427.6
Applied rewrites27.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -3e-74) (/ y (fma x x x)) (if (<= x 2.25e+86) (/ x (fma y y y)) (/ (/ x y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3e-74) {
tmp = y / fma(x, x, x);
} else if (x <= 2.25e+86) {
tmp = x / fma(y, y, y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3e-74) tmp = Float64(y / fma(x, x, x)); elseif (x <= 2.25e+86) tmp = Float64(x / fma(y, y, y)); else tmp = Float64(Float64(x / 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, -3e-74], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.25e+86], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-74}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+86}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -3.00000000000000007e-74Initial program 64.5%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6466.9
Applied rewrites66.9%
if -3.00000000000000007e-74 < x < 2.24999999999999996e86Initial program 72.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6471.8
Applied rewrites71.8%
if 2.24999999999999996e86 < x Initial program 57.4%
Taylor expanded in y around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6427.6
Applied rewrites27.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -3e-74) (/ y (fma x x x)) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3e-74) {
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 <= -3e-74) 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, -3e-74], 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 -3 \cdot 10^{-74}:\\
\;\;\;\;\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 < -3.00000000000000007e-74Initial program 64.5%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6466.9
Applied rewrites66.9%
if -3.00000000000000007e-74 < x Initial program 68.0%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6454.1
Applied rewrites54.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -2.7e-6) (/ y (* x x)) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -2.7e-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 <= -2.7e-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, -2.7e-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 -2.7 \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 < -2.69999999999999998e-6Initial program 53.8%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6467.0
Applied rewrites67.0%
Applied rewrites65.8%
if -2.69999999999999998e-6 < x Initial program 70.7%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6453.4
Applied rewrites53.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -2.7e-6) (/ y (* x x)) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -2.7e-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 <= (-2.7d-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 <= -2.7e-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 <= -2.7e-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 <= -2.7e-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 <= -2.7e-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, -2.7e-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 -2.7 \cdot 10^{-6}:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -2.69999999999999998e-6Initial program 53.8%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6467.0
Applied rewrites67.0%
Applied rewrites65.8%
if -2.69999999999999998e-6 < x Initial program 70.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6492.7
Applied rewrites92.7%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6436.1
Applied rewrites36.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 66.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.4
Applied rewrites91.4%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6432.8
Applied rewrites32.8%
(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 2025015
(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))))