Average Error: 29.2 → 22.0
Time: 26.2s
Precision: 64
Internal Precision: 128
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
\[\begin{array}{l} \mathbf{if}\;n \le -1803761.66460632:\\ \;\;\;\;\left(\frac{\frac{-1}{2}}{x} + 1\right) \cdot \left(\frac{1}{n} \cdot \frac{1}{x}\right) + \frac{\log x}{\left(x \cdot n\right) \cdot n}\\ \mathbf{elif}\;n \le 132140925.11752047:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\log \left(e^{\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n}}\right) + \frac{\frac{1}{n}}{x}\right) + \frac{\log x}{\left(x \cdot n\right) \cdot n}\\ \end{array}\]

Error

Bits error versus x

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if n < -1803761.66460632

    1. Initial program 44.5

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Taylor expanded around inf 32.6

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

      \[\leadsto \color{blue}{\frac{\log x}{n \cdot \left(n \cdot x\right)} + \left(\frac{\frac{\frac{-1}{2}}{x}}{n \cdot x} + \frac{1}{n \cdot x}\right)}\]
    4. Using strategy rm
    5. Applied associate-/r*32.0

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \left(\frac{\frac{\frac{-1}{2}}{x}}{n \cdot x} + \color{blue}{\frac{\frac{1}{n}}{x}}\right)\]
    6. Using strategy rm
    7. Applied div-inv32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \left(\frac{\frac{\frac{-1}{2}}{x}}{n \cdot x} + \color{blue}{\frac{1}{n} \cdot \frac{1}{x}}\right)\]
    8. Applied *-un-lft-identity32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \left(\frac{\color{blue}{1 \cdot \frac{\frac{-1}{2}}{x}}}{n \cdot x} + \frac{1}{n} \cdot \frac{1}{x}\right)\]
    9. Applied times-frac32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \left(\color{blue}{\frac{1}{n} \cdot \frac{\frac{\frac{-1}{2}}{x}}{x}} + \frac{1}{n} \cdot \frac{1}{x}\right)\]
    10. Applied distribute-lft-out32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \color{blue}{\frac{1}{n} \cdot \left(\frac{\frac{\frac{-1}{2}}{x}}{x} + \frac{1}{x}\right)}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \frac{1}{n} \cdot \left(\frac{\frac{\frac{-1}{2}}{x}}{x} + \color{blue}{1 \cdot \frac{1}{x}}\right)\]
    13. Applied div-inv32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \frac{1}{n} \cdot \left(\color{blue}{\frac{\frac{-1}{2}}{x} \cdot \frac{1}{x}} + 1 \cdot \frac{1}{x}\right)\]
    14. Applied distribute-rgt-out32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \frac{1}{n} \cdot \color{blue}{\left(\frac{1}{x} \cdot \left(\frac{\frac{-1}{2}}{x} + 1\right)\right)}\]
    15. Applied associate-*r*32.1

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \color{blue}{\left(\frac{1}{n} \cdot \frac{1}{x}\right) \cdot \left(\frac{\frac{-1}{2}}{x} + 1\right)}\]

    if -1803761.66460632 < n < 132140925.11752047

    1. Initial program 8.9

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]

    if 132140925.11752047 < n

    1. Initial program 44.2

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Taylor expanded around inf 32.1

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

      \[\leadsto \color{blue}{\frac{\log x}{n \cdot \left(n \cdot x\right)} + \left(\frac{\frac{\frac{-1}{2}}{x}}{n \cdot x} + \frac{1}{n \cdot x}\right)}\]
    4. Using strategy rm
    5. Applied associate-/r*31.5

      \[\leadsto \frac{\log x}{n \cdot \left(n \cdot x\right)} + \left(\frac{\frac{\frac{-1}{2}}{x}}{n \cdot x} + \color{blue}{\frac{\frac{1}{n}}{x}}\right)\]
    6. Using strategy rm
    7. Applied add-log-exp31.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \le -1803761.66460632:\\ \;\;\;\;\left(\frac{\frac{-1}{2}}{x} + 1\right) \cdot \left(\frac{1}{n} \cdot \frac{1}{x}\right) + \frac{\log x}{\left(x \cdot n\right) \cdot n}\\ \mathbf{elif}\;n \le 132140925.11752047:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\log \left(e^{\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n}}\right) + \frac{\frac{1}{n}}{x}\right) + \frac{\log x}{\left(x \cdot n\right) \cdot n}\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))

Details

Time bar (total: 25.1s)Debug log

sample345.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

5.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))

prune30.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.1b

localize18.0ms

Local error

Found 3 expressions with local error:

1.0b
(pow (+ x 1) (/ 1 n))
1.0b
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
0.3b
(pow x (/ 1 n))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 44
Calls

3 calls. Slowest were:

8.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
2.0ms
(pow (+ x 1) (/ 1 n))
1.0ms
(pow x (/ 1 n))

series354.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

