# Some integer sequences

Integer sequences can be observed very often in mathematics and programming. In trying to understand the behavior of a function, we gradually increase the size of the input and observe how the output varies in terms of execution time. Ideally, we want this time to be independent from the input size. We can examine what this means for inputs of size n and n+1. If n is a small number, then the difference might seem small, even negligible, but as soon as n grows large, code execution starts to take much longer. We can say that the limits of our programs and the quality of our code become visible only after the system has been stressed.

One of the most flexible ways to alter the behavior of a program is by doing numeric computation. Recurrences like those used in the Fibonacci numbers (F(n) = F(n-1) + F(n-2)) let us describe a number in terms of other numbers. Then, altering the behavior of a program becomes the same thing as altering the sequence of numbers. The growth/shrink rate of numbers introduces dynamics that lets us explore a wide variety of alternatives. We can take many integer sequences and say that a new one must be formed from operations on their elements. We can let a sequence grow faster in a certain range, but then use another sequence to seek a balance or to more slowly converge to a certain value.

What if we used floating point numbers instead of integers? We can do it, but operating on such numbers can lead to errors that are hard to find. A tiny error, when multiplied this way can lead to very different results from those we expected. Numbers with many decimal places usually take more memory than simple integers and they also tend to be slower to compute.

Having a sequence of numbers enables us to specify an action through them. If the meaning of those numbers was angles, we could use them to rotate a line in a certain way until we get a beautiful net of lines. In this case, the numbers themselves have become a design element; the net is just a visual object that reflects this. If the meaning of the numbers was coordinates, we could use them to describe how an object would react after colliding with another. If we imagine the collision in slow motion, we could clearly see the individual states of a sequence. The difference between any two subsequent states before and after doesn’t need to be the same—the object could have hit a wooden surface causing it to decrease speed, or it could have hit a trampoline causing it to increase it. In both cases, moving in the opposite direction would have been described by a number with an opposite sign—either positive or negative. If the numbers in the sequence described an intensity of color, depending on the growth rate, we could have been able to selectively apply varying colors to different parts of an image—an idea used in the generation of fractals. If the numbers meant a distance between every two nodes on a network, we would have been able to find the shortest path from A to B.

Studying integer sequences isn’t a task reserved for great mathematicians only; it enables us to understand why numerical expressions behave in a certain way. Knowing the growth rate of various complexities isn’t enough to create better ways to manipulate numbers. And if we do the wrong computations, we are just wasting CPU cycles.

The Online Encyclopedia of Integer Sequences(OEIS) has a large collection of integer sequences that have appeared in various problems. They are provided as long lists of numbers that can be used by anyone. But simply having a collection of numbers doesn’t enable us to see clearly the ways in which a sequence could possibly behave. We can search for more dynamic ways to experience the numbers that create a better context for what each of them might mean. The easiest thing to do is to plot these sequences and see whether we have missed some subtle behaviors that would have been hard to find in the forest of digits. With a negligibly small subset of sequences, the answer to this is slightly surprising. bit.ly/WgQJGx