
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ x (- (- x) y)) (/ (/ y (- (- -1.0 x) y)) (+ y x))))
assert(x < y);
double code(double x, double y) {
return (x / (-x - y)) * ((y / ((-1.0 - x) - 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 / (-x - y)) * ((y / (((-1.0d0) - x) - y)) / (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return (x / (-x - y)) * ((y / ((-1.0 - x) - y)) / (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return (x / (-x - y)) * ((y / ((-1.0 - x) - y)) / (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(Float64(-x) - y)) * Float64(Float64(y / Float64(Float64(-1.0 - x) - y)) / Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / (-x - y)) * ((y / ((-1.0 - x) - y)) / (y + x));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(x / N[((-x) - y), $MachinePrecision]), $MachinePrecision] * N[(N[(y / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{\left(-x\right) - y} \cdot \frac{\frac{y}{\left(-1 - x\right) - y}}{y + x}
\end{array}
Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
sub-flip-reverseN/A
lower--.f64N/A
lower-neg.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2neg-revN/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 5e-25) (/ (/ (* (/ y (+ y x)) x) (- x -1.0)) (+ y x)) (/ (/ (* (/ y (- y (- -1.0 x))) x) (+ y x)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5e-25) {
tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x);
} else {
tmp = (((y / (y - (-1.0 - x))) * x) / (y + 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 <= 5d-25) then
tmp = (((y / (y + x)) * x) / (x - (-1.0d0))) / (y + x)
else
tmp = (((y / (y - ((-1.0d0) - x))) * x) / (y + x)) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5e-25) {
tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x);
} else {
tmp = (((y / (y - (-1.0 - x))) * x) / (y + x)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5e-25: tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x) else: tmp = (((y / (y - (-1.0 - x))) * x) / (y + x)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5e-25) tmp = Float64(Float64(Float64(Float64(y / Float64(y + x)) * x) / Float64(x - -1.0)) / Float64(y + x)); else tmp = Float64(Float64(Float64(Float64(y / Float64(y - Float64(-1.0 - x))) * x) / Float64(y + 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 <= 5e-25)
tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x);
else
tmp = (((y / (y - (-1.0 - x))) * x) / (y + 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, 5e-25], N[(N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{\frac{y}{y + x} \cdot x}{x - -1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{y}{y - \left(-1 - x\right)} \cdot x}{y + x}}{y + x}\\
\end{array}
\end{array}
if y < 4.99999999999999962e-25Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.5%
if 4.99999999999999962e-25 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites89.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 2.7e+130) (* (/ y (+ y x)) (/ x (* (- y (- -1.0 x)) (+ y x)))) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.7e+130) {
tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x)));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.7d+130) then
tmp = (y / (y + x)) * (x / ((y - ((-1.0d0) - x)) * (y + x)))
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.7e+130) {
tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x)));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.7e+130: tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x))) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.7e+130) tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(y - Float64(-1.0 - x)) * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.7e+130)
tmp = (y / (y + x)) * (x / ((y - (-1.0 - x)) * (y + x)));
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.7e+130], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{+130}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(y - \left(-1 - x\right)\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 2.6999999999999998e130Initial program 69.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-*.f6493.6
Applied rewrites93.6%
if 2.6999999999999998e130 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 4e-7) (/ (/ (* (/ y (+ y x)) x) (- x -1.0)) (+ y x)) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4e-7) {
tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4d-7) then
tmp = (((y / (y + x)) * x) / (x - (-1.0d0))) / (y + x)
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4e-7) {
tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4e-7: tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4e-7) tmp = Float64(Float64(Float64(Float64(y / Float64(y + x)) * x) / Float64(x - -1.0)) / Float64(y + x)); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4e-7)
tmp = (((y / (y + x)) * x) / (x - -1.0)) / (y + x);
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 4e-7], N[(N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\frac{y}{y + x} \cdot x}{x - -1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 3.9999999999999998e-7Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.5%
if 3.9999999999999998e-7 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1.25e+111)
(/ (* (/ -1.0 (- -1.0 x)) y) (+ x y))
(if (<= x -0.026)
(* y (/ x (* (- x -1.0) (* (+ y x) (+ y x)))))
(* (/ y (+ y x)) (/ x (* (- y -1.0) (+ y x)))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.25e+111) {
tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y);
} else if (x <= -0.026) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (y / (y + x)) * (x / ((y - -1.0) * (y + x)));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.25d+111)) then
tmp = (((-1.0d0) / ((-1.0d0) - x)) * y) / (x + y)
else if (x <= (-0.026d0)) then
tmp = y * (x / ((x - (-1.0d0)) * ((y + x) * (y + x))))
else
tmp = (y / (y + x)) * (x / ((y - (-1.0d0)) * (y + x)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.25e+111) {
tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y);
} else if (x <= -0.026) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (y / (y + x)) * (x / ((y - -1.0) * (y + x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.25e+111: tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y) elif x <= -0.026: tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x)))) else: tmp = (y / (y + x)) * (x / ((y - -1.0) * (y + x))) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.25e+111) tmp = Float64(Float64(Float64(-1.0 / Float64(-1.0 - x)) * y) / Float64(x + y)); elseif (x <= -0.026) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x))))); else tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(y - -1.0) * Float64(y + x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.25e+111)
tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y);
elseif (x <= -0.026)
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
else
tmp = (y / (y + x)) * (x / ((y - -1.0) * (y + x)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.25e+111], N[(N[(N[(-1.0 / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -0.026], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(y - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+111}:\\
\;\;\;\;\frac{\frac{-1}{-1 - x} \cdot y}{x + y}\\
\mathbf{elif}\;x \leq -0.026:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(y - -1\right) \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if x < -1.2499999999999999e111Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
if -1.2499999999999999e111 < x < -0.0259999999999999988Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6475.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.8
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.8
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites75.8%
if -0.0259999999999999988 < x Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in x around 0
Applied rewrites75.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 4e-7) (/ (* y (/ x (* (- x -1.0) (+ y x)))) (+ y x)) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4e-7) {
tmp = (y * (x / ((x - -1.0) * (y + x)))) / (y + x);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4d-7) then
tmp = (y * (x / ((x - (-1.0d0)) * (y + x)))) / (y + x)
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4e-7) {
tmp = (y * (x / ((x - -1.0) * (y + x)))) / (y + x);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4e-7: tmp = (y * (x / ((x - -1.0) * (y + x)))) / (y + x) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4e-7) tmp = Float64(Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(y + x)))) / Float64(y + x)); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4e-7)
tmp = (y * (x / ((x - -1.0) * (y + x)))) / (y + x);
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 4e-7], N[(N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{y \cdot \frac{x}{\left(x - -1\right) \cdot \left(y + x\right)}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 3.9999999999999998e-7Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites75.8%
if 3.9999999999999998e-7 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 7e-206)
(/ (/ y (+ 1.0 x)) (+ x y))
(if (<= y 1.56e-167)
(* 1.0 (/ x (* (- y (- -1.0 x)) (+ y x))))
(if (<= y 3.8e-7)
(* y (/ x (* (- x -1.0) (* (+ y x) (+ y x)))))
(/ (/ x (+ 1.0 y)) (+ x y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 7e-206) {
tmp = (y / (1.0 + x)) / (x + y);
} else if (y <= 1.56e-167) {
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
} else if (y <= 3.8e-7) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7d-206) then
tmp = (y / (1.0d0 + x)) / (x + y)
else if (y <= 1.56d-167) then
tmp = 1.0d0 * (x / ((y - ((-1.0d0) - x)) * (y + x)))
else if (y <= 3.8d-7) then
tmp = y * (x / ((x - (-1.0d0)) * ((y + x) * (y + x))))
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 7e-206) {
tmp = (y / (1.0 + x)) / (x + y);
} else if (y <= 1.56e-167) {
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
} else if (y <= 3.8e-7) {
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 7e-206: tmp = (y / (1.0 + x)) / (x + y) elif y <= 1.56e-167: tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x))) elif y <= 3.8e-7: tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x)))) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 7e-206) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(x + y)); elseif (y <= 1.56e-167) tmp = Float64(1.0 * Float64(x / Float64(Float64(y - Float64(-1.0 - x)) * Float64(y + x)))); elseif (y <= 3.8e-7) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x))))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 7e-206)
tmp = (y / (1.0 + x)) / (x + y);
elseif (y <= 1.56e-167)
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
elseif (y <= 3.8e-7)
tmp = y * (x / ((x - -1.0) * ((y + x) * (y + x))));
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 7e-206], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.56e-167], N[(1.0 * N[(x / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e-7], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-206}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{x + y}\\
\mathbf{elif}\;y \leq 1.56 \cdot 10^{-167}:\\
\;\;\;\;1 \cdot \frac{x}{\left(y - \left(-1 - x\right)\right) \cdot \left(y + x\right)}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-7}:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 6.99999999999999979e-206Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.2
Applied rewrites51.2%
if 6.99999999999999979e-206 < y < 1.56000000000000005e-167Initial program 69.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-*.f6493.6
Applied rewrites93.6%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6493.5
lift-+.f64N/A
+-commutativeN/A
lift-+.f6493.5
Applied rewrites93.5%
Taylor expanded in x around 0
Applied rewrites66.0%
if 1.56000000000000005e-167 < y < 3.80000000000000015e-7Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6475.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.8
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.8
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites75.8%
if 3.80000000000000015e-7 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 7e-206)
(/ (/ y (+ 1.0 x)) (+ x y))
(if (<= y 1.56e-167)
(* 1.0 (/ x (* (- y (- -1.0 x)) (+ y x))))
(if (<= y 3.8e-7)
(* (/ y (* (- x -1.0) (* (+ y x) (+ y x)))) x)
(/ (/ x (+ 1.0 y)) (+ x y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 7e-206) {
tmp = (y / (1.0 + x)) / (x + y);
} else if (y <= 1.56e-167) {
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
} else if (y <= 3.8e-7) {
tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x;
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7d-206) then
tmp = (y / (1.0d0 + x)) / (x + y)
else if (y <= 1.56d-167) then
tmp = 1.0d0 * (x / ((y - ((-1.0d0) - x)) * (y + x)))
else if (y <= 3.8d-7) then
tmp = (y / ((x - (-1.0d0)) * ((y + x) * (y + x)))) * x
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 7e-206) {
tmp = (y / (1.0 + x)) / (x + y);
} else if (y <= 1.56e-167) {
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
} else if (y <= 3.8e-7) {
tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x;
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 7e-206: tmp = (y / (1.0 + x)) / (x + y) elif y <= 1.56e-167: tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x))) elif y <= 3.8e-7: tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 7e-206) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(x + y)); elseif (y <= 1.56e-167) tmp = Float64(1.0 * Float64(x / Float64(Float64(y - Float64(-1.0 - x)) * Float64(y + x)))); elseif (y <= 3.8e-7) tmp = Float64(Float64(y / Float64(Float64(x - -1.0) * Float64(Float64(y + x) * Float64(y + x)))) * x); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 7e-206)
tmp = (y / (1.0 + x)) / (x + y);
elseif (y <= 1.56e-167)
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
elseif (y <= 3.8e-7)
tmp = (y / ((x - -1.0) * ((y + x) * (y + x)))) * x;
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 7e-206], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.56e-167], N[(1.0 * N[(x / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e-7], N[(N[(y / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-206}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{x + y}\\
\mathbf{elif}\;y \leq 1.56 \cdot 10^{-167}:\\
\;\;\;\;1 \cdot \frac{x}{\left(y - \left(-1 - x\right)\right) \cdot \left(y + x\right)}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{y}{\left(x - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 6.99999999999999979e-206Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.2
Applied rewrites51.2%
if 6.99999999999999979e-206 < y < 1.56000000000000005e-167Initial program 69.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-*.f6493.6
Applied rewrites93.6%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6493.5
lift-+.f64N/A
+-commutativeN/A
lift-+.f6493.5
Applied rewrites93.5%
Taylor expanded in x around 0
Applied rewrites66.0%
if 1.56000000000000005e-167 < y < 3.80000000000000015e-7Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.0%
if 3.80000000000000015e-7 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -2.5e+25)
(/ (* (/ -1.0 (- -1.0 x)) y) (+ x y))
(if (<= x -1.8e-162)
(* (/ x (* (- y -1.0) (* (+ y x) (+ y x)))) y)
(/ (/ x (- y -1.0)) y))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -2.5e+25) {
tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y);
} else if (x <= -1.8e-162) {
tmp = (x / ((y - -1.0) * ((y + x) * (y + x)))) * y;
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.5d+25)) then
tmp = (((-1.0d0) / ((-1.0d0) - x)) * y) / (x + y)
else if (x <= (-1.8d-162)) then
tmp = (x / ((y - (-1.0d0)) * ((y + x) * (y + x)))) * y
else
tmp = (x / (y - (-1.0d0))) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -2.5e+25) {
tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y);
} else if (x <= -1.8e-162) {
tmp = (x / ((y - -1.0) * ((y + x) * (y + x)))) * y;
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -2.5e+25: tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y) elif x <= -1.8e-162: tmp = (x / ((y - -1.0) * ((y + x) * (y + x)))) * y else: tmp = (x / (y - -1.0)) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -2.5e+25) tmp = Float64(Float64(Float64(-1.0 / Float64(-1.0 - x)) * y) / Float64(x + y)); elseif (x <= -1.8e-162) tmp = Float64(Float64(x / Float64(Float64(y - -1.0) * Float64(Float64(y + x) * Float64(y + x)))) * y); else tmp = Float64(Float64(x / Float64(y - -1.0)) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -2.5e+25)
tmp = ((-1.0 / (-1.0 - x)) * y) / (x + y);
elseif (x <= -1.8e-162)
tmp = (x / ((y - -1.0) * ((y + x) * (y + x)))) * y;
else
tmp = (x / (y - -1.0)) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -2.5e+25], N[(N[(N[(-1.0 / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.8e-162], N[(N[(x / N[(N[(y - -1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{+25}:\\
\;\;\;\;\frac{\frac{-1}{-1 - x} \cdot y}{x + y}\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-162}:\\
\;\;\;\;\frac{x}{\left(y - -1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y}\\
\end{array}
\end{array}
if x < -2.50000000000000012e25Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
if -2.50000000000000012e25 < x < -1.7999999999999999e-162Initial program 69.6%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.2%
Taylor expanded in x around 0
Applied rewrites71.8%
if -1.7999999999999999e-162 < x Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.0
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6450.0
Applied rewrites50.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 4.5e-112)
(/ (/ y (+ 1.0 x)) (+ x y))
(if (<= y 1.1e+114)
(* 1.0 (/ x (* (- y (- -1.0 x)) (+ y x))))
(/ (/ x (+ 1.0 y)) (+ x y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.5e-112) {
tmp = (y / (1.0 + x)) / (x + y);
} else if (y <= 1.1e+114) {
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.5d-112) then
tmp = (y / (1.0d0 + x)) / (x + y)
else if (y <= 1.1d+114) then
tmp = 1.0d0 * (x / ((y - ((-1.0d0) - x)) * (y + x)))
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4.5e-112) {
tmp = (y / (1.0 + x)) / (x + y);
} else if (y <= 1.1e+114) {
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.5e-112: tmp = (y / (1.0 + x)) / (x + y) elif y <= 1.1e+114: tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x))) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.5e-112) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(x + y)); elseif (y <= 1.1e+114) tmp = Float64(1.0 * Float64(x / Float64(Float64(y - Float64(-1.0 - x)) * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4.5e-112)
tmp = (y / (1.0 + x)) / (x + y);
elseif (y <= 1.1e+114)
tmp = 1.0 * (x / ((y - (-1.0 - x)) * (y + x)));
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 4.5e-112], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+114], N[(1.0 * N[(x / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{-112}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{x + y}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+114}:\\
\;\;\;\;1 \cdot \frac{x}{\left(y - \left(-1 - x\right)\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 4.50000000000000012e-112Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.2
Applied rewrites51.2%
if 4.50000000000000012e-112 < y < 1.1e114Initial program 69.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-*.f6493.6
Applied rewrites93.6%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6493.5
lift-+.f64N/A
+-commutativeN/A
lift-+.f6493.5
Applied rewrites93.5%
Taylor expanded in x around 0
Applied rewrites66.0%
if 1.1e114 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 7.6e-57) (/ (/ y (+ 1.0 x)) (+ x y)) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 7.6e-57) {
tmp = (y / (1.0 + x)) / (x + y);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7.6d-57) then
tmp = (y / (1.0d0 + x)) / (x + y)
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 7.6e-57) {
tmp = (y / (1.0 + x)) / (x + y);
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 7.6e-57: tmp = (y / (1.0 + x)) / (x + y) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 7.6e-57) tmp = Float64(Float64(y / Float64(1.0 + x)) / Float64(x + y)); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 7.6e-57)
tmp = (y / (1.0 + x)) / (x + y);
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 7.6e-57], N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.6 \cdot 10^{-57}:\\
\;\;\;\;\frac{\frac{y}{1 + x}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 7.5999999999999995e-57Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.2
Applied rewrites51.2%
if 7.5999999999999995e-57 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 4.6e-77) (/ y (* x (+ 1.0 x))) (/ (/ x (+ 1.0 y)) (+ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.6e-77) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.6d-77) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (x / (1.0d0 + y)) / (x + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4.6e-77) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (1.0 + y)) / (x + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.6e-77: tmp = y / (x * (1.0 + x)) else: tmp = (x / (1.0 + y)) / (x + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.6e-77) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / Float64(1.0 + y)) / Float64(x + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4.6e-77)
tmp = y / (x * (1.0 + x));
else
tmp = (x / (1.0 + y)) / (x + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 4.6e-77], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.6 \cdot 10^{-77}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{1 + y}}{x + y}\\
\end{array}
\end{array}
if y < 4.59999999999999997e-77Initial program 69.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.9
Applied rewrites48.9%
if 4.59999999999999997e-77 < y Initial program 69.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6451.1
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.6
Applied rewrites50.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5e-56) (/ y (* x (+ 1.0 x))) (/ (/ x (- y -1.0)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5e-56) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5d-56) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (x / (y - (-1.0d0))) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5e-56) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5e-56: tmp = y / (x * (1.0 + x)) else: tmp = (x / (y - -1.0)) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5e-56) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / Float64(y - -1.0)) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5e-56)
tmp = y / (x * (1.0 + x));
else
tmp = (x / (y - -1.0)) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 5e-56], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-56}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y}\\
\end{array}
\end{array}
if y < 4.99999999999999997e-56Initial program 69.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.9
Applied rewrites48.9%
if 4.99999999999999997e-56 < y Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6450.0
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6450.0
Applied rewrites50.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5e-56) (/ y (* x (+ 1.0 x))) (/ x (+ (* y y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5e-56) {
tmp = y / (x * (1.0 + x));
} else {
tmp = x / ((y * y) + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5d-56) then
tmp = y / (x * (1.0d0 + x))
else
tmp = x / ((y * y) + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5e-56) {
tmp = y / (x * (1.0 + x));
} else {
tmp = x / ((y * y) + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5e-56: tmp = y / (x * (1.0 + x)) else: tmp = x / ((y * y) + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5e-56) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(x / Float64(Float64(y * y) + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5e-56)
tmp = y / (x * (1.0 + x));
else
tmp = x / ((y * y) + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 5e-56], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(y * y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-56}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y + y}\\
\end{array}
\end{array}
if y < 4.99999999999999997e-56Initial program 69.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.9
Applied rewrites48.9%
if 4.99999999999999997e-56 < y Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-+.f64N/A
lower-*.f6448.7
Applied rewrites48.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 3.4e-144) (* (/ 1.0 x) y) (/ x (+ (* y y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.4e-144) {
tmp = (1.0 / x) * y;
} else {
tmp = x / ((y * y) + y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.4d-144) then
tmp = (1.0d0 / x) * y
else
tmp = x / ((y * y) + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 3.4e-144) {
tmp = (1.0 / x) * y;
} else {
tmp = x / ((y * y) + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 3.4e-144: tmp = (1.0 / x) * y else: tmp = x / ((y * y) + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.4e-144) tmp = Float64(Float64(1.0 / x) * y); else tmp = Float64(x / Float64(Float64(y * y) + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 3.4e-144)
tmp = (1.0 / x) * y;
else
tmp = x / ((y * y) + y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.4e-144], N[(N[(1.0 / x), $MachinePrecision] * y), $MachinePrecision], N[(x / N[(N[(y * y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{-144}:\\
\;\;\;\;\frac{1}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y + y}\\
\end{array}
\end{array}
if y < 3.40000000000000017e-144Initial program 69.6%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.2%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.8
Applied rewrites48.8%
Taylor expanded in x around 0
lower-/.f6425.9
Applied rewrites25.9%
if 3.40000000000000017e-144 < y Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-+.f64N/A
lower-*.f6448.7
Applied rewrites48.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 3.4e-144) (* (/ 1.0 x) y) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 3.4e-144) {
tmp = (1.0 / x) * y;
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 3.4e-144) tmp = Float64(Float64(1.0 / x) * y); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 3.4e-144], N[(N[(1.0 / x), $MachinePrecision] * y), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{-144}:\\
\;\;\;\;\frac{1}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if y < 3.40000000000000017e-144Initial program 69.6%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.2%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.8
Applied rewrites48.8%
Taylor expanded in x around 0
lower-/.f6425.9
Applied rewrites25.9%
if 3.40000000000000017e-144 < y Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.7
Applied rewrites48.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.04e-185) (* (/ 1.0 x) y) (/ x y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.04e-185) {
tmp = (1.0 / x) * y;
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.04d-185)) then
tmp = (1.0d0 / x) * y
else
tmp = x / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.04e-185) {
tmp = (1.0 / x) * y;
} else {
tmp = x / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.04e-185: tmp = (1.0 / x) * y else: tmp = x / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.04e-185) tmp = Float64(Float64(1.0 / x) * y); else tmp = Float64(x / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.04e-185)
tmp = (1.0 / x) * y;
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.04e-185], N[(N[(1.0 / x), $MachinePrecision] * y), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.04 \cdot 10^{-185}:\\
\;\;\;\;\frac{1}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.03999999999999997e-185Initial program 69.6%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.2%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.8
Applied rewrites48.8%
Taylor expanded in x around 0
lower-/.f6425.9
Applied rewrites25.9%
if -1.03999999999999997e-185 < x Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in y around 0
lower-/.f6426.4
Applied rewrites26.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x y))
assert(x < y);
double code(double x, double y) {
return x / y;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
assert x < y;
public static double code(double x, double y) {
return x / y;
}
[x, y] = sort([x, y]) def code(x, y): return x / y
x, y = sort([x, y]) function code(x, y) return Float64(x / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y}
\end{array}
Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in y around 0
lower-/.f6426.4
Applied rewrites26.4%
herbie shell --seed 2025149
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))