# Formula for sequnaces

Posted 8 years ago
4122 Views
|
2 Replies
|
2 Total Likes
|
 I have developed a formula, that given ANY sequance of N numbers, will output a mathematical function that has them.for Instanse: 26,25,192will return a function that:f(1) = 26f(2) = 25f(3) = 192Are you in wolfram interested at that?btw, My formula returns a nasty thing, that when inputed to wolfram: "Simplify function" it returns often a more beautiful thing.
2 Replies
Sort By:
Posted 8 years ago
 Hi there,I guess that you should be a bit more specific about what you mean. Finding a formula that produces any given sequence of numbers is trivial, see:http://community.wolfram.com/groups/-/m/t/320638In fact it is easy to see that there is an infinite number of possible solutions. Heres is one. For any given sequence, e.g. seq={26,25,192} you can define: f[list_List, t_] := Floor[InterpolatingPolynomial[list, t]] That reproduces the entries of the input sequence and then calculates as many further entries as you wish. Table[f[seq, t], {t, 1, 5}] (*{26, 25, 192, 527, 1030}*) It also gives you a formula if you want: 26 + Floor[(-1 + 84 (-2 + t)) (-1 + t)] That does also work for longer sequences, of course. It is easy to see that if you have a sequence of $N$ numbers and you append another list of say $M$ numbers to it you will get a different solution for different $M$-sequences. As $M$ becomes larger you have more and more possible choices. As $M$ tends to infinity you have an infinite number of different choices in fact; all of which will reproduce the first list of $N$ numbers. So your function just like mine picks out one of these infinitely many possibilities. In what sense is yours special?The most interesting task is not to find just any such function that generates that sequence, but one that in some sense is famous/known/"frequent", whatever that means. Mathematica's FindSequenceFunction does a very good job there: FindSequenceFunction[{1, 1, 2, 3, 5, 8}] (*Fibonacci*) Another way to identify a common sequence is to look it up in The Online Encyclopaedia of Integer Sequences. Here is a function which does it for you:  identifySeq[list_List] := Module[{out}, serchstrg = StringJoin[Join[{ToString[list[]]}, "%2C" <> ToString[#] & /@ list[[2 ;;]]]]; out = Import["https://oeis.org/search?q=" <> serchstrg <> "&language=english&go=Search", "Data"]; If[Length[out[]] == 2, Print["No sequence identified."], Print[{out[[2, 3, 1]], ToExpression[StringSplit[out[[2, 3, 2]], ","][[1 ;; -2]]]}]]] It gives two elements of output, e.g. identifySeq[{1, 1, 2, 3, 5, 8, 13}] gives: {{ A000045 ,Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. (Formerly M0692 N0256) , +20 3332 },{0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817}} The first element gives a short description, e.g. Sloan's identification, etc. The second one is a sample of the sequence.My function is certainly far from perfect and I suspect that the built in function does better.Cheers,M.
Posted 8 years ago
 Wow that is some detailed stuff!!I looked it up before creating the Formula, and didnt find anything. Now I see that yes, it is pretty much trivial...Steps:1 - Look if its an arithmetic or a geometric sequance, if so - trivial2 - If not, lets say we have 3 numbers (it will be much easier without a computer to process):seq={26,25,192}so A[n] = ((n-3)(n-2)26 + (n-1)(n-3)25 + (n-2)(n-1)192)/((n-1)!(3-n)!(-1)^(3-n))And by wolfram, that is:A[n] = (243n^2 - 806n + 615) / ((n-1)!(3-n)!(-1)^(3-n))Pretty lame compared to what you just showed me... wolfram returns 84n^2 - 253n + 195 - much more simple.. Which is much more simple than deviding by factorials, but I dont have a PRO subscription so I cant see step-by-step... Thanks for enlightning me... And of course there are infinity options, because I always can add to the sequance another number that is different than the number it would have given me.