
(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 8 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
(if (<= x -9e+102)
(/ (/ y x) x)
(if (<= x -5.8e-160)
(* (/ y (* (+ (+ y x) 1.0) (fma (fma 2.0 y x) x (* y y)))) x)
(if (<= x -2.3e-218)
(/ y (* (+ 1.0 x) x))
(if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -9e+102) {
tmp = (y / x) / x;
} else if (x <= -5.8e-160) {
tmp = (y / (((y + x) + 1.0) * fma(fma(2.0, y, x), x, (y * y)))) * x;
} else if (x <= -2.3e-218) {
tmp = y / ((1.0 + x) * x);
} else if (x <= 7.5e+22) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -9e+102) tmp = Float64(Float64(y / x) / x); elseif (x <= -5.8e-160) tmp = Float64(Float64(y / Float64(Float64(Float64(y + x) + 1.0) * fma(fma(2.0, y, x), x, Float64(y * y)))) * x); elseif (x <= -2.3e-218) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); elseif (x <= 7.5e+22) tmp = Float64(x / Float64(Float64(1.0 + y) * y)); else tmp = Float64(Float64(x / y) / y); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -9e+102], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -5.8e-160], N[(N[(y / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(2.0 * y + x), $MachinePrecision] * x + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, -2.3e-218], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+102}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(2, y, x\right), x, y \cdot y\right)} \cdot x\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -9.00000000000000042e102Initial program 58.1%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6481.9
Applied rewrites81.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.3
Applied rewrites89.3%
if -9.00000000000000042e102 < x < -5.7999999999999998e-160Initial program 82.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6491.0
Applied rewrites91.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6490.9
Applied rewrites90.9%
if -5.7999999999999998e-160 < x < -2.29999999999999995e-218Initial program 57.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6435.3
Applied rewrites35.3%
if -2.29999999999999995e-218 < x < 7.5000000000000002e22Initial program 74.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6494.4
Applied rewrites94.4%
if 7.5000000000000002e22 < x Initial program 24.3%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6495.3
Applied rewrites95.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -9e+102)
(/ (/ y x) x)
(if (<= x -5.8e-160)
(* (/ y (* (+ (+ y x) 1.0) (* (+ y x) (+ y x)))) x)
(if (<= x -2.3e-218)
(/ y (* (+ 1.0 x) x))
(if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -9e+102) {
tmp = (y / x) / x;
} else if (x <= -5.8e-160) {
tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x;
} else if (x <= -2.3e-218) {
tmp = y / ((1.0 + x) * x);
} else if (x <= 7.5e+22) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-9d+102)) then
tmp = (y / x) / x
else if (x <= (-5.8d-160)) then
tmp = (y / (((y + x) + 1.0d0) * ((y + x) * (y + x)))) * x
else if (x <= (-2.3d-218)) then
tmp = y / ((1.0d0 + x) * x)
else if (x <= 7.5d+22) then
tmp = x / ((1.0d0 + y) * y)
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -9e+102) {
tmp = (y / x) / x;
} else if (x <= -5.8e-160) {
tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x;
} else if (x <= -2.3e-218) {
tmp = y / ((1.0 + x) * x);
} else if (x <= 7.5e+22) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -9e+102: tmp = (y / x) / x elif x <= -5.8e-160: tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x elif x <= -2.3e-218: tmp = y / ((1.0 + x) * x) elif x <= 7.5e+22: tmp = x / ((1.0 + y) * y) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -9e+102) tmp = Float64(Float64(y / x) / x); elseif (x <= -5.8e-160) tmp = Float64(Float64(y / Float64(Float64(Float64(y + x) + 1.0) * Float64(Float64(y + x) * Float64(y + x)))) * x); elseif (x <= -2.3e-218) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); elseif (x <= 7.5e+22) tmp = Float64(x / Float64(Float64(1.0 + y) * y)); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -9e+102)
tmp = (y / x) / x;
elseif (x <= -5.8e-160)
tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x;
elseif (x <= -2.3e-218)
tmp = y / ((1.0 + x) * x);
elseif (x <= 7.5e+22)
tmp = x / ((1.0 + y) * y);
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -9e+102], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -5.8e-160], N[(N[(y / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, -2.3e-218], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+102}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -9.00000000000000042e102Initial program 58.1%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6481.9
Applied rewrites81.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.3
Applied rewrites89.3%
if -9.00000000000000042e102 < x < -5.7999999999999998e-160Initial program 82.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6491.0
Applied rewrites91.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.0%
if -5.7999999999999998e-160 < x < -2.29999999999999995e-218Initial program 57.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6435.3
Applied rewrites35.3%
if -2.29999999999999995e-218 < x < 7.5000000000000002e22Initial program 74.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6494.4
Applied rewrites94.4%
if 7.5000000000000002e22 < x Initial program 24.3%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6495.3
Applied rewrites95.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(if (<= x -1820.0)
(/ (/ y x) x)
(if (<= x -5.8e-160)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ y 1.0)))
(if (<= x -2.3e-218)
(/ y (* (+ 1.0 x) x))
(if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))))assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1820.0) {
tmp = (y / x) / x;
} else if (x <= -5.8e-160) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else if (x <= -2.3e-218) {
tmp = y / ((1.0 + x) * x);
} else if (x <= 7.5e+22) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1820.0d0)) then
tmp = (y / x) / x
else if (x <= (-5.8d-160)) then
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0d0))
else if (x <= (-2.3d-218)) then
tmp = y / ((1.0d0 + x) * x)
else if (x <= 7.5d+22) then
tmp = x / ((1.0d0 + y) * y)
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1820.0) {
tmp = (y / x) / x;
} else if (x <= -5.8e-160) {
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
} else if (x <= -2.3e-218) {
tmp = y / ((1.0 + x) * x);
} else if (x <= 7.5e+22) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1820.0: tmp = (y / x) / x elif x <= -5.8e-160: tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0)) elif x <= -2.3e-218: tmp = y / ((1.0 + x) * x) elif x <= 7.5e+22: tmp = x / ((1.0 + y) * y) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1820.0) tmp = Float64(Float64(y / x) / x); elseif (x <= -5.8e-160) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(y + 1.0))); elseif (x <= -2.3e-218) tmp = Float64(y / Float64(Float64(1.0 + x) * x)); elseif (x <= 7.5e+22) tmp = Float64(x / Float64(Float64(1.0 + y) * y)); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1820.0)
tmp = (y / x) / x;
elseif (x <= -5.8e-160)
tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
elseif (x <= -2.3e-218)
tmp = y / ((1.0 + x) * x);
elseif (x <= 7.5e+22)
tmp = x / ((1.0 + y) * y);
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -1820.0], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -5.8e-160], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.3e-218], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1820:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(y + 1\right)}\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -1820Initial program 65.8%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6478.4
Applied rewrites78.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6483.6
Applied rewrites83.6%
if -1820 < x < -5.7999999999999998e-160Initial program 81.6%
Taylor expanded in x around 0
Applied rewrites77.5%
if -5.7999999999999998e-160 < x < -2.29999999999999995e-218Initial program 57.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6435.3
Applied rewrites35.3%
if -2.29999999999999995e-218 < x < 7.5000000000000002e22Initial program 74.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6494.4
Applied rewrites94.4%
if 7.5000000000000002e22 < x Initial program 24.3%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6495.3
Applied rewrites95.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -0.00165) (/ (/ y x) x) (if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = (y / x) / x;
} else if (x <= 7.5e+22) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.00165d0)) then
tmp = (y / x) / x
else if (x <= 7.5d+22) then
tmp = x / ((1.0d0 + y) * y)
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = (y / x) / x;
} else if (x <= 7.5e+22) {
tmp = x / ((1.0 + y) * y);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -0.00165: tmp = (y / x) / x elif x <= 7.5e+22: tmp = x / ((1.0 + y) * y) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -0.00165) tmp = Float64(Float64(y / x) / x); elseif (x <= 7.5e+22) tmp = Float64(x / Float64(Float64(1.0 + y) * y)); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -0.00165)
tmp = (y / x) / x;
elseif (x <= 7.5e+22)
tmp = x / ((1.0 + y) * y);
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -0.00165], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00165:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -0.00165Initial program 66.2%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6482.2
Applied rewrites82.2%
if -0.00165 < x < 7.5000000000000002e22Initial program 75.5%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6473.8
Applied rewrites73.8%
if 7.5000000000000002e22 < x Initial program 24.3%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6495.3
Applied rewrites95.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -0.00165) (/ (/ y x) x) (/ (/ x y) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = (y / x) / x;
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.00165d0)) then
tmp = (y / x) / x
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = (y / x) / x;
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -0.00165: tmp = (y / x) / x else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -0.00165) tmp = Float64(Float64(y / x) / x); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -0.00165)
tmp = (y / x) / x;
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -0.00165], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00165:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -0.00165Initial program 66.2%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6482.2
Applied rewrites82.2%
if -0.00165 < x Initial program 70.7%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6452.9
Applied rewrites52.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6454.8
Applied rewrites54.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -0.00165) (/ y (* x x)) (/ (/ x y) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = y / (x * x);
} else {
tmp = (x / y) / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.00165d0)) then
tmp = y / (x * x)
else
tmp = (x / y) / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = y / (x * x);
} else {
tmp = (x / y) / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -0.00165: tmp = y / (x * x) else: tmp = (x / y) / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -0.00165) tmp = Float64(y / Float64(x * x)); else tmp = Float64(Float64(x / y) / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -0.00165)
tmp = y / (x * x);
else
tmp = (x / y) / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -0.00165], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00165:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if x < -0.00165Initial program 66.2%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
if -0.00165 < x Initial program 70.7%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6452.9
Applied rewrites52.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6454.8
Applied rewrites54.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -0.00165) (/ y (* x x)) (/ x (* y y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = y / (x * x);
} else {
tmp = x / (y * y);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.00165d0)) then
tmp = y / (x * x)
else
tmp = x / (y * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -0.00165) {
tmp = y / (x * x);
} else {
tmp = x / (y * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -0.00165: tmp = y / (x * x) else: tmp = x / (y * y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -0.00165) tmp = Float64(y / Float64(x * x)); else tmp = Float64(x / Float64(y * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -0.00165)
tmp = y / (x * x);
else
tmp = x / (y * y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -0.00165], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00165:\\
\;\;\;\;\frac{y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y}\\
\end{array}
\end{array}
if x < -0.00165Initial program 66.2%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
if -0.00165 < x Initial program 70.7%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6452.9
Applied rewrites52.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (* y y)))
assert(x < y);
double code(double x, double y) {
return x / (y * y);
}
NOTE: x and y should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (y * y)
end function
assert x < y;
public static double code(double x, double y) {
return x / (y * y);
}
[x, y] = sort([x, y]) def code(x, y): return x / (y * y)
x, y = sort([x, y]) function code(x, y) return Float64(x / Float64(y * y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / (y * y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y \cdot y}
\end{array}
Initial program 68.8%
Taylor expanded in y around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6436.9
Applied rewrites36.9%
herbie shell --seed 2025106
(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))))