Alternative 1 | |
---|---|
Error | 2.4 |
Cost | 19776 |
\[\left(-1 + \mathsf{log1p}\left(x\right)\right) + x \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)
\]
(FPCore (x) :precision binary64 (- (- (* (+ x 1.0) (log (+ x 1.0))) (* x (log x))) 1.0))
(FPCore (x) :precision binary64 (fma x (log1p (/ 1.0 x)) (+ -1.0 (log1p x))))
double code(double x) { return (((x + 1.0) * log((x + 1.0))) - (x * log(x))) - 1.0; }
double code(double x) { return fma(x, log1p((1.0 / x)), (-1.0 + log1p(x))); }
function code(x) return Float64(Float64(Float64(Float64(x + 1.0) * log(Float64(x + 1.0))) - Float64(x * log(x))) - 1.0) end
function code(x) return fma(x, log1p(Float64(1.0 / x)), Float64(-1.0 + log1p(x))) end
code[x_] := N[(N[(N[(N[(x + 1.0), $MachinePrecision] * N[Log[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[x_] := N[(x * N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] + N[(-1.0 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x + 1\right) \cdot \log \left(x + 1\right) - x \cdot \log x\right) - 1
\mathsf{fma}\left(x, \mathsf{log1p}\left(\frac{1}{x}\right), -1 + \mathsf{log1p}\left(x\right)\right)
Initial program 2.9
Simplified2.4
[Start]2.9 | \[ \left(\left(x + 1\right) \cdot \log \left(x + 1\right) - x \cdot \log x\right) - 1
\] |
---|---|
associate--l- [=>]2.9 | \[ \color{blue}{\left(x + 1\right) \cdot \log \left(x + 1\right) - \left(x \cdot \log x + 1\right)}
\] |
*-commutative [=>]2.9 | \[ \color{blue}{\log \left(x + 1\right) \cdot \left(x + 1\right)} - \left(x \cdot \log x + 1\right)
\] |
+-commutative [=>]2.9 | \[ \log \left(x + 1\right) \cdot \color{blue}{\left(1 + x\right)} - \left(x \cdot \log x + 1\right)
\] |
distribute-lft-in [=>]2.8 | \[ \color{blue}{\left(\log \left(x + 1\right) \cdot 1 + \log \left(x + 1\right) \cdot x\right)} - \left(x \cdot \log x + 1\right)
\] |
associate--l+ [=>]2.8 | \[ \color{blue}{\log \left(x + 1\right) \cdot 1 + \left(\log \left(x + 1\right) \cdot x - \left(x \cdot \log x + 1\right)\right)}
\] |
+-commutative [=>]2.8 | \[ \color{blue}{\left(\log \left(x + 1\right) \cdot x - \left(x \cdot \log x + 1\right)\right) + \log \left(x + 1\right) \cdot 1}
\] |
associate-+l- [=>]2.8 | \[ \color{blue}{\log \left(x + 1\right) \cdot x - \left(\left(x \cdot \log x + 1\right) - \log \left(x + 1\right) \cdot 1\right)}
\] |
associate--l+ [=>]2.8 | \[ \log \left(x + 1\right) \cdot x - \color{blue}{\left(x \cdot \log x + \left(1 - \log \left(x + 1\right) \cdot 1\right)\right)}
\] |
associate--l- [<=]2.8 | \[ \color{blue}{\left(\log \left(x + 1\right) \cdot x - x \cdot \log x\right) - \left(1 - \log \left(x + 1\right) \cdot 1\right)}
\] |
*-lft-identity [<=]2.8 | \[ \left(\color{blue}{\left(1 \cdot \log \left(x + 1\right)\right)} \cdot x - x \cdot \log x\right) - \left(1 - \log \left(x + 1\right) \cdot 1\right)
\] |
*-commutative [<=]2.8 | \[ \left(\color{blue}{\left(\log \left(x + 1\right) \cdot 1\right)} \cdot x - x \cdot \log x\right) - \left(1 - \log \left(x + 1\right) \cdot 1\right)
\] |
*-commutative [=>]2.8 | \[ \left(\left(\log \left(x + 1\right) \cdot 1\right) \cdot x - \color{blue}{\log x \cdot x}\right) - \left(1 - \log \left(x + 1\right) \cdot 1\right)
\] |
distribute-rgt-out-- [=>]2.6 | \[ \color{blue}{x \cdot \left(\log \left(x + 1\right) \cdot 1 - \log x\right)} - \left(1 - \log \left(x + 1\right) \cdot 1\right)
\] |
sub-neg [=>]2.6 | \[ x \cdot \color{blue}{\left(\log \left(x + 1\right) \cdot 1 + \left(-\log x\right)\right)} - \left(1 - \log \left(x + 1\right) \cdot 1\right)
\] |
Applied egg-rr1.6
Applied egg-rr1.6
Simplified0.4
[Start]1.6 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\frac{x + 1}{x} - 1\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
---|---|
*-lft-identity [<=]1.6 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\frac{\color{blue}{1 \cdot \left(x + 1\right)}}{x} - 1\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
associate-*l/ [<=]1.7 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\color{blue}{\frac{1}{x} \cdot \left(x + 1\right)} - 1\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
distribute-rgt-in [=>]1.7 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\color{blue}{\left(x \cdot \frac{1}{x} + 1 \cdot \frac{1}{x}\right)} - 1\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
rgt-mult-inverse [=>]1.6 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\left(\color{blue}{1} + 1 \cdot \frac{1}{x}\right) - 1\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
*-lft-identity [=>]1.6 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\left(1 + \color{blue}{\frac{1}{x}}\right) - 1\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
+-commutative [=>]1.6 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\color{blue}{\left(\frac{1}{x} + 1\right)} - 1\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
associate--l+ [=>]0.4 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\color{blue}{\frac{1}{x} + \left(1 - 1\right)}\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
metadata-eval [=>]0.4 | \[ \mathsf{fma}\left(x, \mathsf{log1p}\left(\frac{1}{x} + \color{blue}{0}\right), -1 + \mathsf{log1p}\left(x\right)\right)
\] |
Final simplification0.4
Alternative 1 | |
---|---|
Error | 2.4 |
Cost | 19776 |
Alternative 2 | |
---|---|
Error | 1.6 |
Cost | 19776 |
Alternative 3 | |
---|---|
Error | 37.8 |
Cost | 13508 |
Alternative 4 | |
---|---|
Error | 2.7 |
Cost | 13504 |
Alternative 5 | |
---|---|
Error | 2.7 |
Cost | 13504 |
Alternative 6 | |
---|---|
Error | 37.9 |
Cost | 7236 |
Alternative 7 | |
---|---|
Error | 38.0 |
Cost | 7236 |
Alternative 8 | |
---|---|
Error | 41.3 |
Cost | 7108 |
Alternative 9 | |
---|---|
Error | 43.4 |
Cost | 6980 |
Alternative 10 | |
---|---|
Error | 41.3 |
Cost | 6980 |
Alternative 11 | |
---|---|
Error | 41.3 |
Cost | 6980 |
Alternative 12 | |
---|---|
Error | 43.5 |
Cost | 6852 |
Alternative 13 | |
---|---|
Error | 48.8 |
Cost | 6656 |
Alternative 14 | |
---|---|
Error | 48.8 |
Cost | 6464 |
Alternative 15 | |
---|---|
Error | 58.9 |
Cost | 64 |
herbie shell --seed 1
(FPCore (x)
:name "(x+1)*log(x+1) - x*log(x) - 1"
:precision binary64
:pre (and (<= 0.01 x) (<= x 1000.0))
(- (- (* (+ x 1.0) (log (+ x 1.0))) (* x (log x))) 1.0))