On 20 mar, 14:07, Mike Hansen <[email protected]> wrote:
> The best way to work with this object is to do like you did:
>
> sage: K.<a>=NumberField(x^4+x+1)
> sage: R.<x,y,z,t>=K['x,y,z,t']
>
> Then, we can construct some elements of this field:
>
> sage: f = (a^2*x + y)*(z+a*t); f
> (a^2)*x*z + y*z + (a^3)*x*t + (a)*y*t
> sage: g = f/(x+a)
> sage: g
> ((a^2)*x*z + y*z + (a^3)*x*t + (a)*y*t)/(x + (a))
>
> > (1) Obtain a representation "in base a", that is, write f as
> >       f0 + f1*a + f2*a^2 + f3*a^3
>
> I can't think of a way to do this other than what the following
> function does:
>
> def powers_of_a(f):
>     powers = {}
>     for m, fc in zip(f.monomials(), f.coefficients()):
>         for i, c in enumerate(fc):
>             powers[i] = powers.get(i, 0) + c*m
>     for i, p in powers.items():
>         print i, ":", p
>
> sage: powers_of_a(f)
> 0 : y*z
> 1 : y*t
> 2 : x*z
> 3 : x*t

Thank you for your answer, in fact I had a similar solution to
polynomials. However, this or similar code will not work for rational
functions.

powers_of_a(1/(x^2-a))

Traceback (click to the left for traceback)
...
AttributeError: 'sage.rings.fraction_field_element.FractionFieldEle'
object has no attribute 'monomials'

This is related with how to compute norms of polynomials. I will try
to implement this norm and apply it to compute this representation for
rational functions.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to