181.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
106.0ms
(pow (+ x 1) (/ 1 n))
67.0ms
(pow x (/ 1 n))

simplify1.6s

Counts
28 → 53
Calls

28 calls. Slowest were:

597.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
291.0ms
(- (+ (/ (log -1) (* x (pow n 2))) (/ 1 (* x n))) (+ (* 1/2 (/ 1 (* (pow x 2) n))) (/ (log (/ -1 x)) (* x (pow n 2)))))
278.0ms
(- (/ 1 (* x n)) (+ (/ (log (/ 1 x)) (* x (pow n 2))) (* 1/2 (/ 1 (* (pow x 2) n)))))

prune593.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 20.3b

localize24.0ms

Local error

Found 4 expressions with local error:

2.5b
(+ (/ (/ -1/2 x) (* n x)) (/ 1 (* n x)))
1.0b
(/ 1 (* n x))
0.6b
(/ (log x) (* n (* n x)))
0.2b
(/ (/ -1/2 x) (* n x))

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

7.0ms
(+ (/ (/ -1/2 x) (* n x)) (/ 1 (* n x)))
3.0ms
(/ (log x) (* n (* n x)))
3.0ms
(/ (/ -1/2 x) (* n x))

series119.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

63.0ms
(/ (log x) (* n (* n x)))
37.0ms
(+ (/ (/ -1/2 x) (* n x)) (/ 1 (* n x)))
12.0ms
(/ (/ -1/2 x) (* n x))
6.0ms
(/ 1 (* n x))

simplify1.7s

Counts
46 → 84
Calls

46 calls. Slowest were:

628.0ms
(* -1 (/ (log (/ 1 x)) (* x (pow n 2))))
151.0ms
(- (/ 1 (* x n)) (* 1/2 (/ 1 (* (pow x 2) n))))
149.0ms
(- (/ 1 (* x n)) (* 1/2 (/ 1 (* (pow x 2) n))))

prune770.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 19.4b

localize16.0ms

Local error

Found 4 expressions with local error:

2.5b
(+ (/ (/ -1/2 x) (* n x)) (/ (/ 1 n) x))
0.6b
(/ (log x) (* n (* n x)))
0.2b
(/ (/ -1/2 x) (* n x))
0.2b
(/ (/ 1 n) x)

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

13.0ms
(+ (/ (/ -1/2 x) (* n x)) (/ (/ 1 n) x))
6.0ms
(/ (log x) (* n (* n x)))
5.0ms
(/ (/ -1/2 x) (* n x))

series148.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

98.0ms
(/ (log x) (* n (* n x)))
32.0ms
(+ (/ (/ -1/2 x) (* n x)) (/ (/ 1 n) x))
11.0ms
(/ (/ -1/2 x) (* n x))
6.0ms
(/ (/ 1 n) x)

simplify1.7s

Counts
43 → 82
Calls

43 calls. Slowest were:

560.0ms
(* -1 (/ (log (/ 1 x)) (* x (pow n 2))))
142.0ms
(* -1 (/ (- (log (/ -1 x)) (log -1)) (* x (pow n 2))))
129.0ms
(- (/ 1 (* x n)) (* 1/2 (/ 1 (* (pow x 2) n))))

prune812.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 19.4b

localize26.0ms

Local error

Found 4 expressions with local error:

4.0b
(* (/ 1 n) (+ (/ (/ -1/2 x) x) (/ 1 x)))
0.6b
(/ (log x) (* n (* n x)))
0.1b
(/ (/ -1/2 x) x)
0.1b
(* n (* n x))

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

19.0ms
(* (/ 1 n) (+ (/ (/ -1/2 x) x) (/ 1 x)))
6.0ms
(/ (log x) (* n (* n x)))
5.0ms
(/ (/ -1/2 x) x)

series128.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(/ (log x) (* n (* n x)))
37.0ms
(* (/ 1 n) (+ (/ (/ -1/2 x) x) (/ 1 x)))
11.0ms
(/ (/ -1/2 x) x)
10.0ms
(* n (* n x))

simplify3.2s

Counts
50 → 87
Calls

50 calls. Slowest were:

621.0ms
(* -1 (/ (log (/ 1 x)) (* x (pow n 2))))
619.0ms
(+ (* (/ (/ -1/2 x) x) (/ (/ -1/2 x) x)) (- (* (/ 1 x) (/ 1 x)) (* (/ (/ -1/2 x) x) (/ 1 x))))
246.0ms
(* n (+ (* (/ (/ -1/2 x) x) (/ (/ -1/2 x) x)) (- (* (/ 1 x) (/ 1 x)) (* (/ (/ -1/2 x) x) (/ 1 x)))))

prune897.0ms

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 19.4b

regimes516.0ms

Accuracy

85.2% (1.2b remaining)

Error of 22.0b against oracle of 20.7b and baseline of 29.2b

bsearch611.0ms

end0.0ms

sample11.4s

Algorithm
intervals