Hello, > 1) Taylor series of a rational function. > > This works: > sage: cos(x).taylor(x,0,2) > > This doesn't: > sage: x/(1+x).taylor(x,0,2) > > This is very confusing: > sage: var('x') > sage: x/(1+x).taylor(x,0,2)
This is due to the fact that '.' binds tighter than '/'. For example, sage: x/(1+x).taylor(x,0,2) x/(x + 1) sage: x/((1+x).taylor(x,0,2)) x/(x + 1) sage: (x/(1+x)).taylor(x,0,2) x - x^2 In Sage, "(x/(1+x))" creates an object and the you call the taylor() method on that object. > > 2) Map for matrices. This works: > > sage: x=polygen(QQ) > sage: m=(1-x*matrix([[1,1],[1,0]]))^-1; m > sage: matrix([[m[i,j].subs(x=1) for j in range(2)] for i in range(2)]) > > But, surely there is a direct way substitute x=1 for all entries? If you just need to substitute, you can do: sage: m.subs(x=1) [-1 -1] [-1 0] If you want to apply a more general map to the coefficients, then you can do: sage: m.apply_map(lambda e: e.subs(x=1)) [-1 -1] [-1 0] > Another thing I found confusing was that this slight variation gave > division by 0. > > sage: var('x') > sage: m=(1-x*matrix([[1,1],[1,0]]))^-1; m > sage: matrix([[m[i,j].subs(x=1) for j in range(2)] for i in range(2)]) > The problem is that sage hasn't simplified the entries of m. It > thinks Yep, maybe Sage should try and do some simplification of the maxima expression before trying the simplification. There is a ticket for implementing a symbolic matrix class which should take care of that issue. > 3) How do I get access to maxima's ratsimp? sage: n = m.apply_map(lambda e: e.rational_simplify()); n [ -1/(x^2 + x - 1) -x/(x^2 + x - 1)] [ -x/(x^2 + x - 1) (x - 1)/(x^2 + x - 1)] sage: n.subs(x=1) [-1 -1] [-1 0] In the new symbolic matrix class ( when it gets written ;-] ), you should be able to do m.rational_simplify(). Hope that helps, --Mike --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---