Message Boards Message Boards

0
|
4190 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Formula for sequnaces

Posted 9 years ago

I have developed a formula, that given ANY sequance of N numbers, will output a mathematical function that has them.

for Instanse: 26,25,192

will return a function that:

f(1) = 26

f(2) = 25

f(3) = 192

Are 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.

POSTED BY: Amit Moryossef
2 Replies

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/320638

In 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[[1]]]}, "%2C" <> ToString[#] & /@ list[[2 ;;]]]]; 
     out = Import["https://oeis.org/search?q=" <> serchstrg <> "&language=english&go=Search", "Data"]; 
     If[Length[out[[2]]] == 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 BY: Marco Thiel
Posted 9 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 - trivial

2 - 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.

POSTED BY: Amit Moryossef
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract