
(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 11 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}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 2e+14) (/ (/ 1.0 (fma (* z y) z y)) x) (/ (pow (* y x) -1.0) (fma z z 1.0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 2e+14) {
tmp = (1.0 / fma((z * y), z, y)) / x;
} else {
tmp = pow((y * x), -1.0) / fma(z, z, 1.0);
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 2e+14) tmp = Float64(Float64(1.0 / fma(Float64(z * y), z, y)) / x); else tmp = Float64((Float64(y * x) ^ -1.0) / fma(z, z, 1.0)); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 2e+14], N[(N[(1.0 / N[(N[(z * y), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Power[N[(y * x), $MachinePrecision], -1.0], $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+14}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(z \cdot y, z, y\right)}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(y \cdot x\right)}^{-1}}{\mathsf{fma}\left(z, z, 1\right)}\\
\end{array}
\end{array}
if y < 2e14Initial program 89.3%
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-*.f6496.1
Applied rewrites96.1%
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
*-commutativeN/A
lower-*.f6496.1
Applied rewrites96.1%
if 2e14 < y Initial program 92.7%
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
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6497.4
Applied rewrites97.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y (+ 1.0 (* z z))) 5e+303) (/ (/ 1.0 x) (fma (* y z) z y)) (* (pow (* y x) -1.0) (pow z -2.0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+303) {
tmp = (1.0 / x) / fma((y * z), z, y);
} else {
tmp = pow((y * x), -1.0) * pow(z, -2.0);
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+303) tmp = Float64(Float64(1.0 / x) / fma(Float64(y * z), z, y)); else tmp = Float64((Float64(y * x) ^ -1.0) * (z ^ -2.0)); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+303], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(y * x), $MachinePrecision], -1.0], $MachinePrecision] * N[Power[z, -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+303}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(y \cdot x\right)}^{-1} \cdot {z}^{-2}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 4.9999999999999997e303Initial program 97.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-*.f6499.2
Applied rewrites99.2%
if 4.9999999999999997e303 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 71.0%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
inv-powN/A
associate-*r*N/A
pow2N/A
unpow-prod-downN/A
inv-powN/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6479.1
Applied rewrites79.1%
Taylor expanded in z around inf
pow-flipN/A
lower-pow.f64N/A
metadata-eval78.8
Applied rewrites78.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y (+ 1.0 (* z z))) 5e+303) (/ (/ (pow y -1.0) (fma z z 1.0)) x) (* (pow (* y x) -1.0) (pow z -2.0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+303) {
tmp = (pow(y, -1.0) / fma(z, z, 1.0)) / x;
} else {
tmp = pow((y * x), -1.0) * pow(z, -2.0);
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+303) tmp = Float64(Float64((y ^ -1.0) / fma(z, z, 1.0)) / x); else tmp = Float64((Float64(y * x) ^ -1.0) * (z ^ -2.0)); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+303], N[(N[(N[Power[y, -1.0], $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Power[N[(y * x), $MachinePrecision], -1.0], $MachinePrecision] * N[Power[z, -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+303}:\\
\;\;\;\;\frac{\frac{{y}^{-1}}{\mathsf{fma}\left(z, z, 1\right)}}{x}\\
\mathbf{else}:\\
\;\;\;\;{\left(y \cdot x\right)}^{-1} \cdot {z}^{-2}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 4.9999999999999997e303Initial program 97.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-*.f6499.2
Applied rewrites99.2%
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
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
Taylor expanded in y around -inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f64N/A
pow2N/A
lift-*.f6497.2
Applied rewrites97.2%
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
distribute-frac-negN/A
lift--.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
metadata-evalN/A
distribute-neg-inN/A
+-commutativeN/A
frac-2negN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f64N/A
+-commutativeN/A
pow2N/A
lower-fma.f6497.2
Applied rewrites97.2%
if 4.9999999999999997e303 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 71.0%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
inv-powN/A
associate-*r*N/A
pow2N/A
unpow-prod-downN/A
inv-powN/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6479.1
Applied rewrites79.1%
Taylor expanded in z around inf
pow-flipN/A
lower-pow.f64N/A
metadata-eval78.8
Applied rewrites78.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 0.000205) (/ (fma (- z) z 1.0) (* y x)) (/ (/ (pow x -1.0) (* z z)) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 0.000205) {
tmp = fma(-z, z, 1.0) / (y * x);
} else {
tmp = (pow(x, -1.0) / (z * z)) / y;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= 0.000205) tmp = Float64(fma(Float64(-z), z, 1.0) / Float64(y * x)); else tmp = Float64(Float64((x ^ -1.0) / Float64(z * z)) / y); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 0.000205], N[(N[((-z) * z + 1.0), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, -1.0], $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.000205:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, z, 1\right)}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{-1}}{z \cdot z}}{y}\\
\end{array}
\end{array}
if z < 2.05e-4Initial program 93.5%
Taylor expanded in z around 0
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6468.7
Applied rewrites68.7%
if 2.05e-4 < z Initial program 82.3%
Taylor expanded in z around inf
pow2N/A
lift-*.f6480.6
Applied rewrites80.6%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6481.6
pow281.6
+-commutative81.6
pow281.6
Applied rewrites81.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 0.000205) (/ (fma (- z) z 1.0) (* y x)) (/ (pow (* (* z z) x) -1.0) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 0.000205) {
tmp = fma(-z, z, 1.0) / (y * x);
} else {
tmp = pow(((z * z) * x), -1.0) / y;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= 0.000205) tmp = Float64(fma(Float64(-z), z, 1.0) / Float64(y * x)); else tmp = Float64((Float64(Float64(z * z) * x) ^ -1.0) / y); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 0.000205], N[(N[((-z) * z + 1.0), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(z * z), $MachinePrecision] * x), $MachinePrecision], -1.0], $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.000205:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, z, 1\right)}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(z \cdot z\right) \cdot x\right)}^{-1}}{y}\\
\end{array}
\end{array}
if z < 2.05e-4Initial program 93.5%
Taylor expanded in z around 0
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6468.7
Applied rewrites68.7%
if 2.05e-4 < z Initial program 82.3%
Taylor expanded in z around inf
pow2N/A
lift-*.f6480.6
Applied rewrites80.6%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6481.6
pow281.6
+-commutative81.6
pow281.6
Applied rewrites81.6%
Taylor expanded in z around inf
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6481.2
Applied rewrites81.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 0.000205) (/ (fma (- z) z 1.0) (* y x)) (* (pow (* y x) -1.0) (pow z -2.0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 0.000205) {
tmp = fma(-z, z, 1.0) / (y * x);
} else {
tmp = pow((y * x), -1.0) * pow(z, -2.0);
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= 0.000205) tmp = Float64(fma(Float64(-z), z, 1.0) / Float64(y * x)); else tmp = Float64((Float64(y * x) ^ -1.0) * (z ^ -2.0)); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 0.000205], N[(N[((-z) * z + 1.0), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(y * x), $MachinePrecision], -1.0], $MachinePrecision] * N[Power[z, -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.000205:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, z, 1\right)}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;{\left(y \cdot x\right)}^{-1} \cdot {z}^{-2}\\
\end{array}
\end{array}
if z < 2.05e-4Initial program 93.5%
Taylor expanded in z around 0
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6468.7
Applied rewrites68.7%
if 2.05e-4 < z Initial program 82.3%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
inv-powN/A
associate-*r*N/A
pow2N/A
unpow-prod-downN/A
inv-powN/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f6482.7
Applied rewrites82.7%
Taylor expanded in z around inf
pow-flipN/A
lower-pow.f64N/A
metadata-eval81.5
Applied rewrites81.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 0.000205) (/ (fma (- z) z 1.0) (* y x)) (pow (* (* (* z z) y) x) -1.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 0.000205) {
tmp = fma(-z, z, 1.0) / (y * x);
} else {
tmp = pow((((z * z) * y) * x), -1.0);
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= 0.000205) tmp = Float64(fma(Float64(-z), z, 1.0) / Float64(y * x)); else tmp = Float64(Float64(Float64(z * z) * y) * x) ^ -1.0; end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 0.000205], N[(N[((-z) * z + 1.0), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.000205:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, z, 1\right)}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(\left(z \cdot z\right) \cdot y\right) \cdot x\right)}^{-1}\\
\end{array}
\end{array}
if z < 2.05e-4Initial program 93.5%
Taylor expanded in z around 0
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6468.7
Applied rewrites68.7%
if 2.05e-4 < z Initial program 82.3%
Taylor expanded in z around inf
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6480.4
Applied rewrites80.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (+ 1.0 (* z z)) 1.00000002) (/ (fma (- z) z 1.0) (* y x)) (/ (pow (* y y) -0.5) x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((1.0 + (z * z)) <= 1.00000002) {
tmp = fma(-z, z, 1.0) / (y * x);
} else {
tmp = pow((y * y), -0.5) / x;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(1.0 + Float64(z * z)) <= 1.00000002) tmp = Float64(fma(Float64(-z), z, 1.0) / Float64(y * x)); else tmp = Float64((Float64(y * y) ^ -0.5) / x); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision], 1.00000002], N[(N[((-z) * z + 1.0), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(y * y), $MachinePrecision], -0.5], $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;1 + z \cdot z \leq 1.00000002:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, z, 1\right)}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(y \cdot y\right)}^{-0.5}}{x}\\
\end{array}
\end{array}
if (+.f64 #s(literal 1 binary64) (*.f64 z z)) < 1.0000000200000001Initial program 99.7%
Taylor expanded in z around 0
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
if 1.0000000200000001 < (+.f64 #s(literal 1 binary64) (*.f64 z z)) Initial program 81.8%
Taylor expanded in z around 0
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6420.5
Applied rewrites20.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
associate-/r*N/A
unpow-1N/A
lower-/.f64N/A
lower-pow.f6419.9
Applied rewrites19.9%
lift-pow.f64N/A
sqr-powN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
metadata-eval27.9
Applied rewrites27.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (+ 1.0 (* z z)) 1.00000002) (/ (/ 1.0 x) y) (/ (pow (* y y) -0.5) x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((1.0 + (z * z)) <= 1.00000002) {
tmp = (1.0 / x) / y;
} else {
tmp = pow((y * y), -0.5) / x;
}
return tmp;
}
NOTE: x, y, 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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((1.0d0 + (z * z)) <= 1.00000002d0) then
tmp = (1.0d0 / x) / y
else
tmp = ((y * y) ** (-0.5d0)) / x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((1.0 + (z * z)) <= 1.00000002) {
tmp = (1.0 / x) / y;
} else {
tmp = Math.pow((y * y), -0.5) / x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (1.0 + (z * z)) <= 1.00000002: tmp = (1.0 / x) / y else: tmp = math.pow((y * y), -0.5) / x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(1.0 + Float64(z * z)) <= 1.00000002) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64((Float64(y * y) ^ -0.5) / x); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((1.0 + (z * z)) <= 1.00000002)
tmp = (1.0 / x) / y;
else
tmp = ((y * y) ^ -0.5) / x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision], 1.00000002], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[Power[N[(y * y), $MachinePrecision], -0.5], $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;1 + z \cdot z \leq 1.00000002:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(y \cdot y\right)}^{-0.5}}{x}\\
\end{array}
\end{array}
if (+.f64 #s(literal 1 binary64) (*.f64 z z)) < 1.0000000200000001Initial program 99.7%
Taylor expanded in z around 0
Applied rewrites99.5%
if 1.0000000200000001 < (+.f64 #s(literal 1 binary64) (*.f64 z z)) Initial program 81.8%
Taylor expanded in z around 0
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6420.5
Applied rewrites20.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
associate-/r*N/A
unpow-1N/A
lower-/.f64N/A
lower-pow.f6419.9
Applied rewrites19.9%
lift-pow.f64N/A
sqr-powN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
metadata-eval27.9
Applied rewrites27.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (pow (* y x) -1.0))
assert(x < y && y < z);
double code(double x, double y, double z) {
return pow((y * x), -1.0);
}
NOTE: x, y, 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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * x) ** (-1.0d0)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return Math.pow((y * x), -1.0);
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return math.pow((y * x), -1.0)
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(y * x) ^ -1.0 end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (y * x) ^ -1.0;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[Power[N[(y * x), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
{\left(y \cdot x\right)}^{-1}
\end{array}
Initial program 90.7%
Taylor expanded in z around 0
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6459.6
Applied rewrites59.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (pow y -1.0) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
return pow(y, -1.0) / x;
}
NOTE: x, y, 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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y ** (-1.0d0)) / x
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return Math.pow(y, -1.0) / x;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return math.pow(y, -1.0) / x
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64((y ^ -1.0) / x) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (y ^ -1.0) / x;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[Power[y, -1.0], $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{{y}^{-1}}{x}
\end{array}
Initial program 90.7%
Taylor expanded in z around 0
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6459.6
Applied rewrites59.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
associate-/r*N/A
unpow-1N/A
lower-/.f64N/A
lower-pow.f6459.5
Applied rewrites59.5%
herbie shell --seed 2025101
(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)))))