
(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 (- (- (* (log (/ 1.0 y)) (- x)) z) y))
double code(double x, double y, double z) {
return ((log((1.0 / 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((1.0d0 / y)) * -x) - z) - y
end function
public static double code(double x, double y, double z) {
return ((Math.log((1.0 / y)) * -x) - z) - y;
}
def code(x, y, z): return ((math.log((1.0 / y)) * -x) - z) - y
function code(x, y, z) return Float64(Float64(Float64(log(Float64(1.0 / y)) * Float64(-x)) - z) - y) end
function tmp = code(x, y, z) tmp = ((log((1.0 / y)) * -x) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(N[Log[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] * (-x)), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\log \left(\frac{1}{y}\right) \cdot \left(-x\right) - z\right) - y
\end{array}
Initial program 99.8%
Taylor expanded in y around inf 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.05e+137) (not (<= x 3.3e-71))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.05e+137) || !(x <= 3.3e-71)) {
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.05d+137)) .or. (.not. (x <= 3.3d-71))) 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.05e+137) || !(x <= 3.3e-71)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.05e+137) or not (x <= 3.3e-71): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.05e+137) || !(x <= 3.3e-71)) 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.05e+137) || ~((x <= 3.3e-71))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.05e+137], N[Not[LessEqual[x, 3.3e-71]], $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.05 \cdot 10^{+137} \lor \neg \left(x \leq 3.3 \cdot 10^{-71}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -1.05e137 or 3.3000000000000002e-71 < x Initial program 99.7%
Taylor expanded in z around 0 88.9%
if -1.05e137 < x < 3.3000000000000002e-71Initial program 100.0%
Taylor expanded in x around 0 89.0%
neg-mul-189.0%
Simplified89.0%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.5e+153) (not (<= x 5.2e+96))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+153) || !(x <= 5.2e+96)) {
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 <= (-5.5d+153)) .or. (.not. (x <= 5.2d+96))) 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 <= -5.5e+153) || !(x <= 5.2e+96)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.5e+153) or not (x <= 5.2e+96): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e+153) || !(x <= 5.2e+96)) 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 <= -5.5e+153) || ~((x <= 5.2e+96))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e+153], N[Not[LessEqual[x, 5.2e+96]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+153} \lor \neg \left(x \leq 5.2 \cdot 10^{+96}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -5.5000000000000003e153 or 5.2e96 < x Initial program 99.6%
Taylor expanded in y around inf 99.6%
Taylor expanded in x around inf 91.6%
add-sqr-sqrt37.0%
sqrt-unprod8.8%
mul-1-neg8.8%
mul-1-neg8.8%
sqr-neg8.8%
sqrt-unprod8.0%
add-sqr-sqrt14.6%
*-commutative14.6%
add-sqr-sqrt0.4%
sqrt-unprod45.2%
log-rec45.2%
log-rec45.2%
sqr-neg45.2%
sqrt-unprod44.8%
add-sqr-sqrt91.5%
Applied egg-rr30.6%
Taylor expanded in y around 0 76.0%
if -5.5000000000000003e153 < x < 5.2e96Initial program 99.9%
Taylor expanded in x around 0 83.9%
neg-mul-183.9%
Simplified83.9%
Final simplification81.5%
(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 -1.3e+113) (not (<= z 4.5e+58))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e+113) || !(z <= 4.5e+58)) {
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 <= (-1.3d+113)) .or. (.not. (z <= 4.5d+58))) 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 <= -1.3e+113) || !(z <= 4.5e+58)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.3e+113) or not (z <= 4.5e+58): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.3e+113) || !(z <= 4.5e+58)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.3e+113) || ~((z <= 4.5e+58))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.3e+113], N[Not[LessEqual[z, 4.5e+58]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+113} \lor \neg \left(z \leq 4.5 \cdot 10^{+58}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -1.3e113 or 4.4999999999999998e58 < z Initial program 99.9%
add-sqr-sqrt46.9%
pow246.9%
Applied egg-rr46.9%
add-cbrt-cube42.6%
pow1/342.3%
add-sqr-sqrt42.3%
pow142.3%
pow1/242.3%
pow-prod-up42.3%
metadata-eval42.3%
Applied egg-rr42.3%
unpow1/342.6%
Simplified42.6%
Taylor expanded in z around inf 61.3%
neg-mul-161.3%
Simplified61.3%
if -1.3e113 < z < 4.4999999999999998e58Initial program 99.8%
Taylor expanded in y around inf 47.6%
mul-1-neg47.6%
Simplified47.6%
Final simplification52.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.8%
Taylor expanded in x around 0 65.8%
neg-mul-165.8%
Simplified65.8%
Final simplification65.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.8%
Taylor expanded in y around inf 37.6%
mul-1-neg37.6%
Simplified37.6%
Final simplification37.6%
(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.8%
associate--l-99.8%
*-commutative99.8%
fma-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
sub-neg99.8%
add-sqr-sqrt0.0%
sqrt-unprod56.7%
sqr-neg56.7%
sqrt-unprod61.9%
add-sqr-sqrt61.9%
Applied egg-rr61.9%
Taylor expanded in y around inf 2.4%
Final simplification2.4%
herbie shell --seed 2024021
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))