Average Error: 63.0 → 0
Time: 11.4s
Precision: binary64
Cost: 6464
\[n > 6.8 \cdot 10^{+15}\]
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1\]
↓
\[\log n\]
\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1
↓
\log n
(FPCore (n)
:precision binary64
(- (- (* (+ n 1.0) (log (+ n 1.0))) (* n (log n))) 1.0))
↓
(FPCore (n) :precision binary64 (log n))
double code(double n) {
return (((n + 1.0) * log(n + 1.0)) - (n * log(n))) - 1.0;
}
↓
double code(double n) {
return log(n);
}
Try it out
Enter valid numbers for all inputs
Target
| Original | 63.0 |
|---|
| Target | 0 |
|---|
| Herbie | 0 |
|---|
\[\log \left(n + 1\right) - \left(\frac{1}{2 \cdot n} - \left(\frac{1}{3 \cdot \left(n \cdot n\right)} - \frac{4}{{n}^{3}}\right)\right)\]
Alternatives
| Alternative 1 |
|---|
| Error | 63.7 |
|---|
| Cost | 60352 |
|---|
\[\frac{{\left(\left(n + 1\right) \cdot \log \left(n + 1\right)\right)}^{3} - {\left(n \cdot \log n\right)}^{3}}{\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right) + \left(\left(n + 1\right) \cdot \log \left(n + 1\right)\right) \cdot \left(n \cdot \log n + \left(n + 1\right) \cdot \log \left(n + 1\right)\right)} - 1\]
| Alternative 2 |
|---|
| Error | 63.1 |
|---|
| Cost | 46976 |
|---|
\[\frac{\log \left(n + 1\right) \cdot \left(\log \left(n + 1\right) \cdot {\left(n + 1\right)}^{2}\right) - \left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)}{n \cdot \log n + \left(n + 1\right) \cdot \log \left(n + 1\right)} - 1\]
| Alternative 3 |
|---|
| Error | 61.8 |
|---|
| Cost | 46656 |
|---|
\[\left(\sqrt[3]{\left(n + 1\right) \cdot \log \left(n + 1\right)} \cdot \left(\sqrt[3]{\left(n + 1\right) \cdot \log \left(n + 1\right)} \cdot \sqrt[3]{\left(n + 1\right) \cdot \log \left(n + 1\right)}\right) - n \cdot \log n\right) - 1\]
| Alternative 4 |
|---|
| Error | 62.4 |
|---|
| Cost | 46144 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \sqrt[3]{n \cdot \log n} \cdot \left(\sqrt[3]{n \cdot \log n} \cdot \sqrt[3]{n \cdot \log n}\right)\right) - 1\]
| Alternative 5 |
|---|
| Error | 61.9 |
|---|
| Cost | 46144 |
|---|
\[\left(\sqrt[3]{\log \left(n + 1\right)} \cdot \left(\left(n + 1\right) \cdot \left(\sqrt[3]{\log \left(n + 1\right)} \cdot \sqrt[3]{\log \left(n + 1\right)}\right)\right) - n \cdot \log n\right) - 1\]
| Alternative 6 |
|---|
| Error | 62.3 |
|---|
| Cost | 45888 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \sqrt[3]{\log n} \cdot \left(n \cdot \left(\sqrt[3]{\log n} \cdot \sqrt[3]{\log n}\right)\right)\right) - 1\]
| Alternative 7 |
|---|
| Error | 62.3 |
|---|
| Cost | 45888 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \left(\sqrt{\log n} \cdot \sqrt{n}\right) \cdot \left(\sqrt{\log n} \cdot \sqrt{n}\right)\right) - 1\]
| Alternative 8 |
|---|
| Error | 62.1 |
|---|
| Cost | 40000 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(\sqrt[3]{n + 1} \cdot \sqrt[3]{n + 1}\right) + \left(\left(n + 1\right) \cdot \log \left(\sqrt[3]{n + 1}\right) - n \cdot \log n\right)\right) - 1\]
| Alternative 9 |
|---|
| Error | 62.5 |
|---|
| Cost | 33472 |
|---|
\[\left(\left(\left(n + 1\right) \cdot \left(\log \left(\sqrt[3]{n + 1}\right) \cdot 2\right) + \left(n + 1\right) \cdot \log \left(\sqrt[3]{n + 1}\right)\right) - n \cdot \log n\right) - 1\]
| Alternative 10 |
|---|
| Error | 62.5 |
|---|
| Cost | 33344 |
|---|
\[\left(\sqrt{\left(n + 1\right) \cdot \log \left(n + 1\right)} \cdot \sqrt{\left(n + 1\right) \cdot \log \left(n + 1\right)} - n \cdot \log n\right) - 1\]
| Alternative 11 |
|---|
| Error | 63.0 |
|---|
| Cost | 33344 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(\sqrt{n + 1}\right) + \left(\left(n + 1\right) \cdot \log \left(\sqrt{n + 1}\right) - n \cdot \log n\right)\right) - 1\]
| Alternative 12 |
|---|
| Error | 61.9 |
|---|
| Cost | 33344 |
|---|
\[\left(\left(\sqrt[3]{n + 1} \cdot \sqrt[3]{n + 1}\right) \cdot \left(\log \left(n + 1\right) \cdot \sqrt[3]{n + 1}\right) - n \cdot \log n\right) - 1\]
| Alternative 13 |
|---|
| Error | 62.2 |
|---|
| Cost | 33216 |
|---|
\[\left(\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \left(2 \cdot \log \left(\sqrt[3]{n}\right)\right)\right) - n \cdot \log \left(\sqrt[3]{n}\right)\right) - 1\]
| Alternative 14 |
|---|
| Error | 62.6 |
|---|
| Cost | 33216 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \left(n \cdot \left(2 \cdot \log \left(\sqrt[3]{n}\right)\right) + n \cdot \log \left(\sqrt[3]{n}\right)\right)\right) - 1\]
| Alternative 15 |
|---|
| Error | 62.5 |
|---|
| Cost | 33088 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \sqrt{n \cdot \log n} \cdot \sqrt{n \cdot \log n}\right) - 1\]
| Alternative 16 |
|---|
| Error | 62.4 |
|---|
| Cost | 33088 |
|---|
\[\left(\sqrt{\log \left(n + 1\right)} \cdot \left(\left(n + 1\right) \cdot \sqrt{\log \left(n + 1\right)}\right) - n \cdot \log n\right) - 1\]
| Alternative 17 |
|---|
| Error | 62.4 |
|---|
| Cost | 33088 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \left(\sqrt[3]{n} \cdot \sqrt[3]{n}\right) \cdot \left(\log n \cdot \sqrt[3]{n}\right)\right) - 1\]
| Alternative 18 |
|---|
| Error | 62.4 |
|---|
| Cost | 32960 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \sqrt{\log n} \cdot \left(n \cdot \sqrt{\log n}\right)\right) - 1\]
| Alternative 19 |
|---|
| Error | 62.5 |
|---|
| Cost | 26688 |
|---|
\[\left(\sqrt{n + 1} \cdot \left(\log \left(n + 1\right) \cdot \sqrt{n + 1}\right) - n \cdot \log n\right) - 1\]
| Alternative 20 |
|---|
| Error | 62.4 |
|---|
| Cost | 26560 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \sqrt{n} \cdot \left(\log n \cdot \sqrt{n}\right)\right) - 1\]
| Alternative 21 |
|---|
| Error | 63.5 |
|---|
| Cost | 26496 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - \sqrt[3]{{\left(n \cdot \log n\right)}^{3}}\right) - 1\]
| Alternative 22 |
|---|
| Error | 63.3 |
|---|
| Cost | 26496 |
|---|
\[\left(\sqrt[3]{{\left(\left(n + 1\right) \cdot \log \left(n + 1\right)\right)}^{3}} - n \cdot \log n\right) - 1\]
| Alternative 23 |
|---|
| Error | 62.0 |
|---|
| Cost | 26432 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - e^{\log \left(n \cdot \log n\right)}\right) - 1\]
| Alternative 24 |
|---|
| Error | 61.9 |
|---|
| Cost | 26432 |
|---|
\[\left(e^{\log \left(\left(n + 1\right) \cdot \log \left(n + 1\right)\right)} - n \cdot \log n\right) - 1\]
| Alternative 25 |
|---|
| Error | 63.0 |
|---|
| Cost | 26432 |
|---|
\[e^{\log \left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right)} - 1\]
| Alternative 26 |
|---|
| Error | 63.5 |
|---|
| Cost | 20608 |
|---|
\[\left(\frac{\log \left(n + 1\right) \cdot \left(1 + {n}^{3}\right)}{n \cdot n + \left(1 - n\right)} - n \cdot \log n\right) - 1\]
| Alternative 27 |
|---|
| Error | 63.3 |
|---|
| Cost | 14016 |
|---|
\[\left(\frac{\log \left(n + 1\right) \cdot \left(n \cdot n - 1\right)}{n - 1} - n \cdot \log n\right) - 1\]
| Alternative 28 |
|---|
| Error | 63.0 |
|---|
| Cost | 13632 |
|---|
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1\]
| Alternative 29 |
|---|
| Error | 63.3 |
|---|
| Cost | 6848 |
|---|
\[\left(n - n \cdot \log n\right) - 1\]
| Alternative 30 |
|---|
| Error | 0.0 |
|---|
| Cost | 6720 |
|---|
\[\left(1 + \log n\right) - 1\]
| Alternative 31 |
|---|
| Error | 55.0 |
|---|
| Cost | 64 |
|---|
\[1\]
| Alternative 32 |
|---|
| Error | 62.0 |
|---|
| Cost | 64 |
|---|
\[0\]
| Alternative 33 |
|---|
| Error | 63.0 |
|---|
| Cost | 64 |
|---|
\[-1\]
Error

Derivation
Initial program 63.0
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1\]
Taylor expanded around inf 0.0
\[\leadsto \color{blue}{\left(1 - \log \left(\frac{1}{n}\right)\right)} - 1\]
Simplified0.0
\[\leadsto \color{blue}{\left(1 + \log n\right)} - 1\]
- Using strategy
rm Applied add-log-exp_binary64_17750.0
\[\leadsto \left(1 + \log n\right) - \color{blue}{\log \left(e^{1}\right)}\]
Applied add-log-exp_binary64_17750.0
\[\leadsto \left(\color{blue}{\log \left(e^{1}\right)} + \log n\right) - \log \left(e^{1}\right)\]
Applied sum-log_binary64_18270.1
\[\leadsto \color{blue}{\log \left(e^{1} \cdot n\right)} - \log \left(e^{1}\right)\]
Applied diff-log_binary64_18280.1
\[\leadsto \color{blue}{\log \left(\frac{e^{1} \cdot n}{e^{1}}\right)}\]
Simplified0
\[\leadsto \log \color{blue}{n}\]
Simplified0
\[\leadsto \color{blue}{\log n}\]
Final simplification0
\[\leadsto \log n\]
Reproduce
herbie shell --seed 2021042
(FPCore (n)
:name "logs (example 3.8)"
:precision binary64
:pre (> n 6.8e+15)
:herbie-target
(- (log (+ n 1.0)) (- (/ 1.0 (* 2.0 n)) (- (/ 1.0 (* 3.0 (* n n))) (/ 4.0 (pow n 3.0)))))
(- (- (* (+ n 1.0) (log (+ n 1.0))) (* n (log n))) 1.0))