Using Volker's tip, the function is_in_span below will return
- a list of coefficients a_j such that f is the sum of a_j g_j,
- or the string 'Not in span'.
from sage.rings.polynomial.multi_polynomial_sequence import
PolynomialSequence
def is_in_span(R,g,f):
# R: polynomial ring; g: list of polynomials in R; f: polynomial in
R
A = PolynomialSequence(R, g + [f])[0]
if A[:-1].rank() == A.rank(): return A[:-1].solve_left(A[-1])
return 'Not in span'
Le vendredi 14 février 2014 16:02:19 UTC+1, Volker Braun a écrit :
>
> Not quite what you want, but there is this:
>
> sage: R.<x,y> = QQ[]
> sage: from sage.rings.polynomial.multi_polynomial_sequence import
> PolynomialSequence
> sage: PolynomialSequence(R, [x^2, x*y, x^2+y^2]).coefficient_matrix()
> (
> [1 0 0] [x^2]
> [0 1 0] [x*y]
> [1 0 1], [y^2]
> )
>
>
> On Friday, February 14, 2014 2:46:55 PM UTC, Dima Pasechnik wrote:
>>
>> Lately I need to do computations of this sort: for F a field, say, QQ,
>> given polynomials f, g_1,...,g_k in F[x1,...,xn], where n can be, say,
>> 50, find out whether f belongs to the F-span of g_1,...,g_k.
>> (and find an expression for f as sum_j a_j g_j, if it exists)
>>
>> This is of course easy linear algebra.
>> (take the monomials involved, then g_j corresponds to a vector, etc)
>> Is there a natural way to do this in Sage ?
>> (computing the ideal (g_1,...,g_k) is not feasible, and in fact
>> not needed).
>>
>> In GAP one can form vector spaces directly by specifying
>> the field and the list [g_1,...,g_k] - no need for the g_j
>> to be linearly independent or anything like this.
>> gap> x1:=Indeterminate(Rationals,1);
>> gap> x2:=Indeterminate(Rationals,2);
>> gap> r:=PolynomialRing(Rationals,[x1,x2]);
>> gap> V:=VectorSpace(Rationals, [x1^0,x1,x1*x2,x2^2,(x1-x2)^2,x1^2]);
>> gap> 5-x1*x2 in V;
>> true
>> gap> Coefficients(Basis(V),5-x1*x2);
>> [ 5, 0, -1, 0, 0 ]
>> gap> Basis(V);
>> Basis( <vector space of dimension 5 over Rationals>, [ 1, x_1,
>> x_1*x_2, x_2^2, x_1^2 ] )
>>
>> Thanks,
>> Dima
>>
>>
>>
--
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.