
(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 (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.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.45e+81) (not (<= z 7e+91))) (- (- z) y) (- (* (log y) x) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.45e+81) || !(z <= 7e+91)) {
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 <= (-1.45d+81)) .or. (.not. (z <= 7d+91))) 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 <= -1.45e+81) || !(z <= 7e+91)) {
tmp = -z - y;
} else {
tmp = (Math.log(y) * x) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.45e+81) or not (z <= 7e+91): tmp = -z - y else: tmp = (math.log(y) * x) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.45e+81) || !(z <= 7e+91)) 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 <= -1.45e+81) || ~((z <= 7e+91))) tmp = -z - y; else tmp = (log(y) * x) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.45e+81], N[Not[LessEqual[z, 7e+91]], $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 -1.45 \cdot 10^{+81} \lor \neg \left(z \leq 7 \cdot 10^{+91}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x - y\\
\end{array}
\end{array}
if z < -1.45e81 or 7.00000000000000001e91 < z Initial program 99.9%
Taylor expanded in x around 0 86.6%
neg-mul-186.6%
Simplified86.6%
if -1.45e81 < z < 7.00000000000000001e91Initial program 99.8%
Taylor expanded in z around 0 89.8%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (log y) x))) (if (<= z -6.9e+84) (- (- z) y) (if (<= z 3.7e+108) (- t_0 y) (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = log(y) * x;
double tmp;
if (z <= -6.9e+84) {
tmp = -z - y;
} else if (z <= 3.7e+108) {
tmp = t_0 - y;
} else {
tmp = t_0 - z;
}
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 = log(y) * x
if (z <= (-6.9d+84)) then
tmp = -z - y
else if (z <= 3.7d+108) then
tmp = t_0 - y
else
tmp = t_0 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.log(y) * x;
double tmp;
if (z <= -6.9e+84) {
tmp = -z - y;
} else if (z <= 3.7e+108) {
tmp = t_0 - y;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = math.log(y) * x tmp = 0 if z <= -6.9e+84: tmp = -z - y elif z <= 3.7e+108: tmp = t_0 - y else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(log(y) * x) tmp = 0.0 if (z <= -6.9e+84) tmp = Float64(Float64(-z) - y); elseif (z <= 3.7e+108) tmp = Float64(t_0 - y); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = log(y) * x; tmp = 0.0; if (z <= -6.9e+84) tmp = -z - y; elseif (z <= 3.7e+108) tmp = t_0 - y; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -6.9e+84], N[((-z) - y), $MachinePrecision], If[LessEqual[z, 3.7e+108], N[(t$95$0 - y), $MachinePrecision], N[(t$95$0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot x\\
\mathbf{if}\;z \leq -6.9 \cdot 10^{+84}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+108}:\\
\;\;\;\;t_0 - y\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if z < -6.8999999999999997e84Initial program 99.9%
Taylor expanded in x around 0 86.1%
neg-mul-186.1%
Simplified86.1%
if -6.8999999999999997e84 < z < 3.6999999999999998e108Initial program 99.8%
Taylor expanded in z around 0 89.9%
if 3.6999999999999998e108 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 93.7%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.1e+55) (not (<= x 2.6e+170))) (* (log y) x) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e+55) || !(x <= 2.6e+170)) {
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.1d+55)) .or. (.not. (x <= 2.6d+170))) 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.1e+55) || !(x <= 2.6e+170)) {
tmp = Math.log(y) * x;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.1e+55) or not (x <= 2.6e+170): tmp = math.log(y) * x else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.1e+55) || !(x <= 2.6e+170)) 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.1e+55) || ~((x <= 2.6e+170))) tmp = log(y) * x; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.1e+55], N[Not[LessEqual[x, 2.6e+170]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+55} \lor \neg \left(x \leq 2.6 \cdot 10^{+170}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -2.1000000000000001e55 or 2.5999999999999998e170 < x Initial program 99.7%
sub-neg99.7%
associate--l+99.7%
*-commutative99.7%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 71.5%
if -2.1000000000000001e55 < x < 2.5999999999999998e170Initial program 99.9%
Taylor expanded in x around 0 86.5%
neg-mul-186.5%
Simplified86.5%
Final simplification82.1%
(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.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.65e-18) (not (<= z 1e+108))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.65e-18) || !(z <= 1e+108)) {
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.65d-18)) .or. (.not. (z <= 1d+108))) 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.65e-18) || !(z <= 1e+108)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.65e-18) or not (z <= 1e+108): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.65e-18) || !(z <= 1e+108)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.65e-18) || ~((z <= 1e+108))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.65e-18], N[Not[LessEqual[z, 1e+108]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{-18} \lor \neg \left(z \leq 10^{+108}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -1.6500000000000001e-18 or 1e108 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 65.8%
mul-1-neg65.8%
Simplified65.8%
if -1.6500000000000001e-18 < z < 1e108Initial program 99.8%
Taylor expanded in y around inf 53.7%
neg-mul-153.7%
Simplified53.7%
Final simplification59.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 69.2%
neg-mul-169.2%
Simplified69.2%
Final simplification69.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 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 37.5%
neg-mul-137.5%
Simplified37.5%
Final simplification37.5%
herbie shell --seed 2023310
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))