Average Error: 52.3 → 0.1
Time: 16.1s
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}{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.007991014246427286:\\ \;\;\;\;\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.3
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.07332091780053

    1. Initial program 61.5

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

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. Using strategy rm
    4. Applied +-commutative60.7

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

    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.007991014246427286 < x

    1. Initial program 30.6

      \[\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 +-commutative0.1

      \[\leadsto \log \color{blue}{\left(\sqrt{1^2 + x^2}^* + x\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.07332091780053:\\ \;\;\;\;\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.007991014246427286:\\ \;\;\;\;\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 2019022 +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: 15.5s)Debug log

sample134.0ms

Algorithm
intervals
Results
68.0ms74×body1280valid
24.0ms47×body640valid
17.0ms26×body2560valid
9.0ms27×body320valid
6.0ms75×body80valid
2.0msbody160valid

simplify5.0ms

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 42.8b

localize9.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
Rules
add-cube-cbrt
add-exp-log
*-un-lft-identity
pow1
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-cbrt-cube
log-prod
expm1-log1p-u
flip-+
flip3-+
log-div
log-pow
rem-log-exp
hypot-udef
+-commutative
Counts
3 → 38
Calls
3 calls:
Slowest
1.0ms
(log (+ x (hypot 1 x)))
1.0ms
(+ x (hypot 1 x))
0.0ms
(hypot 1 x)

series505.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
349.0ms
(+ x (hypot 1 x))
130.0ms
(log (+ x (hypot 1 x)))
26.0ms
(hypot 1 x)

simplify1.7s

Counts
15 → 47
Calls
15 calls:
Slowest
379.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
261.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
210.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
210.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))
166.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))

prune325.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
associate-*r*
*-un-lft-identity
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
prod-diff
fma-neg
*-commutative
flip--
flip-+
associate--l+
unpow3
diff-log
flip3--
flip3-+
sub-neg
+-commutative
cube-mult
Counts
4 → 61
Calls
4 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))
1.0ms
(+ x (* 3/40 (pow x 5)))

series125.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
55.0ms
(+ x (* 3/40 (pow x 5)))
33.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
19.0ms
(* 1/6 (pow x 3))
18.0ms
(* 3/40 (pow x 5))

simplify1.0s

Counts
28 → 73
Calls
28 calls:
Slowest
167.0ms
(/ (exp (+ x (* 3/40 (pow x 5)))) (exp (* 1/6 (pow x 3))))
153.0ms
(fma 1 (+ x (* 3/40 (pow x 5))) (- (* (pow x 3) 1/6)))
138.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
114.0ms
(- (+ x (* 3/40 (pow x 5))) (* 1/6 (pow x 3)))
97.0ms
(fma (sqrt (+ x (* 3/40 (pow x 5)))) (sqrt (+ x (* 3/40 (pow x 5)))) (- (* (pow x 3) 1/6)))

prune676.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize10.0ms

Local error

Found 3 expressions with local error:

3.3b
(log (+ (hypot 1 x) x))
0.4b
(+ (hypot 1 x) x)
0.0b
(hypot 1 x)

rewrite10.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
pow1
add-log-exp
log1p-expm1-u
add-cbrt-cube
fma-def
log-prod
expm1-log1p-u
flip-+
flip3-+
log-div
log-pow
rem-log-exp
hypot-udef
+-commutative
Counts
3 → 41
Calls
3 calls:
Slowest
5.0ms
(+ (hypot 1 x) x)
4.0ms
(log (+ (hypot 1 x) x))
0.0ms
(hypot 1 x)

series188.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
118.0ms
(log (+ (hypot 1 x) x))
41.0ms
(+ (hypot 1 x) x)
29.0ms
(hypot 1 x)

simplify1.7s

Counts
17 → 50
Calls
17 calls:
Slowest
371.0ms
(- (+ (log 2) (* 1/4 (/ 1 (pow x 2)))) (+ (log (/ 1 x)) (* 3/32 (/ 1 (pow x 4)))))
241.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ (* 1/16 (/ 1 (pow x 5))) (* 1/2 (/ 1 x))))
203.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))
197.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
179.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))

prune440.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

localize39.0ms

Local error

Found 4 expressions with local error:

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

rewrite41.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
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)))
5.0ms
(/ (/ 1/8 x) (* x x))
1.0ms
(/ -1/16 (pow x 5))

series201.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
90.0ms
(log (+ (/ -1/2 x) (+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))))
72.0ms
(+ (/ -1/16 (pow x 5)) (/ (/ 1/8 x) (* x x)))
25.0ms
(/ -1/16 (pow x 5))
14.0ms
(/ (/ 1/8 x) (* x x))

simplify2.6s

Counts
44 → 91
Calls
44 calls:
Slowest
546.0ms
(/ (* (* (/ 1/8 x) (/ 1/8 x)) (/ 1/8 x)) (* (* (* x x) (* x x)) (* x x)))
326.0ms
(- (+ (* 6 (pow x 4)) (log -1/16)) (+ (* 2 (pow x 2)) (* 5 (log x))))
267.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)))))))
212.0ms
(- (+ (log (/ -1 x)) (+ (log 1/2) (* 3/32 (/ 1 (pow x 4))))) (* 1/4 (/ 1 (pow x 2))))
207.0ms
(log (+ (* -1/2 (* (pow x 5) (* x x))) (* x (+ (* -1/16 (* x x)) (* (pow x 5) (/ 1/8 x))))))

prune847.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes48.0ms

Accuracy

99.7% (0.1b remaining)

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

bsearch115.0ms

end0.0ms

sample4.7s

Algorithm
intervals
Results
2.2s2295×body1280valid
1.2s1557×body640valid
553.0ms787×body2560valid
331.0ms824×body320valid
216.0ms2164×body80valid
77.0ms373×body160valid