3.0

3.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 1.58 KB File ID: #19565

Polynomial division by convolution - quotient and reminder

by

 

12 Apr 2008 (Updated )

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

| Watch this File

File Information
Description

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'.

Acknowledgements

Calculates Inverse Z Transform By Long Division inspired this file.

This file inspired Polynomial Division Derived Form Covolution.

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
27 Apr 2009 Zeeshan Shareef

Thank you...
It help me alot.

30 Mar 2009 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

30 Mar 2009 Krishna Prasad

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

30 Mar 2009 Krishna Prasad  
Updates
24 Mar 2009

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

30 Mar 2009

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

07 Jul 2011

update the m file

Contact us