On Jan 31, 2008 7:59 AM, pgdoyle <[EMAIL PROTECTED]> wrote: > > > > On Jan 31, 12:29 am, "William Stein" <[EMAIL PROTECTED]> wrote: > > > On Jan 30, 2008 3:48 PM, pgdoyle <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > I would like to take the Taylor series of a matrix. But I find I > > > can't even put a Taylor polynomial into a matrix without its being > > > simplified. > > > > > sage: f=-x/(2*x-4); f > > > -x/(2*x - 4) > > > sage: g=taylor(f,x,1,1); g > > > 1/2 + x - 1 > > > sage: matrix(1,[g]) > > > [x - 1/2] > > > sage: m=matrix(1,[f]); m > > > [-x/(2*x - 4)] > > > sage: m.apply_map(lambda e: taylor(e,x,1,1)) > > > [x - 1/2] > > > > > Any suggestions? > > > > You're already doing it exactly correctly. Try a higher degree > > approximation to avoid confusion: > > > > sage: m = matrix(1,[-x/(2*x-4)]) > > sage: m.apply_map(lambda e: taylor(e,x,1,4)) > > [x + (x - 1)^4 + (x - 1)^3 + (x - 1)^2 - 1/2] > > William: > > Sorry - I didn't make the issue clear enough. When I ask for the > Taylor polynomial at x=1, I want a polynomial in x-1. And that's what > I get, except that when I put this polynomial into a matrix, 1/2 + x - > 1 gets simplified to x-1/2. Your example shows this behavior very > clearly.
That's weird. Most of the polynomial is not simplified except the -1/2 is moved to the end. Note that the rest of the terms stay put. I wonder why Maxima does that. (No clue.) Note that it isn't a complete loss; all the other terms remain exactly as you wanted. sage: m = matrix(1,[-x/(2*x-4)]) sage: m.apply_map(lambda e: taylor(e,x,0,4)) [x^4/32 + x^3/16 + x^2/8 + x/4] sage: m.apply_map(lambda e: taylor(e,x,0,4)) [x^4/32 + x^3/16 + x^2/8 + x/4] sage: m.apply_map(lambda e: taylor(e,x,1,4)) [x + (x - 1)^4 + (x - 1)^3 + (x - 1)^2 - 1/2] sage: m.apply_map(lambda e: taylor(e,x,2,4)) [-1/(x - 2) - 1/2] sage: m.apply_map(lambda e: taylor(e,x,3,4)) [x - (x - 3)^4 + (x - 3)^3 - (x - 3)^2 - 9/2] sage: m[0,0].taylor(x,3,4) -3/2 + x - 3 - (x - 3)^2 + (x - 3)^3 - (x - 3)^4 I'm sure this can be fixed, so I've made a bug report: http://trac.sagemath.org/sage_trac/ticket/2025 -- William > I understand that a whole new approach to power series is in the > works, which will keep track of degrees of approximation, and I expect > this will include taking the power series of a matrix. But for now, I > just want to be able to use Sage instead of Mathematica for an > exposition of generating functions for Markov chains, where I need to > compute and display Taylor polynomials of matrices. Hopefully there > is some way I can keep a polynomial in x-1 from getting simplified > automatically when it's an element of a matrix. > > Cheers, > > Peter > > Cheers, > > Peter > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ 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://www.sagemath.org -~----------~----~----~----~------~----~------~--~---