I am finally working on my n-point Pade code , and I am encountering an error that I have not seen before. The heart of the question revolves around this code:
zi = {0.1, 0.2, 0.3} ai = {0.904837, 1.05171, -0.499584} Quiet[ RecurrenceTable[ {A[0] == 0, A[1] == ai[[1]], A[n+1]==A[n] + (z - zi[[n]]) ai[[n+1]] A[n-1]}, A, {n, Length@ai -1 } ], {Part::pspec}]
(Using Quiet necessary because Part complains about zi[[n]] and ai[[n+1]] when n is purely symbolic.) The code itself is part of the function from which I want to get a symbolic result, so z is a Symbol . But, when I run the above code, I get an error message:
RecurrenceTable::nlnum1: The function value {0.904837,0.904837+0. z} is not a list of numbers with dimensions {2} when the arguments are {0,0.,0.904837}.
Note the term {0.904837,0.904837+0. z} {0.904837,0.904837+0. z} , where 0. z does not reduce to zero. What do I need to do to get it to evaluate to zero, since it seems to be the source of the problem? Are there any alternatives?
Also, as a general complaint about the help system for Wolfram Research employees who are pursuing stackoverflow: v.7 RecurrenceTable::nlnum1 not searchable! Also, the >> link at the end of the error will lead you to the definition of the error, but will lead you to the definition of RecurrenceTable , instead, where common errors are not cross-referenced.
Change After looking at my code, the solution I came up with was to fully appreciate the RecurrenceTable , including the initial conditions. The working code is as follows:
Clear[NPointPade, NPointPadeFcn] NPointPade[pts : {{_, _} ..}] := NPointPade @@ Transpose[pts] NPointPade[zi_List, fi_List] /; Length[zi] == Length[fi] := Module[{ap, fcn, rec}, ap = {fi[[1]]}; fcn = Module[{gp = #, zp, res}, zp = zi[[ -Length@gp ;;]]; res = (gp[[1]] - #)/((#2 - zp[[1]]) #) &[ Rest@gp , Rest@zp ]; AppendTo[ap, res[[1]]]; res ] &; NestWhile[fcn, fi, (Length[#] > 1 &)]; (* The recurrence relation is used twice, with different initial conditions, so pre-evaluate it to pass along to NPointPadeFcn *) rec[aif_, zif_, a_, b_][z_] := Evaluate[RecurrenceTable[ {A[n + 1] == A[n] + (z - zif[n])*aif[n + 1]*A[n - 1], A[0] == a, A[1] == b}, A, {n, { Length@ap - 1}}][[1]]]; NPointPadeFcn[{zi, ap, rec }] ] NPointPadeFcn[{zi_List, ai_List, rec_}][z_] /; Length[zi] == Length[ai] := Module[{aif, zif}, zif[n_Integer] /; 1 <= n <= Length[zi] := zi[[n]]; aif[n_Integer] /; 1 <= n <= Length[zi] := ai[[n]]; rec[aif, zif, 0, ai[[1]]][z]/rec[aif, zif, 1, 1][z] ] Format[NPointPadeFcn[x_List]] := NPointPadeFcn[Shallow[x, 1]];
Like the built-in interpolation functions, NPointPade does some preprocessing and returns a function that can be evaluated, NPointPadeFcn . The pre-processing performed by NPointPade generates a list ai from zi and the values ββof the functions at these points in addition to a preliminary evaluation of the recurrence relations. When NPointPadeFcn is supplied with a value of z , it evaluates two linear repetition ratios, supplying it with corresponding values.
Edit : for the curious, here is NPointPade at work

In the first graph, it is difficult to determine the difference between the two functions, but the second graph shows the absolute (blue) and relative (red) errors. As written, it takes 20 minutes to create Pade, so I need to work on speeding it up. But at the moment it works.