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 [email protected] schrieb am Donnerstag, 8. Oktober 2020 um 13:28:59 UTC+2: > 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 > > > On 10/6/20 11:30 AM, Ralf Hemmecke wrote: > > 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 > > > > -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/d6409945-9d49-4629-b73b-2f1717d39949n%40googlegroups.com.
