Average Error: 52.7 → 0.1
Time: 13.4s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.072687741282904:\\ \;\;\;\;\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.00772616579663237:\\ \;\;\;\;\left({x}^{5} \cdot \frac{3}{40} - {x}^{3} \cdot \frac{1}{6}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\log \left((e^{\log_* (1 + e^{\log \left(\sqrt{1^2 + x^2}^* + x\right)})} - 1)^*\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.0
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.072687741282904

    1. Initial program 61.8

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

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\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(\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.072687741282904 < x < 0.00772616579663237

    1. Initial program 58.5

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

      \[\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}}\]
    4. Using strategy rm
    5. Applied associate--l+0.1

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

    if 0.00772616579663237 < x

    1. Initial program 32.0

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

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. Using strategy rm
    4. Applied expm1-log1p-u0.1

      \[\leadsto \log \color{blue}{\left((e^{\log_* (1 + \left(x + \sqrt{1^2 + x^2}^*\right))} - 1)^*\right)}\]
    5. Using strategy rm
    6. Applied add-exp-log0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.072687741282904:\\ \;\;\;\;\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.00772616579663237:\\ \;\;\;\;\left({x}^{5} \cdot \frac{3}{40} - {x}^{3} \cdot \frac{1}{6}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\log \left((e^{\log_* (1 + e^{\log \left(\sqrt{1^2 + x^2}^* + x\right)})} - 1)^*\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019007 +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: 12.8s)Debug log

sample141.0ms

Algorithm
intervals

simplify9.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune14.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 42.0b

localize17.0ms

Local error

Found 3 expressions with local error:

4.6b
(log (+ x (hypot 1 x)))
0.7b
(+ x (hypot 1 x))
0.0b
(hypot 1 x)

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
3 → 38
Calls

3 calls. Slowest were:

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

series196.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

135.0ms
(log (+ x (hypot 1 x)))
37.0ms
(+ x (hypot 1 x))
24.0ms
(hypot 1 x)

simplify1.7s

Counts
15 → 47
Calls

15 calls. Slowest were:

367.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
266.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
193.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))

prune324.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
3 → 49
Calls

3 calls. Slowest were:

9.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
3.0ms
(* 1/6 (pow x 3))
2.0ms
(* 3/40 (pow x 5))

series97.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.0s

Counts
25 → 58
Calls

25 calls. Slowest were:

166.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))
148.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
144.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

prune431.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize5.0ms

Local error

Found 3 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
3 → 44
Calls

3 calls. Slowest were:

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

series117.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

70.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))
32.0ms
(* 3/40 (pow x 5))
15.0ms
(* 1/6 (pow x 3))

simplify319.0ms

Counts
19 → 53
Calls

19 calls. Slowest were:

66.0ms
(/ (exp (* 3/40 (pow x 5))) (exp (* 1/6 (pow x 3))))
53.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))
50.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))

prune556.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize19.0ms

Local error

Found 4 expressions with local error:

29.9b
(log (expm1 (log1p (+ x (hypot 1 x)))))
1.6b
(expm1 (log1p (+ x (hypot 1 x))))
0.7b
(+ x (hypot 1 x))
0.0b
(hypot 1 x)

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
Calls

4 calls. Slowest were:

2.0ms
(log (expm1 (log1p (+ x (hypot 1 x)))))
1.0ms
(+ x (hypot 1 x))
0.0ms
(expm1 (log1p (+ x (hypot 1 x))))

series411.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

216.0ms
(log (expm1 (log1p (+ x (hypot 1 x)))))
111.0ms
(expm1 (log1p (+ x (hypot 1 x))))
49.0ms
(+ x (hypot 1 x))
36.0ms
(hypot 1 x)

simplify2.0s

Counts
16 → 59
Calls

16 calls. Slowest were:

488.0ms
(- (+ (exp (- (log 2) (log (/ 1 x)))) (+ (* 1/2 (/ (exp (- (log 2) (log (/ 1 x)))) x)) (* 1/4 (/ (exp (- (log 2) (log (/ 1 x)))) (pow x 2))))) 1)
273.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
225.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))

prune479.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

regimes42.0ms

Accuracy

99.8% (0.1b remaining)

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

bsearch99.0ms

end0.0ms

sample4.7s

Algorithm
intervals