Average Error: 52.4 → 0.1
Time: 19.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}{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.007171326267842194:\\ \;\;\;\;\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

Original52.4
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.0758538884884035

    1. Initial program 61.7

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

    1. Initial program 58.9

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

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

    1. Initial program 30.3

      \[\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. Recombined 3 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.0758538884884035:\\ \;\;\;\;\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.007171326267842194:\\ \;\;\;\;\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 2019010 +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: 18.5s)Debug log

sample185.0ms

Algorithm
intervals

simplify9.0ms

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

prune15.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 48.8b

localize17.0ms

Local error

Found 2 expressions with local error:

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

rewrite4.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
add-exp-log
*-un-lft-identity
log-prod
pow1
add-sqr-sqrt
add-log-exp
log1p-expm1-u
flip-+
add-cbrt-cube
flip3-+
log-div
expm1-log1p-u
log-pow
rem-log-exp
+-commutative
Counts
2 → 28
Calls
2 calls:
Slowest
2.0ms
(log (+ x (hypot 1 x)))
1.0ms
(+ x (hypot 1 x))

series225.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
176.0ms
(log (+ x (hypot 1 x)))
49.0ms
(+ x (hypot 1 x))

simplify1.4s

Counts
12 → 34
Calls
12 calls:
Slowest
439.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
239.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
196.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
170.0ms
(- (+ (* 2 x) (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
137.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))

prune335.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Rules
associate-*r*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-exp-log
prod-diff
fma-neg
add-cbrt-cube
pow1
expm1-log1p-u
*-commutative
flip--
associate--l+
unpow3
diff-log
flip3--
sub-neg
cube-mult
Counts
3 → 49
Calls
3 calls:
Slowest
6.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))

series74.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
32.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
23.0ms
(* 1/6 (pow x 3))
19.0ms
(* 3/40 (pow x 5))

simplify1.0s

Counts
25 → 58
Calls
25 calls:
Slowest
149.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))
147.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
131.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
111.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
110.0ms
(fma (sqrt (+ x (* 3/40 (pow x 5)))) (sqrt (+ x (* 3/40 (pow x 5)))) (- (* (pow x 3) 1/6)))

prune552.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize46.0ms

Local error

Found 4 expressions with local error:

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

rewrite31.0ms

Algorithm
rewrite-expression-head
Rules
16×*-un-lft-identity
add-cube-cbrt
add-sqr-sqrt
add-exp-log
add-log-exp
add-cbrt-cube
div-inv
frac-add
log-prod
log-div
pow1
associate-/l*
distribute-lft-out
log1p-expm1-u
times-frac
fma-def
associate-/r*
expm1-log1p-u
flip-+
flip3-+
frac-2neg
clear-num
associate-/l/
log-pow
rem-log-exp
div-exp
sum-log
+-commutative
cbrt-undiv
Counts
4 → 79
Calls
4 calls:
Slowest
16.0ms
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
10.0ms
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
3.0ms
(/ (/ 1/8 x) (* x x))
0.0ms
(/ -1/16 (pow x 5))

series184.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
79.0ms
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
49.0ms
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
30.0ms
(/ -1/16 (pow x 5))
26.0ms
(/ (/ 1/8 x) (* x x))

simplify3.0s

Counts
44 → 91
Calls
44 calls:
Slowest
561.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
382.0ms
(- (+ (* 6 (pow x 4)) (log -1/16)) (+ (* 2 (pow x 2)) (* 5 (log x))))
301.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)))))))
256.0ms
(log (+ (* -1/2 (* (pow x 5) (* x x))) (* x (+ (* -1/16 (* x x)) (* (pow x 5) (/ 1/8 x))))))
221.0ms
(log (- (* (/ -1/2 x) (/ -1/2 x)) (* (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x))) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x))))))

prune924.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.0b

localize38.0ms

Local error

Found 4 expressions with local error:

15.4b
(log (+ (* x x) (- (* (hypot 1 x) (hypot 1 x)) (* x (hypot 1 x)))))
12.3b
(+ (pow x 3) (pow (hypot 1 x) 3))
9.3b
(log (+ (pow x 3) (pow (hypot 1 x) 3)))
4.9b
(- (* (hypot 1 x) (hypot 1 x)) (* x (hypot 1 x)))

rewrite45.0ms

Algorithm
rewrite-expression-head
Rules
11×*-un-lft-identity
add-log-exp
log-prod
add-cube-cbrt
add-sqr-sqrt
add-exp-log
pow1
fma-def
log1p-expm1-u
add-cbrt-cube
log-div
expm1-log1p-u
flip-+
flip3-+
distribute-lft-out
sum-cubes
log-pow
rem-log-exp
flip--
prod-diff
unpow3
diff-log
fma-neg
distribute-rgt-out--
flip3--
sub-neg
sum-log
+-commutative
cube-mult
Counts
4 → 71
Calls
4 calls:
Slowest
14.0ms
(log (+ (* x x) (- (* (hypot 1 x) (hypot 1 x)) (* x (hypot 1 x)))))
13.0ms
(- (* (hypot 1 x) (hypot 1 x)) (* x (hypot 1 x)))
10.0ms
(+ (pow x 3) (pow (hypot 1 x) 3))
7.0ms
(log (+ (pow x 3) (pow (hypot 1 x) 3)))

series454.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
188.0ms
(log (+ (* x x) (- (* (hypot 1 x) (hypot 1 x)) (* x (hypot 1 x)))))
136.0ms
(log (+ (pow x 3) (pow (hypot 1 x) 3)))
68.0ms
(- (* (hypot 1 x) (hypot 1 x)) (* x (hypot 1 x)))
62.0ms
(+ (pow x 3) (pow (hypot 1 x) 3))

simplify3.8s

Counts
39 → 83
Calls
39 calls:
Slowest
639.0ms
(log (- (* (pow x 3) (pow x 3)) (* (pow (hypot 1 x) 3) (pow (hypot 1 x) 3))))
529.0ms
(- (+ (log 3/2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ -1 x)) (* 7/96 (/ 1 (pow x 4)))))
310.0ms
(- (+ (log 3) (* 1/2 (/ 1 (pow x 2)))) (+ (* 2 (log (/ -1 x))) (* 1/6 (/ 1 (pow x 4)))))
301.0ms
(log (+ (pow (* x x) 3) (pow (- (* (hypot 1 x) (hypot 1 x)) (* x (hypot 1 x))) 3)))
210.0ms
(- (* 1/16 (/ 1 (pow x 3))) (+ (* 3/2 x) (* 3/8 (/ 1 x))))

prune1.1s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes61.0ms

Accuracy

99.7% (0.1b remaining)

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

bsearch142.0ms

end0.0ms

sample4.8s

Algorithm
intervals