File Exchange

image thumbnail

Polynomial division by convolution - quotient and reminder

version 1.34 (1.58 KB) by

Division of two polynomials to get quotient and reminder using convolution matrix.

0 Downloads

Updated

View License

Polynomial division by convolution matrix approach.

Given b(x) and a(x), and find q(x) and r(x) in
    b(x) = a(x)*q(x) + r(x)
where
 b(x) = b(0)+ ... +b(k)*x^k + ... +b(n)*x^n
 a(x) = a(0)+ ... +a(k)*x^k + ... +a(m)*x^m
 q(x) = q(0)+ ...+ q(k)*x^k + ... +q(n-m)*x^(n-m)
 r(x) = r(0)+ ...+ r(k)*x^k + ... +r(m-1)*x^(m-1)

If coefficients of b(x) and a(x) are all integers, then the entire process may involve mostly integer arithmetric operations. The roundoff errors may thus be eliminated.

This code is similar to the MATLAB's built-in function: 'deconv.m'.

Comments and Ratings (4)

Thank you...
It help me alot.

Feng Cheng Chang

Krishia Prasad:
Please try it again. It should have worked perfectly for both polynomials b(x) and a(x) with trailing zeros.
For the example you gave: b(x)=x^4+1 and a(x)=x^2, yielding the desired results: q(x)=x^2 and r(x)=1.
>> b = [1 0 0 0 1]; a = [1 0 0];
>> [q,r,qc,rc,c] = PolyDiv(b,a)
  q = 1 0 0
  r = 1
  qc = 1 0 0
  rc = 0 1
  c = 1
Also it should be OK for b(x) with leading zero coefficients; however, not for a(x) with trailing zero coefficients.
>> b = [0 0 1 0 0 0 1 0]; a = [1 0 1 0 0];
>> [q,r,qc,rc,c] = PolyDiv(b,a)
 q = 1 0
 r = -1 0 1 0
 qc = 0 0 1 0
 rc = -1 0 1 0
 c = 1
Anyway I thank you for giving me this peculiar case to work with.
I will update the code involving any polynomials with both leading and trailing zero coefficients.
                    Feng Cheng Chang

Krishna Prasad

Krishna Prasad (view profile)

This programme is not working when the coefficient of the polynomial are zeros.
e.g a(x)=x^4+1
        b(x)=x^2

Krishna Prasad

Krishna Prasad (view profile)

Updates

1.34

update the m file

1.33

Update the m-file, to include any polynomials with both leading and trailing zero coefficients.

1.32

Correct typo in Description, and update the M-file.

MATLAB Release
MATLAB 6.5 (R13)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video