Hi Neven,
> Suppose I have code like this:
>
> l := [44, 178, 412, 746, 1168, 1669, 2260, 2941, 3712, 4573, 5524, 6565]
> guess(l).1
>
> Replacing the "guess" with a "guessRat" is essentially the same thing AFAIU.
>
> The above code returns a value of type Expression(Integer) that
> represents (visually, at least) a recurrence relation. The recurrence
> relation obviously defines a rational function, which means the
> operation was technically a success.
>
> The problem is that if I try to convert the Expression to an actual
> rational function in a naive manner, as illustrated in the following,
> the conversion fails:
>
> guess(l).1::Fraction(Polynomial(Integer))
Welcome. ;-) To tell the truth, when I tried to use the guessing package
for the first time, I ran into the same problem. The user interface is
not very intuitive. One has to be familiar with the Expression domain to
turn the result in something useful for further computation.
But more importantly, one must look up the code of guess, guessRat and
guessHPaux
https://github.com/fricas/fricas/blob/master/src/algebra/mantepse.spad#L3381
in order to learn what the actual structure of the result is.
Then you find that there is RecurrenceOperator. So do it this way:
l := [44, 178, 412, 746, 1168, 1669, 2260, 2941, 3712, 4573, 5524, 6565]
Z ==> Integer
E ==> Expression Z
K ==> Kernel E
ROZE ==> RecurrenceOperator(Z, E)
e1 := guess(l).1
e2 := getEq(e1)$ROZE
k2 := mainKernel(e2)::K
How to continue to actually get the other parts out of the result, is
probably a matter of taking things apart with "Expression(Integer)"
means, probably, isPlus and isTimes, etc.
I definitely agree that this must be improved. Definitely there should
be better documentation of how to take apart the result. Finding that
RecurrenceOperator is the key, is unnecessarily hard and involves
looking into the .spad files.
Can you file a bug report at github?
Thanks
Ralf