Average Error: 39.2 → 0.1
Time: 55.8s
Precision: 64
Internal Precision: 1408
\[\log \left(1 + x\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;\log \left({x}^{3} + 1\right) - \left(\log \left({\left(x \cdot x\right)}^{3} + {\left(1 - x\right)}^{3}\right) - \log \left(\left(\left(1 - x\right) - x \cdot x\right) \cdot \left(1 - x\right) + \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \le -0.0024829857670106417:\\
\;\;\;\;\log \left({x}^{3} + 1\right) - \log \left(x \cdot x + \left(1 - x\right)\right)\\
\mathbf{if}\;\log \left({x}^{3} + 1\right) - \left(\log \left({\left(x \cdot x\right)}^{3} + {\left(1 - x\right)}^{3}\right) - \log \left(\left(\left(1 - x\right) - x \cdot x\right) \cdot \left(1 - x\right) + \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \le 0.0015651223709737463:\\
\;\;\;\;x - \left(\frac{1}{2} - x \cdot \frac{1}{3}\right) \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}\]
Target
| Original | 39.2 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;1 + x = 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \log \left(1 + x\right)}{\left(1 + x\right) - 1}\\
\end{array}\]
Derivation
- Split input into 3 regimes
if (- (log (+ (pow x 3) 1)) (- (log (+ (pow (* x x) 3) (pow (- 1 x) 3))) (log (+ (* (- (- 1 x) (* x x)) (- 1 x)) (* (* x x) (* x x)))))) < -0.0024829857670106417
Initial program 0.3
\[\log \left(1 + x\right)\]
- Using strategy
rm Applied flip3-+0.4
\[\leadsto \log \color{blue}{\left(\frac{{1}^{3} + {x}^{3}}{1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)}\right)}\]
Applied log-div1.1
\[\leadsto \color{blue}{\log \left({1}^{3} + {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)}\]
Applied simplify1.1
\[\leadsto \color{blue}{\log \left({x}^{3} + 1\right)} - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\]
Applied simplify1.1
\[\leadsto \log \left({x}^{3} + 1\right) - \color{blue}{\log \left(x \cdot x + \left(1 - x\right)\right)}\]
if -0.0024829857670106417 < (- (log (+ (pow x 3) 1)) (- (log (+ (pow (* x x) 3) (pow (- 1 x) 3))) (log (+ (* (- (- 1 x) (* x x)) (- 1 x)) (* (* x x) (* x x)))))) < 0.0015651223709737463
Initial program 59.1
\[\log \left(1 + x\right)\]
Taylor expanded around 0 0.1
\[\leadsto \color{blue}{\left(\frac{1}{3} \cdot {x}^{3} + x\right) - \frac{1}{2} \cdot {x}^{2}}\]
Applied simplify0.1
\[\leadsto \color{blue}{x - \left(\frac{1}{2} - x \cdot \frac{1}{3}\right) \cdot \left(x \cdot x\right)}\]
if 0.0015651223709737463 < (- (log (+ (pow x 3) 1)) (- (log (+ (pow (* x x) 3) (pow (- 1 x) 3))) (log (+ (* (- (- 1 x) (* x x)) (- 1 x)) (* (* x x) (* x x))))))
Initial program 0.0
\[\log \left(1 + x\right)\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1070991898 1055468627 4280279443 640792587 928206309 3646738750)'
(FPCore (x)
:name "ln(1 + x)"
:herbie-target
(if (== (+ 1 x) 1) x (/ (* x (log (+ 1 x))) (- (+ 1 x) 1)))
(log (+ 1 x)))