Average Error: 52.6 → 0.1
Time: 15.6s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0647793477551444:\\ \;\;\;\;\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.007223277181757343:\\ \;\;\;\;\left({x}^{5} \cdot \frac{3}{40} - {x}^{3} \cdot \frac{1}{6}\right) + x\\ \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.6
Target45.1
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.0647793477551444

    1. Initial program 61.7

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

      \[\leadsto \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.0647793477551444 < x < 0.007223277181757343

    1. Initial program 58.7

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

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

    1. Initial program 31.2

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

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

Reproduce

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

start183.0ms

Algorithm
intervals

setup25.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 46.2b

localize12.0ms

Local error

Found 2 expressions with local error:

4.8b
(log (+ x (hypot 1 x)))
0.0b
(+ x (hypot 1 x))

rewrite2.0ms

Algorithm
rewrite-expression-head
Counts
2 → 28
Calls

2 calls. Slowest were:

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

series157.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

114.0ms
(log (+ x (hypot 1 x)))
43.0ms
(+ x (hypot 1 x))

simplify1.3s

Counts
12 → 34
Calls

12 calls. Slowest were:

386.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
234.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))))

prune312.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 3 expressions with local error:

17.1b
(- (+ 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))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 49
Calls

3 calls. Slowest were:

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

series77.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

37.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:

189.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
143.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
141.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))

prune800.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize6.0ms

Local error

Found 3 expressions with local error:

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

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
3 → 44
Calls

3 calls. Slowest were:

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

series130.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

70.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))
34.0ms
(* 3/40 (pow x 5))
26.0ms
(* 1/6 (pow x 3))

simplify350.0ms

Counts
19 → 53
Calls

19 calls. Slowest were:

67.0ms
(fma 3/40 (pow x 5) (- (* (pow x 3) 1/6)))
60.0ms
(/ (exp (* 3/40 (pow x 5))) (exp (* 1/6 (pow x 3))))
56.0ms
(- (* 3/40 (pow x 5)) (* 1/6 (pow x 3)))

prune722.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize36.0ms

Local error

Found 4 expressions with local error:

22.8b
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
13.6b
(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))

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 79
Calls

4 calls. Slowest were:

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

series221.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

109.0ms
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
68.0ms
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
24.0ms
(/ (/ 1/8 x) (* x x))
19.0ms
(/ -1/16 (pow x 5))

simplify2.8s

Counts
44 → 91
Calls

44 calls. Slowest were:

583.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
319.0ms
(- (+ (* 6 (pow x 4)) (log -1/16)) (+ (* 2 (pow x 2)) (* 5 (log x))))
299.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)))))))

prune1.3s

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes47.0ms

Accuracy

99.7% (0.1b remaining)

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

bsearch136.0ms