Average Error: 52.2 → 0.1
Time: 19.8s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0435353126017766:\\ \;\;\;\;\log \left(\frac{\frac{-1}{2}}{x} + \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} + \frac{\frac{-1}{16}}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.007938820784157252:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{3}{40}\right) - {x}^{3} \cdot \frac{1}{6}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{1^2 + x^2}^* + 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.2
Target44.6
Herbie0.1
\[\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.0435353126017766

    1. Initial program 61.7

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

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. Taylor expanded around -inf 0.2

      \[\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.2

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

    if -1.0435353126017766 < x < 0.007938820784157252

    1. Initial program 59.0

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Simplified59.0

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. Taylor expanded around 0 0.1

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

    if 0.007938820784157252 < x

    1. Initial program 30.1

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019002 +o rules:numerics
(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: 19.1s)Debug log

sample174.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 44.9b

localize8.0ms

Local error

Found 3 expressions with local error:

3.2b
(log (+ x (hypot 1 x)))
0.3b
(+ x (hypot 1 x))
0.0b
(hypot 1 x)

rewrite2.0ms

Algorithm
rewrite-expression-head
Counts
3 → 38
Calls

3 calls. Slowest were:

1.0ms
(log (+ x (hypot 1 x)))
1.0ms
(+ x (hypot 1 x))
0.0ms
(hypot 1 x)

series198.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

137.0ms
(log (+ x (hypot 1 x)))
31.0ms
(hypot 1 x)
30.0ms
(+ x (hypot 1 x))

simplify1.7s

Counts
15 → 47
Calls

15 calls. Slowest were:

361.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
295.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
214.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))

prune418.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize32.0ms

Local error

Found 3 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
3 → 49
Calls

3 calls. Slowest were:

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

series64.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

24.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
21.0ms
(* 3/40 (pow x 5))
19.0ms
(* 1/6 (pow x 3))

simplify1.1s

Counts
25 → 58
Calls

25 calls. Slowest were:

194.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))
128.0ms
(fma (sqrt (+ x (* 3/40 (pow x 5)))) (sqrt (+ x (* 3/40 (pow x 5)))) (- (* (pow x 3) 1/6)))
125.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))

prune580.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 4 expressions with local error:

3.2b
(log (* (cbrt (+ x (hypot 1 x))) (cbrt (+ x (hypot 1 x)))))
3.2b
(log (cbrt (+ x (hypot 1 x))))
0.3b
(+ x (hypot 1 x))
0.3b
(+ x (hypot 1 x))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

8.0ms
(log (* (cbrt (+ x (hypot 1 x))) (cbrt (+ x (hypot 1 x)))))
3.0ms
(log (cbrt (+ x (hypot 1 x))))
1.0ms
(+ x (hypot 1 x))

series584.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

293.0ms
(log (* (cbrt (+ x (hypot 1 x))) (cbrt (+ x (hypot 1 x)))))
228.0ms
(log (cbrt (+ x (hypot 1 x))))
34.0ms
(+ x (hypot 1 x))
30.0ms
(+ x (hypot 1 x))

simplify3.1s

Counts
35 → 83
Calls

35 calls. Slowest were:

336.0ms
(- (+ (* 1/3 (log (/ -1 x))) (+ (* 1/3 (log 1/2)) (* 1/32 (/ 1 (pow x 4))))) (* 1/12 (/ 1 (pow x 2))))
304.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
273.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))

prune764.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

localize24.0ms

Local error

Found 4 expressions with local error:

3.3b
(log (sqrt (cbrt (+ x (hypot 1 x)))))
3.3b
(log (sqrt (cbrt (+ x (hypot 1 x)))))
3.2b
(log (* (cbrt (+ x (hypot 1 x))) (cbrt (+ x (hypot 1 x)))))
0.3b
(+ x (hypot 1 x))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
4 → 85
Calls

4 calls. Slowest were:

6.0ms
(log (* (cbrt (+ x (hypot 1 x))) (cbrt (+ x (hypot 1 x)))))
2.0ms
(log (sqrt (cbrt (+ x (hypot 1 x)))))
2.0ms
(log (sqrt (cbrt (+ x (hypot 1 x)))))

series775.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

285.0ms
(log (sqrt (cbrt (+ x (hypot 1 x)))))
239.0ms
(log (sqrt (cbrt (+ x (hypot 1 x)))))
209.0ms
(log (* (cbrt (+ x (hypot 1 x))) (cbrt (+ x (hypot 1 x)))))
42.0ms
(+ x (hypot 1 x))

simplify3.6s

Counts
50 → 97
Calls

50 calls. Slowest were:

392.0ms
(- (+ (* 1/6 (log (/ -1 x))) (+ (* 1/6 (log 1/2)) (* 1/64 (/ 1 (pow x 4))))) (* 1/24 (/ 1 (pow x 2))))
338.0ms
(- (+ (* 1/6 (log (/ -1 x))) (+ (* 1/6 (log 1/2)) (* 1/64 (/ 1 (pow x 4))))) (* 1/24 (/ 1 (pow x 2))))
325.0ms
(- (+ (* 1/6 (log 2)) (* 1/24 (/ 1 (pow x 2)))) (+ (* 1/6 (log (/ 1 x))) (* 1/64 (/ 1 (pow x 4)))))

prune1.1s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes69.0ms

Accuracy

99.7% (0.1b remaining)

Error of 0.1b against oracle of 0.0b and baseline of 31.1b

bsearch140.0ms

end0.0ms

sample4.7s

Algorithm
intervals