Hi there,
I am trying to solve a simple 2nd order difference equation using rsolve
(for demonstration purposes). This is my code:
from sympy import Function, rsolve
from sympy.abc import n
y = Function('y')
f = y(n + 2) - 4.75*y(n + 1) + 4*y(n) - 150
sol2 = rsolve(f, y(n))
print(sol2)
The solution that is reported is not the full one but only:
3.65586884574495**n*C0 + 600.0, i.e. the larger root is taken into account
only, and the particular solution.
When I run the following, things are getting OK (but not quite, because
every time you have to guess the appropriate integers for your fraction):
from fractions import Fraction
from sympy import Function, rsolve
from sympy.abc import n
y = Function('y')
f = y(n + 2) - Fraction(19,4)*y(n + 1) + Fraction(4,1)*y(n) - 150
sol = rsolve(f, y(n))
print(sol)
The solution now is as expected: C0*(-sqrt(105)/8 + 19/8)**n +
C1*(sqrt(105)/8 + 19/8)**n + 600
What could I be doing wrong in my first example?
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/b9bd98e1-af56-4326-a9dd-be3b1d89ab6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.