Multiplication of two polynomials having different variables
조회 수: 20 (최근 30일)
이전 댓글 표시
i want to multiply two variables like
(X^3 + X^2+ X+1)*(Y^3 +Y^2 +Y+1)
Is there any built in function like "conv" ( which help us to multiply two variables of same variable)?
댓글 수: 0
채택된 답변
John D'Errico
2020년 7월 1일
편집: John D'Errico
2020년 7월 1일
The simple answer is to use the symbolic toolbox. If you have it, I cannnot think of a good reason why you would not use it.
syms X Y
(X^3 + X^2+ X+1)*(Y^3 +Y^2 +Y+1)
ans =
(X^3 + X^2 + X + 1)*(Y^3 + Y^2 + Y + 1)
expand(ans)
ans =
X^3*Y^3 + X^3*Y^2 + X^3*Y + X^3 + X^2*Y^3 + X^2*Y^2 + X^2*Y + X^2 + X*Y^3 + X*Y^2 + X*Y + X + Y^3 + Y^2 + Y + 1
Lacking that, you can download my sympoly toolbox. It is on the file exchange. So I can do this:
sympoly X Y
(X^3 + X^2+ X+1)*(Y^3 +Y^2 +Y+1)
ans =
1 + Y + Y^2 + Y^3 + X + X*Y + X*Y^2 + X*Y^3 + X^2 + X^2*Y + X^2*Y^2 + X^2*Y^3 + X^3 + X^3*Y + X^3*Y^2 + X^3*Y^3
So at least for basic polynomial manipulations, it works quite well.
Lacking that, can you solve the problem with neither tool present? Of course. Since you wanted to use conv...
xpoly = [1 1 1 0];
ypoly = [1 1 1 1];
Effectively, you know these are the coefficients of polynomials in x and y, such that the ith element of xpoly is the coefficient of X^(4- i).
xypoly = xpoly'*ypoly
xypoly =
1 1 1 1
1 1 1 1
1 1 1 1
0 0 0 0
So the (i,j) element of xypoly is the coefficient of x^(4 - i) * y^(4 - j).
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!