On Thursday, April 4, 2013 8:35:28 AM UTC-4, Ken Levasseur wrote:
>
> Kent:
> Thanks, I wasn't aware of the rhs function in maxima.
> Ken
>
>
There is also a .rhs() method for most symbolic things in Sage, just in
case that helps some other place.
In this case, this leads to a problem.
First, implicit in Ken's post is that we need to load that package.
sage: maxima('load(solve_rec)')
"/Users/.../sage-5.7.rc0/local/share/maxima/5.29.1/share/solve_rec/solve_rec.mac"
That's fine. But next,
sage: sol=maxima('solve_rec(a[n+2]+a[n+1]-2*a[n]=0,a[n],a[0]=1,a[1]=3)')
sage: sol
a[n]=(-2)^(n+1)/3+5/3
sage: type(sol)
sage.interfaces.maxima.MaximaElement
sage: a(n) = maxima('rhs(sol)')
sage: a
n |--> 0
This is because Maxima doesn't know what sol is, only Sage does. In
general Kent's solution would work, but here that little quirk prevents it
from working. Try instead
sage: sol.rhs() # a Maxima method, so still a Maxima element
(-2)^(n+1)/3+5/3
sage: sol.rhs().sage() # convert it to Sage
1/3*(-2)^(n + 1) + 5/3
sage: a(n) = sol.rhs().sage()
sage: a # Hooray!
n |--> 1/3*(-2)^(n + 1) + 5/3
sage: a(55) # is this right?
24019198012642647
This has the advantage of staying object-oriented, if one cares about such
things (which I probably don't...)
- kcrisman
--
You received this message because you are subscribed to the Google Groups
"sage-edu" 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 http://groups.google.com/group/sage-edu?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.