Average Error: 52.3 → 0.1
Time: 17.3s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0504041428544855:\\ \;\;\;\;\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.007939929311480388:\\ \;\;\;\;\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}^* + x}\right) + \log \left(\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.3
Target44.5
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.0504041428544855

    1. Initial program 61.6

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

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

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

    1. Initial program 58.8

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

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

    1. Initial program 30.1

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

      \[\leadsto \color{blue}{\log \left(\sqrt{x + \sqrt{1^2 + x^2}^*}\right) + \log \left(\sqrt{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.0504041428544855:\\ \;\;\;\;\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.007939929311480388:\\ \;\;\;\;\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}^* + x}\right) + \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right)\\ \end{array}\]

Reproduce

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

sample138.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 42.4b

localize8.0ms

Local error

Found 3 expressions with local error:

3.3b
(log (+ x (hypot 1 x)))
0.4b
(+ 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)

series241.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

157.0ms
(log (+ x (hypot 1 x)))
47.0ms
(+ x (hypot 1 x))
37.0ms
(hypot 1 x)

simplify1.9s

Counts
15 → 47
Calls

15 calls. Slowest were:

417.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
307.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
204.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))

prune346.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize34.0ms

Local error

Found 4 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.1b
(* 3/40 (pow x 5))
0.0b
(+ x (* 3/40 (pow x 5)))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 61
Calls

4 calls. Slowest were:

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

series162.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify1.1s

Counts
28 → 73
Calls

28 calls. Slowest were:

195.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
169.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))
125.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

prune605.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 4 expressions with local error:

3.4b
(log (sqrt (+ x (hypot 1 x))))
3.4b
(log (sqrt (+ x (hypot 1 x))))
0.4b
(+ x (hypot 1 x))
0.4b
(+ x (hypot 1 x))

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

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

series258.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

112.0ms
(log (sqrt (+ x (hypot 1 x))))
73.0ms
(log (sqrt (+ x (hypot 1 x))))
38.0ms
(+ x (hypot 1 x))
36.0ms
(+ x (hypot 1 x))

simplify1.5s

Counts
30 → 76
Calls

30 calls. Slowest were:

286.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
204.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
153.0ms
(- (+ (* 2 x) (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))

prune1.1s

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 4 expressions with local error:

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

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

series198.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

86.0ms
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
78.0ms
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
20.0ms
(/ -1/16 (pow x 5))
15.0ms
(/ (/ 1/8 x) (* x x))

simplify3.1s

Counts
44 → 91
Calls

44 calls. Slowest were:

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

prune882.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.0b

regimes66.0ms

Accuracy

99.7% (0.1b remaining)

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

bsearch85.0ms

end0.0ms

sample5.0s

Algorithm
intervals