| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 7104 |
\[\left(z + \left(\log y \cdot x - z \cdot 2\right)\right) - y
\]

(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
(FPCore (x y z) :precision binary64 (- (+ z (- (* (log y) x) (* z 2.0))) y))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
double code(double x, double y, double z) {
return (z + ((log(y) * x) - (z * 2.0))) - 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
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (z + ((log(y) * x) - (z * 2.0d0))) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
public static double code(double x, double y, double z) {
return (z + ((Math.log(y) * x) - (z * 2.0))) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
def code(x, y, z): return (z + ((math.log(y) * x) - (z * 2.0))) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function code(x, y, z) return Float64(Float64(z + Float64(Float64(log(y) * x) - Float64(z * 2.0))) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
function tmp = code(x, y, z) tmp = (z + ((log(y) * x) - (z * 2.0))) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
code[x_, y_, z_] := N[(N[(z + N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]
\left(x \cdot \log y - z\right) - y
\left(z + \left(\log y \cdot x - z \cdot 2\right)\right) - y
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 99.9%
Applied egg-rr99.4%
[Start]99.9% | \[ \left(x \cdot \log y - z\right) - y
\] |
|---|---|
add-cube-cbrt [=>]99.4% | \[ \left(\color{blue}{\left(\sqrt[3]{x \cdot \log y} \cdot \sqrt[3]{x \cdot \log y}\right) \cdot \sqrt[3]{x \cdot \log y}} - z\right) - y
\] |
pow3 [=>]99.4% | \[ \left(\color{blue}{{\left(\sqrt[3]{x \cdot \log y}\right)}^{3}} - z\right) - y
\] |
Applied egg-rr99.9%
[Start]99.4% | \[ \left({\left(\sqrt[3]{x \cdot \log y}\right)}^{3} - z\right) - y
\] |
|---|---|
unpow3 [=>]99.4% | \[ \left(\color{blue}{\left(\sqrt[3]{x \cdot \log y} \cdot \sqrt[3]{x \cdot \log y}\right) \cdot \sqrt[3]{x \cdot \log y}} - z\right) - y
\] |
add-cube-cbrt [<=]99.9% | \[ \left(\color{blue}{x \cdot \log y} - z\right) - y
\] |
*-un-lft-identity [=>]99.9% | \[ \left(x \cdot \log y - \color{blue}{1 \cdot z}\right) - y
\] |
prod-diff [=>]99.9% | \[ \color{blue}{\left(\mathsf{fma}\left(x, \log y, -z \cdot 1\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right)} - y
\] |
*-commutative [<=]99.9% | \[ \left(\mathsf{fma}\left(x, \log y, -\color{blue}{1 \cdot z}\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right) - y
\] |
*-un-lft-identity [<=]99.9% | \[ \left(\mathsf{fma}\left(x, \log y, -\color{blue}{z}\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right) - y
\] |
fma-neg [<=]99.9% | \[ \left(\color{blue}{\left(x \cdot \log y - z\right)} + \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right) - y
\] |
*-commutative [<=]99.9% | \[ \left(\left(x \cdot \log y - z\right) + \mathsf{fma}\left(-z, 1, \color{blue}{1 \cdot z}\right)\right) - y
\] |
*-un-lft-identity [<=]99.9% | \[ \left(\left(x \cdot \log y - z\right) + \mathsf{fma}\left(-z, 1, \color{blue}{z}\right)\right) - y
\] |
Simplified99.9%
[Start]99.9% | \[ \left(\left(x \cdot \log y - z\right) + \mathsf{fma}\left(-z, 1, z\right)\right) - y
\] |
|---|---|
fma-udef [=>]99.9% | \[ \left(\left(x \cdot \log y - z\right) + \color{blue}{\left(\left(-z\right) \cdot 1 + z\right)}\right) - y
\] |
*-rgt-identity [=>]99.9% | \[ \left(\left(x \cdot \log y - z\right) + \left(\color{blue}{\left(-z\right)} + z\right)\right) - y
\] |
associate-+r+ [=>]99.9% | \[ \color{blue}{\left(\left(\left(x \cdot \log y - z\right) + \left(-z\right)\right) + z\right)} - y
\] |
+-commutative [=>]99.9% | \[ \color{blue}{\left(z + \left(\left(x \cdot \log y - z\right) + \left(-z\right)\right)\right)} - y
\] |
unsub-neg [=>]99.9% | \[ \left(z + \color{blue}{\left(\left(x \cdot \log y - z\right) - z\right)}\right) - y
\] |
*-commutative [=>]99.9% | \[ \left(z + \left(\left(\color{blue}{\log y \cdot x} - z\right) - z\right)\right) - y
\] |
Taylor expanded in y around 0 99.9%
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 7104 |
| Alternative 2 | |
|---|---|
| Accuracy | 85.4% |
| Cost | 6985 |
| Alternative 3 | |
|---|---|
| Accuracy | 85.1% |
| Cost | 6984 |
| Alternative 4 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 6857 |
| Alternative 5 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 6848 |
| Alternative 6 | |
|---|---|
| Accuracy | 53.3% |
| Cost | 260 |
| Alternative 7 | |
|---|---|
| Accuracy | 66.4% |
| Cost | 256 |
| Alternative 8 | |
|---|---|
| Accuracy | 34.7% |
| Cost | 128 |
herbie shell --seed 2023171
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))