rsolve . nb (pt,  rifacimento dicembre 2002)

Equazioni alle differenze finite (Difference equations / Recurrence relations)

<< "DiscreteMath/RSolve.m"

?RSolve

Numeri naturali

r = RSolve[{a[n] == a[n - 1] + 1, a[0] == 0}, a[n], n]

f[n_] := 
      Evaluate[a[
            n] /. r[[1]]]

f[10]

Successione di Fibonacci

rfib = 
      RSolve[{fib[n] == fib[n - 1] + fib[n - 2], 
fib[0] == 
            1, fib[1] == 1}, fib[n], n]

fibon = 
        Simplify[
          fib[n] /. rfib[[1]]];

fibon

rFibon[n_] := Evaluate[N[fibon]]

rFibon[20]