Formula for simple recursive sequences

50 views
Skip to first unread message

Christophe Bal

unread,
Sep 25, 2014, 2:26:30 PM9/25/14
to sage-s...@googlegroups.com
Hello.

Is it possible to ask to sage to give formulas for simple recursive sequences ?

For example,  w_{n+1} = (n+1)/n*w_n + 1/n  with  w_0 = 1 , we have  w_n = 2 n + 1 . More simple example could be arithmetico-geometrical sequences  w_{n+1} = a*w_n + b .

Christophe BAL

kcrisman

unread,
Sep 25, 2014, 3:51:25 PM9/25/14
to sage-s...@googlegroups.com
Brief answer which I think others can expand upon - I believe both Maxima and Sympy can do so inside Sage, though I don't know that we have a good interface to those capabilities yet. 

Christophe Bal

unread,
Sep 25, 2014, 4:19:29 PM9/25/14
to sage-s...@googlegroups.com
So I will ask the question on the Sympy list.

Thanks.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Jorge Garcia

unread,
Sep 25, 2014, 4:34:58 PM9/25/14
to sage-s...@googlegroups.com

Do you mean to write a recusive function to genrate a sequence such as fibonacci:
def fib(n):
    if(n==0 or n==1):
        return 1
    else:
        return f(n-1)+fib(n-2)

Jorge Garcia

unread,
Sep 25, 2014, 4:38:45 PM9/25/14
to sage-s...@googlegroups.com

Also, geometric and arithmetic sequences need not be generated recusively. How about using a list comprehesion to find the series for Xeno's Paradox:
sum([(1/2)**(n+1) for n in range(5)])

Christophe Bal

unread,
Sep 25, 2014, 4:46:52 PM9/25/14
to sage-s...@googlegroups.com
This examples gives value for known n, what I'm looking for is a general formula with a symbolic n.

For arithmetico-geometrical sequences, my purpose is more pedagogical than practical.

2014-09-25 22:38 GMT+02:00 Jorge Garcia <calc...@gmail.com>:

Also, geometric and arithmetic sequences need not be generated recusively. How about using a list comprehesion to find the series for Xeno's Paradox:
sum([(1/2)**(n+1) for n in range(5)])

--

Christophe Bal

unread,
Sep 25, 2014, 4:56:19 PM9/25/14
to sage-s...@googlegroups.com
Maybe a solution would be to use the natural serie sum(k=0 ; n ; u_{k+1} - u_k) associated to one sequence u_k, and then have a tool giving a formula for the serie. There are algorithms for hypergeometric series if I do not say an idiocy.

So my question become : can I ask to Sage to give a formula to a serie sum(k=0 ; n ; w_k) where w_k is at least hypergeometric.

Ralf Stephan

unread,
Sep 26, 2014, 1:54:04 PM9/26/14
to sage-s...@googlegroups.com
See also http://ask.sagemath.org/question/23610/symbolic-integer-arithmetic/#23613
with my take on a generalized Binet formula. That would take care of all degree-2 recurrences with constant coeffs from QQ. I have something in the brewing on top of trac #15714 which needs review. But this gets you only the C-finite case, and D-finite is completely different, and I have no idea about algorithms there.

On the other hand, guessing C-finite is done in #15714, and for D-finite Sage has ore_algebra as optional package.

Regards,
Reply all
Reply to author
Forward
0 new messages