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.Fri, 27 Apr 2018 12:05:40 +0200Algorithm to polynomial multiplicationhttps://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/ I need to create algorithm to polynomial multiplication , but I don't know how to do it. Please for help.Wed, 25 Apr 2018 08:02:57 +0200https://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/Comment by B r u n o for <p>I need to create algorithm to polynomial multiplication , but I don't know how to do it. Please for help.</p>
https://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/?comment=42161#post-id-42161Some questions:
1. How is that related to SageMath?
2. What have you tried so far?
3. Did you notice that SageMath already has algorithms for polynomial multiplication?
4. Is that homework?Wed, 25 Apr 2018 15:05:54 +0200https://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/?comment=42161#post-id-42161Comment by gab123 for <p>I need to create algorithm to polynomial multiplication , but I don't know how to do it. Please for help.</p>
https://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/?comment=42164#post-id-42164I know that SageMath has algorithms for polynomial multiplication, but I must write it myself. Yes, it is my homework
I wrote something like this, but in the end should be showed polynomial, not only factors. I don't know how to do it. Could you help me? Please
W1=[1,2,3,4]
W2=[5,4,3,2,1]
W3=[]
for i in range(0,len(W1)+len(W2)-1):
W3.append(0)
for i in range(0,len(W1)):
for j in range(0,len(W2)):
W3[i+j]=W3[i+j]+W1[i]*W2[j]
print(W3)Wed, 25 Apr 2018 19:14:18 +0200https://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/?comment=42164#post-id-42164Comment by B r u n o for <p>I need to create algorithm to polynomial multiplication , but I don't know how to do it. Please for help.</p>
https://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/?comment=42189#post-id-42189Your algorithm is fine for multiplying the polynomials. What you get is the list of coefficients. (I don't know what you mean by "factors".) If you want a polynomial from this list, you have to build a polynomial ring and get the polynomial from the list of coefficients in the following way:
sage: R = PolynomialRing(ZZ, 'x')
sage: L = [1, 2, 3, 4, 5]
sage: p = R(L)
sage: p
5*x^4 + 4*x^3 + 3*x^2 + 2*x + 1Fri, 27 Apr 2018 12:05:40 +0200https://ask.sagemath.org/question/42155/algorithm-to-polynomial-multiplication/?comment=42189#post-id-42189