
(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 8 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}
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (if (<= z_m 9.4e+114) (/ (/ (/ 1.0 x) (fma z_m z_m 1.0)) y) (/ (/ 1.0 (* z_m y)) (* z_m x))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 9.4e+114) {
tmp = ((1.0 / x) / fma(z_m, z_m, 1.0)) / y;
} else {
tmp = (1.0 / (z_m * y)) / (z_m * x);
}
return tmp;
}
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) tmp = 0.0 if (z_m <= 9.4e+114) tmp = Float64(Float64(Float64(1.0 / x) / fma(z_m, z_m, 1.0)) / y); else tmp = Float64(Float64(1.0 / Float64(z_m * y)) / Float64(z_m * x)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 9.4e+114], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(z$95$m * z$95$m + 1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] / N[(z$95$m * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 9.4 \cdot 10^{+114}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{\mathsf{fma}\left(z\_m, z\_m, 1\right)}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z\_m \cdot y}}{z\_m \cdot x}\\
\end{array}
\end{array}
if z < 9.4000000000000001e114Initial program 97.7%
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.f6498.1
Applied rewrites98.1%
if 9.4000000000000001e114 < z Initial program 74.5%
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-*.f6487.4
Applied rewrites87.4%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6474.4
Applied rewrites74.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6496.0
Applied rewrites96.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6496.6
Applied rewrites96.6%
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (if (<= (* y (+ 1.0 (* z_m z_m))) 2e+302) (/ 1.0 (* (* (fma z_m z_m 1.0) y) x)) (/ 1.0 (* (* (* z_m x) y) z_m))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
double tmp;
if ((y * (1.0 + (z_m * z_m))) <= 2e+302) {
tmp = 1.0 / ((fma(z_m, z_m, 1.0) * y) * x);
} else {
tmp = 1.0 / (((z_m * x) * y) * z_m);
}
return tmp;
}
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z_m * z_m))) <= 2e+302) tmp = Float64(1.0 / Float64(Float64(fma(z_m, z_m, 1.0) * y) * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * y) * z_m)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := If[LessEqual[N[(y * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+302], N[(1.0 / N[(N[(N[(z$95$m * z$95$m + 1.0), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * y), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z\_m \cdot z\_m\right) \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\frac{1}{\left(\mathsf{fma}\left(z\_m, z\_m, 1\right) \cdot y\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot y\right) \cdot z\_m}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 2.0000000000000002e302Initial program 97.3%
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.f6496.8
Applied rewrites96.8%
if 2.0000000000000002e302 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 70.4%
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-*.f6480.3
Applied rewrites80.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6468.5
Applied rewrites68.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6492.6
Applied rewrites92.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f6495.6
Applied rewrites95.6%
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (if (<= z_m 0.86) (/ (/ (- 1.0 (* z_m z_m)) y) x) (/ 1.0 (* (* (* z_m x) z_m) y))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = ((1.0 - (z_m * z_m)) / y) / x;
} else {
tmp = 1.0 / (((z_m * x) * z_m) * y);
}
return tmp;
}
z_m = private
NOTE: x, y, and z_m 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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 0.86d0) then
tmp = ((1.0d0 - (z_m * z_m)) / y) / x
else
tmp = 1.0d0 / (((z_m * x) * z_m) * y)
end if
code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = ((1.0 - (z_m * z_m)) / y) / x;
} else {
tmp = 1.0 / (((z_m * x) * z_m) * y);
}
return tmp;
}
z_m = math.fabs(z) [x, y, z_m] = sort([x, y, z_m]) def code(x, y, z_m): tmp = 0 if z_m <= 0.86: tmp = ((1.0 - (z_m * z_m)) / y) / x else: tmp = 1.0 / (((z_m * x) * z_m) * y) return tmp
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) tmp = 0.0 if (z_m <= 0.86) tmp = Float64(Float64(Float64(1.0 - Float64(z_m * z_m)) / y) / x); else tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * z_m) * y)); end return tmp end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
tmp = 0.0;
if (z_m <= 0.86)
tmp = ((1.0 - (z_m * z_m)) / y) / x;
else
tmp = 1.0 / (((z_m * x) * z_m) * y);
end
tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * z$95$m), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{\frac{1 - z\_m \cdot z\_m}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot z\_m\right) \cdot y}\\
\end{array}
\end{array}
if z < 0.859999999999999987Initial program 99.7%
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%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-*.f6499.3
Applied rewrites99.3%
if 0.859999999999999987 < z Initial program 81.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-*.f6489.3
Applied rewrites89.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6480.0
Applied rewrites80.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6493.9
Applied rewrites93.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6487.8
Applied rewrites87.8%
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (if (<= z_m 0.86) (/ (- 1.0 (* z_m z_m)) (* y x)) (/ 1.0 (* (* (* z_m x) z_m) y))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / (((z_m * x) * z_m) * y);
}
return tmp;
}
z_m = private
NOTE: x, y, and z_m 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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 0.86d0) then
tmp = (1.0d0 - (z_m * z_m)) / (y * x)
else
tmp = 1.0d0 / (((z_m * x) * z_m) * y)
end if
code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / (((z_m * x) * z_m) * y);
}
return tmp;
}
z_m = math.fabs(z) [x, y, z_m] = sort([x, y, z_m]) def code(x, y, z_m): tmp = 0 if z_m <= 0.86: tmp = (1.0 - (z_m * z_m)) / (y * x) else: tmp = 1.0 / (((z_m * x) * z_m) * y) return tmp
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) tmp = 0.0 if (z_m <= 0.86) tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * z_m) * y)); end return tmp end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
tmp = 0.0;
if (z_m <= 0.86)
tmp = (1.0 - (z_m * z_m)) / (y * x);
else
tmp = 1.0 / (((z_m * x) * z_m) * y);
end
tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * z$95$m), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot z\_m\right) \cdot y}\\
\end{array}
\end{array}
if z < 0.859999999999999987Initial program 99.7%
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 0.859999999999999987 < z Initial program 81.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-*.f6489.3
Applied rewrites89.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6480.0
Applied rewrites80.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6493.9
Applied rewrites93.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6487.8
Applied rewrites87.8%
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (if (<= z_m 0.86) (/ (- 1.0 (* z_m z_m)) (* y x)) (/ 1.0 (* (* (* z_m x) y) z_m))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / (((z_m * x) * y) * z_m);
}
return tmp;
}
z_m = private
NOTE: x, y, and z_m 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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 0.86d0) then
tmp = (1.0d0 - (z_m * z_m)) / (y * x)
else
tmp = 1.0d0 / (((z_m * x) * y) * z_m)
end if
code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / (((z_m * x) * y) * z_m);
}
return tmp;
}
z_m = math.fabs(z) [x, y, z_m] = sort([x, y, z_m]) def code(x, y, z_m): tmp = 0 if z_m <= 0.86: tmp = (1.0 - (z_m * z_m)) / (y * x) else: tmp = 1.0 / (((z_m * x) * y) * z_m) return tmp
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) tmp = 0.0 if (z_m <= 0.86) tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * y) * z_m)); end return tmp end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
tmp = 0.0;
if (z_m <= 0.86)
tmp = (1.0 - (z_m * z_m)) / (y * x);
else
tmp = 1.0 / (((z_m * x) * y) * z_m);
end
tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * y), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot y\right) \cdot z\_m}\\
\end{array}
\end{array}
if z < 0.859999999999999987Initial program 99.7%
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 0.859999999999999987 < z Initial program 81.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-*.f6489.3
Applied rewrites89.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6480.0
Applied rewrites80.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6493.9
Applied rewrites93.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f6494.3
Applied rewrites94.3%
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (if (<= z_m 0.86) (/ (- 1.0 (* z_m z_m)) (* y x)) (/ 1.0 (* (* y z_m) (* z_m x)))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / ((y * z_m) * (z_m * x));
}
return tmp;
}
z_m = private
NOTE: x, y, and z_m 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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 0.86d0) then
tmp = (1.0d0 - (z_m * z_m)) / (y * x)
else
tmp = 1.0d0 / ((y * z_m) * (z_m * x))
end if
code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / ((y * z_m) * (z_m * x));
}
return tmp;
}
z_m = math.fabs(z) [x, y, z_m] = sort([x, y, z_m]) def code(x, y, z_m): tmp = 0 if z_m <= 0.86: tmp = (1.0 - (z_m * z_m)) / (y * x) else: tmp = 1.0 / ((y * z_m) * (z_m * x)) return tmp
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) tmp = 0.0 if (z_m <= 0.86) tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x)); else tmp = Float64(1.0 / Float64(Float64(y * z_m) * Float64(z_m * x))); end return tmp end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
tmp = 0.0;
if (z_m <= 0.86)
tmp = (1.0 - (z_m * z_m)) / (y * x);
else
tmp = 1.0 / ((y * z_m) * (z_m * x));
end
tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(y * z$95$m), $MachinePrecision] * N[(z$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(y \cdot z\_m\right) \cdot \left(z\_m \cdot x\right)}\\
\end{array}
\end{array}
if z < 0.859999999999999987Initial program 99.7%
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 0.859999999999999987 < z Initial program 81.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-*.f6489.3
Applied rewrites89.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6480.0
Applied rewrites80.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6493.9
Applied rewrites93.9%
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (if (<= z_m 0.86) (/ (- 1.0 (* z_m z_m)) (* y x)) (/ 1.0 (* (* (* z_m z_m) y) x))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / (((z_m * z_m) * y) * x);
}
return tmp;
}
z_m = private
NOTE: x, y, and z_m 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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 0.86d0) then
tmp = (1.0d0 - (z_m * z_m)) / (y * x)
else
tmp = 1.0d0 / (((z_m * z_m) * y) * x)
end if
code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 0.86) {
tmp = (1.0 - (z_m * z_m)) / (y * x);
} else {
tmp = 1.0 / (((z_m * z_m) * y) * x);
}
return tmp;
}
z_m = math.fabs(z) [x, y, z_m] = sort([x, y, z_m]) def code(x, y, z_m): tmp = 0 if z_m <= 0.86: tmp = (1.0 - (z_m * z_m)) / (y * x) else: tmp = 1.0 / (((z_m * z_m) * y) * x) return tmp
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) tmp = 0.0 if (z_m <= 0.86) tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(z_m * z_m) * y) * x)); end return tmp end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
tmp = 0.0;
if (z_m <= 0.86)
tmp = (1.0 - (z_m * z_m)) / (y * x);
else
tmp = 1.0 / (((z_m * z_m) * y) * x);
end
tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot z\_m\right) \cdot y\right) \cdot x}\\
\end{array}
\end{array}
if z < 0.859999999999999987Initial program 99.7%
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 0.859999999999999987 < z Initial program 81.2%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6480.0
Applied rewrites80.0%
z_m = (fabs.f64 z) NOTE: x, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x y z_m) :precision binary64 (/ 1.0 (* y x)))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
return 1.0 / (y * x);
}
z_m = private
NOTE: x, y, and z_m 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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = 1.0d0 / (y * x)
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
return 1.0 / (y * x);
}
z_m = math.fabs(z) [x, y, z_m] = sort([x, y, z_m]) def code(x, y, z_m): return 1.0 / (y * x)
z_m = abs(z) x, y, z_m = sort([x, y, z_m]) function code(x, y, z_m) return Float64(1.0 / Float64(y * x)) end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp = code(x, y, z_m)
tmp = 1.0 / (y * x);
end
z_m = N[Abs[z], $MachinePrecision] NOTE: x, y, and z_m should be sorted in increasing order before calling this function. code[x_, y_, z$95$m_] := N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\frac{1}{y \cdot x}
\end{array}
Initial program 90.3%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.1
Applied rewrites58.1%
herbie shell --seed 2025120
(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)))))