Average Error: 52.4 → 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.0758538884884035:\\ \;\;\;\;\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.9596366603743689:\\ \;\;\;\;\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.4
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.0758538884884035

    1. Initial program 61.7

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

    1. Initial program 58.8

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

    1. Initial program 30.4

      \[\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.0758538884884035:\\ \;\;\;\;\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.9596366603743689:\\ \;\;\;\;\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 2019010 
(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.7s)Debug log

sample149.0ms

Algorithm
intervals

simplify3.0ms

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 53.6b

localize23.0ms

Local error

Found 3 expressions with local error:

12.6b
(sqrt (+ (* x x) 1))
2.3b
(log (+ x (sqrt (+ (* x x) 1))))
0.5b
(+ x (sqrt (+ (* x x) 1)))

rewrite10.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
4.0ms
(sqrt (+ (* x x) 1))
3.0ms
(log (+ x (sqrt (+ (* x x) 1))))
3.0ms
(+ x (sqrt (+ (* x x) 1)))

series164.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
111.0ms
(log (+ x (sqrt (+ (* x x) 1))))
27.0ms
(sqrt (+ (* x x) 1))
26.0ms
(+ x (sqrt (+ (* x x) 1)))

simplify1.6s

Counts
21 → 47
Calls
21 calls:
Slowest
424.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
272.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
171.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
141.0ms
(- (+ (* 2 x) (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
112.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))

prune442.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite7.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--
associate--l+
unpow3
diff-log
flip3--
sub-neg
cube-mult
Counts
3 → 37
Calls
3 calls:
Slowest
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))

series96.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
36.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
34.0ms
(* 3/40 (pow x 5))
26.0ms
(* 1/6 (pow x 3))

simplify444.0ms

Counts
17 → 46
Calls
17 calls:
Slowest
165.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
83.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
78.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
60.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
11.0ms
(* 1/6 (pow x 3))

prune412.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 4 expressions with local error:

20.2b
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
12.1b
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
0.1b
(/ (/ 1/8 x) (* x x))
0.0b
(/ -1/16 (pow x 5))

rewrite39.0ms

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

series148.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
82.0ms
(log (- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x)))))
27.0ms
(- (/ -1/16 (pow x 5)) (- (/ 1/2 x) (/ (/ 1/8 x) (* x x))))
21.0ms
(/ -1/16 (pow x 5))
18.0ms
(/ (/ 1/8 x) (* x x))

simplify4.7s

Counts
54 → 89
Calls
54 calls:
Slowest
613.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
357.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
299.0ms
(log (- (* -1/16 (* x (* x x))) (* (pow x 5) (- (* 1/2 (* x x)) (* x (/ 1/8 x))))))
292.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))))))
274.0ms
(- (+ (log (/ 1 x)) (+ (* 3/32 (/ 1 (pow x 4))) (log -1/2))) (* 1/4 (/ 1 (pow x 2))))

prune886.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

9.9b
(log (+ x (+ (+ 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))))
0.0b
(+ x (/ 1/2 x))

rewrite15.0ms

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

series188.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
117.0ms
(log (+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x)))))
26.0ms
(/ (/ -1/8 x) (* x x))
25.0ms
(+ x (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x))))
19.0ms
(+ x (/ 1/2 x))

simplify3.0s

Counts
31 → 69
Calls
31 calls:
Slowest
994.0ms
(log (+ (pow x 3) (pow (+ (+ x (/ 1/2 x)) (/ (/ -1/8 x) (* x x))) 3)))
541.0ms
(/ (* (* (/ -1/8 x) (/ -1/8 x)) (/ -1/8 x)) (* (* (* x x) (* x x)) (* x x)))
331.0ms
(- (+ (log -2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ -1 x)) (* 3/32 (/ 1 (pow x 4)))))
266.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
250.0ms
(- (log -1/8) (+ (* 4 (pow x 2)) (+ (* 24 (pow x 4)) (* 3 (log x)))))

prune525.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.0b

regimes34.0ms

Accuracy

99.5% (0.2b remaining)

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

bsearch124.0ms

end0.0ms

sample4.6s

Algorithm
intervals