
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 6.5e-65)
(/ 1.0 (fma (* y_m z) (* z x) (* x y_m)))
(/ 1.0 (fma (* (* x y_m) z) z (* x y_m))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 6.5e-65) {
tmp = 1.0 / fma((y_m * z), (z * x), (x * y_m));
} else {
tmp = 1.0 / fma(((x * y_m) * z), z, (x * y_m));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 6.5e-65) tmp = Float64(1.0 / fma(Float64(y_m * z), Float64(z * x), Float64(x * y_m))); else tmp = Float64(1.0 / fma(Float64(Float64(x * y_m) * z), z, Float64(x * y_m))); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 6.5e-65], N[(1.0 / N[(N[(y$95$m * z), $MachinePrecision] * N[(z * x), $MachinePrecision] + N[(x * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * y$95$m), $MachinePrecision] * z), $MachinePrecision] * z + N[(x * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 6.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(y\_m \cdot z, z \cdot x, x \cdot y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\left(x \cdot y\_m\right) \cdot z, z, x \cdot y\_m\right)}\\
\end{array}
\end{array}
if y < 6.5e-65Initial program 84.6%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6484.6
Applied rewrites84.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
associate-*l*N/A
*-lft-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lower-*.f6497.8
Applied rewrites97.8%
if 6.5e-65 < y Initial program 92.8%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6492.4
Applied rewrites92.4%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
distribute-lft-inN/A
*-lft-identityN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6498.6
Applied rewrites98.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 5e+118)
(/ 1.0 (fma (* y_m z) (* z x) (* x y_m)))
(/ (/ 1.0 (fma z z 1.0)) (* x y_m)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 5e+118) {
tmp = 1.0 / fma((y_m * z), (z * x), (x * y_m));
} else {
tmp = (1.0 / fma(z, z, 1.0)) / (x * y_m);
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 5e+118) tmp = Float64(1.0 / fma(Float64(y_m * z), Float64(z * x), Float64(x * y_m))); else tmp = Float64(Float64(1.0 / fma(z, z, 1.0)) / Float64(x * y_m)); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 5e+118], N[(1.0 / N[(N[(y$95$m * z), $MachinePrecision] * N[(z * x), $MachinePrecision] + N[(x * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x * y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 5 \cdot 10^{+118}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(y\_m \cdot z, z \cdot x, x \cdot y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(z, z, 1\right)}}{x \cdot y\_m}\\
\end{array}
\end{array}
if y < 4.99999999999999972e118Initial program 88.4%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6488.3
Applied rewrites88.3%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
associate-*l*N/A
*-lft-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lower-*.f6498.3
Applied rewrites98.3%
if 4.99999999999999972e118 < y Initial program 93.4%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6493.0
Applied rewrites93.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-fma.f64N/A
lower-*.f6498.7
Applied rewrites98.7%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= z 1e+154)
(/ (/ (/ 1.0 x) (fma z z 1.0)) y_m)
(/ 1.0 (fma (* x (* y_m z)) z (* x y_m))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 1e+154) {
tmp = ((1.0 / x) / fma(z, z, 1.0)) / y_m;
} else {
tmp = 1.0 / fma((x * (y_m * z)), z, (x * y_m));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 1e+154) tmp = Float64(Float64(Float64(1.0 / x) / fma(z, z, 1.0)) / y_m); else tmp = Float64(1.0 / fma(Float64(x * Float64(y_m * z)), z, Float64(x * y_m))); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 1e+154], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(1.0 / N[(N[(x * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision] * z + N[(x * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 10^{+154}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{\mathsf{fma}\left(z, z, 1\right)}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x \cdot \left(y\_m \cdot z\right), z, x \cdot y\_m\right)}\\
\end{array}
\end{array}
if z < 1.00000000000000004e154Initial program 92.8%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6495.1
Applied rewrites95.1%
if 1.00000000000000004e154 < z Initial program 74.6%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6474.6
Applied rewrites74.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
distribute-lft-inN/A
*-lft-identityN/A
+-commutativeN/A
pow2N/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f6497.4
Applied rewrites97.4%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 2e-26)
(/ (/ 1.0 x) (fma (* y_m z) z y_m))
(/ (/ 1.0 (fma z z 1.0)) (* x y_m)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 2e-26) {
tmp = (1.0 / x) / fma((y_m * z), z, y_m);
} else {
tmp = (1.0 / fma(z, z, 1.0)) / (x * y_m);
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 2e-26) tmp = Float64(Float64(1.0 / x) / fma(Float64(y_m * z), z, y_m)); else tmp = Float64(Float64(1.0 / fma(z, z, 1.0)) / Float64(x * y_m)); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 2e-26], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y$95$m * z), $MachinePrecision] * z + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x * y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 2 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y\_m \cdot z, z, y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(z, z, 1\right)}}{x \cdot y\_m}\\
\end{array}
\end{array}
if y < 2.0000000000000001e-26Initial program 85.1%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6493.5
Applied rewrites93.5%
if 2.0000000000000001e-26 < y Initial program 93.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6492.8
Applied rewrites92.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-fma.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 8500000000000.0)
(/ (/ 1.0 x) (fma (* y_m z) z y_m))
(/ (/ 1.0 (* y_m x)) (fma z z 1.0)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 8500000000000.0) {
tmp = (1.0 / x) / fma((y_m * z), z, y_m);
} else {
tmp = (1.0 / (y_m * x)) / fma(z, z, 1.0);
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 8500000000000.0) tmp = Float64(Float64(1.0 / x) / fma(Float64(y_m * z), z, y_m)); else tmp = Float64(Float64(1.0 / Float64(y_m * x)) / fma(z, z, 1.0)); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 8500000000000.0], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y$95$m * z), $MachinePrecision] * z + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 8500000000000:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y\_m \cdot z, z, y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m \cdot x}}{\mathsf{fma}\left(z, z, 1\right)}\\
\end{array}
\end{array}
if y < 8.5e12Initial program 86.2%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6493.4
Applied rewrites93.4%
if 8.5e12 < y Initial program 93.3%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-/r*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6497.6
Applied rewrites97.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (+ 1.0 (* z z)) 2000000.0)
(/ 1.0 (* (* (fma z z 1.0) y_m) x))
(/ (/ 1.0 (* (* z z) x)) y_m))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((1.0 + (z * z)) <= 2000000.0) {
tmp = 1.0 / ((fma(z, z, 1.0) * y_m) * x);
} else {
tmp = (1.0 / ((z * z) * x)) / y_m;
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(1.0 + Float64(z * z)) <= 2000000.0) tmp = Float64(1.0 / Float64(Float64(fma(z, z, 1.0) * y_m) * x)); else tmp = Float64(Float64(1.0 / Float64(Float64(z * z) * x)) / y_m); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision], 2000000.0], N[(1.0 / N[(N[(N[(z * z + 1.0), $MachinePrecision] * y$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(z * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;1 + z \cdot z \leq 2000000:\\
\;\;\;\;\frac{1}{\left(\mathsf{fma}\left(z, z, 1\right) \cdot y\_m\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\left(z \cdot z\right) \cdot x}}{y\_m}\\
\end{array}
\end{array}
if (+.f64 #s(literal 1 binary64) (*.f64 z z)) < 2e6Initial program 99.6%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6499.2
Applied rewrites99.2%
if 2e6 < (+.f64 #s(literal 1 binary64) (*.f64 z z)) Initial program 80.8%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6485.1
Applied rewrites85.1%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.7
Applied rewrites84.7%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (+ 1.0 (* z z)) 2.0)
(/ (- 1.0 (* z z)) (* y_m x))
(/ (/ 1.0 (* (* z z) x)) y_m))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((1.0 + (z * z)) <= 2.0) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = (1.0 / ((z * z) * x)) / y_m;
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, and z 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(y_s, x, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((1.0d0 + (z * z)) <= 2.0d0) then
tmp = (1.0d0 - (z * z)) / (y_m * x)
else
tmp = (1.0d0 / ((z * z) * x)) / y_m
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((1.0 + (z * z)) <= 2.0) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = (1.0 / ((z * z) * x)) / y_m;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if (1.0 + (z * z)) <= 2.0: tmp = (1.0 - (z * z)) / (y_m * x) else: tmp = (1.0 / ((z * z) * x)) / y_m return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(1.0 + Float64(z * z)) <= 2.0) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y_m * x)); else tmp = Float64(Float64(1.0 / Float64(Float64(z * z) * x)) / y_m); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if ((1.0 + (z * z)) <= 2.0)
tmp = (1.0 - (z * z)) / (y_m * x);
else
tmp = (1.0 / ((z * z) * x)) / y_m;
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision], 2.0], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(z * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;1 + z \cdot z \leq 2:\\
\;\;\;\;\frac{1 - z \cdot z}{y\_m \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\left(z \cdot z\right) \cdot x}}{y\_m}\\
\end{array}
\end{array}
if (+.f64 #s(literal 1 binary64) (*.f64 z z)) < 2Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
pow2N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
if 2 < (+.f64 #s(literal 1 binary64) (*.f64 z z)) Initial program 81.0%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6485.3
Applied rewrites85.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.2
Applied rewrites84.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= z 0.88)
(/ (- 1.0 (* z z)) (* y_m x))
(/ 1.0 (* (* (* z z) x) y_m)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.88) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = 1.0 / (((z * z) * x) * y_m);
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, and z 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(y_s, x, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 0.88d0) then
tmp = (1.0d0 - (z * z)) / (y_m * x)
else
tmp = 1.0d0 / (((z * z) * x) * y_m)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.88) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = 1.0 / (((z * z) * x) * y_m);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if z <= 0.88: tmp = (1.0 - (z * z)) / (y_m * x) else: tmp = 1.0 / (((z * z) * x) * y_m) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 0.88) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y_m * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(z * z) * x) * y_m)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if (z <= 0.88)
tmp = (1.0 - (z * z)) / (y_m * x);
else
tmp = 1.0 / (((z * z) * x) * y_m);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 0.88], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z * z), $MachinePrecision] * x), $MachinePrecision] * y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 0.88:\\
\;\;\;\;\frac{1 - z \cdot z}{y\_m \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z \cdot z\right) \cdot x\right) \cdot y\_m}\\
\end{array}
\end{array}
if z < 0.880000000000000004Initial program 93.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
pow2N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
if 0.880000000000000004 < z Initial program 81.5%
Taylor expanded in z around inf
pow2N/A
lift-*.f6480.5
Applied rewrites80.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6481.7
pow281.7
+-commutative81.7
pow281.7
Applied rewrites81.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.0
Applied rewrites84.0%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= z 0.88)
(/ (- 1.0 (* z z)) (* y_m x))
(/ 1.0 (* (* (* y_m z) z) x)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.88) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = 1.0 / (((y_m * z) * z) * x);
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, and z 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(y_s, x, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 0.88d0) then
tmp = (1.0d0 - (z * z)) / (y_m * x)
else
tmp = 1.0d0 / (((y_m * z) * z) * x)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.88) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = 1.0 / (((y_m * z) * z) * x);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if z <= 0.88: tmp = (1.0 - (z * z)) / (y_m * x) else: tmp = 1.0 / (((y_m * z) * z) * x) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 0.88) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y_m * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(y_m * z) * z) * x)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if (z <= 0.88)
tmp = (1.0 - (z * z)) / (y_m * x);
else
tmp = 1.0 / (((y_m * z) * z) * x);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 0.88], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(y$95$m * z), $MachinePrecision] * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 0.88:\\
\;\;\;\;\frac{1 - z \cdot z}{y\_m \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(y\_m \cdot z\right) \cdot z\right) \cdot x}\\
\end{array}
\end{array}
if z < 0.880000000000000004Initial program 93.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
pow2N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
if 0.880000000000000004 < z Initial program 81.5%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6485.6
Applied rewrites85.6%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6486.2
Applied rewrites86.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= z 0.88)
(/ (- 1.0 (* z z)) (* y_m x))
(/ 1.0 (* (* (* z z) y_m) x)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.88) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = 1.0 / (((z * z) * y_m) * x);
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, and z 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(y_s, x, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 0.88d0) then
tmp = (1.0d0 - (z * z)) / (y_m * x)
else
tmp = 1.0d0 / (((z * z) * y_m) * x)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.88) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = 1.0 / (((z * z) * y_m) * x);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if z <= 0.88: tmp = (1.0 - (z * z)) / (y_m * x) else: tmp = 1.0 / (((z * z) * y_m) * x) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 0.88) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y_m * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(z * z) * y_m) * x)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if (z <= 0.88)
tmp = (1.0 - (z * z)) / (y_m * x);
else
tmp = 1.0 / (((z * z) * y_m) * x);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 0.88], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z * z), $MachinePrecision] * y$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 0.88:\\
\;\;\;\;\frac{1 - z \cdot z}{y\_m \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z \cdot z\right) \cdot y\_m\right) \cdot x}\\
\end{array}
\end{array}
if z < 0.880000000000000004Initial program 93.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
pow2N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
if 0.880000000000000004 < z Initial program 81.5%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6480.3
Applied rewrites80.3%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 0.98) (/ (- 1.0 (* z z)) (* y_m x)) (/ y_m (* (* y_m y_m) x)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.98) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = y_m / ((y_m * y_m) * x);
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, and z 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(y_s, x, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 0.98d0) then
tmp = (1.0d0 - (z * z)) / (y_m * x)
else
tmp = y_m / ((y_m * y_m) * x)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.98) {
tmp = (1.0 - (z * z)) / (y_m * x);
} else {
tmp = y_m / ((y_m * y_m) * x);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if z <= 0.98: tmp = (1.0 - (z * z)) / (y_m * x) else: tmp = y_m / ((y_m * y_m) * x) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 0.98) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y_m * x)); else tmp = Float64(y_m / Float64(Float64(y_m * y_m) * x)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if (z <= 0.98)
tmp = (1.0 - (z * z)) / (y_m * x);
else
tmp = y_m / ((y_m * y_m) * x);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 0.98], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(y$95$m / N[(N[(y$95$m * y$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 0.98:\\
\;\;\;\;\frac{1 - z \cdot z}{y\_m \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y\_m}{\left(y\_m \cdot y\_m\right) \cdot x}\\
\end{array}
\end{array}
if z < 0.97999999999999998Initial program 93.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
pow2N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
if 0.97999999999999998 < z Initial program 81.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
pow2N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f648.3
Applied rewrites8.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
div-subN/A
frac-2negN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites1.0%
Taylor expanded in x around 0
mul-1-negN/A
distribute-frac-neg2N/A
distribute-lft-out--N/A
mul-1-negN/A
frac-2negN/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f643.7
Applied rewrites3.7%
Taylor expanded in z around 0
Applied rewrites37.4%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 2.3e+42) (/ 1.0 (* y_m x)) (/ y_m (* (* y_m y_m) x)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 2.3e+42) {
tmp = 1.0 / (y_m * x);
} else {
tmp = y_m / ((y_m * y_m) * x);
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, and z 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(y_s, x, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 2.3d+42) then
tmp = 1.0d0 / (y_m * x)
else
tmp = y_m / ((y_m * y_m) * x)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 2.3e+42) {
tmp = 1.0 / (y_m * x);
} else {
tmp = y_m / ((y_m * y_m) * x);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if z <= 2.3e+42: tmp = 1.0 / (y_m * x) else: tmp = y_m / ((y_m * y_m) * x) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 2.3e+42) tmp = Float64(1.0 / Float64(y_m * x)); else tmp = Float64(y_m / Float64(Float64(y_m * y_m) * x)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if (z <= 2.3e+42)
tmp = 1.0 / (y_m * x);
else
tmp = y_m / ((y_m * y_m) * x);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 2.3e+42], N[(1.0 / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(y$95$m / N[(N[(y$95$m * y$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 2.3 \cdot 10^{+42}:\\
\;\;\;\;\frac{1}{y\_m \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y\_m}{\left(y\_m \cdot y\_m\right) \cdot x}\\
\end{array}
\end{array}
if z < 2.3e42Initial program 93.7%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.2
Applied rewrites71.2%
if 2.3e42 < z Initial program 78.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
pow2N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f647.0
Applied rewrites7.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
div-subN/A
frac-2negN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites0.9%
Taylor expanded in x around 0
mul-1-negN/A
distribute-frac-neg2N/A
distribute-lft-out--N/A
mul-1-negN/A
frac-2negN/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f642.1
Applied rewrites2.1%
Taylor expanded in z around 0
Applied rewrites38.4%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (/ 1.0 (* y_m x))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
return y_s * (1.0 / (y_m * x));
}
y\_m = private
y\_s = private
NOTE: x, y_m, and z 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(y_s, x, y_m, z)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (1.0d0 / (y_m * x))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (1.0 / (y_m * x));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): return y_s * (1.0 / (y_m * x))
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) return Float64(y_s * Float64(1.0 / Float64(y_m * x))) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp = code(y_s, x, y_m, z)
tmp = y_s * (1.0 / (y_m * x));
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(1.0 / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \frac{1}{y\_m \cdot x}
\end{array}
Initial program 90.5%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6459.5
Applied rewrites59.5%
herbie shell --seed 2025112
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
(/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))