Polynomial division - quotients Q and remainder R
6 views (last 30 days)
Show older comments
I want to divide two polynomials (numerator and denominator). The result should be displayed as quotients Q and remainder R. Like here:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/567299/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/567304/image.png)
Result:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/567309/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/567314/image.png)
Matlab code
clear all;
close all;
clc;
syms x
I_sym = x^7 + x^3 + x^2 + x;
G_sym = x^4 + x^3 + x^2 + 1;
xK_sym = x^4;
%% Convert to polynomial
I_pol = sym2poly(I_sym);
G_pol = sym2poly(G_sym);
xK_pol = sym2poly(xK_sym);
Numerator = conv(xK_pol, I_pol);
Denominator = G_pol;
[Q, R] = deconv(Numerator, Denominator)
The result looks like this:
Q =
1 -1 0 1 -1 2 0 -3
R =
0 0 0 0 0 0 0 0 4 1 0 3
This is not the expected result. What have I done wrong?
0 Comments
Answers (1)
Pratheek Punchathody
on 6 Apr 2021
Edited: Pratheek Punchathody
on 6 Apr 2021
Looks like you have obtained the right quotient and remainder for the above two polynomials. Even using the direct co-efficients of the polyomials with the "deconv" function, the mentioned results are obtained.
u = [1 0 0 0 1 1 1 0 0 0 0 0];
v = [1 1 1 0 1];
[q,r] = deconv(u,v);
Results:
q =
1 -1 0 1 -1 2 0 -3
r =
0 0 0 0 0 0 0 0 4 1 0 3
0 Comments
See Also
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!