
(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 22 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (* (/ y (- y (- -1.0 x))) (/ x (+ y x))) (+ y x)))
assert(x < y);
double code(double x, double y) {
return ((y / (y - (-1.0 - x))) * (x / (y + x))) / (y + x);
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y / (y - ((-1.0d0) - x))) * (x / (y + x))) / (y + x)
end function
assert x < y;
public static double code(double x, double y) {
return ((y / (y - (-1.0 - x))) * (x / (y + x))) / (y + x);
}
[x, y] = sort([x, y]) def code(x, y): return ((y / (y - (-1.0 - x))) * (x / (y + x))) / (y + x)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(y / Float64(y - Float64(-1.0 - x))) * Float64(x / Float64(y + x))) / Float64(y + x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((y / (y - (-1.0 - x))) * (x / (y + x))) / (y + x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{y - \left(-1 - x\right)} \cdot \frac{x}{y + x}}{y + x}
\end{array}
Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/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 (* (/ (/ y (- y (- -1.0 x))) (+ x y)) (/ x (+ y x))))
assert(x < y);
double code(double x, double y) {
return ((y / (y - (-1.0 - x))) / (x + y)) * (x / (y + x));
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y / (y - ((-1.0d0) - x))) / (x + y)) * (x / (y + x))
end function
assert x < y;
public static double code(double x, double y) {
return ((y / (y - (-1.0 - x))) / (x + y)) * (x / (y + x));
}
[x, y] = sort([x, y]) def code(x, y): return ((y / (y - (-1.0 - x))) / (x + y)) * (x / (y + x))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(y / Float64(y - Float64(-1.0 - x))) / Float64(x + y)) * Float64(x / Float64(y + x))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((y / (y - (-1.0 - x))) / (x + y)) * (x / (y + x));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{y - \left(-1 - x\right)}}{x + y} \cdot \frac{x}{y + x}
\end{array}
Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y (- -1.0 x)))))
(if (<= y 1.85e-16)
(/ (/ (* (/ x (+ x y)) y) (- x -1.0)) (+ x y))
(if (<= y 1.42e+154)
(/ (* t_0 x) (* (+ y x) (+ y x)))
(* (/ t_0 (+ x y)) (/ x y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (y - (-1.0 - x));
double tmp;
if (y <= 1.85e-16) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else if (y <= 1.42e+154) {
tmp = (t_0 * x) / ((y + x) * (y + x));
} else {
tmp = (t_0 / (x + 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) :: t_0
real(8) :: tmp
t_0 = y / (y - ((-1.0d0) - x))
if (y <= 1.85d-16) then
tmp = (((x / (x + y)) * y) / (x - (-1.0d0))) / (x + y)
else if (y <= 1.42d+154) then
tmp = (t_0 * x) / ((y + x) * (y + x))
else
tmp = (t_0 / (x + y)) * (x / y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (y - (-1.0 - x));
double tmp;
if (y <= 1.85e-16) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else if (y <= 1.42e+154) {
tmp = (t_0 * x) / ((y + x) * (y + x));
} else {
tmp = (t_0 / (x + y)) * (x / y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (y - (-1.0 - x)) tmp = 0 if y <= 1.85e-16: tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y) elif y <= 1.42e+154: tmp = (t_0 * x) / ((y + x) * (y + x)) else: tmp = (t_0 / (x + y)) * (x / y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(y - Float64(-1.0 - x))) tmp = 0.0 if (y <= 1.85e-16) tmp = Float64(Float64(Float64(Float64(x / Float64(x + y)) * y) / Float64(x - -1.0)) / Float64(x + y)); elseif (y <= 1.42e+154) tmp = Float64(Float64(t_0 * x) / Float64(Float64(y + x) * Float64(y + x))); else tmp = Float64(Float64(t_0 / Float64(x + y)) * Float64(x / y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (y - (-1.0 - x));
tmp = 0.0;
if (y <= 1.85e-16)
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
elseif (y <= 1.42e+154)
tmp = (t_0 * x) / ((y + x) * (y + x));
else
tmp = (t_0 / (x + 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_] := Block[{t$95$0 = N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.85e-16], N[(N[(N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.42e+154], N[(N[(t$95$0 * x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{y - \left(-1 - x\right)}\\
\mathbf{if}\;y \leq 1.85 \cdot 10^{-16}:\\
\;\;\;\;\frac{\frac{\frac{x}{x + y} \cdot y}{x - -1}}{x + y}\\
\mathbf{elif}\;y \leq 1.42 \cdot 10^{+154}:\\
\;\;\;\;\frac{t\_0 \cdot x}{\left(y + x\right) \cdot \left(y + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x + y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 1.85e-16Initial 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
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.8%
if 1.85e-16 < y < 1.42e154Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites82.7%
if 1.42e154 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f6460.7
Applied rewrites60.7%
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 8e-231)
(/ (/ (* (/ x (+ x y)) y) (- x -1.0)) (+ x y))
(if (<= y 1.42e+154)
(* (/ y (* t_0 (+ y x))) (/ x (+ y x)))
(* (/ (/ y t_0) (+ x y)) (/ x y))))))assert(x < y);
double code(double x, double y) {
double t_0 = y - (-1.0 - x);
double tmp;
if (y <= 8e-231) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else if (y <= 1.42e+154) {
tmp = (y / (t_0 * (y + x))) * (x / (y + x));
} else {
tmp = ((y / t_0) / (x + 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) :: t_0
real(8) :: tmp
t_0 = y - ((-1.0d0) - x)
if (y <= 8d-231) then
tmp = (((x / (x + y)) * y) / (x - (-1.0d0))) / (x + y)
else if (y <= 1.42d+154) then
tmp = (y / (t_0 * (y + x))) * (x / (y + x))
else
tmp = ((y / t_0) / (x + y)) * (x / y)
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 <= 8e-231) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else if (y <= 1.42e+154) {
tmp = (y / (t_0 * (y + x))) * (x / (y + x));
} else {
tmp = ((y / t_0) / (x + y)) * (x / y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y - (-1.0 - x) tmp = 0 if y <= 8e-231: tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y) elif y <= 1.42e+154: tmp = (y / (t_0 * (y + x))) * (x / (y + x)) else: tmp = ((y / t_0) / (x + y)) * (x / y) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y - Float64(-1.0 - x)) tmp = 0.0 if (y <= 8e-231) tmp = Float64(Float64(Float64(Float64(x / Float64(x + y)) * y) / Float64(x - -1.0)) / Float64(x + y)); elseif (y <= 1.42e+154) tmp = Float64(Float64(y / Float64(t_0 * Float64(y + x))) * Float64(x / Float64(y + x))); else tmp = Float64(Float64(Float64(y / t_0) / Float64(x + y)) * Float64(x / y)); 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 <= 8e-231)
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
elseif (y <= 1.42e+154)
tmp = (y / (t_0 * (y + x))) * (x / (y + x));
else
tmp = ((y / t_0) / (x + 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_] := Block[{t$95$0 = N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 8e-231], N[(N[(N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.42e+154], N[(N[(y / N[(t$95$0 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / t$95$0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / y), $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 8 \cdot 10^{-231}:\\
\;\;\;\;\frac{\frac{\frac{x}{x + y} \cdot y}{x - -1}}{x + y}\\
\mathbf{elif}\;y \leq 1.42 \cdot 10^{+154}:\\
\;\;\;\;\frac{y}{t\_0 \cdot \left(y + x\right)} \cdot \frac{x}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{t\_0}}{x + y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 7.9999999999999999e-231Initial 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
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.8%
if 7.9999999999999999e-231 < y < 1.42e154Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
if 1.42e154 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f6460.7
Applied rewrites60.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -5e+110)
(/ (/ (* (/ x (+ x y)) y) (- x -1.0)) (+ x y))
(if (<= x -2.15e-14)
(* (/ x (* (- y (- -1.0 x)) (* (+ y x) (+ y x)))) y)
(/ (* (/ y (- y -1.0)) (/ x (+ y x))) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -5e+110) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else if (x <= -2.15e-14) {
tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y;
} else {
tmp = ((y / (y - -1.0)) * (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 (x <= (-5d+110)) then
tmp = (((x / (x + y)) * y) / (x - (-1.0d0))) / (x + y)
else if (x <= (-2.15d-14)) then
tmp = (x / ((y - ((-1.0d0) - x)) * ((y + x) * (y + x)))) * y
else
tmp = ((y / (y - (-1.0d0))) * (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 (x <= -5e+110) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else if (x <= -2.15e-14) {
tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y;
} else {
tmp = ((y / (y - -1.0)) * (x / (y + x))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -5e+110: tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y) elif x <= -2.15e-14: tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y else: tmp = ((y / (y - -1.0)) * (x / (y + x))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -5e+110) tmp = Float64(Float64(Float64(Float64(x / Float64(x + y)) * y) / Float64(x - -1.0)) / Float64(x + y)); elseif (x <= -2.15e-14) tmp = Float64(Float64(x / Float64(Float64(y - Float64(-1.0 - x)) * Float64(Float64(y + x) * Float64(y + x)))) * y); else tmp = Float64(Float64(Float64(y / Float64(y - -1.0)) * Float64(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 (x <= -5e+110)
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
elseif (x <= -2.15e-14)
tmp = (x / ((y - (-1.0 - x)) * ((y + x) * (y + x)))) * y;
else
tmp = ((y / (y - -1.0)) * (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[x, -5e+110], N[(N[(N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.15e-14], N[(N[(x / N[(N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(y / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + 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 -5 \cdot 10^{+110}:\\
\;\;\;\;\frac{\frac{\frac{x}{x + y} \cdot y}{x - -1}}{x + y}\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-14}:\\
\;\;\;\;\frac{x}{\left(y - \left(-1 - x\right)\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{y - -1} \cdot \frac{x}{y + x}}{y + x}\\
\end{array}
\end{array}
if x < -4.99999999999999978e110Initial 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
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.8%
if -4.99999999999999978e110 < x < -2.14999999999999999e-14Initial 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.3%
if -2.14999999999999999e-14 < x Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 0.085) (/ (/ (* (/ x (+ x y)) y) (- x -1.0)) (+ x y)) (* (/ (/ y (- y (- -1.0 x))) (+ x y)) (/ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 0.085) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else {
tmp = ((y / (y - (-1.0 - x))) / (x + 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 <= 0.085d0) then
tmp = (((x / (x + y)) * y) / (x - (-1.0d0))) / (x + y)
else
tmp = ((y / (y - ((-1.0d0) - x))) / (x + y)) * (x / y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 0.085) {
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
} else {
tmp = ((y / (y - (-1.0 - x))) / (x + y)) * (x / y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 0.085: tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y) else: tmp = ((y / (y - (-1.0 - x))) / (x + y)) * (x / y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 0.085) tmp = Float64(Float64(Float64(Float64(x / Float64(x + y)) * y) / Float64(x - -1.0)) / Float64(x + y)); else tmp = Float64(Float64(Float64(y / Float64(y - Float64(-1.0 - x))) / Float64(x + 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 <= 0.085)
tmp = (((x / (x + y)) * y) / (x - -1.0)) / (x + y);
else
tmp = ((y / (y - (-1.0 - x))) / (x + 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, 0.085], N[(N[(N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.085:\\
\;\;\;\;\frac{\frac{\frac{x}{x + y} \cdot y}{x - -1}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{y - \left(-1 - x\right)}}{x + y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 0.0850000000000000061Initial 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
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.8%
if 0.0850000000000000061 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f6460.7
Applied rewrites60.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 0.085) (* (/ x (+ x y)) (/ (/ y (- x -1.0)) (+ x y))) (* (/ (/ y (- y (- -1.0 x))) (+ x y)) (/ x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 0.085) {
tmp = (x / (x + y)) * ((y / (x - -1.0)) / (x + y));
} else {
tmp = ((y / (y - (-1.0 - x))) / (x + 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 <= 0.085d0) then
tmp = (x / (x + y)) * ((y / (x - (-1.0d0))) / (x + y))
else
tmp = ((y / (y - ((-1.0d0) - x))) / (x + y)) * (x / y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 0.085) {
tmp = (x / (x + y)) * ((y / (x - -1.0)) / (x + y));
} else {
tmp = ((y / (y - (-1.0 - x))) / (x + y)) * (x / y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 0.085: tmp = (x / (x + y)) * ((y / (x - -1.0)) / (x + y)) else: tmp = ((y / (y - (-1.0 - x))) / (x + y)) * (x / y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 0.085) tmp = Float64(Float64(x / Float64(x + y)) * Float64(Float64(y / Float64(x - -1.0)) / Float64(x + y))); else tmp = Float64(Float64(Float64(y / Float64(y - Float64(-1.0 - x))) / Float64(x + 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 <= 0.085)
tmp = (x / (x + y)) * ((y / (x - -1.0)) / (x + y));
else
tmp = ((y / (y - (-1.0 - x))) / (x + 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, 0.085], N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.085:\\
\;\;\;\;\frac{x}{x + y} \cdot \frac{\frac{y}{x - -1}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{y - \left(-1 - x\right)}}{x + y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 0.0850000000000000061Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f64N/A
Applied rewrites75.8%
if 0.0850000000000000061 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f6460.7
Applied rewrites60.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= y -2.3e-26)
(* (/ (/ y x) (+ x y)) (/ x (+ y x)))
(if (<= y 0.085)
(/ (* (/ y (+ x y)) x) (* (- x -1.0) (+ x y)))
(* (/ (/ y (- y (- -1.0 x))) (+ x y)) (/ x y)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= -2.3e-26) {
tmp = ((y / x) / (x + y)) * (x / (y + x));
} else if (y <= 0.085) {
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
} else {
tmp = ((y / (y - (-1.0 - x))) / (x + 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.3d-26)) then
tmp = ((y / x) / (x + y)) * (x / (y + x))
else if (y <= 0.085d0) then
tmp = ((y / (x + y)) * x) / ((x - (-1.0d0)) * (x + y))
else
tmp = ((y / (y - ((-1.0d0) - x))) / (x + 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.3e-26) {
tmp = ((y / x) / (x + y)) * (x / (y + x));
} else if (y <= 0.085) {
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
} else {
tmp = ((y / (y - (-1.0 - x))) / (x + y)) * (x / y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= -2.3e-26: tmp = ((y / x) / (x + y)) * (x / (y + x)) elif y <= 0.085: tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y)) else: tmp = ((y / (y - (-1.0 - x))) / (x + y)) * (x / y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= -2.3e-26) tmp = Float64(Float64(Float64(y / x) / Float64(x + y)) * Float64(x / Float64(y + x))); elseif (y <= 0.085) tmp = Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(Float64(x - -1.0) * Float64(x + y))); else tmp = Float64(Float64(Float64(y / Float64(y - Float64(-1.0 - x))) / Float64(x + 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.3e-26)
tmp = ((y / x) / (x + y)) * (x / (y + x));
elseif (y <= 0.085)
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
else
tmp = ((y / (y - (-1.0 - x))) / (x + 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.3e-26], N[(N[(N[(y / x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.085], N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(N[(x - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / N[(y - N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 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.3 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + y} \cdot \frac{x}{y + x}\\
\mathbf{elif}\;y \leq 0.085:\\
\;\;\;\;\frac{\frac{y}{x + y} \cdot x}{\left(x - -1\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{y - \left(-1 - x\right)}}{x + y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -2.30000000000000009e-26Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -2.30000000000000009e-26 < y < 0.0850000000000000061Initial 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
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
if 0.0850000000000000061 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f6460.7
Applied rewrites60.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= y -2.3e-26)
(* (/ (/ y x) (+ x y)) t_0)
(if (<= y 0.085)
(/ (* (/ y (+ x y)) x) (* (- x -1.0) (+ x y)))
(if (<= y 4.1e+165)
(/ (* (/ y (- y -1.0)) x) (* (+ x y) (+ x y)))
(* 1.0 (* t_0 (/ -1.0 (- (- -1.0 x) y)))))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -2.3e-26) {
tmp = ((y / x) / (x + y)) * t_0;
} else if (y <= 0.085) {
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
} else if (y <= 4.1e+165) {
tmp = ((y / (y - -1.0)) * x) / ((x + y) * (x + y));
} else {
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - 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) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (y <= (-2.3d-26)) then
tmp = ((y / x) / (x + y)) * t_0
else if (y <= 0.085d0) then
tmp = ((y / (x + y)) * x) / ((x - (-1.0d0)) * (x + y))
else if (y <= 4.1d+165) then
tmp = ((y / (y - (-1.0d0))) * x) / ((x + y) * (x + y))
else
tmp = 1.0d0 * (t_0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -2.3e-26) {
tmp = ((y / x) / (x + y)) * t_0;
} else if (y <= 0.085) {
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
} else if (y <= 4.1e+165) {
tmp = ((y / (y - -1.0)) * x) / ((x + y) * (x + y));
} else {
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if y <= -2.3e-26: tmp = ((y / x) / (x + y)) * t_0 elif y <= 0.085: tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y)) elif y <= 4.1e+165: tmp = ((y / (y - -1.0)) * x) / ((x + y) * (x + y)) else: tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (y <= -2.3e-26) tmp = Float64(Float64(Float64(y / x) / Float64(x + y)) * t_0); elseif (y <= 0.085) tmp = Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(Float64(x - -1.0) * Float64(x + y))); elseif (y <= 4.1e+165) tmp = Float64(Float64(Float64(y / Float64(y - -1.0)) * x) / Float64(Float64(x + y) * Float64(x + y))); else tmp = Float64(1.0 * Float64(t_0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (y <= -2.3e-26)
tmp = ((y / x) / (x + y)) * t_0;
elseif (y <= 0.085)
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
elseif (y <= 4.1e+165)
tmp = ((y / (y - -1.0)) * x) / ((x + y) * (x + y));
else
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.3e-26], N[(N[(N[(y / x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[y, 0.085], N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(N[(x - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.1e+165], N[(N[(N[(y / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(t$95$0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;y \leq -2.3 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + y} \cdot t\_0\\
\mathbf{elif}\;y \leq 0.085:\\
\;\;\;\;\frac{\frac{y}{x + y} \cdot x}{\left(x - -1\right) \cdot \left(x + y\right)}\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+165}:\\
\;\;\;\;\frac{\frac{y}{y - -1} \cdot x}{\left(x + y\right) \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(t\_0 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < -2.30000000000000009e-26Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -2.30000000000000009e-26 < y < 0.0850000000000000061Initial 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
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
if 0.0850000000000000061 < y < 4.1000000000000003e165Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-+.f64N/A
lift-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f6469.4
Applied rewrites69.4%
if 4.1000000000000003e165 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= y -2.3e-26)
(* (/ (/ y x) (+ x y)) t_0)
(if (<= y 0.085)
(/ (* (/ y (+ x y)) x) (* (- x -1.0) (+ x y)))
(if (<= y 5.8e+102)
(* x (/ y (* (- y -1.0) (* (+ x y) (+ x y)))))
(* 1.0 (* t_0 (/ -1.0 (- (- -1.0 x) y)))))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -2.3e-26) {
tmp = ((y / x) / (x + y)) * t_0;
} else if (y <= 0.085) {
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
} else if (y <= 5.8e+102) {
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
} else {
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - 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) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (y <= (-2.3d-26)) then
tmp = ((y / x) / (x + y)) * t_0
else if (y <= 0.085d0) then
tmp = ((y / (x + y)) * x) / ((x - (-1.0d0)) * (x + y))
else if (y <= 5.8d+102) then
tmp = x * (y / ((y - (-1.0d0)) * ((x + y) * (x + y))))
else
tmp = 1.0d0 * (t_0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -2.3e-26) {
tmp = ((y / x) / (x + y)) * t_0;
} else if (y <= 0.085) {
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
} else if (y <= 5.8e+102) {
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
} else {
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if y <= -2.3e-26: tmp = ((y / x) / (x + y)) * t_0 elif y <= 0.085: tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y)) elif y <= 5.8e+102: tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y)))) else: tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (y <= -2.3e-26) tmp = Float64(Float64(Float64(y / x) / Float64(x + y)) * t_0); elseif (y <= 0.085) tmp = Float64(Float64(Float64(y / Float64(x + y)) * x) / Float64(Float64(x - -1.0) * Float64(x + y))); elseif (y <= 5.8e+102) tmp = Float64(x * Float64(y / Float64(Float64(y - -1.0) * Float64(Float64(x + y) * Float64(x + y))))); else tmp = Float64(1.0 * Float64(t_0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (y <= -2.3e-26)
tmp = ((y / x) / (x + y)) * t_0;
elseif (y <= 0.085)
tmp = ((y / (x + y)) * x) / ((x - -1.0) * (x + y));
elseif (y <= 5.8e+102)
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
else
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.3e-26], N[(N[(N[(y / x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[y, 0.085], N[(N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / N[(N[(x - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.8e+102], N[(x * N[(y / N[(N[(y - -1.0), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(t$95$0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;y \leq -2.3 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + y} \cdot t\_0\\
\mathbf{elif}\;y \leq 0.085:\\
\;\;\;\;\frac{\frac{y}{x + y} \cdot x}{\left(x - -1\right) \cdot \left(x + y\right)}\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+102}:\\
\;\;\;\;x \cdot \frac{y}{\left(y - -1\right) \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(t\_0 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < -2.30000000000000009e-26Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -2.30000000000000009e-26 < y < 0.0850000000000000061Initial 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
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
if 0.0850000000000000061 < y < 5.8000000000000005e102Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-+.f64N/A
lift-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f6469.4
Applied rewrites69.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6475.4
Applied rewrites75.4%
if 5.8000000000000005e102 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y x))))
(if (<= y -1.06e-57)
(* (/ (/ y x) (+ x y)) t_0)
(if (<= y 0.085)
(* (/ y (+ x y)) (/ x (* (- x -1.0) (+ x y))))
(if (<= y 5.8e+102)
(* x (/ y (* (- y -1.0) (* (+ x y) (+ x y)))))
(* 1.0 (* t_0 (/ -1.0 (- (- -1.0 x) y)))))))))assert(x < y);
double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -1.06e-57) {
tmp = ((y / x) / (x + y)) * t_0;
} else if (y <= 0.085) {
tmp = (y / (x + y)) * (x / ((x - -1.0) * (x + y)));
} else if (y <= 5.8e+102) {
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
} else {
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - 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) :: t_0
real(8) :: tmp
t_0 = x / (y + x)
if (y <= (-1.06d-57)) then
tmp = ((y / x) / (x + y)) * t_0
else if (y <= 0.085d0) then
tmp = (y / (x + y)) * (x / ((x - (-1.0d0)) * (x + y)))
else if (y <= 5.8d+102) then
tmp = x * (y / ((y - (-1.0d0)) * ((x + y) * (x + y))))
else
tmp = 1.0d0 * (t_0 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x / (y + x);
double tmp;
if (y <= -1.06e-57) {
tmp = ((y / x) / (x + y)) * t_0;
} else if (y <= 0.085) {
tmp = (y / (x + y)) * (x / ((x - -1.0) * (x + y)));
} else if (y <= 5.8e+102) {
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
} else {
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x / (y + x) tmp = 0 if y <= -1.06e-57: tmp = ((y / x) / (x + y)) * t_0 elif y <= 0.085: tmp = (y / (x + y)) * (x / ((x - -1.0) * (x + y))) elif y <= 5.8e+102: tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y)))) else: tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x / Float64(y + x)) tmp = 0.0 if (y <= -1.06e-57) tmp = Float64(Float64(Float64(y / x) / Float64(x + y)) * t_0); elseif (y <= 0.085) tmp = Float64(Float64(y / Float64(x + y)) * Float64(x / Float64(Float64(x - -1.0) * Float64(x + y)))); elseif (y <= 5.8e+102) tmp = Float64(x * Float64(y / Float64(Float64(y - -1.0) * Float64(Float64(x + y) * Float64(x + y))))); else tmp = Float64(1.0 * Float64(t_0 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x / (y + x);
tmp = 0.0;
if (y <= -1.06e-57)
tmp = ((y / x) / (x + y)) * t_0;
elseif (y <= 0.085)
tmp = (y / (x + y)) * (x / ((x - -1.0) * (x + y)));
elseif (y <= 5.8e+102)
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
else
tmp = 1.0 * (t_0 * (-1.0 / ((-1.0 - x) - y)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.06e-57], N[(N[(N[(y / x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[y, 0.085], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(x - -1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.8e+102], N[(x * N[(y / N[(N[(y - -1.0), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(t$95$0 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{x}{y + x}\\
\mathbf{if}\;y \leq -1.06 \cdot 10^{-57}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + y} \cdot t\_0\\
\mathbf{elif}\;y \leq 0.085:\\
\;\;\;\;\frac{y}{x + y} \cdot \frac{x}{\left(x - -1\right) \cdot \left(x + y\right)}\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+102}:\\
\;\;\;\;x \cdot \frac{y}{\left(y - -1\right) \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(t\_0 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if y < -1.0600000000000001e-57Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -1.0600000000000001e-57 < y < 0.0850000000000000061Initial 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
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6476.4
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6476.4
Applied rewrites76.4%
if 0.0850000000000000061 < y < 5.8000000000000005e102Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-+.f64N/A
lift-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f6469.4
Applied rewrites69.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6475.4
Applied rewrites75.4%
if 5.8000000000000005e102 < y Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) (+ x y))) (t_1 (/ x (+ y x))))
(if (<= x -5e+110)
(* (/ (/ y x) (+ x y)) t_1)
(if (<= x -1.7e-9)
(* y (/ x (* (- x -1.0) t_0)))
(if (<= x -3.3e-190)
(* x (/ y (* (- y -1.0) t_0)))
(* 1.0 (* t_1 (/ -1.0 (- (- -1.0 x) y)))))))))assert(x < y);
double code(double x, double y) {
double t_0 = (x + y) * (x + y);
double t_1 = x / (y + x);
double tmp;
if (x <= -5e+110) {
tmp = ((y / x) / (x + y)) * t_1;
} else if (x <= -1.7e-9) {
tmp = y * (x / ((x - -1.0) * t_0));
} else if (x <= -3.3e-190) {
tmp = x * (y / ((y - -1.0) * t_0));
} else {
tmp = 1.0 * (t_1 * (-1.0 / ((-1.0 - 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x + y) * (x + y)
t_1 = x / (y + x)
if (x <= (-5d+110)) then
tmp = ((y / x) / (x + y)) * t_1
else if (x <= (-1.7d-9)) then
tmp = y * (x / ((x - (-1.0d0)) * t_0))
else if (x <= (-3.3d-190)) then
tmp = x * (y / ((y - (-1.0d0)) * t_0))
else
tmp = 1.0d0 * (t_1 * ((-1.0d0) / (((-1.0d0) - x) - y)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (x + y) * (x + y);
double t_1 = x / (y + x);
double tmp;
if (x <= -5e+110) {
tmp = ((y / x) / (x + y)) * t_1;
} else if (x <= -1.7e-9) {
tmp = y * (x / ((x - -1.0) * t_0));
} else if (x <= -3.3e-190) {
tmp = x * (y / ((y - -1.0) * t_0));
} else {
tmp = 1.0 * (t_1 * (-1.0 / ((-1.0 - x) - y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (x + y) * (x + y) t_1 = x / (y + x) tmp = 0 if x <= -5e+110: tmp = ((y / x) / (x + y)) * t_1 elif x <= -1.7e-9: tmp = y * (x / ((x - -1.0) * t_0)) elif x <= -3.3e-190: tmp = x * (y / ((y - -1.0) * t_0)) else: tmp = 1.0 * (t_1 * (-1.0 / ((-1.0 - x) - y))) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(x + y) * Float64(x + y)) t_1 = Float64(x / Float64(y + x)) tmp = 0.0 if (x <= -5e+110) tmp = Float64(Float64(Float64(y / x) / Float64(x + y)) * t_1); elseif (x <= -1.7e-9) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * t_0))); elseif (x <= -3.3e-190) tmp = Float64(x * Float64(y / Float64(Float64(y - -1.0) * t_0))); else tmp = Float64(1.0 * Float64(t_1 * Float64(-1.0 / Float64(Float64(-1.0 - x) - y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = (x + y) * (x + y);
t_1 = x / (y + x);
tmp = 0.0;
if (x <= -5e+110)
tmp = ((y / x) / (x + y)) * t_1;
elseif (x <= -1.7e-9)
tmp = y * (x / ((x - -1.0) * t_0));
elseif (x <= -3.3e-190)
tmp = x * (y / ((y - -1.0) * t_0));
else
tmp = 1.0 * (t_1 * (-1.0 / ((-1.0 - x) - y)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e+110], N[(N[(N[(y / x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[x, -1.7e-9], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.3e-190], N[(x * N[(y / N[(N[(y - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(t$95$1 * N[(-1.0 / N[(N[(-1.0 - x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot \left(x + y\right)\\
t_1 := \frac{x}{y + x}\\
\mathbf{if}\;x \leq -5 \cdot 10^{+110}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + y} \cdot t\_1\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-9}:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot t\_0}\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-190}:\\
\;\;\;\;x \cdot \frac{y}{\left(y - -1\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(t\_1 \cdot \frac{-1}{\left(-1 - x\right) - y}\right)\\
\end{array}
\end{array}
if x < -4.99999999999999978e110Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -4.99999999999999978e110 < x < -1.6999999999999999e-9Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.7
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.7
Applied rewrites75.7%
if -1.6999999999999999e-9 < x < -3.30000000000000019e-190Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-+.f64N/A
lift-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f6469.4
Applied rewrites69.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6475.4
Applied rewrites75.4%
if -3.30000000000000019e-190 < x Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites50.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) (+ x y))))
(if (<= x -5e+110)
(* (/ (/ y x) (+ x y)) (/ x (+ y x)))
(if (<= x -1.7e-9)
(* y (/ x (* (- x -1.0) t_0)))
(if (<= x -3.3e-190)
(* x (/ y (* (- y -1.0) t_0)))
(/ (/ x (- y -1.0)) (+ y x)))))))assert(x < y);
double code(double x, double y) {
double t_0 = (x + y) * (x + y);
double tmp;
if (x <= -5e+110) {
tmp = ((y / x) / (x + y)) * (x / (y + x));
} else if (x <= -1.7e-9) {
tmp = y * (x / ((x - -1.0) * t_0));
} else if (x <= -3.3e-190) {
tmp = x * (y / ((y - -1.0) * t_0));
} 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) :: t_0
real(8) :: tmp
t_0 = (x + y) * (x + y)
if (x <= (-5d+110)) then
tmp = ((y / x) / (x + y)) * (x / (y + x))
else if (x <= (-1.7d-9)) then
tmp = y * (x / ((x - (-1.0d0)) * t_0))
else if (x <= (-3.3d-190)) then
tmp = x * (y / ((y - (-1.0d0)) * t_0))
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 t_0 = (x + y) * (x + y);
double tmp;
if (x <= -5e+110) {
tmp = ((y / x) / (x + y)) * (x / (y + x));
} else if (x <= -1.7e-9) {
tmp = y * (x / ((x - -1.0) * t_0));
} else if (x <= -3.3e-190) {
tmp = x * (y / ((y - -1.0) * t_0));
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (x + y) * (x + y) tmp = 0 if x <= -5e+110: tmp = ((y / x) / (x + y)) * (x / (y + x)) elif x <= -1.7e-9: tmp = y * (x / ((x - -1.0) * t_0)) elif x <= -3.3e-190: tmp = x * (y / ((y - -1.0) * t_0)) else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(x + y) * Float64(x + y)) tmp = 0.0 if (x <= -5e+110) tmp = Float64(Float64(Float64(y / x) / Float64(x + y)) * Float64(x / Float64(y + x))); elseif (x <= -1.7e-9) tmp = Float64(y * Float64(x / Float64(Float64(x - -1.0) * t_0))); elseif (x <= -3.3e-190) tmp = Float64(x * Float64(y / Float64(Float64(y - -1.0) * t_0))); 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)
t_0 = (x + y) * (x + y);
tmp = 0.0;
if (x <= -5e+110)
tmp = ((y / x) / (x + y)) * (x / (y + x));
elseif (x <= -1.7e-9)
tmp = y * (x / ((x - -1.0) * t_0));
elseif (x <= -3.3e-190)
tmp = x * (y / ((y - -1.0) * t_0));
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_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e+110], N[(N[(N[(y / x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.7e-9], N[(y * N[(x / N[(N[(x - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.3e-190], N[(x * N[(y / N[(N[(y - -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $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}
t_0 := \left(x + y\right) \cdot \left(x + y\right)\\
\mathbf{if}\;x \leq -5 \cdot 10^{+110}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + y} \cdot \frac{x}{y + x}\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-9}:\\
\;\;\;\;y \cdot \frac{x}{\left(x - -1\right) \cdot t\_0}\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-190}:\\
\;\;\;\;x \cdot \frac{y}{\left(y - -1\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if x < -4.99999999999999978e110Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -4.99999999999999978e110 < x < -1.6999999999999999e-9Initial program 69.6%
Taylor expanded in y around 0
lower-+.f6459.4
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.7
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6475.7
Applied rewrites75.7%
if -1.6999999999999999e-9 < x < -3.30000000000000019e-190Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-+.f64N/A
lift-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f6469.4
Applied rewrites69.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6475.4
Applied rewrites75.4%
if -3.30000000000000019e-190 < x Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.0
Applied rewrites50.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 (<= x -1.42e-6)
(/ (/ y (- x -1.0)) (+ y x))
(if (<= x -3.3e-190)
(* x (/ y (* (- y -1.0) (* (+ x y) (+ x y)))))
(/ (/ x (- y -1.0)) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.42e-6) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (x <= -3.3e-190) {
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
} 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 <= (-1.42d-6)) then
tmp = (y / (x - (-1.0d0))) / (y + x)
else if (x <= (-3.3d-190)) then
tmp = x * (y / ((y - (-1.0d0)) * ((x + y) * (x + y))))
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 <= -1.42e-6) {
tmp = (y / (x - -1.0)) / (y + x);
} else if (x <= -3.3e-190) {
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.42e-6: tmp = (y / (x - -1.0)) / (y + x) elif x <= -3.3e-190: tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y)))) else: tmp = (x / (y - -1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.42e-6) tmp = Float64(Float64(y / Float64(x - -1.0)) / Float64(y + x)); elseif (x <= -3.3e-190) tmp = Float64(x * Float64(y / Float64(Float64(y - -1.0) * Float64(Float64(x + y) * Float64(x + y))))); 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 <= -1.42e-6)
tmp = (y / (x - -1.0)) / (y + x);
elseif (x <= -3.3e-190)
tmp = x * (y / ((y - -1.0) * ((x + y) * (x + y))));
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, -1.42e-6], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.3e-190], N[(x * N[(y / N[(N[(y - -1.0), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -1.42 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-190}:\\
\;\;\;\;x \cdot \frac{y}{\left(y - -1\right) \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if x < -1.42e-6Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.6
Applied rewrites51.6%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.6
Applied rewrites51.6%
if -1.42e-6 < x < -3.30000000000000019e-190Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites74.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-+.f64N/A
lift-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lower-*.f6469.4
Applied rewrites69.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6475.4
Applied rewrites75.4%
if -3.30000000000000019e-190 < x Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.0
Applied rewrites50.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 (<= x -3.35e+50)
(* (/ (/ y x) (+ x y)) (/ x (+ y x)))
(if (<= x -4.4e-118)
(* (/ y (* (- x -1.0) (* (+ x y) (+ x y)))) x)
(/ (/ x (- y -1.0)) (+ y x)))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.35e+50) {
tmp = ((y / x) / (x + y)) * (x / (y + x));
} else if (x <= -4.4e-118) {
tmp = (y / ((x - -1.0) * ((x + y) * (x + 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 <= (-3.35d+50)) then
tmp = ((y / x) / (x + y)) * (x / (y + x))
else if (x <= (-4.4d-118)) then
tmp = (y / ((x - (-1.0d0)) * ((x + y) * (x + 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 <= -3.35e+50) {
tmp = ((y / x) / (x + y)) * (x / (y + x));
} else if (x <= -4.4e-118) {
tmp = (y / ((x - -1.0) * ((x + y) * (x + 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 <= -3.35e+50: tmp = ((y / x) / (x + y)) * (x / (y + x)) elif x <= -4.4e-118: tmp = (y / ((x - -1.0) * ((x + y) * (x + 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 <= -3.35e+50) tmp = Float64(Float64(Float64(y / x) / Float64(x + y)) * Float64(x / Float64(y + x))); elseif (x <= -4.4e-118) tmp = Float64(Float64(y / Float64(Float64(x - -1.0) * Float64(Float64(x + y) * Float64(x + 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 <= -3.35e+50)
tmp = ((y / x) / (x + y)) * (x / (y + x));
elseif (x <= -4.4e-118)
tmp = (y / ((x - -1.0) * ((x + y) * (x + 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, -3.35e+50], N[(N[(N[(y / x), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.4e-118], 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 - -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 -3.35 \cdot 10^{+50}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + y} \cdot \frac{x}{y + x}\\
\mathbf{elif}\;x \leq -4.4 \cdot 10^{-118}:\\
\;\;\;\;\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 - -1}}{y + x}\\
\end{array}
\end{array}
if x < -3.3499999999999999e50Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6438.9
Applied rewrites38.9%
if -3.3499999999999999e50 < x < -4.39999999999999967e-118Initial 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
lower-/.f6471.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.9
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6471.9
Applied rewrites71.9%
if -4.39999999999999967e-118 < x Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.0
Applied rewrites50.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 (<= x -7.8e-106) (/ (/ 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 <= -7.8e-106) {
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 <= (-7.8d-106)) 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 <= -7.8e-106) {
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 <= -7.8e-106: 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 <= -7.8e-106) 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 <= -7.8e-106)
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, -7.8e-106], 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 -7.8 \cdot 10^{-106}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if x < -7.80000000000000019e-106Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6451.6
Applied rewrites51.6%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6451.6
Applied rewrites51.6%
if -7.80000000000000019e-106 < x Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.0
Applied rewrites50.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 (<= x -7.8e-106) (/ (/ y (- x -1.0)) x) (/ (/ x (- y -1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7.8e-106) {
tmp = (y / (x - -1.0)) / 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 <= (-7.8d-106)) then
tmp = (y / (x - (-1.0d0))) / 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 <= -7.8e-106) {
tmp = (y / (x - -1.0)) / x;
} else {
tmp = (x / (y - -1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -7.8e-106: tmp = (y / (x - -1.0)) / 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 <= -7.8e-106) tmp = Float64(Float64(y / Float64(x - -1.0)) / 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 <= -7.8e-106)
tmp = (y / (x - -1.0)) / 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, -7.8e-106], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / x), $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 -7.8 \cdot 10^{-106}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y + x}\\
\end{array}
\end{array}
if x < -7.80000000000000019e-106Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.9
Applied rewrites49.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6451.2
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6451.2
Applied rewrites51.2%
if -7.80000000000000019e-106 < x Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f6450.0
Applied rewrites50.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 (<= x -7.8e-106) (/ (/ y (- x -1.0)) x) (/ (/ x (- y -1.0)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7.8e-106) {
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 (x <= (-7.8d-106)) 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 (x <= -7.8e-106) {
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 x <= -7.8e-106: 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 (x <= -7.8e-106) tmp = Float64(Float64(y / Float64(x - -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 (x <= -7.8e-106)
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[x, -7.8e-106], N[(N[(y / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / x), $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 -7.8 \cdot 10^{-106}:\\
\;\;\;\;\frac{\frac{y}{x - -1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y}\\
\end{array}
\end{array}
if x < -7.80000000000000019e-106Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.9
Applied rewrites49.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6451.2
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6451.2
Applied rewrites51.2%
if -7.80000000000000019e-106 < x Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.3
Applied rewrites48.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6449.5
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6449.5
Applied rewrites49.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -7.8e-106) (/ y (fma x x x)) (/ (/ x (- y -1.0)) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7.8e-106) {
tmp = y / fma(x, x, x);
} else {
tmp = (x / (y - -1.0)) / y;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -7.8e-106) tmp = Float64(y / fma(x, x, x)); else tmp = Float64(Float64(x / Float64(y - -1.0)) / 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, -7.8e-106], N[(y / N[(x * x + x), $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}\;x \leq -7.8 \cdot 10^{-106}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y - -1}}{y}\\
\end{array}
\end{array}
if x < -7.80000000000000019e-106Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.9
Applied rewrites49.9%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6449.9
Applied rewrites49.9%
if -7.80000000000000019e-106 < x Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.3
Applied rewrites48.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6449.5
lift-+.f64N/A
+-commutativeN/A
add-flip-revN/A
metadata-evalN/A
lower--.f6449.5
Applied rewrites49.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -7.8e-106) (/ y (fma x x x)) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -7.8e-106) {
tmp = y / fma(x, x, x);
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -7.8e-106) tmp = Float64(y / fma(x, x, x)); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -7.8e-106], N[(y / N[(x * x + x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{-106}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if x < -7.80000000000000019e-106Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.9
Applied rewrites49.9%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6449.9
Applied rewrites49.9%
if -7.80000000000000019e-106 < x Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.3
Applied rewrites48.3%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.3
Applied rewrites48.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.32e-210) (/ y x) (/ x (fma y y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.32e-210) {
tmp = y / x;
} else {
tmp = x / fma(y, y, y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.32e-210) tmp = Float64(y / x); else tmp = Float64(x / fma(y, y, y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.32e-210], N[(y / x), $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 1.32 \cdot 10^{-210}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right)}\\
\end{array}
\end{array}
if y < 1.3200000000000001e-210Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.9
Applied rewrites49.9%
Taylor expanded in x around 0
lower-/.f6426.7
Applied rewrites26.7%
if 1.3200000000000001e-210 < y Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6448.3
Applied rewrites48.3%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6448.3
Applied rewrites48.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ y x))
assert(x < y);
double code(double x, double y) {
return 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
end function
assert x < y;
public static double code(double x, double y) {
return y / x;
}
[x, y] = sort([x, y]) def code(x, y): return y / x
x, y = sort([x, y]) function code(x, y) return Float64(y / x) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = y / x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(y / x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{y}{x}
\end{array}
Initial program 69.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6449.9
Applied rewrites49.9%
Taylor expanded in x around 0
lower-/.f6426.7
Applied rewrites26.7%
herbie shell --seed 2025155
(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))))