ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 08 Jun 2012 16:23:40 +0200Recurrence equation value errorhttps://ask.sagemath.org/question/9049/recurrence-equation-value-error/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?Fri, 08 Jun 2012 15:22:35 +0200https://ask.sagemath.org/question/9049/recurrence-equation-value-error/Comment by kcrisman for <p>Hello,
As an anxious student I tried googling for an answer for 2hours without any result. I'm new Sagemath user.</p>
<p>I have to solve equation:</p>
<pre><code>a[n+2]-4*a[n+1]+4*a[n]=2^n+cos(n*pi/2), a[0]=1, a[1]=2
</code></pre>
<p>My sage input is:</p>
<pre><code>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})
</code></pre>
<p>But I'm getting an error: </p>
<blockquote>
<p>ValueError: 'y' expected, got 'cos'</p>
</blockquote>
<p>Sage has some problems with cosine function, any idea how to solve it?</p>
https://ask.sagemath.org/question/9049/recurrence-equation-value-error/?comment=19650#post-id-19650Also, 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.Fri, 08 Jun 2012 16:21:26 +0200https://ask.sagemath.org/question/9049/recurrence-equation-value-error/?comment=19650#post-id-19650Comment by kcrisman for <p>Hello,
As an anxious student I tried googling for an answer for 2hours without any result. I'm new Sagemath user.</p>
<p>I have to solve equation:</p>
<pre><code>a[n+2]-4*a[n+1]+4*a[n]=2^n+cos(n*pi/2), a[0]=1, a[1]=2
</code></pre>
<p>My sage input is:</p>
<pre><code>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})
</code></pre>
<p>But I'm getting an error: </p>
<blockquote>
<p>ValueError: 'y' expected, got 'cos'</p>
</blockquote>
<p>Sage has some problems with cosine function, any idea how to solve it?</p>
https://ask.sagemath.org/question/9049/recurrence-equation-value-error/?comment=19652#post-id-19652This 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.Fri, 08 Jun 2012 16:17:56 +0200https://ask.sagemath.org/question/9049/recurrence-equation-value-error/?comment=19652#post-id-19652Answer by kcrisman for <p>Hello,
As an anxious student I tried googling for an answer for 2hours without any result. I'm new Sagemath user.</p>
<p>I have to solve equation:</p>
<pre><code>a[n+2]-4*a[n+1]+4*a[n]=2^n+cos(n*pi/2), a[0]=1, a[1]=2
</code></pre>
<p>My sage input is:</p>
<pre><code>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})
</code></pre>
<p>But I'm getting an error: </p>
<blockquote>
<p>ValueError: 'y' expected, got 'cos'</p>
</blockquote>
<p>Sage has some problems with cosine function, any idea how to solve it?</p>
https://ask.sagemath.org/question/9049/recurrence-equation-value-error/?answer=13675#post-id-13675After 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...Fri, 08 Jun 2012 16:23:40 +0200https://ask.sagemath.org/question/9049/recurrence-equation-value-error/?answer=13675#post-id-13675