You could try substituting x+1 for x first, then do what you want, and substitute back at the end, I would expect the auto-simplification to happen at that last step too, but you would be able to (say) replace x by (x-1) in the textual output. I wonder if it is possible to have a variable whose name, as a string, as "(x-1)"?
John On 31/01/2008, 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. > > 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 > > > -- John Cremona --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---