[sage-support] Re: Coefficients of multivariate polynomials along with degrees

2012-02-20 Thread john_perry_usm
On Feb 19, 6:38 am, ObsessiveMathsFreak
obsessivemathsfr...@gmail.com wrote:
 Basically, I want to restrict the variables of a multivariate
 polynomial to a certain set of symbols.

 B.variables() should return
 [x,y]
 instead of
 [a,x,y]

 How can this be done.

Maybe I misunderstand you, but this approach works fine in sage 4.8,
and probably earlier:

sage: R.a = QQ[]
sage: P.x,y = R[]
sage: f = a*x^2 - 2*y
sage: f.variables()
(x, y)

That said, I can't factor a^2*x^2-y^2 going this route, because this
type of polynomial tries to interact with a specific (different)
backend.

 (Incidentally, the Sage polynomial/ring documentation is absolute and
 utter bedlam. Is it not possible for ordinary mortals to work with
 polynomials without having to declare polynomials rings over
 integers. )

Again, maybe I misunderstand you, but the polynomial rings given above
are not over the integers, and there are examples of this in the
documentation:

http://www.sagemath.org/doc/constructions/rings.html#polynomial-rings

Which I accessed via clicking on Help/Documentation from the home
page, then on View the online documentation, then on
Constructions, then on Polynomial Rings.

Could you be more specific as to where the bedlam lies? There's a doc
days coming up, and I'm sure people working on documentation could use
advice.

regards
john perry

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coefficients of multivariate polynomials along with degrees

2012-02-19 Thread ObsessiveMathsFreak
Is there any way to get this code to deal with non integer
coefficients. Specifically, can it return coefficients that are
symbolic.

For example I would like

f(x,y)=a*x^10*y+3*x
B=f(x,y).polynomial(SR)
print B.coefficients()

to return

[a,3]

but instead it returns

[1,3]

Is it possible to have this code consider 'a' not as a variable but as
a constant?

On Feb 9, 10:36 pm, ObsessiveMathsFreak
obsessivemathsfr...@gmail.com wrote:
 Are you certain that these two functions return elements in the same
 order?

 On Feb 8, 11:40 pm, Mike Hansen mhan...@gmail.com wrote:







  On Wed, Feb 8, 2012 at 3:29 PM, ObsessiveMathsFreak

  obsessivemathsfr...@gmail.com wrote:
   Is there no way of getting sage to give back the degree's of the
   corresponding multivariate polynomials as well. That is to return
   something like

   [[10,[100,1]],[3,[1,0]]]

  exponents() is what you need:

  sage: zip(B.coefficients(), B.exponents())
  [(10, (100, 1)), (3, (1, 0))]

  --Mike

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coefficients of multivariate polynomials along with degrees

2012-02-19 Thread ObsessiveMathsFreak
Basically, I want to restrict the variables of a multivariate
polynomial to a certain set of symbols.

B.variables() should return
[x,y]
instead of
[a,x,y]

How can this be done.

(Incidentally, the Sage polynomial/ring documentation is absolute and
utter bedlam. Is it not possible for ordinary mortals to work with
polynomials without having to declare polynomials rings over
integers. )

On Feb 19, 12:12 pm, ObsessiveMathsFreak
obsessivemathsfr...@gmail.com wrote:
 Is there any way to get this code to deal with non integer
 coefficients. Specifically, can it return coefficients that are
 symbolic.

 For example I would like

 f(x,y)=a*x^10*y+3*x
 B=f(x,y).polynomial(SR)
 print B.coefficients()

 to return

 [a,3]

 but instead it returns

 [1,3]

 Is it possible to have this code consider 'a' not as a variable but as
 a constant?

 On Feb 9, 10:36 pm, ObsessiveMathsFreak







 obsessivemathsfr...@gmail.com wrote:
  Are you certain that these two functions return elements in the same
  order?

  On Feb 8, 11:40 pm, Mike Hansen mhan...@gmail.com wrote:

   On Wed, Feb 8, 2012 at 3:29 PM, ObsessiveMathsFreak

   obsessivemathsfr...@gmail.com wrote:
Is there no way of getting sage to give back the degree's of the
corresponding multivariate polynomials as well. That is to return
something like

[[10,[100,1]],[3,[1,0]]]

   exponents() is what you need:

   sage: zip(B.coefficients(), B.exponents())
   [(10, (100, 1)), (3, (1, 0))]

   --Mike

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Coefficients of multivariate polynomials along with degrees

2012-02-19 Thread Mike Hansen
On Sun, Feb 19, 2012 at 4:38 AM, ObsessiveMathsFreak
obsessivemathsfr...@gmail.com wrote:
 Basically, I want to restrict the variables of a multivariate
 polynomial to a certain set of symbols.

 B.variables() should return
 [x,y]
 instead of
 [a,x,y]

 How can this be done.

I have a patch at http://trac.sagemath.org/sage_trac/ticket/12542
which provides a fix for this:

sage: var('a,x,y')
sage: f = a*x^10*y+3*x
sage: B = f.polynomial(ring=SR['x,y'])
sage: B.coefficients()
[a, 3]

The key is specifying that the resulting polynomial should live in the
ring SR['x,y'] instead of (by default) SR['a,x,y'].

--Mike

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coefficients of multivariate polynomials along with degrees

2012-02-09 Thread ObsessiveMathsFreak
Are you certain that these two functions return elements in the same
order?

On Feb 8, 11:40 pm, Mike Hansen mhan...@gmail.com wrote:
 On Wed, Feb 8, 2012 at 3:29 PM, ObsessiveMathsFreak

 obsessivemathsfr...@gmail.com wrote:
  Is there no way of getting sage to give back the degree's of the
  corresponding multivariate polynomials as well. That is to return
  something like

  [[10,[100,1]],[3,[1,0]]]

 exponents() is what you need:

 sage: zip(B.coefficients(), B.exponents())
 [(10, (100, 1)), (3, (1, 0))]

 --Mike

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org