Guess Extended Rate

16 views
Skip to first unread message

Ralf Hemmecke

unread,
Oct 6, 2020, 5:30:28 AM10/6/20
to fricas-devel
Suppose I have

aList(n)==[n*factorial(n+2*k-1)/(factorial(n + k)*factorial(k))*(-1)^k_
for k in 0..14]
res := guessAlg(aList 1)

The result shows as:

n 2 2 3 4
[[[x ]f(x): x f(x) + f(x) - 1 = 0, f(x) = 1 - x + 2 x - 5 x + O(x )]]

with type List(Expression(Integer)).

I can do

(7) -> k := first rest tower res.1

n 2 2 3 4
[[x ]f(x): x f(x) + f(x) - 1 = 0, f(x) = 1 - x + 2 x - 5 x + O(x )]
Type: Kernel(Expression(Integer))
(8) -> operator k

(8) rootOfADE
Type: BasicOperator
(9) -> argument k

(9) [n, %infoser0()]
Type: List(Expression(Integer))

But if I want the equation? How do I get it from res?

In general it would also for the other guess functions to be able to do
something with the result other than displaying it.

Ralf

Ralf Hemmecke

unread,
Oct 8, 2020, 7:28:59 AM10/8/20
to fricas-devel
Meanwhile, I found one answer myself.
https://fricas.github.io/api/RecurrenceOperator

ROZE==>RecurrenceOperator(Integer, Expression Integer)
getEq(res)$ROZE

I do not like this abbreviated name. That goes against the usual rule of
having fully expanded names. We have ==> to abbreviate.



Other question...

aList(n)==[n*factorial(n+2*k-1)/(factorial(n + k)*factorial(k))*(-1)^k_
for k in 0..14];
g := guessPRec(aList 1)

[[f(n): (n+2)*f(n+1)+(4*n+2)*f(n)=0, f(0)=1]]

rec := getEq(first g)$ROZE

(n+2)*f(n+1)+(4*n+2)*f(n)=0

Such a recurrence cries for turning it into a program that can compute
the elements of the sequence.

Of course, it doesn't work to simply define

fexpr := subst(f(n+1)-rec/(n+2),n=n-1)
f(0) == 1
f(n) == fexpr

because then f(1) would return exactly the expression involving n.

also

f(k) == subst(fexpr, n=k)

doesn't work, since it does not trigger recursion.

(1) Is it actually possible to turn an expression into a program?
(2) How do I transform rec to an expression of the form
f(n) = ... f(n-1) + ... f(n-2)
but NOT doing by hand.
(3) Can I extract the initial values from the result of guessPRec?

Thank you
Ralf

Martin R

unread,
Oct 13, 2020, 3:52:04 AM10/13/20
to FriCAS - computer algebra system
I wrote a utility seriesSolve to (try to) compute the sequence given a differential equation, but it is very ugly to use. Some (untested) examples (possibly bitrotten):

f := operator 'f
SSOLVE ==> EXPRSOL(INT, EXPR INT, UFPS EXPR INT, UFPS SMPEXPR EXPR INT)
binTree := seriesSolve(-2*f z + 2*z + f z^2+f(z^2), f, z, [0])$SSOLVE
alcohol := seriesSolve(2*z*f(z^3) + z*f(z)^3  - 3*f(z) + 3, f, z, [])$SSOLVE

)lib UTSSOL EXPRSOL SUPEXPR
G := operator 'G
s := seriesSolve(D(G x, x)-exp(-G(-x)), G, x, [log 2])$EXPRSOL(INT, EXPR INT, UFPS EXPR INT, UFPS SUPEXPR EXPR INT)

fm: UFPS SMPEXPR EXPR INT -> UFPS SMPEXPR EXPR INT
z := monomial(1,1)$UFPS SMPEXPR EXPR INT
fm f == f * (1-q*z) - f.(q*z)*(y*q*z+y)- f.(q*z)*q*z*f - y*q*z

res := seriesSolve(fm, [0])$UTSSOL(EXPR INT, UFPS EXPR INT, UFPS SMPEXPR EXPR INT);

Good Luck,

Martin
Reply all
Reply to author
Forward
0 new messages