
(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 8 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 (let* ((t_0 (log (cbrt y)))) (- (- (* x (+ t_0 (* 2.0 t_0))) z) y)))
double code(double x, double y, double z) {
double t_0 = log(cbrt(y));
return ((x * (t_0 + (2.0 * t_0))) - z) - y;
}
public static double code(double x, double y, double z) {
double t_0 = Math.log(Math.cbrt(y));
return ((x * (t_0 + (2.0 * t_0))) - z) - y;
}
function code(x, y, z) t_0 = log(cbrt(y)) return Float64(Float64(Float64(x * Float64(t_0 + Float64(2.0 * t_0))) - z) - y) end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[Power[y, 1/3], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt[3]{y}\right)\\
\left(x \cdot \left(t_0 + 2 \cdot t_0\right) - z\right) - y
\end{array}
\end{array}
Initial program 99.9%
add-log-exp50.2%
*-commutative50.2%
exp-to-pow50.2%
Applied egg-rr50.2%
add-cube-cbrt50.2%
unpow-prod-down50.2%
log-prod50.2%
pow250.2%
Applied egg-rr50.2%
log-pow50.6%
log-pow99.8%
distribute-lft-out99.9%
log-pow99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))))
(if (<= y 7.5e+42)
(- t_0 z)
(if (or (<= y 4e+127) (not (<= y 1.7e+163))) (- (- z) y) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (y <= 7.5e+42) {
tmp = t_0 - z;
} else if ((y <= 4e+127) || !(y <= 1.7e+163)) {
tmp = -z - y;
} else {
tmp = t_0 - 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) :: t_0
real(8) :: tmp
t_0 = x * log(y)
if (y <= 7.5d+42) then
tmp = t_0 - z
else if ((y <= 4d+127) .or. (.not. (y <= 1.7d+163))) then
tmp = -z - y
else
tmp = t_0 - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.log(y);
double tmp;
if (y <= 7.5e+42) {
tmp = t_0 - z;
} else if ((y <= 4e+127) || !(y <= 1.7e+163)) {
tmp = -z - y;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if y <= 7.5e+42: tmp = t_0 - z elif (y <= 4e+127) or not (y <= 1.7e+163): tmp = -z - y else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (y <= 7.5e+42) tmp = Float64(t_0 - z); elseif ((y <= 4e+127) || !(y <= 1.7e+163)) tmp = Float64(Float64(-z) - y); else tmp = Float64(t_0 - y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); tmp = 0.0; if (y <= 7.5e+42) tmp = t_0 - z; elseif ((y <= 4e+127) || ~((y <= 1.7e+163))) tmp = -z - y; else tmp = t_0 - y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 7.5e+42], N[(t$95$0 - z), $MachinePrecision], If[Or[LessEqual[y, 4e+127], N[Not[LessEqual[y, 1.7e+163]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;y \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;t_0 - z\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+127} \lor \neg \left(y \leq 1.7 \cdot 10^{+163}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t_0 - y\\
\end{array}
\end{array}
if y < 7.50000000000000041e42Initial program 99.8%
add-log-exp46.6%
*-commutative46.6%
exp-to-pow46.6%
Applied egg-rr46.6%
add-cube-cbrt46.6%
unpow-prod-down46.6%
log-prod46.6%
pow246.6%
Applied egg-rr46.6%
log-pow47.4%
log-pow99.8%
distribute-lft-out99.8%
log-pow99.8%
Simplified99.8%
add-log-exp99.8%
*-commutative99.8%
exp-to-pow99.8%
pow299.8%
log-prod99.8%
add-cube-cbrt99.8%
expm1-log1p-u14.8%
Applied egg-rr14.8%
Taylor expanded in y around 0 90.0%
if 7.50000000000000041e42 < y < 3.99999999999999982e127 or 1.7000000000000001e163 < y Initial program 100.0%
Taylor expanded in x around 0 89.3%
neg-mul-189.3%
Simplified89.3%
if 3.99999999999999982e127 < y < 1.7000000000000001e163Initial program 99.7%
Taylor expanded in z around 0 90.6%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.9e+30) (not (<= x 3e+173))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.9e+30) || !(x <= 3e+173)) {
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 <= (-3.9d+30)) .or. (.not. (x <= 3d+173))) 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 <= -3.9e+30) || !(x <= 3e+173)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.9e+30) or not (x <= 3e+173): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.9e+30) || !(x <= 3e+173)) 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 <= -3.9e+30) || ~((x <= 3e+173))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.9e+30], N[Not[LessEqual[x, 3e+173]], $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 -3.9 \cdot 10^{+30} \lor \neg \left(x \leq 3 \cdot 10^{+173}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.90000000000000011e30 or 2.9999999999999998e173 < x Initial program 99.7%
Taylor expanded in z around 0 86.2%
if -3.90000000000000011e30 < x < 2.9999999999999998e173Initial program 99.9%
Taylor expanded in x around 0 87.5%
neg-mul-187.5%
Simplified87.5%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.1e+203) (not (<= x 1.4e+179))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.1e+203) || !(x <= 1.4e+179)) {
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.1d+203)) .or. (.not. (x <= 1.4d+179))) 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.1e+203) || !(x <= 1.4e+179)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.1e+203) or not (x <= 1.4e+179): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.1e+203) || !(x <= 1.4e+179)) 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.1e+203) || ~((x <= 1.4e+179))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.1e+203], N[Not[LessEqual[x, 1.4e+179]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+203} \lor \neg \left(x \leq 1.4 \cdot 10^{+179}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.1e203 or 1.4e179 < x Initial program 99.6%
Taylor expanded in z around 0 93.9%
fma-neg93.9%
Simplified93.9%
Taylor expanded in x around inf 83.0%
if -3.1e203 < x < 1.4e179Initial program 99.9%
Taylor expanded in x around 0 83.9%
neg-mul-183.9%
Simplified83.9%
Final simplification83.8%
(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 (<= y 5.6e+69) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.6e+69) {
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.6d+69) 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.6e+69) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.6e+69: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.6e+69) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.6e+69) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.6e+69], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{+69}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 5.59999999999999964e69Initial program 99.8%
add-log-exp49.3%
*-commutative49.3%
exp-to-pow49.3%
Applied egg-rr49.3%
add-cube-cbrt49.3%
unpow-prod-down49.3%
log-prod49.3%
pow249.3%
Applied egg-rr49.3%
log-pow50.0%
log-pow99.8%
distribute-lft-out99.8%
log-pow99.8%
Simplified99.8%
add-log-exp99.8%
*-commutative99.8%
exp-to-pow99.8%
pow299.8%
log-prod99.8%
add-cube-cbrt99.8%
expm1-log1p-u23.9%
Applied egg-rr23.9%
Taylor expanded in z around inf 48.1%
neg-mul-148.1%
Simplified48.1%
if 5.59999999999999964e69 < y Initial program 99.9%
Taylor expanded in y around inf 68.6%
neg-mul-168.6%
Simplified68.6%
Final simplification56.0%
(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 70.0%
neg-mul-170.0%
Simplified70.0%
Final simplification70.0%
(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 34.8%
neg-mul-134.8%
Simplified34.8%
Final simplification34.8%
herbie shell --seed 2023297
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))