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

    1. Initial program 61.9

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

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

      \[\leadsto \log \left(x + \color{blue}{\sqrt{\sqrt{1^2 + x^2}^*} \cdot \sqrt{\sqrt{1^2 + x^2}^*}}\right)\]
    5. 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)}\]
    6. 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.0817179295038961 < x < 0.008008469962328969

    1. Initial program 58.7

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

      \[\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.008008469962328969 < x

    1. Initial program 30.9

      \[\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 add-sqr-sqrt0.1

      \[\leadsto \log \left(x + \color{blue}{\sqrt{\sqrt{1^2 + x^2}^*} \cdot \sqrt{\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.0817179295038961:\\ \;\;\;\;\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.008008469962328969:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{3}{40}\right) - {x}^{3} \cdot \frac{1}{6}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{\sqrt{1^2 + x^2}^*} \cdot \sqrt{\sqrt{1^2 + x^2}^*} + x\right)\\ \end{array}\]

Reproduce

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

sample130.0ms

Algorithm
intervals

simplify8.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune15.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 46.7b

localize17.0ms

Local error

Found 3 expressions with local error:

3.3b
(log (+ x (hypot 1 x)))
0.5b
(+ x (hypot 1 x))
0.0b
(hypot 1 x)

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
3 → 38
Calls

3 calls. Slowest were:

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

series188.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

118.0ms
(log (+ x (hypot 1 x)))
35.0ms
(hypot 1 x)
35.0ms
(+ x (hypot 1 x))

simplify1.6s

Counts
15 → 47
Calls

15 calls. Slowest were:

402.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
217.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
198.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))

prune339.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize27.0ms

Local error

Found 3 expressions with local error:

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
3 → 49
Calls

3 calls. Slowest were:

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

series86.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify892.0ms

Counts
25 → 58
Calls

25 calls. Slowest were:

146.0ms
(fma (sqrt (+ x (* 3/40 (pow x 5)))) (sqrt (+ x (* 3/40 (pow x 5)))) (- (* (pow x 3) 1/6)))
143.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
133.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

prune619.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize10.0ms

Local error

Found 4 expressions with local error:

5.9b
(+ x (* (sqrt (hypot 1 x)) (sqrt (hypot 1 x))))
3.3b
(log (+ x (* (sqrt (hypot 1 x)) (sqrt (hypot 1 x)))))
0.2b
(* (sqrt (hypot 1 x)) (sqrt (hypot 1 x)))
0.0b
(hypot 1 x)

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

5.0ms
(* (sqrt (hypot 1 x)) (sqrt (hypot 1 x)))
2.0ms
(+ x (* (sqrt (hypot 1 x)) (sqrt (hypot 1 x))))
1.0ms
(log (+ x (* (sqrt (hypot 1 x)) (sqrt (hypot 1 x)))))

series235.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

135.0ms
(log (+ x (* (sqrt (hypot 1 x)) (sqrt (hypot 1 x)))))
45.0ms
(+ x (* (sqrt (hypot 1 x)) (sqrt (hypot 1 x))))
29.0ms
(hypot 1 x)
26.0ms
(* (sqrt (hypot 1 x)) (sqrt (hypot 1 x)))

simplify2.2s

Counts
39 → 82
Calls

39 calls. Slowest were:

371.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
262.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
219.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))

prune709.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize33.0ms

Local error

Found 4 expressions with local error:

19.8b
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
12.3b
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
0.2b
(/ -1/16 (pow x 5))
0.1b
(/ (/ 1/8 x) (* x x))

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 79
Calls

4 calls. Slowest were:

17.0ms
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
6.0ms
(/ (/ 1/8 x) (* x x))
6.0ms
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))

series209.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

97.0ms
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
67.0ms
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
28.0ms
(/ -1/16 (pow x 5))
17.0ms
(/ (/ 1/8 x) (* x x))

simplify2.8s

Counts
44 → 91
Calls

44 calls. Slowest were:

476.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
324.0ms
(- (+ (* 6 (pow x 4)) (log -1/16)) (+ (* 2 (pow x 2)) (* 5 (log x))))
322.0ms
(log (+ (* -1/2 (- (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))) (* x (- (* (/ -1/16 (pow x 5)) (/ -1/16 (pow x 5))) (* (/ (/ 1/8 x) (* x x)) (/ (/ 1/8 x) (* x x)))))))

prune873.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes32.0ms

Accuracy

99.8% (0.1b remaining)

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

bsearch142.0ms

end0.0ms

sample4.5s

Algorithm
intervals