Average Error: 52.3 → 0.2
Time: 18.3s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.07332091780053:\\ \;\;\;\;\log \left(\frac{\frac{-1}{16}}{{x}^{5}} - \left(\frac{\frac{1}{2}}{x} - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\right)\\ \mathbf{elif}\;x \le 0.9631561982799212:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{3}{40}\right) - {x}^{3} \cdot \frac{1}{6}\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \left(\frac{\frac{\frac{-1}{8}}{x}}{x \cdot x} + \left(x + \frac{\frac{1}{2}}{x}\right)\right)\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.9
Herbie0.2
\[\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.07332091780053

    1. Initial program 61.5

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. 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)}\]
    3. Simplified0.2

      \[\leadsto \log \color{blue}{\left(\frac{\frac{-1}{16}}{{x}^{5}} - \left(\frac{\frac{1}{2}}{x} - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\right)}\]

    if -1.07332091780053 < x < 0.9631561982799212

    1. Initial program 58.7

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Taylor expanded around 0 0.2

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

    if 0.9631561982799212 < x

    1. Initial program 30.8

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Taylor expanded around inf 0.3

      \[\leadsto \log \left(x + \color{blue}{\left(\left(x + \frac{1}{2} \cdot \frac{1}{x}\right) - \frac{1}{8} \cdot \frac{1}{{x}^{3}}\right)}\right)\]
    3. Simplified0.3

      \[\leadsto \log \left(x + \color{blue}{\left(\left(x + \frac{\frac{1}{2}}{x}\right) + \frac{\frac{\frac{-1}{8}}{x}}{x \cdot x}\right)}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.07332091780053:\\ \;\;\;\;\log \left(\frac{\frac{-1}{16}}{{x}^{5}} - \left(\frac{\frac{1}{2}}{x} - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\right)\\ \mathbf{elif}\;x \le 0.9631561982799212:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{3}{40}\right) - {x}^{3} \cdot \frac{1}{6}\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \left(\frac{\frac{\frac{-1}{8}}{x}}{x \cdot x} + \left(x + \frac{\frac{1}{2}}{x}\right)\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019022 
(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.6s)Debug log

sample119.0ms

Algorithm
intervals
Results
59.0ms74×body1280valid
22.0ms47×body640valid
16.0ms26×body2560valid
8.0ms27×body320valid
5.0ms75×body80valid
1.0msbody160valid

simplify4.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
3.0ms
(log (+ x (sqrt (+ (* x x) 1))))

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 50.1b

localize23.0ms

Local error

Found 3 expressions with local error:

13.6b
(sqrt (+ (* x x) 1))
3.3b
(log (+ x (sqrt (+ (* x x) 1))))
0.4b
(+ x (sqrt (+ (* x x) 1)))

rewrite27.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-exp-log
pow1
add-log-exp
flip-+
sqrt-prod
add-cbrt-cube
flip3-+
log-prod
sqrt-div
log-div
log-pow
rem-log-exp
pow1/2
rem-sqrt-square
+-commutative
Counts
3 → 38
Calls
3 calls:
Slowest
22.0ms
(log (+ x (sqrt (+ (* x x) 1))))
2.0ms
(+ x (sqrt (+ (* x x) 1)))
2.0ms
(sqrt (+ (* x x) 1))

series186.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
126.0ms
(log (+ x (sqrt (+ (* x x) 1))))
35.0ms
(+ x (sqrt (+ (* x x) 1)))
25.0ms
(sqrt (+ (* x x) 1))

simplify1.6s

Counts
21 → 47
Calls
21 calls:
Slowest
397.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
254.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
135.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
126.0ms
(sqrt (- (* (* x x) (* x x)) (* 1 1)))
122.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))

prune383.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0b

localize33.0ms

Local error

Found 4 expressions with local error:

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

rewrite15.0ms

Algorithm
rewrite-expression-head
Rules
associate-*r*
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1
*-commutative
flip--
flip-+
associate--l+
unpow3
diff-log
flip3--
flip3-+
sub-neg
+-commutative
cube-mult
Counts
4 → 47
Calls
4 calls:
Slowest
8.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))
2.0ms
(+ x (* 3/40 (pow x 5)))

series146.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
50.0ms
(+ x (* 3/40 (pow x 5)))
36.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
31.0ms
(* 3/40 (pow x 5))
29.0ms
(* 1/6 (pow x 3))

simplify382.0ms

