Average Error: 53.1 → 0.1
Time: 23.2s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.064344331483051:\\ \;\;\;\;\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.007255032243074975:\\ \;\;\;\;\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

Original53.1
Target44.9
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.064344331483051

    1. Initial program 62.1

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

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

    1. Initial program 58.6

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

      \[\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}}\]

    if 0.007255032243074975 < x

    1. Initial program 31.1

      \[\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.064344331483051:\\ \;\;\;\;\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.007255032243074975:\\ \;\;\;\;\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 2018365 +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: 17.1s)Debug log

start180.0ms

Algorithm
intervals

setup16.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 45.6b

localize10.0ms

Local error

Found 2 expressions with local error:

3.2b
(log (+ x (hypot 1 x)))
0.5b
(+ x (hypot 1 x))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 28
Calls

2 calls. Slowest were:

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

series182.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

144.0ms
(log (+ x (hypot 1 x)))
38.0ms
(+ x (hypot 1 x))

simplify1.5s

Counts
12 → 34
Calls

12 calls. Slowest were:

511.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
290.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
195.0ms
(- (+ (* 2 x) (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))

prune296.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize20.0ms

Local error

Found 3 expressions with local error:

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

rewrite8.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)))
1.0ms
(* 1/6 (pow x 3))
1.0ms
(* 3/40 (pow x 5))

series75.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify1.0s

Counts
25 → 58
Calls

25 calls. Slowest were:

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

prune759.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 4 expressions with local error:

22.5b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
22.5b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
22.5b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
13.6b
(cbrt (- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3))))

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 78
Calls

4 calls. Slowest were:

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

series224.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

138.0ms
(cbrt (- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3))))
33.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
28.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
25.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

simplify5.1s

Counts
44 → 90
Calls

44 calls. Slowest were:

531.0ms
(cbrt (- (pow (+ x (* 3/40 (pow x 5))) 3) (pow (* 1/6 (pow x 3)) 3)))
517.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
408.0ms
(cbrt (- (* (+ x (* 3/40 (pow x 5))) (+ x (* 3/40 (pow x 5)))) (* (* 1/6 (pow x 3)) (* 1/6 (pow x 3)))))

prune1.4s

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize32.0ms

Local error

Found 4 expressions with local error:

22.5b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
22.5b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
22.5b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
22.5b
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 84
Calls

4 calls. Slowest were:

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

series118.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

35.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
33.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
26.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
24.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

simplify3.9s

Counts
48 → 96
Calls

48 calls. Slowest were:

209.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))
180.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
154.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))

prune1.9s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.0b

regimes51.0ms

Accuracy

99.8% (0.1b remaining)

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

bsearch128.0ms