Average Error: 52.7 → 0.2
Time: 21.3s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0523035624951123:\\ \;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} + \left(\frac{\frac{-1}{2}}{x} - \frac{\frac{1}{16}}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.9529990917264621:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{3}{40}\right) - {x}^{3} \cdot \frac{1}{6}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\left(\frac{\frac{1}{2}}{x} + x\right) - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right) + x\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original52.7
Target45.3
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt 0:\\ \;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \sqrt{x \cdot x + 1}\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.0523035624951123

    1. Initial program 61.9

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Initial simplification61.9

      \[\leadsto \log \left(x + \sqrt{x \cdot x + 1}\right)\]
    3. Taylor expanded around -inf 0.1

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

      \[\leadsto \log \color{blue}{\left(\left(\frac{\frac{-1}{2}}{x} - \frac{\frac{1}{16}}{{x}^{5}}\right) + \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)}\]

    if -1.0523035624951123 < x < 0.9529990917264621

    1. Initial program 58.5

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Initial simplification58.5

      \[\leadsto \log \left(x + \sqrt{x \cdot x + 1}\right)\]
    3. Taylor expanded around 0 0.2

      \[\leadsto \color{blue}{\left(x + \frac{3}{40} \cdot {x}^{5}\right) - \frac{1}{6} \cdot {x}^{3}}\]

    if 0.9529990917264621 < x

    1. Initial program 31.8

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Initial simplification31.8

      \[\leadsto \log \left(x + \sqrt{x \cdot x + 1}\right)\]
    3. Taylor expanded around inf 0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.0523035624951123:\\ \;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} + \left(\frac{\frac{-1}{2}}{x} - \frac{\frac{1}{16}}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.9529990917264621:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{3}{40}\right) - {x}^{3} \cdot \frac{1}{6}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\left(\frac{\frac{1}{2}}{x} + x\right) - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right) + x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2018360 
(FPCore (x)
  :name "Hyperbolic arcsine"

  :herbie-target
  (if (< x 0) (log (/ -1 (- x (sqrt (+ (* x x) 1))))) (log (+ x (sqrt (+ (* x x) 1)))))

  (log (+ x (sqrt (+ (* x x) 1)))))

Details

Time bar (total: 15.3s)Debug log

start184.0ms

Algorithm
intervals

setup21.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 53.4b

localize27.0ms

Local error

Found 3 expressions with local error:

14.5b
(sqrt (+ (* x x) 1))
2.7b
(log (+ x (sqrt (+ (* x x) 1))))
0.7b
(+ x (sqrt (+ (* x x) 1)))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
3 → 38
Calls

3 calls. Slowest were:

15.0ms
(+ x (sqrt (+ (* x x) 1)))
4.0ms
(sqrt (+ (* x x) 1))
3.0ms
(log (+ x (sqrt (+ (* x x) 1))))

series164.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

109.0ms
(log (+ x (sqrt (+ (* x x) 1))))
37.0ms
(+ x (sqrt (+ (* x x) 1)))
18.0ms
(sqrt (+ (* x x) 1))

simplify1.7s

Counts
21 → 47
Calls

21 calls. Slowest were:

443.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
395.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
117.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))

prune585.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize26.0ms

Local error

Found 3 expressions with local error:

18.2b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
0.1b
(* 1/6 (pow x 3))
0.1b
(* 3/40 (pow x 5))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

8.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
1.0ms
(* 1/6 (pow x 3))
1.0ms
(* 3/40 (pow x 5))

series91.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

32.0ms
(* 3/40 (pow x 5))
30.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
29.0ms
(* 1/6 (pow x 3))

simplify392.0ms

Counts
17 → 46
Calls

17 calls. Slowest were:

141.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
71.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
65.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

prune622.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize39.0ms

Local error

Found 4 expressions with local error:

13.1b
(log (+ x (- (+ x (/ 1/2 x)) (/ (/ 1/8 x) (* x x)))))
0.1b
(/ (/ 1/8 x) (* x x))
0.0b
(- (+ x (/ 1/2 x)) (/ (/ 1/8 x) (* x x)))
0.0b
(+ x (/ 1/2 x))

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

10.0ms
(- (+ x (/ 1/2 x)) (/ (/ 1/8 x) (* x x)))
6.0ms
(log (+ x (- (+ x (/ 1/2 x)) (/ (/ 1/8 x) (* x x)))))
5.0ms
(/ (/ 1/8 x) (* x x))

series131.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

71.0ms
(log (+ x (- (+ x (/ 1/2 x)) (/ (/ 1/8 x) (* x x)))))
23.0ms
(/ (/ 1/8 x) (* x x))
21.0ms
(+ x (/ 1/2 x))
16.0ms
(- (+ x (/ 1/2 x)) (/ (/ 1/8 x) (* x x)))

simplify4.0s

Counts
40 → 76
Calls

40 calls. Slowest were:

783.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
522.0ms
(log (+ (pow x 3) (pow (- (+ x (/ 1/2 x)) (/ (/ 1/8 x) (* x x))) 3)))
392.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))

prune878.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize27.0ms

Local error

Found 4 expressions with local error:

21.8b
(+ (- (/ -1/2 x) (/ 1/16 (pow x 5))) (/ (/ 1/8 x) (* x x)))
15.3b
(log (+ (- (/ -1/2 x) (/ 1/16 (pow x 5))) (/ (/ 1/8 x) (* x x))))
0.1b
(/ (/ 1/8 x) (* x x))
0.1b
(/ 1/16 (pow x 5))

rewrite51.0ms

Algorithm
rewrite-expression-head
Counts
4 → 74
Calls

4 calls. Slowest were:

34.0ms
(+ (- (/ -1/2 x) (/ 1/16 (pow x 5))) (/ (/ 1/8 x) (* x x)))
11.0ms
(log (+ (- (/ -1/2 x) (/ 1/16 (pow x 5))) (/ (/ 1/8 x) (* x x))))
3.0ms
(/ (/ 1/8 x) (* x x))

series191.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

117.0ms
(log (+ (- (/ -1/2 x) (/ 1/16 (pow x 5))) (/ (/ 1/8 x) (* x x))))
32.0ms
(+ (- (/ -1/2 x) (/ 1/16 (pow x 5))) (/ (/ 1/8 x) (* x x)))
26.0ms
(/ 1/16 (pow x 5))
16.0ms
(/ (/ 1/8 x) (* x x))

simplify4.5s

Counts
51 → 86
Calls

51 calls. Slowest were:

463.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
405.0ms
(- (+ (log (/ 1 x)) (+ (* 3/32 (/ 1 (pow x 4))) (log -1/2))) (* 1/4 (/ 1 (pow x 2))))
396.0ms
(* (+ (* (/ -1/2 x) (/ -1/2 x)) (+ (* (/ 1/16 (pow x 5)) (/ 1/16 (pow x 5))) (* (/ -1/2 x) (/ 1/16 (pow x 5))))) (* x x))

prune1.2s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.0b

regimes167.0ms

Accuracy

99.5% (0.2b remaining)

Error of 0.2b against oracle of 0.0b and baseline of 30.7b

bsearch150.0ms