On Feb 1, 8:59 am, "William Stein" <[EMAIL PROTECTED]> wrote:
> 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.
>
It's not just that the constant term gets moved: The 1/2 gets
combined with the -1 in the linear term x-1.
Also, I don't see how this could be the fault of Maxima:
sage: %maxima
sage: f:taylor(-x/(2*x-4),x,1,5)
sage: m:[f]
sage: m*2
1/2+(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5
[1/2+(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5]
[1+2*(x-1)+2*(x-1)^2+2*(x-1)^3+2*(x-1)^4+2*(x-1)^5]
Note how Maxima has the terms in the expected order for a power
series, and preserves this order, without doing any simplification,
when putting it the expression into a matrix.
Cheers,
Peter
> 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
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---