
(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)));
}
real(8) function code(x, y, z)
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}
Sampling outcomes in binary64 precision:
Herbie found 9 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)));
}
real(8) function code(x, y, z)
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 and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y (+ 1.0 (* z z))) 1e+298) (/ (/ 1.0 (fma z (* y z) y)) x) (* (/ 1.0 (* y (* z x))) (/ 1.0 z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 1e+298) {
tmp = (1.0 / fma(z, (y * z), y)) / x;
} else {
tmp = (1.0 / (y * (z * x))) * (1.0 / z);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 1e+298) tmp = Float64(Float64(1.0 / fma(z, Float64(y * z), y)) / x); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x))) * Float64(1.0 / z)); end return tmp end
NOTE: x and y 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], 1e+298], N[(N[(1.0 / N[(z * N[(y * z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 10^{+298}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(z, y \cdot z, y\right)}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot x\right)} \cdot \frac{1}{z}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 9.9999999999999996e297Initial program 94.9%
associate-/r*94.5%
+-commutative94.5%
fma-def94.5%
Simplified94.5%
Taylor expanded in x around 0 92.8%
associate-*r*94.5%
*-commutative94.5%
associate-*r*94.7%
associate-/r*94.7%
unpow294.7%
fma-udef94.7%
associate-/r*95.0%
associate-/l/94.9%
fma-udef94.9%
distribute-lft-in94.9%
*-rgt-identity94.9%
fma-def94.9%
fma-def94.9%
*-commutative94.9%
associate-*r*96.7%
fma-udef96.7%
Simplified96.7%
if 9.9999999999999996e297 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 68.8%
associate-/r*68.8%
+-commutative68.8%
fma-def68.8%
Simplified68.8%
Taylor expanded in z around inf 79.6%
*-commutative79.6%
unpow279.6%
associate-*r*79.1%
*-commutative79.1%
associate-*r*89.3%
*-commutative89.3%
Simplified89.3%
inv-pow89.3%
unpow-prod-down89.3%
inv-pow89.3%
associate-*l*99.7%
Applied egg-rr99.7%
unpow-199.7%
*-commutative99.7%
Simplified99.7%
Final simplification97.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (* y (+ 1.0 (* z z))))) (if (<= t_0 1e+298) (/ (/ 1.0 x) t_0) (* (/ 1.0 (* y (* z x))) (/ 1.0 z)))))
assert(x < y);
double code(double x, double y, double z) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+298) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / (y * (z * x))) * (1.0 / z);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 + (z * z))
if (t_0 <= 1d+298) then
tmp = (1.0d0 / x) / t_0
else
tmp = (1.0d0 / (y * (z * x))) * (1.0d0 / z)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+298) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / (y * (z * x))) * (1.0 / z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): t_0 = y * (1.0 + (z * z)) tmp = 0 if t_0 <= 1e+298: tmp = (1.0 / x) / t_0 else: tmp = (1.0 / (y * (z * x))) * (1.0 / z) return tmp
x, y = sort([x, y]) function code(x, y, z) t_0 = Float64(y * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 1e+298) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x))) * Float64(1.0 / z)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
t_0 = y * (1.0 + (z * z));
tmp = 0.0;
if (t_0 <= 1e+298)
tmp = (1.0 / x) / t_0;
else
tmp = (1.0 / (y * (z * x))) * (1.0 / z);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+298], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + z \cdot z\right)\\
\mathbf{if}\;t_0 \leq 10^{+298}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot x\right)} \cdot \frac{1}{z}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 9.9999999999999996e297Initial program 94.9%
if 9.9999999999999996e297 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 68.8%
associate-/r*68.8%
+-commutative68.8%
fma-def68.8%
Simplified68.8%
Taylor expanded in z around inf 79.6%
*-commutative79.6%
unpow279.6%
associate-*r*79.1%
*-commutative79.1%
associate-*r*89.3%
*-commutative89.3%
Simplified89.3%
inv-pow89.3%
unpow-prod-down89.3%
inv-pow89.3%
associate-*l*99.7%
Applied egg-rr99.7%
unpow-199.7%
*-commutative99.7%
Simplified99.7%
Final simplification95.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e+88) (/ 1.0 (* x (+ y (* y (* z z))))) (* (/ 1.0 (* y (* z x))) (/ 1.0 z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+88) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (1.0 / (y * (z * x))) * (1.0 / z);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 1d+88) then
tmp = 1.0d0 / (x * (y + (y * (z * z))))
else
tmp = (1.0d0 / (y * (z * x))) * (1.0d0 / z)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+88) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (1.0 / (y * (z * x))) * (1.0 / z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1e+88: tmp = 1.0 / (x * (y + (y * (z * z)))) else: tmp = (1.0 / (y * (z * x))) * (1.0 / z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+88) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(y * Float64(z * z))))); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x))) * Float64(1.0 / z)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 1e+88)
tmp = 1.0 / (x * (y + (y * (z * z))));
else
tmp = (1.0 / (y * (z * x))) * (1.0 / z);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+88], N[(1.0 / N[(x * N[(y + N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+88}:\\
\;\;\;\;\frac{1}{x \cdot \left(y + y \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot x\right)} \cdot \frac{1}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999959e87Initial program 98.4%
associate-/r*97.9%
+-commutative97.9%
fma-def97.9%
Simplified97.9%
fma-udef97.9%
distribute-lft-in97.9%
*-rgt-identity97.9%
Applied egg-rr97.9%
if 9.99999999999999959e87 < (*.f64 z z) Initial program 78.9%
associate-/r*78.9%
+-commutative78.9%
fma-def78.9%
Simplified78.9%
Taylor expanded in z around inf 79.6%
*-commutative79.6%
unpow279.6%
associate-*r*82.5%
*-commutative82.5%
associate-*r*90.5%
*-commutative90.5%
Simplified90.5%
inv-pow90.5%
unpow-prod-down91.3%
inv-pow91.3%
associate-*l*96.9%
Applied egg-rr96.9%
unpow-196.9%
*-commutative96.9%
Simplified96.9%
Final simplification97.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1.0) (/ (/ 1.0 x) y) (/ 1.0 (* x (* y (* z z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (y * (z * z)));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 1.0d0) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (x * (y * (z * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (y * (z * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1.0: tmp = (1.0 / x) / y else: tmp = 1.0 / (x * (y * (z * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1.0) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(x * Float64(y * Float64(z * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 1.0)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (x * (y * (z * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1.0], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(x * N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 1:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(y \cdot \left(z \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
add-sqr-sqrt99.6%
div-inv99.4%
times-frac99.4%
hypot-1-def99.4%
hypot-1-def99.4%
Applied egg-rr99.4%
Taylor expanded in z around 0 98.9%
associate-/l/99.5%
Simplified99.5%
if 1 < (*.f64 z z) Initial program 80.9%
associate-/r*80.9%
+-commutative80.9%
fma-def80.9%
Simplified80.9%
Taylor expanded in z around inf 79.2%
unpow279.2%
Simplified79.2%
Final simplification89.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-14) (/ (/ 1.0 x) y) (/ 1.0 (* x (* z (* y z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-14) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (z * (y * z)));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d-14) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (x * (z * (y * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-14) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (z * (y * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-14: tmp = (1.0 / x) / y else: tmp = 1.0 / (x * (z * (y * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-14) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(x * Float64(z * Float64(y * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e-14)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (x * (z * (y * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-14], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(x * N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000002e-14Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
add-sqr-sqrt99.6%
div-inv99.4%
times-frac99.4%
hypot-1-def99.4%
hypot-1-def99.4%
Applied egg-rr99.4%
Taylor expanded in z around 0 98.9%
associate-/l/99.5%
Simplified99.5%
if 5.0000000000000002e-14 < (*.f64 z z) Initial program 80.9%
associate-/r*80.9%
+-commutative80.9%
fma-def80.9%
Simplified80.9%
Taylor expanded in z around inf 79.2%
unpow279.2%
*-commutative79.2%
associate-*r*85.5%
Simplified85.5%
Final simplification92.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-14) (/ (/ 1.0 x) y) (/ 1.0 (* z (* (* y z) x)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-14) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * ((y * z) * x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d-14) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (z * ((y * z) * x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-14) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * ((y * z) * x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-14: tmp = (1.0 / x) / y else: tmp = 1.0 / (z * ((y * z) * x)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-14) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(z * Float64(Float64(y * z) * x))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e-14)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (z * ((y * z) * x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-14], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(z * N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(\left(y \cdot z\right) \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000002e-14Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
add-sqr-sqrt99.6%
div-inv99.4%
times-frac99.4%
hypot-1-def99.4%
hypot-1-def99.4%
Applied egg-rr99.4%
Taylor expanded in z around 0 98.9%
associate-/l/99.5%
Simplified99.5%
if 5.0000000000000002e-14 < (*.f64 z z) Initial program 80.9%
associate-/r*80.9%
+-commutative80.9%
fma-def80.9%
Simplified80.9%
Taylor expanded in z around inf 79.8%
*-commutative79.8%
unpow279.8%
associate-*r*83.1%
associate-*l*89.7%
*-commutative89.7%
associate-*l*93.1%
*-commutative93.1%
Simplified93.1%
Final simplification96.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-14) (/ (/ 1.0 x) y) (/ (/ (/ 1.0 x) (* y z)) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-14) {
tmp = (1.0 / x) / y;
} else {
tmp = ((1.0 / x) / (y * z)) / z;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d-14) then
tmp = (1.0d0 / x) / y
else
tmp = ((1.0d0 / x) / (y * z)) / z
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-14) {
tmp = (1.0 / x) / y;
} else {
tmp = ((1.0 / x) / (y * z)) / z;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-14: tmp = (1.0 / x) / y else: tmp = ((1.0 / x) / (y * z)) / z return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-14) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(Float64(1.0 / x) / Float64(y * z)) / z); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e-14)
tmp = (1.0 / x) / y;
else
tmp = ((1.0 / x) / (y * z)) / z;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-14], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y \cdot z}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000002e-14Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
add-sqr-sqrt99.6%
div-inv99.4%
times-frac99.4%
hypot-1-def99.4%
hypot-1-def99.4%
Applied egg-rr99.4%
Taylor expanded in z around 0 98.9%
associate-/l/99.5%
Simplified99.5%
if 5.0000000000000002e-14 < (*.f64 z z) Initial program 80.9%
associate-/r*80.9%
+-commutative80.9%
fma-def80.9%
Simplified80.9%
Taylor expanded in z around inf 79.8%
*-commutative79.8%
unpow279.8%
associate-*r*83.1%
*-commutative83.1%
associate-*r*89.7%
*-commutative89.7%
Simplified89.7%
inv-pow89.7%
unpow-prod-down90.2%
inv-pow90.2%
associate-*l*94.9%
Applied egg-rr94.9%
unpow-194.9%
associate-*r/94.8%
associate-*l/94.8%
metadata-eval94.8%
associate-/r*94.9%
*-commutative94.9%
Simplified94.9%
Taylor expanded in y around 0 94.8%
associate-*r*93.5%
*-commutative93.5%
associate-/l/93.7%
*-commutative93.7%
Simplified93.7%
Final simplification96.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ 1.0 (* y x)))
assert(x < y);
double code(double x, double y, double z) {
return 1.0 / (y * x);
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 / (y * x)
end function
assert x < y;
public static double code(double x, double y, double z) {
return 1.0 / (y * x);
}
[x, y] = sort([x, y]) def code(x, y, z): return 1.0 / (y * x)
x, y = sort([x, y]) function code(x, y, z) return Float64(1.0 / Float64(y * x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = 1.0 / (y * x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{y \cdot x}
\end{array}
Initial program 90.7%
associate-/r*90.3%
+-commutative90.3%
fma-def90.3%
Simplified90.3%
Taylor expanded in z around 0 61.5%
Final simplification61.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 x) y))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / x) / y;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / y
end function
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / x) / y;
}
[x, y] = sort([x, y]) def code(x, y, z): return (1.0 / x) / y
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / x) / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / x) / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x}}{y}
\end{array}
Initial program 90.7%
associate-/r*90.3%
+-commutative90.3%
fma-def90.3%
Simplified90.3%
fma-udef90.3%
+-commutative90.3%
associate-/r*90.7%
associate-/r*92.2%
add-sqr-sqrt92.2%
div-inv92.1%
times-frac90.6%
hypot-1-def90.6%
hypot-1-def96.8%
Applied egg-rr96.8%
Taylor expanded in z around 0 61.5%
associate-/l/61.8%
Simplified61.8%
Final simplification61.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z z))) (t_1 (* y t_0)) (t_2 (/ (/ 1.0 y) (* t_0 x))))
(if (< t_1 (- INFINITY))
t_2
(if (< t_1 8.680743250567252e+305) (/ (/ 1.0 x) (* t_0 y)) t_2))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * z) t_1 = y * t_0 t_2 = (1.0 / y) / (t_0 * x) tmp = 0 if t_1 < -math.inf: tmp = t_2 elif t_1 < 8.680743250567252e+305: tmp = (1.0 / x) / (t_0 * y) else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * z)) t_1 = Float64(y * t_0) t_2 = Float64(Float64(1.0 / y) / Float64(t_0 * x)) tmp = 0.0 if (t_1 < Float64(-Inf)) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = Float64(Float64(1.0 / x) / Float64(t_0 * y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * z); t_1 = y * t_0; t_2 = (1.0 / y) / (t_0 * x); tmp = 0.0; if (t_1 < -Inf) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = (1.0 / x) / (t_0 * y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / y), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, (-Infinity)], t$95$2, If[Less[t$95$1, 8.680743250567252e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot z\\
t_1 := y \cdot t_0\\
t_2 := \frac{\frac{1}{y}}{t_0 \cdot x}\\
\mathbf{if}\;t_1 < -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 < 8.680743250567252 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0 \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
herbie shell --seed 2023195
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< (* y (+ 1.0 (* z z))) (- INFINITY)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x)) (if (< (* y (+ 1.0 (* z z))) 8.680743250567252e+305) (/ (/ 1.0 x) (* (+ 1.0 (* z z)) y)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x))))
(/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))