Counts
20 → 59
Calls
20 calls:
Slowest
121.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
85.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
66.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
62.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
5.0ms
(sqrt (pow x 3))

prune472.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0b

localize20.0ms

Local error

Found 4 expressions with local error:

13.1b
(log (+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x)))))
0.2b
(+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x)))
0.1b
(/ (/ -1/8 x) (* x x))
0.0b
(+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x))))

rewrite31.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
add-cube-cbrt
add-exp-log
add-sqr-sqrt
add-log-exp
add-cbrt-cube
pow1
associate-/l*
flip-+
times-frac
flip3-+
div-inv
log-prod
frac-add
log-div
+-commutative
associate-/l/
distribute-lft-out
log-pow
rem-log-exp
div-exp
frac-2neg
sum-log
associate-/r*
clear-num
associate-+r+
associate-+l+
cbrt-undiv
Counts
4 → 62
Calls
4 calls:
Slowest
12.0ms
(+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x)))
8.0ms
(log (+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x)))))
6.0ms
(+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x))))
5.0ms
(/ (/ -1/8 x) (* x x))

series128.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
71.0ms
(log (+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x)))))
22.0ms
(+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x))))
20.0ms
(/ (/ -1/8 x) (* x x))
15.0ms
(+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x)))

simplify3.8s

Counts
37 → 74
Calls
37 calls:
Slowest
639.0ms
(log (+ (pow x 3) (pow (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x))) 3)))
506.0ms
(/ (* (* (/ -1/8 x) (/ -1/8 x)) (/ -1/8 x)) (* (* (* x x) (* x x)) (* x x)))
403.0ms
(- (+ (log -2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ -1 x)) (* 3/32 (/ 1 (pow x 4)))))
271.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
236.0ms
(- (log -1/8) (+ (* 4 (pow x 2)) (+ (* 24 (pow x 4)) (* 3 (log x)))))

prune604.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0b

localize18.0ms

Local error

Found 4 expressions with local error:

20.6b
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
15.1b
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
0.3b
(/ -1/16 (pow x 5))
0.2b
(- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))

rewrite54.0ms

Algorithm
rewrite-expression-head
Rules
18×*-un-lft-identity
14×add-sqr-sqrt
11×add-log-exp
frac-sub
distribute-lft-out--
add-cube-cbrt
log-prod
flip--
add-exp-log
flip3--
log-div
pow1
difference-of-squares
diff-log
add-cbrt-cube
sub-neg
associate-/r*
associate--r+
associate--r-
div-inv
log-pow
rem-log-exp
times-frac
frac-2neg
clear-num
Counts
4 → 71
Calls
4 calls:
Slowest
23.0ms
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
22.0ms
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
7.0ms
(- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))
1.0ms
(/ -1/16 (pow x 5))

series189.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
94.0ms
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
37.0ms
(- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))
33.0ms
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
24.0ms
(/ -1/16 (pow x 5))

simplify4.0s

Counts
50 → 83
Calls
50 calls:
Slowest
327.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
318.0ms
(- (+ (log (/ 1 x)) (+ (* 3/32 (/ 1 (pow x 4))) (log -1/2))) (* 1/4 (/ 1 (pow x 2))))
278.0ms
(* (pow x 5) (+ (* (/ 1/2 x) (/ 1/2 x)) (+ (* (/ (/ 1/8 x) (* x x)) (/ (/ 1/8 x) (* x x))) (* (/ 1/2 x) (/ (/ 1/8 x) (* x x))))))
240.0ms
(- (* -1/16 (+ (/ 1/2 x) (/ (/ 1/8 x) (* x x)))) (* (pow x 5) (- (* (/ 1/2 x) (/ 1/2 x)) (* (/ (/ 1/8 x) (* x x)) (/ (/ 1/8 x) (* x x))))))
233.0ms
(log (- (* -1/16 (* x (* x x))) (* (pow x 5) (- (* 1/2 (* x x)) (* x (/ 1/8 x))))))

prune741.0ms

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0b

regimes40.0ms

Accuracy

99.4% (0.2b remaining)

Error of 0.2b against oracle of 0.0b and baseline of 31.1b

bsearch156.0ms

end0.0ms

sample4.5s

Algorithm
intervals
Results
2.3s2295×body1280valid
817.0ms1557×body640valid
605.0ms787×body2560valid
312.0ms824×body320valid
226.0ms2164×body80valid
69.0ms373×body160valid