
(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 7 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 (fma (log y) x (- (- z) y)))
double code(double x, double y, double z) {
return fma(log(y), x, (-z - y));
}
function code(x, y, z) return fma(log(y), x, Float64(Float64(-z) - y)) end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] * x + N[((-z) - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(-z\right) - y\right)
\end{array}
Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
*-commutative99.8%
fma-define99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (or (<= z -9.8e+86)
(not (or (<= z 5.5e-37) (and (not (<= z 6.5e+36)) (<= z 5e+102)))))
(- (- z) y)
(- (* (log y) x) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.8e+86) || !((z <= 5.5e-37) || (!(z <= 6.5e+36) && (z <= 5e+102)))) {
tmp = -z - y;
} else {
tmp = (log(y) * x) - 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+86)) .or. (.not. (z <= 5.5d-37) .or. (.not. (z <= 6.5d+36)) .and. (z <= 5d+102))) then
tmp = -z - y
else
tmp = (log(y) * x) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -9.8e+86) || !((z <= 5.5e-37) || (!(z <= 6.5e+36) && (z <= 5e+102)))) {
tmp = -z - y;
} else {
tmp = (Math.log(y) * x) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.8e+86) or not ((z <= 5.5e-37) or (not (z <= 6.5e+36) and (z <= 5e+102))): tmp = -z - y else: tmp = (math.log(y) * x) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.8e+86) || !((z <= 5.5e-37) || (!(z <= 6.5e+36) && (z <= 5e+102)))) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(log(y) * x) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9.8e+86) || ~(((z <= 5.5e-37) || (~((z <= 6.5e+36)) && (z <= 5e+102))))) tmp = -z - y; else tmp = (log(y) * x) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.8e+86], N[Not[Or[LessEqual[z, 5.5e-37], And[N[Not[LessEqual[z, 6.5e+36]], $MachinePrecision], LessEqual[z, 5e+102]]]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.8 \cdot 10^{+86} \lor \neg \left(z \leq 5.5 \cdot 10^{-37} \lor \neg \left(z \leq 6.5 \cdot 10^{+36}\right) \land z \leq 5 \cdot 10^{+102}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x - y\\
\end{array}
\end{array}
if z < -9.7999999999999999e86 or 5.4999999999999998e-37 < z < 6.4999999999999998e36 or 5e102 < z Initial program 100.0%
Taylor expanded in x around 0 90.8%
neg-mul-190.8%
Simplified90.8%
if -9.7999999999999999e86 < z < 5.4999999999999998e-37 or 6.4999999999999998e36 < z < 5e102Initial program 99.8%
Taylor expanded in z around 0 91.2%
Final simplification91.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.56e+123) (not (<= x 3.8e+131))) (* (log y) x) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.56e+123) || !(x <= 3.8e+131)) {
tmp = log(y) * x;
} else {
tmp = -z - 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 ((x <= (-2.56d+123)) .or. (.not. (x <= 3.8d+131))) then
tmp = log(y) * x
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.56e+123) || !(x <= 3.8e+131)) {
tmp = Math.log(y) * x;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.56e+123) or not (x <= 3.8e+131): tmp = math.log(y) * x else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.56e+123) || !(x <= 3.8e+131)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.56e+123) || ~((x <= 3.8e+131))) tmp = log(y) * x; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.56e+123], N[Not[LessEqual[x, 3.8e+131]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.56 \cdot 10^{+123} \lor \neg \left(x \leq 3.8 \cdot 10^{+131}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -2.5600000000000001e123 or 3.8000000000000004e131 < x Initial program 99.7%
sub-neg99.7%
associate--l+99.7%
*-commutative99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 71.2%
if -2.5600000000000001e123 < x < 3.8000000000000004e131Initial program 99.9%
Taylor expanded in x around 0 86.0%
neg-mul-186.0%
Simplified86.0%
Final simplification81.2%
(FPCore (x y z) :precision binary64 (- (- (* (log y) x) z) y))
double code(double x, double y, double z) {
return ((log(y) * x) - 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 = ((log(y) * x) - z) - y
end function
public static double code(double x, double y, double z) {
return ((Math.log(y) * x) - z) - y;
}
def code(x, y, z): return ((math.log(y) * x) - z) - y
function code(x, y, z) return Float64(Float64(Float64(log(y) * x) - z) - y) end
function tmp = code(x, y, z) tmp = ((log(y) * x) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\log y \cdot x - z\right) - y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+32) (not (<= z 2.9e+145))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+32) || !(z <= 2.9e+145)) {
tmp = -z;
} else {
tmp = -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 <= (-2d+32)) .or. (.not. (z <= 2.9d+145))) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+32) || !(z <= 2.9e+145)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+32) or not (z <= 2.9e+145): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+32) || !(z <= 2.9e+145)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+32) || ~((z <= 2.9e+145))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+32], N[Not[LessEqual[z, 2.9e+145]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+32} \lor \neg \left(z \leq 2.9 \cdot 10^{+145}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -2.00000000000000011e32 or 2.9000000000000001e145 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-define99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 74.4%
mul-1-neg74.4%
Simplified74.4%
if -2.00000000000000011e32 < z < 2.9000000000000001e145Initial program 99.8%
Taylor expanded in y around inf 45.1%
neg-mul-145.1%
Simplified45.1%
Final simplification54.8%
(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.8%
Taylor expanded in x around 0 67.5%
neg-mul-167.5%
Simplified67.5%
Final simplification67.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%
Taylor expanded in y around inf 34.8%
neg-mul-134.8%
Simplified34.8%
Final simplification34.8%
herbie shell --seed 2024078
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))