
(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 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (/ (* y (/ x (+ y x))) (- y (- -1.0 x))) (+ y x)))
assert(x < y);
double code(double x, double y) {
return ((y * (x / (y + x))) / (y - (-1.0 - x))) / (y + x);
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y * (x / (y + x))) / (y - ((-1.0d0) - x))) / (y + x)
end function
assert x < y;
public static double code(double x, double y) {
return ((y * (x / (y + x))) / (y - (-1.0 - x))) / (y + x);
}
[x, y] = sort([x, y]) def code(x, y): return ((y * (x / (y + x))) / (y - (-1.0 - x))) / (y + x)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(y * Float64(x / Float64(y + x))) / Float64(y - Float64(-1.0 - x))) / Float64(y + x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((y * (x / (y + x))) / (y - (-1.0 - x))) / (y + x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(y * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y \cdot \frac{x}{y + x}}{y - \left(-1 - x\right)}}{y + x}
\end{array}
Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/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 (* (/ x (+ x y)) (/ (/ y (+ x y)) (- y (- -1.0 x)))))
assert(x < y);
double code(double x, double y) {
return (x / (x + y)) * ((y / (x + y)) / (y - (-1.0 - 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 / (x + y)) / (y - ((-1.0d0) - x)))
end function
assert x < y;
public static double code(double x, double y) {
return (x / (x + y)) * ((y / (x + y)) / (y - (-1.0 - x)));
}
[x, y] = sort([x, y]) def code(x, y): return (x / (x + y)) * ((y / (x + y)) / (y - (-1.0 - x)))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(x + y)) * Float64(Float64(y / Float64(x + y)) / Float64(y - Float64(-1.0 - x)))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / (x + y)) * ((y / (x + y)) / (y - (-1.0 - 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[(x + y), $MachinePrecision]), $MachinePrecision] / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{x + y} \cdot \frac{\frac{y}{x + y}}{y - \left(-1 - x\right)}
\end{array}
Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.8
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-+.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
times-fracN/A
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (- y (- -1.0 x))))
(if (<= y -1.7e+119)
(* (/ y (+ x y)) (/ (/ x (- x -1.0)) (+ x y)))
(if (<= y 2.9e+144)
(/ (* (/ x (+ y x)) y) (* t_0 (+ y x)))
(/ (/ x t_0) (+ y x))))))assert(x < y);
double code(double x, double y) {
double t_0 = y - (-1.0 - x);
double tmp;
if (y <= -1.7e+119) {
tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y));
} else if (y <= 2.9e+144) {
tmp = ((x / (y + x)) * y) / (t_0 * (y + x));
} else {
tmp = (x / t_0) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y - ((-1.0d0) - x)
if (y <= (-1.7d+119)) then
tmp = (y / (x + y)) * ((x / (x - (-1.0d0))) / (x + y))
else if (y <= 2.9d+144) then
tmp = ((x / (y + x)) * y) / (t_0 * (y + x))
else
tmp = (x / t_0) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y - (-1.0 - x);
double tmp;
if (y <= -1.7e+119) {
tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y));
} else if (y <= 2.9e+144) {
tmp = ((x / (y + x)) * y) / (t_0 * (y + x));
} else {
tmp = (x / t_0) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y - (-1.0 - x) tmp = 0 if y <= -1.7e+119: tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y)) elif y <= 2.9e+144: tmp = ((x / (y + x)) * y) / (t_0 * (y + x)) else: tmp = (x / t_0) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y - Float64(-1.0 - x)) tmp = 0.0 if (y <= -1.7e+119) tmp = Float64(Float64(y / Float64(x + y)) * Float64(Float64(x / Float64(x - -1.0)) / Float64(x + y))); elseif (y <= 2.9e+144) tmp = Float64(Float64(Float64(x / Float64(y + x)) * y) / Float64(t_0 * Float64(y + x))); else tmp = Float64(Float64(x / t_0) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y - (-1.0 - x);
tmp = 0.0;
if (y <= -1.7e+119)
tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y));
elseif (y <= 2.9e+144)
tmp = ((x / (y + x)) * y) / (t_0 * (y + x));
else
tmp = (x / t_0) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+119], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+144], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(t$95$0 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / t$95$0), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y - \left(-1 - x\right)\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+119}:\\
\;\;\;\;\frac{y}{x + y} \cdot \frac{\frac{x}{x - -1}}{x + y}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+144}:\\
\;\;\;\;\frac{\frac{x}{y + x} \cdot y}{t\_0 \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t\_0}}{y + x}\\
\end{array}
\end{array}
if y < -1.70000000000000007e119Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites76.7%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
+-commutativeN/A
lift-+.f64N/A
associate-*r/N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
Applied rewrites62.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6476.6
Applied rewrites76.6%
if -1.70000000000000007e119 < y < 2.89999999999999998e144Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/r*N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6493.6
Applied rewrites93.6%
if 2.89999999999999998e144 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 0.118) (/ (/ (* x (/ y (+ x y))) (- x -1.0)) (+ x y)) (/ (/ x (- y (- -1.0 x))) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 0.118) {
tmp = ((x * (y / (x + y))) / (x - -1.0)) / (x + y);
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.118d0) then
tmp = ((x * (y / (x + y))) / (x - (-1.0d0))) / (x + y)
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 0.118) {
tmp = ((x * (y / (x + y))) / (x - -1.0)) / (x + y);
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 0.118: tmp = ((x * (y / (x + y))) / (x - -1.0)) / (x + y) else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 0.118) tmp = Float64(Float64(Float64(x * Float64(y / Float64(x + y))) / Float64(x - -1.0)) / Float64(x + y)); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - 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 <= 0.118)
tmp = ((x * (y / (x + y))) / (x - -1.0)) / (x + y);
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 0.118], N[(N[(N[(x * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.118:\\
\;\;\;\;\frac{\frac{x \cdot \frac{y}{x + y}}{x - -1}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if y < 0.11799999999999999Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites76.7%
if 0.11799999999999999 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 0.118) (* (/ y (+ x y)) (/ (/ x (- x -1.0)) (+ x y))) (/ (/ x (- y (- -1.0 x))) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 0.118) {
tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.118d0) then
tmp = (y / (x + y)) * ((x / (x - (-1.0d0))) / (x + y))
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 0.118) {
tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 0.118: tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y)) else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 0.118) tmp = Float64(Float64(y / Float64(x + y)) * Float64(Float64(x / Float64(x - -1.0)) / Float64(x + y))); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - 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 <= 0.118)
tmp = (y / (x + y)) * ((x / (x - -1.0)) / (x + y));
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 0.118], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.118:\\
\;\;\;\;\frac{y}{x + y} \cdot \frac{\frac{x}{x - -1}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if y < 0.11799999999999999Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites76.7%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
+-commutativeN/A
lift-+.f64N/A
associate-*r/N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
Applied rewrites62.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6476.6
Applied rewrites76.6%
if 0.11799999999999999 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y -1.7e+119)
(/ (/ y x) (+ y x))
(if (<= y 0.118)
(* y (/ (/ x (+ x y)) (* (- x -1.0) (+ x y))))
(/ (/ x (- y (- -1.0 x))) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -1.7e+119) {
tmp = (y / x) / (y + x);
} else if (y <= 0.118) {
tmp = y * ((x / (x + y)) / ((x - -1.0) * (x + y)));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.7d+119)) then
tmp = (y / x) / (y + x)
else if (y <= 0.118d0) then
tmp = y * ((x / (x + y)) / ((x - (-1.0d0)) * (x + y)))
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= -1.7e+119) {
tmp = (y / x) / (y + x);
} else if (y <= 0.118) {
tmp = y * ((x / (x + y)) / ((x - -1.0) * (x + y)));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= -1.7e+119: tmp = (y / x) / (y + x) elif y <= 0.118: tmp = y * ((x / (x + y)) / ((x - -1.0) * (x + y))) else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= -1.7e+119) tmp = Float64(Float64(y / x) / Float64(y + x)); elseif (y <= 0.118) tmp = Float64(y * Float64(Float64(x / Float64(x + y)) / Float64(Float64(x - -1.0) * Float64(x + y)))); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - 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 <= -1.7e+119)
tmp = (y / x) / (y + x);
elseif (y <= 0.118)
tmp = y * ((x / (x + y)) / ((x - -1.0) * (x + y)));
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, -1.7e+119], N[(N[(y / x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.118], N[(y * N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+119}:\\
\;\;\;\;\frac{\frac{y}{x}}{y + x}\\
\mathbf{elif}\;y \leq 0.118:\\
\;\;\;\;y \cdot \frac{\frac{x}{x + y}}{\left(x - -1\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if y < -1.70000000000000007e119Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -1.70000000000000007e119 < y < 0.11799999999999999Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites76.7%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
+-commutativeN/A
lift-+.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites83.8%
if 0.11799999999999999 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.45e-260)
(/ (/ y (- x -1.0)) (+ y x))
(if (<= y 8.2e-162)
(/ (* (/ x (+ y x)) y) (* (- y -1.0) (+ y x)))
(if (<= y 0.000415)
(* y (/ x (* (- x -1.0) (* (+ x y) (+ x y)))))
(/ (/ x (- y (- -1.0 x))) (+ y x))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.45e-260) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 8.2e-162) {
tmp = ((x / (y + x)) * y) / ((y - -1.0) * (y + x));
} else if (y <= 0.000415) {
tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y))));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.45d-260) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else if (y <= 8.2d-162) then
tmp = ((x / (y + x)) * y) / ((y - (-1.0d0)) * (y + x))
else if (y <= 0.000415d0) then
tmp = y * (x / ((x - (-1.0d0)) * ((x + y) * (x + y))))
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.45e-260) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 8.2e-162) {
tmp = ((x / (y + x)) * y) / ((y - -1.0) * (y + x));
} else if (y <= 0.000415) {
tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y))));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.45e-260: tmp = (y / (x - -1.0)) / (y + x) elif y <= 8.2e-162: tmp = ((x / (y + x)) * y) / ((y - -1.0) * (y + x)) elif y <= 0.000415: tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y)))) else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.45e-260) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); elseif (y <= 8.2e-162) tmp = Float64(Float64(Float64(x / Float64(y + x)) * y) / Float64(Float64(y - -1.0) * Float64(y + x))); elseif (y <= 0.000415) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(Float64(x + y) * Float64(x + y))))); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - 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 <= 1.45e-260)
tmp = (y / (x - -1.0)) / (y + x);
elseif (y <= 8.2e-162)
tmp = ((x / (y + x)) * y) / ((y - -1.0) * (y + x));
elseif (y <= 0.000415)
tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y))));
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.45e-260], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e-162], N[(N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(N[(y - -1.0), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.000415], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.45 \cdot 10^{-260}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{x}{y + x} \cdot y}{\left(y - -1\right) \cdot \left(y + x\right)}\\
\mathbf{elif}\;y \leq 0.000415:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if y < 1.45e-260Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.5
Applied rewrites51.5%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.5
Applied rewrites51.5%
if 1.45e-260 < y < 8.20000000000000039e-162Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/r*N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6493.6
Applied rewrites93.6%
Taylor expanded in x around 0
Applied rewrites76.0%
if 8.20000000000000039e-162 < y < 4.15e-4Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6476.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.1
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6476.1
Applied rewrites76.1%
if 4.15e-4 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.18e-259)
(/ (/ y (- x -1.0)) (+ y x))
(if (<= y 4e-162)
(/ (/ x (- y -1.0)) (* y (+ 1.0 (/ x y))))
(if (<= y 0.000415)
(* y (/ x (* (- x -1.0) (* (+ x y) (+ x y)))))
(/ (/ x (- y (- -1.0 x))) (+ y x))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.18e-259) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 4e-162) {
tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y)));
} else if (y <= 0.000415) {
tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y))));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.18d-259) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else if (y <= 4d-162) then
tmp = (x / (y - (-1.0d0))) / (y * (1.0d0 + (x / y)))
else if (y <= 0.000415d0) then
tmp = y * (x / ((x - (-1.0d0)) * ((x + y) * (x + y))))
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.18e-259) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 4e-162) {
tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y)));
} else if (y <= 0.000415) {
tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y))));
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.18e-259: tmp = (y / (x - -1.0)) / (y + x) elif y <= 4e-162: tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y))) elif y <= 0.000415: tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y)))) else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.18e-259) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); elseif (y <= 4e-162) tmp = Float64(Float64(x / Float64(y - -1.0)) / Float64(y * Float64(1.0 + Float64(x / y)))); elseif (y <= 0.000415) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * Float64(Float64(x + y) * Float64(x + y))))); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - 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 <= 1.18e-259)
tmp = (y / (x - -1.0)) / (y + x);
elseif (y <= 4e-162)
tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y)));
elseif (y <= 0.000415)
tmp = y * (x / ((x - -1.0) * ((x + y) * (x + y))));
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.18e-259], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e-162], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.000415], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.18 \cdot 10^{-259}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y \cdot \left(1 + \frac{x}{y}\right)}\\
\mathbf{elif}\;y \leq 0.000415:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if y < 1.18e-259Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.5
Applied rewrites51.5%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.5
Applied rewrites51.5%
if 1.18e-259 < y < 3.99999999999999982e-162Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.3
Applied rewrites50.3%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6462.7
Applied rewrites62.7%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6462.7
Applied rewrites62.7%
if 3.99999999999999982e-162 < y < 4.15e-4Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6476.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.1
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6476.1
Applied rewrites76.1%
if 4.15e-4 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.18e-259)
(/ (/ y (- x -1.0)) (+ y x))
(if (<= y 4e-162)
(/ (/ x (- y -1.0)) (* y (+ 1.0 (/ x y))))
(if (<= y 0.000415)
(* (/ y (* (- x -1.0) (* (+ x y) (+ x y)))) x)
(/ (/ x (- y (- -1.0 x))) (+ y x))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.18e-259) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 4e-162) {
tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y)));
} else if (y <= 0.000415) {
tmp = (y / ((x - -1.0) * ((x + y) * (x + y)))) * x;
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.18d-259) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else if (y <= 4d-162) then
tmp = (x / (y - (-1.0d0))) / (y * (1.0d0 + (x / y)))
else if (y <= 0.000415d0) then
tmp = (y / ((x - (-1.0d0)) * ((x + y) * (x + y)))) * x
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.18e-259) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 4e-162) {
tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y)));
} else if (y <= 0.000415) {
tmp = (y / ((x - -1.0) * ((x + y) * (x + y)))) * x;
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.18e-259: tmp = (y / (x - -1.0)) / (y + x) elif y <= 4e-162: tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y))) elif y <= 0.000415: tmp = (y / ((x - -1.0) * ((x + y) * (x + y)))) * x else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.18e-259) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); elseif (y <= 4e-162) tmp = Float64(Float64(x / Float64(y - -1.0)) / Float64(y * Float64(1.0 + Float64(x / y)))); elseif (y <= 0.000415) tmp = Float64(Float64(y / Float64(Float64(x - -1.0) * Float64(Float64(x + y) * Float64(x + y)))) * x); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - 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 <= 1.18e-259)
tmp = (y / (x - -1.0)) / (y + x);
elseif (y <= 4e-162)
tmp = (x / (y - -1.0)) / (y * (1.0 + (x / y)));
elseif (y <= 0.000415)
tmp = (y / ((x - -1.0) * ((x + y) * (x + y)))) * x;
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.18e-259], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e-162], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.000415], N[(N[(y / N[(N[(x - -1.0), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.18 \cdot 10^{-259}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y \cdot \left(1 + \frac{x}{y}\right)}\\
\mathbf{elif}\;y \leq 0.000415:\\
\;\;\;\;\frac{y}{\left(x - -1\right) \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if y < 1.18e-259Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.5
Applied rewrites51.5%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.5
Applied rewrites51.5%
if 1.18e-259 < y < 3.99999999999999982e-162Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.3
Applied rewrites50.3%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6462.7
Applied rewrites62.7%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6462.7
Applied rewrites62.7%
if 3.99999999999999982e-162 < y < 4.15e-4Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6472.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.7
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6472.7
Applied rewrites72.7%
if 4.15e-4 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y 1.05e-79)
(/ (/ y (- x -1.0)) (+ y x))
(if (<= y 7e-5)
(/ (* x y) (* (* (+ x y) (+ x y)) 1.0))
(/ (/ x (- y (- -1.0 x))) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.05e-79) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 7e-5) {
tmp = (x * y) / (((x + y) * (x + y)) * 1.0);
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.05d-79) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else if (y <= 7d-5) then
tmp = (x * y) / (((x + y) * (x + y)) * 1.0d0)
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.05e-79) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (y <= 7e-5) {
tmp = (x * y) / (((x + y) * (x + y)) * 1.0);
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.05e-79: tmp = (y / (x - -1.0)) / (y + x) elif y <= 7e-5: tmp = (x * y) / (((x + y) * (x + y)) * 1.0) else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.05e-79) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); elseif (y <= 7e-5) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * 1.0)); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - 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 <= 1.05e-79)
tmp = (y / (x - -1.0)) / (y + x);
elseif (y <= 7e-5)
tmp = (x * y) / (((x + y) * (x + y)) * 1.0);
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.05e-79], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-5], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.05 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-5}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if y < 1.05e-79Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.5
Applied rewrites51.5%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.5
Applied rewrites51.5%
if 1.05e-79 < y < 6.9999999999999994e-5Initial program 69.1%
Taylor expanded in y around 0
lower-+.f6459.8
Applied rewrites59.8%
Taylor expanded in x around 0
Applied rewrites49.9%
if 6.9999999999999994e-5 < y Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (/ x (- y -1.0)) (+ y x))))
(if (<= x -3.45e+62)
(/ (/ y x) (+ y x))
(if (<= x -5e+34) t_0 (if (<= x -1.8e-142) (/ y (* x (+ 1.0 x))) t_0)))))assert(x < y);
double code(double x, double y) {
double t_0 = (x / (y - -1.0)) / (y + x);
double tmp;
if (x <= -3.45e+62) {
tmp = (y / x) / (y + x);
} else if (x <= -5e+34) {
tmp = t_0;
} else if (x <= -1.8e-142) {
tmp = y / (x * (1.0 + x));
} else {
tmp = t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x / (y - (-1.0d0))) / (y + x)
if (x <= (-3.45d+62)) then
tmp = (y / x) / (y + x)
else if (x <= (-5d+34)) then
tmp = t_0
else if (x <= (-1.8d-142)) then
tmp = y / (x * (1.0d0 + x))
else
tmp = t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (x / (y - -1.0)) / (y + x);
double tmp;
if (x <= -3.45e+62) {
tmp = (y / x) / (y + x);
} else if (x <= -5e+34) {
tmp = t_0;
} else if (x <= -1.8e-142) {
tmp = y / (x * (1.0 + x));
} else {
tmp = t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (x / (y - -1.0)) / (y + x) tmp = 0 if x <= -3.45e+62: tmp = (y / x) / (y + x) elif x <= -5e+34: tmp = t_0 elif x <= -1.8e-142: tmp = y / (x * (1.0 + x)) else: tmp = t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(x / Float64(y - -1.0)) / Float64(y + x)) tmp = 0.0 if (x <= -3.45e+62) tmp = Float64(Float64(y / x) / Float64(y + x)); elseif (x <= -5e+34) tmp = t_0; elseif (x <= -1.8e-142) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = t_0; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (x / (y - -1.0)) / (y + x);
tmp = 0.0;
if (x <= -3.45e+62)
tmp = (y / x) / (y + x);
elseif (x <= -5e+34)
tmp = t_0;
elseif (x <= -1.8e-142)
tmp = y / (x * (1.0 + x));
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.45e+62], N[(N[(y / x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e+34], t$95$0, If[LessEqual[x, -1.8e-142], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{x}{y - -1}}{y + x}\\
\mathbf{if}\;x \leq -3.45 \cdot 10^{+62}:\\
\;\;\;\;\frac{\frac{y}{x}}{y + x}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{+34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-142}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.44999999999999999e62Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -3.44999999999999999e62 < x < -4.9999999999999998e34 or -1.8e-142 < x Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.3
Applied rewrites50.3%
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6450.3
Applied rewrites50.3%
if -4.9999999999999998e34 < x < -1.8e-142Initial program 69.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.2
Applied rewrites49.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -3.45e+62)
(/ (/ y x) (+ y x))
(if (<= x -5e+34)
(/ x (fma y y y))
(if (<= x -1.8e-142) (/ y (* x (+ 1.0 x))) (/ (/ x y) (- y -1.0))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.45e+62) {
tmp = (y / x) / (y + x);
} else if (x <= -5e+34) {
tmp = x / fma(y, y, y);
} else if (x <= -1.8e-142) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3.45e+62) tmp = Float64(Float64(y / x) / Float64(y + x)); elseif (x <= -5e+34) tmp = Float64(x / fma(y, y, y)); elseif (x <= -1.8e-142) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / y) / Float64(y - -1.0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -3.45e+62], N[(N[(y / x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e+34], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.8e-142], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.45 \cdot 10^{+62}:\\
\;\;\;\;\frac{\frac{y}{x}}{y + x}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{+34}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-142}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y - -1}\\
\end{array}
\end{array}
if x < -3.44999999999999999e62Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -3.44999999999999999e62 < x < -4.9999999999999998e34Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.6
Applied rewrites48.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.6
Applied rewrites48.6%
if -4.9999999999999998e34 < x < -1.8e-142Initial program 69.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.2
Applied rewrites49.2%
if -1.8e-142 < x Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.6
Applied rewrites48.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6449.7
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6449.7
Applied rewrites49.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -8.4e-132) (/ (/ y (- x -1.0)) (+ y x)) (/ (/ x (- y (- -1.0 x))) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -8.4e-132) {
tmp = (y / (x - -1.0)) / (y + x);
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-8.4d-132)) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else
tmp = (x / (y - ((-1.0d0) - x))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -8.4e-132) {
tmp = (y / (x - -1.0)) / (y + x);
} else {
tmp = (x / (y - (-1.0 - x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -8.4e-132: tmp = (y / (x - -1.0)) / (y + x) else: tmp = (x / (y - (-1.0 - x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -8.4e-132) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); else tmp = Float64(Float64(x / Float64(y - Float64(-1.0 - x))) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -8.4e-132)
tmp = (y / (x - -1.0)) / (y + x);
else
tmp = (x / (y - (-1.0 - x))) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -8.4e-132], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - \left(-1 - x\right)}}{y + x}\\
\end{array}
\end{array}
if x < -8.4000000000000004e-132Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.5
Applied rewrites51.5%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.5
Applied rewrites51.5%
if -8.4000000000000004e-132 < x Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites51.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -8.4e-132) (/ (/ y (- x -1.0)) (+ y x)) (/ (/ x (- y -1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -8.4e-132) {
tmp = (y / (x - -1.0)) / (y + x);
} else {
tmp = (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 <= (-8.4d-132)) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else
tmp = (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 <= -8.4e-132) {
tmp = (y / (x - -1.0)) / (y + x);
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -8.4e-132: tmp = (y / (x - -1.0)) / (y + x) else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -8.4e-132) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); else tmp = Float64(Float64(x / 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 <= -8.4e-132)
tmp = (y / (x - -1.0)) / (y + x);
else
tmp = (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, -8.4e-132], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if x < -8.4000000000000004e-132Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.5
Applied rewrites51.5%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.5
Applied rewrites51.5%
if -8.4000000000000004e-132 < x Initial program 69.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.3
Applied rewrites50.3%
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6450.3
Applied rewrites50.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.8e-142) (/ y (* x (+ 1.0 x))) (/ (/ x y) (- y -1.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.8e-142) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.8d-142)) then
tmp = y / (x * (1.0d0 + x))
else
tmp = (x / y) / (y - (-1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.8e-142) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / y) / (y - -1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.8e-142: tmp = y / (x * (1.0 + x)) else: tmp = (x / y) / (y - -1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.8e-142) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(Float64(x / y) / Float64(y - -1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.8e-142)
tmp = y / (x * (1.0 + x));
else
tmp = (x / y) / (y - -1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.8e-142], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-142}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y - -1}\\
\end{array}
\end{array}
if x < -1.8e-142Initial program 69.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.2
Applied rewrites49.2%
if -1.8e-142 < x Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.6
Applied rewrites48.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6449.7
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6449.7
Applied rewrites49.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.8e-142) (/ y (* x (+ 1.0 x))) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.8e-142) {
tmp = y / (x * (1.0 + x));
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.8e-142) tmp = Float64(y / Float64(x * Float64(1.0 + x))); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1.8e-142], N[(y / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-142}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -1.8e-142Initial program 69.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.2
Applied rewrites49.2%
if -1.8e-142 < x Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.6
Applied rewrites48.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.6
Applied rewrites48.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (fma y y y)))
assert(x < y);
double code(double x, double y) {
return x / fma(y, y, y);
}
x, y = sort([x, y]) function code(x, y) return Float64(x / fma(y, y, y)) end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{\mathsf{fma}\left(y, y, y\right)}
\end{array}
Initial program 69.1%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.6
Applied rewrites48.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.6
Applied rewrites48.6%
herbie shell --seed 2025143
(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))))