How to find a formula for the nth term of a sequence

Key Takeaways:
  • Discovered closed-form Fibonacci formula: floor(cosh(-0.111572 + 0.481212 * n))
  • Formula predicts first 30 Fibonacci numbers with perfect accuracy
  • Works on sequences where arithmetic/geometric formulas fail
  • GUI-based workflow—no programming required to find the formula

The Problem

Given the Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, ...), find a closed-form formula f(n) that computes the nth term without recursion.

TuringBot vs Manual Derivation

ApproachTuringBotManual / Wolfram Alpha
InputJust the sequence valuesMust know sequence type
AssumptionsNone—discovers form automaticallyMust guess functional form
Any OEIS sequenceYesOnly well-known types
Math expertise neededNoYes

Finding the Formula

Load fibonacci.txt (first 30 terms) into TuringBot:

1 1
2 1
3 2
4 3
5 5
6 8
7 13
8 21
9 34
10 55

A list of the first 30 terms can be found in this file: fibonacci.txt.

TuringBot takes as input TXT or CSV files with one variable per column and efficiently finds formulas that connect those variables. This is what it looks like after we load fibonacci.txt and run the optimization:

Finding a formula for the nth Fibonacci term with TuringBot.

The software finds not only a single formula but the best formulas of all possible complexities. A larger formula is only shown if it performs better than all simpler alternatives. In this case, the last formula turned out to predict with perfect accuracy every single one of the first 30 Fibonacci terms. The formula is the following:

f(x) = floor(cosh(-0.111572 + 0.481212 * x))

A very elegant solution. The same procedure can be used to find a formula for the nth term of any other sequence (if it exists).

Conclusion

In this tutorial, we have seen how the symbolic regression software TuringBot can be used to find a closed-form expression for the nth term in a sequence of numbers. We found a very short formula for the Fibonacci sequence by simply writing it into a text file with one number per row and loading this file into the software.

If you are interested in trying TuringBot your data, you can download it from the official website. It is available for both Windows and Linux.

About TuringBot

TuringBot finds mathematical formulas from data using symbolic regression. Load a CSV, select your target variable, and get interpretable equations—not black-box models.

Free version available for Windows, macOS, and Linux.