Average Error: 39.0 → 0.2
Time: 11.1s
Precision: 64
Internal Precision: 128
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le 0.0001756469204950462:\\ \;\;\;\;x - \left(x \cdot x\right) \cdot \left(\frac{1}{2} - \frac{1}{3} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{x + 1}\right) + \log \left(\sqrt{x + 1}\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < 0.0001756469204950462

    1. Initial program 58.7

      \[\log \left(1 + x\right)\]
    2. Taylor expanded around 0 0.2

      \[\leadsto \color{blue}{\left(x + \frac{1}{3} \cdot {x}^{3}\right) - \frac{1}{2} \cdot {x}^{2}}\]
    3. Simplified0.2

      \[\leadsto \color{blue}{x - \left(x \cdot x\right) \cdot \left(\frac{1}{2} - \frac{1}{3} \cdot x\right)}\]

    if 0.0001756469204950462 < x

    1. Initial program 0.0

      \[\log \left(1 + x\right)\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.1

      \[\leadsto \log \color{blue}{\left(\sqrt{1 + x} \cdot \sqrt{1 + x}\right)}\]
    4. Applied log-prod0.1

      \[\leadsto \color{blue}{\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 0.0001756469204950462:\\ \;\;\;\;x - \left(x \cdot x\right) \cdot \left(\frac{1}{2} - \frac{1}{3} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{x + 1}\right) + \log \left(\sqrt{x + 1}\right)\\ \end{array}\]

Reproduce

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (x)
  :name "log(1+x)"
  (log (+ 1 x)))

Details

Time bar (total: 5.6s)Debug log

start209.0ms

Algorithm
intervals

setup61.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 40.7b

localize20.0ms

Local error

Found 1 expressions with local error:

4.1b
(log (+ 1 x))

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
1 → 14
Calls

1 calls. Slowest were:

5.0ms
(log (+ 1 x))

series60.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

59.0ms
(log (+ 1 x))

simplify1.1s

Counts
9 → 17
Calls

9 calls. Slowest were:

540.0ms
(- (+ (/ 1 x) (log -1)) (+ (log (/ -1 x)) (* 1/2 (/ 1 (pow x 2)))))
273.0ms
(- (/ 1 x) (+ (* 1/2 (/ 1 (pow x 2))) (log (/ 1 x))))
203.0ms
(- (+ x (* 1/3 (pow x 3))) (* 1/2 (pow x 2)))

prune199.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize29.0ms

Local error

Found 3 expressions with local error:

0.3b
(* 1/3 x)
0.0b
(* (* x x) (- 1/2 (* 1/3 x)))
0.0b
(- x (* (* x x) (- 1/2 (* 1/3 x))))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
3 → 44
Calls

3 calls. Slowest were:

9.0ms
(* (* x x) (- 1/2 (* 1/3 x)))
3.0ms
(- x (* (* x x) (- 1/2 (* 1/3 x))))
1.0ms
(* 1/3 x)

series81.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

48.0ms
(* (* x x) (- 1/2 (* 1/3 x)))
20.0ms
(- x (* (* x x) (- 1/2 (* 1/3 x))))
12.0ms
(* 1/3 x)

simplify3.1s

Counts
25 → 53
Calls

25 calls. Slowest were:

1.3s
(* (* (* (* x x) (* x x)) (* x x)) (* (* (- 1/2 (* 1/3 x)) (- 1/2 (* 1/3 x))) (- 1/2 (* 1/3 x))))
199.0ms
(- (+ x (* 1/3 (pow x 3))) (* 1/2 (pow x 2)))
195.0ms
(- (+ x (* 1/3 (pow x 3))) (* 1/2 (pow x 2)))

prune659.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.0b

regimes86.0ms

Accuracy

99.5% (0.1b remaining)

Error of 0.2b against oracle of 0.1b and baseline of 20.7b

bsearch66.0ms