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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original52.5
Target44.6
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.0431269623985902

    1. Initial program 61.7

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. 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)}\]
    3. Simplified0.1

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

    if -1.0431269623985902 < x < 0.9641901334977748

    1. Initial program 58.5

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

      \[\leadsto \color{blue}{\left(x + \frac{3}{40} \cdot {x}^{5}\right) - \frac{1}{6} \cdot {x}^{3}}\]
    3. Using strategy rm
    4. Applied associate--l+0.3

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

    if 0.9641901334977748 < x

    1. Initial program 31.5

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

      \[\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)\]
    3. Simplified0.3

      \[\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.0431269623985902:\\ \;\;\;\;\log \left(\frac{\frac{-1}{16}}{{x}^{5}} - \left(\frac{\frac{1}{2}}{x} - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\right)\\ \mathbf{elif}\;x \le 0.9641901334977748:\\ \;\;\;\;\left({x}^{5} \cdot \frac{3}{40} - {x}^{3} \cdot \frac{1}{6}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \left(\frac{\frac{\frac{-1}{8}}{x}}{x \cdot x} + \left(x + \frac{\frac{1}{2}}{x}\right)\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019004 
(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

sample123.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 52.5b

localize25.0ms

Local error

Found 3 expressions with local error:

17.7b
(sqrt (+ (* x x) 1))
2.0b
(log (+ x (sqrt (+ (* x x) 1))))
0.9b
(+ x (sqrt (+ (* x x) 1)))

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
3 → 38
Calls

3 calls. Slowest were:

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

series203.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

144.0ms
(log (+ x (sqrt (+ (* x x) 1))))
35.0ms
(+ x (sqrt (+ (* x x) 1)))
24.0ms
(sqrt (+ (* x x) 1))

simplify1.5s

Counts
21 → 47
Calls

21 calls. Slowest were:

368.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
205.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
174.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))

prune418.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 3 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

4.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))

series69.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

27.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
27.0ms
(* 3/40 (pow x 5))
15.0ms
(* 1/6 (pow x 3))

simplify369.0ms

Counts
17 → 46
Calls

17 calls. Slowest were:

122.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
87.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
80.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

prune407.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 3 expressions with local error:

21.5b
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))
0.3b
(* 1/6 (pow x 3))
0.1b
(* 3/40 (pow x 5))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 36
Calls

3 calls. Slowest were:

6.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))
2.0ms
(* 1/6 (pow x 3))
2.0ms
(* 3/40 (pow x 5))

series123.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

79.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))
24.0ms
(* 1/6 (pow x 3))
20.0ms
(* 3/40 (pow x 5))

simplify193.0ms

Counts
17 → 45
Calls

17 calls. Slowest were:

69.0ms
(/ (exp (* 3/40 (pow x 5))) (exp (* 1/6 (pow x 3))))
45.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))
24.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))

prune432.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.0b

localize19.0ms

Local error

Found 4 expressions with local error:

17.4b
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
12.4b
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
0.1b
(/ (/ 1/8 x) (* x x))
0.1b
(/ -1/16 (pow x 5))

rewrite53.0ms

Algorithm
rewrite-expression-head
Counts
4 → 77
Calls

4 calls. Slowest were:

24.0ms
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
21.0ms
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
6.0ms
(/ (/ 1/8 x) (* x x))

series179.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

90.0ms
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
42.0ms
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
26.0ms
(/ (/ 1/8 x) (* x x))
20.0ms
(/ -1/16 (pow x 5))

simplify5.0s

Counts
54 → 89
Calls

54 calls. Slowest were:

490.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
426.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
373.0ms
(log (+ (sqrt (/ -1/16 (pow x 5))) (sqrt (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))))

prune792.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.0b

regimes213.0ms

Accuracy

99.4% (0.2b remaining)

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

bsearch123.0ms

end0.0ms

sample5.0s

Algorithm
intervals