
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.52e+162) (not (<= z 2.9e+95))) (- (- z) y) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.52e+162) || !(z <= 2.9e+95)) {
tmp = -z - y;
} else {
tmp = (x * log(y)) - y;
}
return tmp;
}
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 <= (-1.52d+162)) .or. (.not. (z <= 2.9d+95))) then
tmp = -z - y
else
tmp = (x * log(y)) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.52e+162) || !(z <= 2.9e+95)) {
tmp = -z - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.52e+162) or not (z <= 2.9e+95): tmp = -z - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.52e+162) || !(z <= 2.9e+95)) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.52e+162) || ~((z <= 2.9e+95))) tmp = -z - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.52e+162], N[Not[LessEqual[z, 2.9e+95]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.52 \cdot 10^{+162} \lor \neg \left(z \leq 2.9 \cdot 10^{+95}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -1.5200000000000001e162 or 2.90000000000000013e95 < z Initial program 100.0%
Taylor expanded in x around 0 91.8%
neg-mul-191.8%
Simplified91.8%
if -1.5200000000000001e162 < z < 2.90000000000000013e95Initial program 99.9%
*-commutative99.9%
add-cube-cbrt99.2%
associate-*r*99.2%
fma-neg99.2%
pow299.2%
Applied egg-rr99.2%
Taylor expanded in z around 0 86.4%
pow-base-186.4%
associate-*r*86.4%
*-lft-identity86.4%
Simplified86.4%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (- (- z) y))
double code(double x, double y, double z) {
return -z - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z - y
end function
public static double code(double x, double y, double z) {
return -z - y;
}
def code(x, y, z): return -z - y
function code(x, y, z) return Float64(Float64(-z) - y) end
function tmp = code(x, y, z) tmp = -z - y; end
code[x_, y_, z_] := N[((-z) - y), $MachinePrecision]
\begin{array}{l}
\\
\left(-z\right) - y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 66.2%
neg-mul-166.2%
Simplified66.2%
Final simplification66.2%
(FPCore (x y z) :precision binary64 (- z y))
double code(double x, double y, double z) {
return z - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z - y
end function
public static double code(double x, double y, double z) {
return z - y;
}
def code(x, y, z): return z - y
function code(x, y, z) return Float64(z - y) end
function tmp = code(x, y, z) tmp = z - y; end
code[x_, y_, z_] := N[(z - y), $MachinePrecision]
\begin{array}{l}
\\
z - y
\end{array}
Initial program 99.9%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
rem-cube-cbrt99.9%
sub-neg99.9%
*-commutative99.9%
add-cube-cbrt99.4%
unpow299.4%
associate-*r*99.4%
fma-udef99.4%
*-commutative99.4%
unpow299.4%
cbrt-unprod75.8%
pow275.8%
add-sqr-sqrt37.2%
sqrt-unprod45.7%
sqr-neg45.7%
sqrt-unprod21.2%
add-sqr-sqrt43.9%
Applied egg-rr43.9%
*-commutative43.9%
Simplified43.9%
Taylor expanded in x around 0 32.7%
Final simplification32.7%
herbie shell --seed 2023336
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))