# Strange behaviour if FindSequenceFunction

Consider a sequence starting with 2, subtract 2 to get the next term, now add 3 to get the next term and so on according to the rule (-2,+3) consecutively which starts like

s = {2, 0, 3, 1, 4, 2, 5, 3, 6, 4};


and ask for the sequence function:

FindSequenceFunction[s, n] // Simplify


$\frac{3 \left(894-909 n+307 n^2-42 n^3+2 n^4\right)}{2 \left(579-539 n+170 n^2-22 n^3+n^4\right)}$

This strange looking formula is in fact the wrong alternative, as the next term should be 4 + 3 = 7. Instead it repdocuces just the given terms an gives fractions beyond:

Table[%, {n, 0, 20}]

(* Out[94]= {447/193, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 711/193, 1545/437, 968/281, 1654/489, \
377/113, 571/173, 2490/761, 24504/7543, 3723/1153, 44757/13933} *)


Let us now drop the last element of s:

FindSequenceFunction[Drop[s, 1], n] // Simplify
(* Out[72]= 1/4 (3 + 5 (-1)^n + 2 n) *)

Table[1/4 (3 + 5 (-1)^n + 2 n), {n, 0, 10}]
(* Out[80]= {2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7} *)


This formula is correct.

The same holds if we append one term to s

FindSequenceFunction[Join[s, {7}], n] // Simplify
(* Out[74]= 1/4 (1 - 5 (-1)^n + 2 n) *)

Table[1/4 (1 - 5 (-1)^n + 2 n), {n, 1, 10}]
(* Out[82]= {2, 0, 3, 1, 4, 2, 5, 3, 6, 4} *)


Question: is there a general rule for the reliability of the result of FindSequenceFunction[]?

Regards,
Wolfgang

• Isn't it that any finite sequence has an infinite amount of possible rules? So what is meant by reliable? – mikuszefski Dec 12 '14 at 14:32
• You are right. But MMA found a "wrong" result with k terms and the "right" one with k-1 and k+1 terms. Perhaps there's a better question resulting from my observation. For instance, the natural requirement that all terms must be integers also beyond the given ones. Maybe this is already sufficient ...? Yes, I think so! – Dr. Wolfgang Hintze Dec 12 '14 at 15:22
• Alternative ... oeis.org/wiki/User:Enrique_P%C3%A9rez_Herrero/OEIS_Package – Dr. belisarius Dec 12 '14 at 16:51
• @Dr.WolfgangHintze Hmmm, I don't. There should still be an infinite amount of infinite integer series that contain the given finite sequence. – mikuszefski Dec 12 '14 at 18:16
• @ belisarius: thanks for the interesting link – Dr. Wolfgang Hintze Dec 12 '14 at 21:17