
(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.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.8e+157) (not (<= z 4.8e+55))) (- (+ y z)) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.8e+157) || !(z <= 4.8e+55)) {
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 <= (-9.8d+157)) .or. (.not. (z <= 4.8d+55))) 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 <= -9.8e+157) || !(z <= 4.8e+55)) {
tmp = -(y + z);
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.8e+157) or not (z <= 4.8e+55): tmp = -(y + z) else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.8e+157) || !(z <= 4.8e+55)) 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 <= -9.8e+157) || ~((z <= 4.8e+55))) tmp = -(y + z); else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.8e+157], N[Not[LessEqual[z, 4.8e+55]], $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 -9.8 \cdot 10^{+157} \lor \neg \left(z \leq 4.8 \cdot 10^{+55}\right):\\
\;\;\;\;-\left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -9.8000000000000003e157 or 4.7999999999999998e55 < z Initial program 100.0%
Taylor expanded in x around 0 86.2%
mul-1-neg86.2%
Simplified86.2%
if -9.8000000000000003e157 < z < 4.7999999999999998e55Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 87.8%
Final simplification87.4%
(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.8%
Taylor expanded in x around 0 58.5%
mul-1-neg58.5%
Simplified58.5%
Final simplification58.5%
(FPCore (x y z) :precision binary64 (- y))
double code(double x, double y, double z) {
return -y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -y
end function
public static double code(double x, double y, double z) {
return -y;
}
def code(x, y, z): return -y
function code(x, y, z) return Float64(-y) end
function tmp = code(x, y, z) tmp = -y; end
code[x_, y_, z_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around inf 30.1%
neg-mul-130.1%
Simplified30.1%
Final simplification30.1%
herbie shell --seed 2023199
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))