Ask Your Question
0

Recurrence equation value error

asked 2012-06-08 15:22:35 +0100

blu3 gravatar image

Hello, As an anxious student I tried googling for an answer for 2hours without any result. I'm new Sagemath user.

I have to solve equation:

a[n+2]-4*a[n+1]+4*a[n]=2^n+cos(n*pi/2), a[0]=1, a[1]=2

My sage input is:

from sympy import *
y = Function('y')
n = Symbol('n',integer=True)

rsolve(y(n+2)-4*y(n+1)+4*y(n)-2^n-cos(n*pi/2), y(n), {y(0):1,y(1):2})

But I'm getting an error:

ValueError: 'y' expected, got 'cos'

Sage has some problems with cosine function, any idea how to solve it?

edit retag flag offensive close merge delete

Comments

This is really a sympy question. Hopefully someone can help, but you may also want to ask at http://groups.google.com/group/sympy for a backup.

kcrisman gravatar imagekcrisman ( 2012-06-08 16:17:56 +0100 )edit

Also, it's conceivable that when you imported *everything* from Sympy that some Sage object was clobbered, or maybe Sympy doesn't expect more than one type of function in its recurrences, or something.

kcrisman gravatar imagekcrisman ( 2012-06-08 16:21:26 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-06-08 16:23:40 +0100

kcrisman gravatar image

After importing * from sympy, I get

sage: rsolve?
Definition:     rsolve(f, y, init=None)
Docstring:
    Solve univariate recurrence with rational coefficients.

       Given k-th order linear recurrence Ly = f, or equivalently:

and nothing says f can be a trig function...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-06-08 15:22:35 +0100

Seen: 881 times

Last updated: Jun 08 '12