ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 21 Jul 2020 10:46:56 +0200how to get the coefficient of a multivariate polynomial with respect to a specific variable and degree, in a quotient ring ?https://ask.sagemath.org/question/52594/how-to-get-the-coefficient-of-a-multivariate-polynomial-with-respect-to-a-specific-variable-and-degree-in-a-quotient-ring/Here is what I tried.
sage: F = ZZ.quo(3*ZZ); F
sage: A.<X, Y, Z> = PolynomialRing(F); A
sage: R.<x, y, z> = A.quotient(ideal(X^2 - 1, Y^2 - 1, Z^2 - 1))
sage: f = x*z + x*y*z + y + 1
sage: f.coefficient(z, 1)
sage: f.coefficient({z: 1})
sage: f.coeffcient(z)andriamTue, 21 Jul 2020 10:46:56 +0200https://ask.sagemath.org/question/52594/get the coefficients of polynomial of several variables?https://ask.sagemath.org/question/41526/get-the-coefficients-of-polynomial-of-several-variables/ Consider that I have a polynomial with n variables x1,x2,...,xn and want to get the coefficient of that polynomial. For example I can have:
x1+2*x1*x5^2+3*x1^2*x4-5*x2*x5^2+1/2*x2*x3+x6^2*x7*x8+9*x3*x9^3
I would like to ask Sage to give coefficient for the polynomial with variables x1..x9 and the result should be something like this:
coefficient,(exponent of x1..x9);
1,(1,0,0,0,0,0,0,0,0);
2,(1,0,0,0,2,0,0,0,0);
3,(2,0,0,1,0,0,0,0,0);
-5,(0,1,0,0,2,0,0,0,0);
1/2,(0,1,1,0,0,0,0,0,0);
1,(0,0,0,0,0,2,1,1);
9,(0,0,1,0,0,0,0,0,3)
How can I achieve this?
DanialBaghWed, 14 Mar 2018 03:12:52 +0100https://ask.sagemath.org/question/41526/leading coefficient polynomialhttps://ask.sagemath.org/question/35031/leading-coefficient-polynomial/ Hello everybody,
I'm new to sagemath and python in general, and one of my course in Uni uses it... I have a vague and unclear tutorial the prof gave us and for now I know only the most basic commands.
I have to write a function that takes a polynomial of any degree and tells me the coefficient of the highest degree member (for example , 2x^4+3x^3 would be 2, 7x^3+2x^4+2 would be 7...).
I think the function would have to use "expand", "degree", and of course "coefficient". But i barely have any idea as how to write it.
If anyone could help me it would be great, I am kinda lost here...
Sorry for sloppy english and thanks in advance.
waddupbbySun, 02 Oct 2016 18:27:48 +0200https://ask.sagemath.org/question/35031/Extract coefficients of polynomialshttps://ask.sagemath.org/question/33096/extract-coefficients-of-polynomials/ I have the following code:
var('a')
_.<k> = PolynomialRing(ZZ)
f = k^3+2*k^2+1
g = k^3 + a*k^2 + 1
f.coefficients()
g.coefficients()
the coefficients of f that i get are perfect:
[1, 2, 1]
the coefficients of g should be [1,a,1], but instead i get:
[[k^3 + 1, 0], [k^2, 1]]
I've tried the solution suggested [here](http://ask.sagemath.org/question/10195/extracting-coefficients-of-multivariate-polynomials/):
but it doesn't always produce the coefficients in a logical order.
As always, any help figuring out how to get the correct coefficients of g would be greatly appreciated.sophiaThu, 14 Apr 2016 05:59:50 +0200https://ask.sagemath.org/question/33096/Creating an array of variableshttps://ask.sagemath.org/question/8390/creating-an-array-of-variables/Here is a very very basic question.
I want to create a polynomial, say
a_0*x^0 + a_1*x + a_2*x^2+ \cdots + a_{20} x^{20}.
I could define these a_i one at a time, but it would be much better to have a way to create an array A of length 20 where A[i] is the coefficient a_i. The idea is that I want to do some operations and solve for these coefficients, which will end up being rational numbers.
There must be some very basic command that I don't know, but I can't find it in the documentation.NathanMon, 17 Oct 2011 12:16:43 +0200https://ask.sagemath.org/question/8390/