On Wednesday, July 10, 2013 9:31:25 AM UTC-7, Peter Mueller wrote:
>
> In the following code the computation seems to run forever, even hitting 
> Ctrl-C doesn't stop that.
>
> k.<b,c> = QQ[]
> l = k.fraction_field()
> r.<x> = l[]
> A = 2*(x^4+x^40)+b*(x^8+x^36)+c*(x^12+x^32)
> B = A.subs(1/x)
>
> If I drop the factor 2* in A=..., then I instantly get the correct result. 
> I'm running Sage 5.10.
>
> I know that factorizations of multivariate polynomials always has been a 
> mess in Sage, but I'm surprised to see that even a trivial formal 
> computation doesn't work reliably.
>

I don't know why this happens, but a workaround:

var('y')
A.subs(y)
(((((2*y^4 + b)*y^4 + c)*y^20 + c)*y^4 + b)*y^4 + 2)*y^4
A.subs(y).expand()
2*y^40 + b*y^36 + c*y^32 + c*y^12 + b*y^8 + 2*y^4
B = A.subs(y).expand().subs(y=1/x)

(You really just need the first and last lines, of course.)

I wonder if using symbolic variables instead of polynomial rings might be 
faster and more reliable in general? That is, use var('x') instead of r.<x> 
= l[] before defining A. Or use var('x,b,c') instead of your first three 
lines.

sage: var('x,b,c')
(x, b, c)
sage: A = 2*(x^4+x^40)+b*(x^8+x^36)+c*(x^12+x^32)
sage: B = A.subs(x=1/x)
sage: B
b*(1/x^8 + 1/x^36) + c*(1/x^12 + 1/x^32) + 2/x^4 + 2/x^40

-- 
John

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" 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-support.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to