# Why does FindSequenceFunction not work in this case?

Why does this not work?

FindSequenceFunction[{1/2, (2/3)^2, (3/4)^4, (4/5)^6, (5/6)^8}, n]
(*FindSequenceFunction[{1/2,4/9,81/256,4096/15625,390625/1679616},n]*)


I thought (n/(n + 1))^(2 n - 2) but unfortunately the first number isn't correct. Except the first number, I expect all the following numbers are of the form (n/(n + 1))^(2 n - 2).

• Help says attempts to find a simple function that yields the sequence Subscript[a, n] note the word attempts, which means it might not be able to find such a function. May be it needs more terms? May be there is no such function? But I see some weakness in this function, Here is an easier one it could not find f[n_] := (n/(n + 1))^(n); Table[f[n], {n, 1, 10}] and now FindGeneratingFunction[%, n] could not find the function (n/(n + 1))^(n) which generates this sequence. I tried more terms, it still could not find it. May 29 at 8:06
• @Nasser I see. Is there a better function for this? May 29 at 8:12
• I do not know of alternative. May be someone will have better idea what is going on and if there is a workaround. May 29 at 8:24
• When FindSequenceFuntion fails, the next step is to try oeis.org. That website also deals with fractions that are rational numbers. While it doesn't have that particular sequence (or the one that @Nasser mentioned), one of the hints (oeis.org/hints.html) is to enter the numerators and denominators separately. For these two cases, that gives enough information to find the sequence function.
– JimB
May 29 at 18:39

Consider the sequence given by @Nasser in the comments above:

seq = Table[(n/(n + 1))^(n), {n, 1, 10}] Find the sequences of the numerators and denominators:

numerators = Numerator[seq]
(* {1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489, 10000000000} *)
denominators = Denominator[seq]
(* {2, 9, 64, 625, 7776, 117649, 2097152, 43046721, 1000000000, 25937424601} *)


(A hint given at oeis.org is to look at the numerator and denominator sequences separately.)

Use FindSequenceFunction on the numerators:

FindSequenceFunction[numerators, n]
(* n^n *)


Now on the denominators:

FindSequenceFunction[denominators, n]
(* FindSequenceFunction[{2, 9, 64, 625, 7776, 117649, 2097152, 43046721, 1000000000, 25937424601}, n] *)


But just the input is returned. So check this sequence at oeis.org and we find that one of the generators of those numbers is

n^(n-1)


If we produce the first 10 values from that result we see

Table[n^(n - 1), {n, 1, 10}]
(* {1, 2, 9, 64, 625, 7776, 117649, 2097152, 43046721, 1000000000} *)


We need the first term to be 2 rather than 1:

Table[(n + 1)^n, {n, 1, 10}]
(* {2, 9, 64, 625, 7776, 117649, 2097152, 43046721, 1000000000, 25937424601} *)


Now putting the numerator and denominator functions together we have

n^n/(n+1)^n


or

(n/(n+1))^n


which is the formula that generated the sequence.

For the OP's original problem FindSequenceFunction doesn't work and for the denominator the first term doesn't "fit". However, skipping the first term and searching for the numerator and denominator sequences at oeis.org does work and one can then construct a formula for the OP's sequence.

If one had many sequences in Mathematica to check at oeis.org, then the following function will at least report "At least one sequence found." or "Sorry, couldn't find sequence." One would still have to go to oeis.org to look at the positive hits.

checkOEIS[sequence_] := Module[{html, string},
(* Change ", " to "%2C" *)
string = StringReplace[ToString[sequence], ", " -> "%2C"];
(* Remove curly brackets *)
string = StringTake[string, {2, StringLength[string] - 1}];
(* Get report *)
html = Import["https://oeis.org/search?q=" <> string <>  "&language=english&go=Search"];
(* If "Sorry" is in the received text, then there is no corresponding sequence found *)
If[StringPosition[html, "Sorry, but the terms"] == List[],
Print["At least one sequence found."],
Print["Sorry, couldn't find sequence."]]
]

checkOEIS[{1, 2, 3, 4}]
(* At least one sequence found. *)

• FindSequenceFunction[Table[n^(2 n - 2), {n, 1, 12}], n] returns the input. May 30 at 5:26
• @user64494 oeis.org does find the generating function for that sequence.
– JimB
May 30 at 6:12
• JimB (@ does not work.): Sorry, OEIS is not a Mathematica tool. May 30 at 6:16
• @user64494 Yes but one piece of software doesn't do everything (although Mathematica can certainly do a lot). A valid solution to any question posed at this forum might very well include calls to R, the operating system, etc. What I proposed did use Mathematica for half of the solution. Had I only used oeis.org, then my answer would have been better as a comment and I would agree with your assessment.
– JimB
May 30 at 6:32
• JimB: Mathematica may execute C++ and R codes, but can't programmatically find and extract sequences from OEIS. May 30 at 11:04
seq = {1/2, (2/3)^2, (3/4)^4, (4/5)^6, (5/6)^8};


As you point out, the powers are not easily represented and FindSequenceFunction is not able to handle this case without help. The sequence is

x[n_] = (n/(n + 1))^FindSequenceFunction[{1, 2, 4, 6, 8, 10}, n] % // InputForm

(* (n/(1 + n))^DifferenceRoot[Function[{\[FormalY], \[FormalN]},
{-2 - \[FormalY][\[FormalN]] + \[FormalY][1 + \[FormalN]] == 0,
\[FormalY] == 1, \[FormalY] == 2}]][n] *)

Table[x[n], {n, Length[seq]}] === seq

(* True )