
(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 -3.9e+25) (not (<= z 5.1e+118))) (- (+ y z)) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.9e+25) || !(z <= 5.1e+118)) {
tmp = -(y + z);
} 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 <= (-3.9d+25)) .or. (.not. (z <= 5.1d+118))) then
tmp = -(y + z)
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 <= -3.9e+25) || !(z <= 5.1e+118)) {
tmp = -(y + z);
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.9e+25) or not (z <= 5.1e+118): tmp = -(y + z) else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.9e+25) || !(z <= 5.1e+118)) tmp = Float64(-Float64(y + z)); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.9e+25) || ~((z <= 5.1e+118))) tmp = -(y + z); else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.9e+25], N[Not[LessEqual[z, 5.1e+118]], $MachinePrecision]], (-N[(y + z), $MachinePrecision]), N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+25} \lor \neg \left(z \leq 5.1 \cdot 10^{+118}\right):\\
\;\;\;\;-\left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -3.9000000000000002e25 or 5.10000000000000002e118 < z Initial program 99.9%
Taylor expanded in x around 0 86.1%
neg-mul-186.1%
Simplified86.1%
if -3.9000000000000002e25 < z < 5.10000000000000002e118Initial program 99.8%
add-cube-cbrt98.9%
pow398.9%
Applied egg-rr98.9%
Taylor expanded in z around 0 89.6%
pow-base-189.6%
*-lft-identity89.6%
Simplified89.6%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (- (+ y z)))
double code(double x, double y, double z) {
return -(y + z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -(y + z)
end function
public static double code(double x, double y, double z) {
return -(y + z);
}
def code(x, y, z): return -(y + z)
function code(x, y, z) return Float64(-Float64(y + z)) end
function tmp = code(x, y, z) tmp = -(y + z); end
code[x_, y_, z_] := (-N[(y + z), $MachinePrecision])
\begin{array}{l}
\\
-\left(y + z\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 68.1%
neg-mul-168.1%
Simplified68.1%
Final simplification68.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(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%
flip--53.6%
clear-num53.6%
fma-def53.6%
pow253.6%
Applied egg-rr53.6%
Taylor expanded in x around 0 68.0%
add-sqr-sqrt36.9%
sqrt-unprod37.9%
associate-/r/37.9%
metadata-eval37.9%
associate-/r/37.9%
metadata-eval37.9%
swap-sqr37.9%
metadata-eval37.9%
*-un-lft-identity37.9%
sqrt-unprod14.8%
add-sqr-sqrt34.4%
add-log-exp24.8%
*-un-lft-identity24.8%
log-prod24.8%
metadata-eval24.8%
add-log-exp34.4%
Applied egg-rr34.4%
+-lft-identity34.4%
Simplified34.4%
Final simplification34.4%
herbie shell --seed 2023185
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))