Average Error: 31.2 → 0.3
Time: 21.6s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
\[\log \left((2 \cdot x + \left(\frac{\frac{-1}{2}}{x}\right))_* - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\]

Error

Bits error versus x

Derivation

  1. Initial program 31.2

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

    \[\leadsto \color{blue}{\log \left(x + \sqrt{(x \cdot x + -1)_*}\right)}\]
  3. Taylor expanded around inf 0.3

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

    \[\leadsto \log \color{blue}{\left((2 \cdot x + \left(\frac{\frac{-1}{2}}{x}\right))_* - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)}\]
  5. Final simplification0.3

    \[\leadsto \log \left((2 \cdot x + \left(\frac{\frac{-1}{2}}{x}\right))_* - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\]

Reproduce

herbie shell --seed 2019022 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-cosine"
  (log (+ x (sqrt (- (* x x) 1)))))

Details

Time bar (total: 21.2s)Debug log

sample92.0ms

Algorithm
intervals
Results
33.0ms235×body160nan
25.0ms518×body80nan
16.0ms256×body80valid

simplify96.0ms

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

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.9b

localize22.0ms

Local error

Found 3 expressions with local error:

29.7b
(sqrt (fma x x -1))
0.0b
(+ x (sqrt (fma x x -1)))
0.0b
(log (+ x (sqrt (fma x x -1))))

rewrite6.0ms

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

series127.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
73.0ms
(log (+ x (sqrt (fma x x -1))))
28.0ms
(+ x (sqrt (fma x x -1)))
27.0ms
(sqrt (fma x x -1))

simplify2.5s

Counts
19 → 51
Calls
19 calls:
Slowest
353.0ms
(- (+ (* 1/2 (/ (pow x 2) (sqrt -1))) (sqrt -1)) (* 1/8 (/ (pow x 4) (pow (sqrt -1) 3))))
320.0ms
(+ (log -1/2) (+ (log (/ -1 x)) (+ (* 3/32 (/ 1 (pow x 4))) (* 1/4 (/ 1 (pow x 2))))))
314.0ms
(log (- (* x x) (* (sqrt (fma x x -1)) (sqrt (fma x x -1)))))
279.0ms
(- (log 2) (+ (log (/ 1 x)) (+ (* 3/32 (/ 1 (pow x 4))) (* 1/4 (/ 1 (pow x 2))))))
274.0ms
(- (* 2 x) (+ (* 1/8 (/ 1 (pow x 3))) (* 1/2 (/ 1 x))))

prune405.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize32.0ms

Local error

Found 3 expressions with local error:

0.1b
(/ (/ 1/8 x) (* x x))
0.0b
(log (- (fma 2 x (/ -1/2 x)) (/ (/ 1/8 x) (* x x))))
0.0b
(- (fma 2 x (/ -1/2 x)) (/ (/ 1/8 x) (* x x)))

rewrite28.0ms

Algorithm
rewrite-expression-head
Rules
29×add-sqr-sqrt
25×*-un-lft-identity
24×prod-diff
21×add-cube-cbrt
18×times-frac
div-inv
add-exp-log
log-prod
add-log-exp
add-cbrt-cube
difference-of-squares
associate-/l*
pow1
log1p-expm1-u
fma-neg
expm1-log1p-u
distribute-lft-out--
flip--
flip3--
log-div
associate-/l/
fma-udef
log-pow
associate--l+
rem-log-exp
div-exp
diff-log
frac-2neg
sub-neg
associate-/r*
clear-num
cbrt-undiv
Counts
3 → 88
Calls
3 calls:
Slowest
10.0ms
(- (fma 2 x (/ -1/2 x)) (/ (/ 1/8 x) (* x x)))
9.0ms
(log (- (fma 2 x (/ -1/2 x)) (/ (/ 1/8 x) (* x x))))
6.0ms
(/ (/ 1/8 x) (* x x))

series148.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
103.0ms
(log (- (fma 2 x (/ -1/2 x)) (/ (/ 1/8 x) (* x x))))
27.0ms
(/ (/ 1/8 x) (* x x))
18.0ms
(- (fma 2 x (/ -1/2 x)) (/ (/ 1/8 x) (* x x)))

simplify12.6s

Counts
87 → 97
Calls
87 calls:
Slowest
764.0ms
(fma (- (/ 1 (* x x))) (/ 1/8 x) (* (/ 1 (* x x)) (/ 1/8 x)))
479.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
393.0ms
(fma (sqrt (fma 2 x (/ -1/2 x))) (sqrt (fma 2 x (/ -1/2 x))) (- (* (/ (/ 1/8 x) (* x x)) 1)))
389.0ms
(fma (- (/ (/ 1 x) x)) (/ 1/8 x) (* (/ (/ 1 x) x) (/ 1/8 x)))
380.0ms
(fma (- (/ (/ 1 x) x)) (/ 1/8 x) (* (/ (/ 1 x) x) (/ 1/8 x)))

prune871.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes35.0ms

Accuracy

0% (0.2b remaining)

Error of 0.3b against oracle of 0.1b and baseline of 0.3b

bsearch1.0ms

end0.0ms

sample4.2s

Algorithm
intervals
Results
1.7s16473×body80nan
1.4s7733×body160nan
736.0ms8000×body80valid