
(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 x (log y) (- (- z) y)))
double code(double x, double y, double z) {
return fma(x, log(y), (-z - y));
}
function code(x, y, z) return fma(x, log(y), Float64(Float64(-z) - y)) end
code[x_, y_, z_] := N[(x * N[Log[y], $MachinePrecision] + N[((-z) - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \log y, \left(-z\right) - y\right)
\end{array}
Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))))
(if (<= z -6.6e+107)
(- t_0 z)
(if (or (<= z -1.05e-9) (not (<= z 3.75e+81))) (- (- z) y) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (z <= -6.6e+107) {
tmp = t_0 - z;
} else if ((z <= -1.05e-9) || !(z <= 3.75e+81)) {
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 (z <= (-6.6d+107)) then
tmp = t_0 - z
else if ((z <= (-1.05d-9)) .or. (.not. (z <= 3.75d+81))) 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 (z <= -6.6e+107) {
tmp = t_0 - z;
} else if ((z <= -1.05e-9) || !(z <= 3.75e+81)) {
tmp = -z - y;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if z <= -6.6e+107: tmp = t_0 - z elif (z <= -1.05e-9) or not (z <= 3.75e+81): 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 (z <= -6.6e+107) tmp = Float64(t_0 - z); elseif ((z <= -1.05e-9) || !(z <= 3.75e+81)) 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 (z <= -6.6e+107) tmp = t_0 - z; elseif ((z <= -1.05e-9) || ~((z <= 3.75e+81))) 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[z, -6.6e+107], N[(t$95$0 - z), $MachinePrecision], If[Or[LessEqual[z, -1.05e-9], N[Not[LessEqual[z, 3.75e+81]], $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}\;z \leq -6.6 \cdot 10^{+107}:\\
\;\;\;\;t_0 - z\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-9} \lor \neg \left(z \leq 3.75 \cdot 10^{+81}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t_0 - y\\
\end{array}
\end{array}
if z < -6.60000000000000064e107Initial program 100.0%
Taylor expanded in y around 0 89.9%
if -6.60000000000000064e107 < z < -1.0500000000000001e-9 or 3.74999999999999986e81 < z Initial program 100.0%
Taylor expanded in x around 0 89.5%
mul-1-neg89.5%
distribute-neg-in89.5%
+-commutative89.5%
sub-neg89.5%
Simplified89.5%
if -1.0500000000000001e-9 < z < 3.74999999999999986e81Initial program 99.8%
Taylor expanded in z around 0 94.1%
Final simplification91.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05e-8) (not (<= z 3.7e+79))) (- (- z) y) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e-8) || !(z <= 3.7e+79)) {
tmp = -z - y;
} else {
tmp = (x * log(y)) - 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.05d-8)) .or. (.not. (z <= 3.7d+79))) then
tmp = -z - y
else
tmp = (x * log(y)) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e-8) || !(z <= 3.7e+79)) {
tmp = -z - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05e-8) or not (z <= 3.7e+79): tmp = -z - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05e-8) || !(z <= 3.7e+79)) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05e-8) || ~((z <= 3.7e+79))) tmp = -z - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05e-8], N[Not[LessEqual[z, 3.7e+79]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-8} \lor \neg \left(z \leq 3.7 \cdot 10^{+79}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -1.04999999999999997e-8 or 3.70000000000000009e79 < z Initial program 100.0%
Taylor expanded in x around 0 85.3%
mul-1-neg85.3%
distribute-neg-in85.3%
+-commutative85.3%
sub-neg85.3%
Simplified85.3%
if -1.04999999999999997e-8 < z < 3.70000000000000009e79Initial program 99.8%
Taylor expanded in z around 0 94.1%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.1e+49) (not (<= x 3.2e+188))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.1e+49) || !(x <= 3.2e+188)) {
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+49)) .or. (.not. (x <= 3.2d+188))) 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+49) || !(x <= 3.2e+188)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.1e+49) or not (x <= 3.2e+188): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.1e+49) || !(x <= 3.2e+188)) 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+49) || ~((x <= 3.2e+188))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.1e+49], N[Not[LessEqual[x, 3.2e+188]], $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^{+49} \lor \neg \left(x \leq 3.2 \cdot 10^{+188}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.09999999999999992e49 or 3.1999999999999997e188 < x Initial program 99.8%
Taylor expanded in y around 0 85.0%
Taylor expanded in x around inf 70.8%
if -3.09999999999999992e49 < x < 3.1999999999999997e188Initial program 99.9%
Taylor expanded in x around 0 86.8%
mul-1-neg86.8%
distribute-neg-in86.8%
+-commutative86.8%
sub-neg86.8%
Simplified86.8%
Final simplification82.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.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -7.2e+96) (- z) (if (<= z 1.9e+128) (- y) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.2e+96) {
tmp = -z;
} else if (z <= 1.9e+128) {
tmp = -y;
} else {
tmp = -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) :: tmp
if (z <= (-7.2d+96)) then
tmp = -z
else if (z <= 1.9d+128) then
tmp = -y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7.2e+96) {
tmp = -z;
} else if (z <= 1.9e+128) {
tmp = -y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.2e+96: tmp = -z elif z <= 1.9e+128: tmp = -y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.2e+96) tmp = Float64(-z); elseif (z <= 1.9e+128) tmp = Float64(-y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.2e+96) tmp = -z; elseif (z <= 1.9e+128) tmp = -y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.2e+96], (-z), If[LessEqual[z, 1.9e+128], (-y), (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+96}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{+128}:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -7.20000000000000026e96 or 1.89999999999999995e128 < z Initial program 100.0%
Taylor expanded in z around inf 72.4%
mul-1-neg72.4%
Simplified72.4%
if -7.20000000000000026e96 < z < 1.89999999999999995e128Initial program 99.9%
Taylor expanded in y around inf 50.7%
neg-mul-150.7%
Simplified50.7%
Final simplification58.3%
(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.4%
mul-1-neg70.4%
distribute-neg-in70.4%
+-commutative70.4%
sub-neg70.4%
Simplified70.4%
Final simplification70.4%
(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.9%
neg-mul-137.9%
Simplified37.9%
Final simplification37.9%
herbie shell --seed 2023200
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))