A short investigation of the Virahanka-Fibonacci Numbers. Additional details on C-finite sequences in Sage can be found in the documentation.

*Requirements: None*

In [1]:

```
# Define the ring of C-finite sequences over the rationals
C.<z> = CFiniteSequences(QQ)
print(C)
```

The ring of C-Finite sequences in z over Rational Field

In [2]:

```
# C-finite sequences can be defined by their recurrence and initial conditions
fib = C.from_recurrence([1,1],[1,1]) # Recurrence v_{n+2} = v_{n+1} + v_n with v_0 = v_1 = 1
fib
```

Out[2]:

C-finite sequence, generated by -1/(z^2 + z - 1)

In [3]:

```
# C-finite sequences can also be defined by their rational generating function
fib2 = C('1/(1-z-z^2)')
print(fib2)
print(fib==fib2)
```

C-finite sequence, generated by -1/(z^2 + z - 1) True

In [4]:

```
# Series truncations can be computed from the sequence
fib.series(10)
```

Out[4]:

1 + x + 2*x^2 + 3*x^3 + 5*x^4 + 8*x^5 + 13*x^6 + 21*x^7 + 34*x^8 + 55*x^9 + O(x^10)

In [5]:

```
# Sequence terms can also be accessed directly
print([fib[k] for k in range(10)])
print(fib[1000])
```

In [6]:

```
# Sage can find the closed form of the sequence (corresponding to Theorem 2.3 in the textbook)
show(fib.closed_form())
```

In [7]:

```
# Sage can also guess a C-recurrence from a list of initial values
C.guess([1,1,2,3,5,8])
```

Out[7]:

C-finite sequence, generated by -1/(x^2 + x - 1)

In [ ]:

```
```