| Alternative 1 | |
|---|---|
| Error | 9.6 |
| Cost | 6985 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -250 \lor \neg \left(x \leq 3.1 \cdot 10^{-47}\right):\\
\;\;\;\;\log y \cdot x - y\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) - z\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
(FPCore (x y z) :precision binary64 (- (- (* (log y) x) y) z))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
double code(double x, double y, double z) {
return ((log(y) * x) - y) - z;
}
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 = ((log(y) * x) - y) - z
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 ((Math.log(y) * x) - y) - z;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
def code(x, y, z): return ((math.log(y) * x) - y) - z
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function code(x, y, z) return Float64(Float64(Float64(log(y) * x) - y) - z) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
function tmp = code(x, y, z) tmp = ((log(y) * x) - y) - z; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
code[x_, y_, z_] := N[(N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]
\left(x \cdot \log y - z\right) - y
\left(\log y \cdot x - y\right) - z
Results
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \left(x \cdot \log y - z\right) - y
\] |
|---|---|
associate--l- [=>]0.1 | \[ \color{blue}{x \cdot \log y - \left(z + y\right)}
\] |
Taylor expanded in y around inf 0.1
Simplified0.1
[Start]0.1 | \[ \left(-1 \cdot y + -1 \cdot \left(\log \left(\frac{1}{y}\right) \cdot x\right)\right) - z
\] |
|---|---|
*-commutative [<=]0.1 | \[ \left(\color{blue}{y \cdot -1} + -1 \cdot \left(\log \left(\frac{1}{y}\right) \cdot x\right)\right) - z
\] |
log-rec [=>]0.1 | \[ \left(y \cdot -1 + -1 \cdot \left(\color{blue}{\left(-\log y\right)} \cdot x\right)\right) - z
\] |
distribute-lft-neg-in [<=]0.1 | \[ \left(y \cdot -1 + -1 \cdot \color{blue}{\left(-\log y \cdot x\right)}\right) - z
\] |
*-commutative [<=]0.1 | \[ \left(y \cdot -1 + -1 \cdot \left(-\color{blue}{x \cdot \log y}\right)\right) - z
\] |
mul-1-neg [=>]0.1 | \[ \left(y \cdot -1 + \color{blue}{\left(-\left(-x \cdot \log y\right)\right)}\right) - z
\] |
unsub-neg [=>]0.1 | \[ \color{blue}{\left(y \cdot -1 - \left(-x \cdot \log y\right)\right)} - z
\] |
*-commutative [=>]0.1 | \[ \left(\color{blue}{-1 \cdot y} - \left(-x \cdot \log y\right)\right) - z
\] |
mul-1-neg [=>]0.1 | \[ \left(\color{blue}{\left(-y\right)} - \left(-x \cdot \log y\right)\right) - z
\] |
*-commutative [=>]0.1 | \[ \left(\left(-y\right) - \left(-\color{blue}{\log y \cdot x}\right)\right) - z
\] |
distribute-rgt-neg-in [=>]0.1 | \[ \left(\left(-y\right) - \color{blue}{\log y \cdot \left(-x\right)}\right) - z
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 9.6 |
| Cost | 6985 |
| Alternative 2 | |
|---|---|
| Error | 13.4 |
| Cost | 6857 |
| Alternative 3 | |
|---|---|
| Error | 10.3 |
| Cost | 6852 |
| Alternative 4 | |
|---|---|
| Error | 0.1 |
| Cost | 6848 |
| Alternative 5 | |
|---|---|
| Error | 30.4 |
| Cost | 260 |
| Alternative 6 | |
|---|---|
| Error | 21.6 |
| Cost | 256 |
| Alternative 7 | |
|---|---|
| Error | 41.8 |
| Cost | 128 |
herbie shell --seed 2023016
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))