
(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 9 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%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.4e+68) (not (<= x 3e+110))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4e+68) || !(x <= 3e+110)) {
tmp = (x * log(y)) - y;
} 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 <= (-1.4d+68)) .or. (.not. (x <= 3d+110))) then
tmp = (x * log(y)) - y
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4e+68) || !(x <= 3e+110)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.4e+68) or not (x <= 3e+110): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.4e+68) || !(x <= 3e+110)) tmp = Float64(Float64(x * log(y)) - y); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.4e+68) || ~((x <= 3e+110))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.4e+68], N[Not[LessEqual[x, 3e+110]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+68} \lor \neg \left(x \leq 3 \cdot 10^{+110}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -1.4e68 or 3.00000000000000007e110 < x Initial program 99.7%
Taylor expanded in z around 0 85.0%
if -1.4e68 < x < 3.00000000000000007e110Initial program 99.9%
Taylor expanded in x around 0 88.3%
neg-mul-188.3%
+-commutative88.3%
distribute-neg-in88.3%
sub-neg88.3%
Simplified88.3%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.4e+144) (not (<= x 4.4e+110))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.4e+144) || !(x <= 4.4e+110)) {
tmp = x * log(y);
} 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 <= (-3.4d+144)) .or. (.not. (x <= 4.4d+110))) then
tmp = x * log(y)
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.4e+144) || !(x <= 4.4e+110)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.4e+144) or not (x <= 4.4e+110): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.4e+144) || !(x <= 4.4e+110)) tmp = Float64(x * log(y)); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.4e+144) || ~((x <= 4.4e+110))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.4e+144], N[Not[LessEqual[x, 4.4e+110]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{+144} \lor \neg \left(x \leq 4.4 \cdot 10^{+110}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.3999999999999999e144 or 4.39999999999999984e110 < x Initial program 99.7%
Taylor expanded in x around inf 76.2%
if -3.3999999999999999e144 < x < 4.39999999999999984e110Initial program 99.9%
Taylor expanded in x around 0 86.9%
neg-mul-186.9%
+-commutative86.9%
distribute-neg-in86.9%
sub-neg86.9%
Simplified86.9%
Final simplification84.0%
(FPCore (x y z) :precision binary64 (if (<= y 3.6e-7) (- (* x (log y)) z) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.6e-7) {
tmp = (x * log(y)) - z;
} 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 (y <= 3.6d-7) then
tmp = (x * log(y)) - z
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.6e-7) {
tmp = (x * Math.log(y)) - z;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.6e-7: tmp = (x * math.log(y)) - z else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.6e-7) tmp = Float64(Float64(x * log(y)) - z); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.6e-7) tmp = (x * log(y)) - z; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.6e-7], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{-7}:\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if y < 3.59999999999999994e-7Initial program 99.8%
Taylor expanded in y around 0 93.9%
if 3.59999999999999994e-7 < y Initial program 99.9%
Taylor expanded in x around 0 82.1%
neg-mul-182.1%
+-commutative82.1%
distribute-neg-in82.1%
sub-neg82.1%
Simplified82.1%
(FPCore (x y z) :precision binary64 (if (<= y 5.2e+66) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.2e+66) {
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 (y <= 5.2d+66) 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 (y <= 5.2e+66) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.2e+66: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.2e+66) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.2e+66) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.2e+66], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{+66}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 5.20000000000000024e66Initial program 99.8%
Taylor expanded in z around inf 49.2%
neg-mul-149.2%
Simplified49.2%
if 5.20000000000000024e66 < y Initial program 99.9%
Taylor expanded in y around inf 68.4%
neg-mul-168.4%
Simplified68.4%
(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 69.8%
neg-mul-169.8%
+-commutative69.8%
distribute-neg-in69.8%
sub-neg69.8%
Simplified69.8%
(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.9%
Taylor expanded in y around inf 35.7%
neg-mul-135.7%
Simplified35.7%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf 35.9%
neg-mul-135.9%
Simplified35.9%
neg-sub035.9%
sub-neg35.9%
add-sqr-sqrt20.5%
sqrt-unprod8.8%
sqr-neg8.8%
sqrt-unprod0.8%
add-sqr-sqrt2.2%
Applied egg-rr2.2%
+-lft-identity2.2%
Simplified2.2%
(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 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.9%
Taylor expanded in x around inf 78.6%
mul-1-neg78.6%
unsub-neg78.6%
Simplified78.6%
Taylor expanded in y around inf 25.0%
associate-*r/25.0%
mul-1-neg25.0%
Simplified25.0%
associate-*r/29.7%
add-sqr-sqrt0.0%
sqrt-unprod2.1%
sqr-neg2.1%
sqrt-unprod2.1%
add-sqr-sqrt2.1%
Applied egg-rr2.1%
*-commutative2.1%
associate-/l*2.1%
*-inverses2.1%
*-rgt-identity2.1%
Simplified2.1%
herbie shell --seed 2024181
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))