
- MATLAB - Home
- MATLAB - Overview
- MATLAB - Features
- MATLAB - Environment Setup
- MATLAB - Editors
- MATLAB - Online
- MATLAB - Workspace
- MATLAB - Syntax
- MATLAB - Variables
- MATLAB - Commands
- MATLAB - Data Types
- MATLAB - Operators
- MATLAB - Dates and Time
- MATLAB - Numbers
- MATLAB - Random Numbers
- MATLAB - Strings and Characters
- MATLAB - Text Formatting
- MATLAB - Timetables
- MATLAB - M-Files
- MATLAB - Colon Notation
- MATLAB - Data Import
- MATLAB - Data Output
- MATLAB - Normalize Data
- MATLAB - Predefined Variables
- MATLAB - Decision Making
- MATLAB - Decisions
- MATLAB - If End Statement
- MATLAB - If Else Statement
- MATLAB - If…Elseif Else Statement
- MATLAB - Nest If Statememt
- MATLAB - Switch Statement
- MATLAB - Nested Switch
- MATLAB - Loops
- MATLAB - Loops
- MATLAB - For Loop
- MATLAB - While Loop
- MATLAB - Nested Loops
- MATLAB - Break Statement
- MATLAB - Continue Statement
- MATLAB - End Statement
- MATLAB - Arrays
- MATLAB - Arrays
- MATLAB - Vectors
- MATLAB - Transpose Operator
- MATLAB - Array Indexing
- MATLAB - Multi-Dimensional Array
- MATLAB - Compatible Arrays
- MATLAB - Categorical Arrays
- MATLAB - Cell Arrays
- MATLAB - Matrix
- MATLAB - Sparse Matrix
- MATLAB - Tables
- MATLAB - Structures
- MATLAB - Array Multiplication
- MATLAB - Array Division
- MATLAB - Array Functions
- MATLAB - Functions
- MATLAB - Functions
- MATLAB - Function Arguments
- MATLAB - Anonymous Functions
- MATLAB - Nested Functions
- MATLAB - Return Statement
- MATLAB - Void Function
- MATLAB - Local Functions
- MATLAB - Global Variables
- MATLAB - Function Handles
- MATLAB - Filter Function
- MATLAB - Factorial
- MATLAB - Private Functions
- MATLAB - Sub-functions
- MATLAB - Recursive Functions
- MATLAB - Function Precedence Order
- MATLAB - Map Function
- MATLAB - Mean Function
- MATLAB - End Function
- MATLAB - Error Handling
- MATLAB - Error Handling
- MATLAB - Try...Catch statement
- MATLAB - Debugging
- MATLAB - Plotting
- MATLAB - Plotting
- MATLAB - Plot Arrays
- MATLAB - Plot Vectors
- MATLAB - Bar Graph
- MATLAB - Histograms
- MATLAB - Graphics
- MATLAB - 2D Line Plot
- MATLAB - 3D Plots
- MATLAB - Formatting a Plot
- MATLAB - Logarithmic Axes Plots
- MATLAB - Plotting Error Bars
- MATLAB - Plot a 3D Contour
- MATLAB - Polar Plots
- MATLAB - Scatter Plots
- MATLAB - Plot Expression or Function
- MATLAB - Draw Rectangle
- MATLAB - Plot Spectrogram
- MATLAB - Plot Mesh Surface
- MATLAB - Plot Sine Wave
- MATLAB - Interpolation
- MATLAB - Interpolation
- MATLAB - Linear Interpolation
- MATLAB - 2D Array Interpolation
- MATLAB - 3D Array Interpolation
- MATLAB - Polynomials
- MATLAB - Polynomials
- MATLAB - Polynomial Addition
- MATLAB - Polynomial Multiplication
- MATLAB - Polynomial Division
- MATLAB - Derivatives of Polynomials
- MATLAB - Transformation
- MATLAB - Transforms
- MATLAB - Laplace Transform
- MATLAB - Laplacian Filter
- MATLAB - Laplacian of Gaussian Filter
- MATLAB - Inverse Fourier transform
- MATLAB - Fourier Transform
- MATLAB - Fast Fourier Transform
- MATLAB - 2-D Inverse Cosine Transform
- MATLAB - Add Legend to Axes
- MATLAB - Object Oriented
- MATLAB - Object Oriented Programming
- MATLAB - Classes and Object
- MATLAB - Functions Overloading
- MATLAB - Operator Overloading
- MATLAB - User-Defined Classes
- MATLAB - Copy Objects
- MATLAB - Algebra
- MATLAB - Linear Algebra
- MATLAB - Gauss Elimination
- MATLAB - Gauss-Jordan Elimination
- MATLAB - Reduced Row Echelon Form
- MATLAB - Eigenvalues and Eigenvectors
- MATLAB - Integration
- MATLAB - Integration
- MATLAB - Double Integral
- MATLAB - Trapezoidal Rule
- MATLAB - Simpson's Rule
- MATLAB - Miscellenous
- MATLAB - Calculus
- MATLAB - Differential
- MATLAB - Inverse of Matrix
- MATLAB - GNU Octave
- MATLAB - Simulink
MATLAB - Polynomial Division
Polynomial division is the process of dividing one polynomial by another. In MATLAB, you can perform polynomial division using the deconv function, which computes the deconvolution of two polynomials. Since polynomial division is essentially the inverse operation of polynomial multiplication, the deconv function can be used for polynomial division.
Using deconv() Function in Matlab
The deconv() function in MATLAB helps you to divide one polynomial by another.
Syntax
[x,r] = deconv(y,h)
Imagine you have two polynomials, P(x) and Q(x).When you divide P(x) by Q(x), you get the result called the quotient X(x) and a remainder R(x). The deconv() function in matlab does this division for you.
For example , if you have P(x) = 6x3 + 5x2 + 4x + 3 and Q(x) = 2x + 1, using deconv() will give you the quotient X(x) = 3x2 + 2x + 1 and the remainder R(x) = 0.
In Matlab , you use deconv(y, h) where y is coefficients of P(x) and h are the coefficients of of Q(x). The function returns the coefficients of X(x) as quotient and R(x) as remainder.
Example 1: Division of Polynomials
Let us consider this two polynomials as shown below −
P(x) = 6x3 + 5x2 + 4x + 3 Q(x) = 2x + 1
The coefficients for above polynomials is as follows −
P = [ 6 5 4 3 ]; Q = [2 1]
Here is a Matlab code,
% Define the coefficients of the polynomials P = [6 5 4 3]; % Coefficients of P(x) = 6x^3 + 5x^2 + 4x + 3 Q = [2 1]; % Coefficients of Q(x) = 2x + 1 % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder);
In the example above − The result of dividing P(x) by Q(x), i.e., the polynomial resulting from the division. The leftover polynomial that can't be divided further by Q(x).
The quotient X(x) will be a polynomial of degree 2, as P(x) is of degree 3 and Q(x) is of degree 1.
The remainder R(x) will be a constant term, as it represents the leftover part after division.
When the code is executed the output we get is as follows −
>> % Define the coefficients of the polynomials P = [6 5 4 3]; % Coefficients of P(x) = 6x^3 + 5x^2 + 4x + 3 Q = [2 1]; % Coefficients of Q(x) = 2x + 1 % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder); Quotient coefficients: 3.0000 1.0000 1.5000 Remainder coefficients: 0 0 0 1.5000 >>
Example 2: Higher-Degree Polynomials
Let's divide two higher-degree polynomials.
Polynomials: P(x) = 4x5 + 3x4 + 2x3 + x2 + 5x + 6 Q(x) = 2x2 + x + 1 Coefficients: P = [ 4 3 2 1 5 6 ] Q = [ 2 1 1 ]
To solve above polynomial division the code we have is −
% Define the coefficients of the polynomials P = [4 3 2 1 5 6]; % Coefficients of P(x) = 4x^5 + 3x^4 + 2x^3 + x^2 + 5x + 6 Q = [2 1 1]; % Coefficients of Q(x) = 2x^2 + x + 1 % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder);
In the code above we have −
- P(x) is of degree 5.
- Q(x) is of degree 2.
- The quotient will be a polynomial of degree 3, and the remainder will be a polynomial of degree 1.
On code execution in matlab command window the output we get is −
>> % Define the coefficients of the polynomials P = [4 3 2 1 5 6]; % Coefficients of P(x) = 4x^5 + 3x^4 + 2x^3 + x^2 + 5x + 6 Q = [2 1 1]; % Coefficients of Q(x) = 2x^2 + x + 1 % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder); Quotient coefficients: 2.0000 0.5000 -0.2500 0.3750 Remainder coefficients: 0 0 0 0 4.8750 5.6250 >>
Example 3: Division Resulting in Zero Remainder
Consider two polynomials where the division results in zero remainder.
Polynomials: P(x) = x4 + 4x3 + 6x2 + 4x + 1 (which is the expansion of (x+1)4) Q(x) = x + 1 Coefficients: P = [ 1 4 6 4 1 ] Q = [ 1 1 ]
The matlab code we have is −
% Define the coefficients of the polynomials P = [1 4 6 4 1]; % Coefficients of P(x) = x^4 + 4x^3 + 6x^2 + 4x + 1 Q = [1 1]; % Coefficients of Q(x) = x + 1 % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder);
In the code above,
- Since P(x) is exactly divisible by Q(x), the remainder will be zero.
- The quotient will be the result of dividing P(x) by Q(x), i.e., (x+1)3
When the code is executed in matlab command window the output is −
>> % Define the coefficients of the polynomials P = [1 4 6 4 1]; % Coefficients of P(x) = x^4 + 4x^3 + 6x^2 + 4x + 1 Q = [1 1]; % Coefficients of Q(x) = x + 1 % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder); Quotient coefficients: 1 3 3 1 Remainder coefficients: 0 0 0 0 0 >>
Example 4: Division of a Polynomial by a Constant
If you divide a polynomial by a constant (degree 0 polynomial), the quotient will simply be the original polynomial divided by that constant.
Polynomials: P(x) = 3x3 + 6x2 + 9x + 12 Q(x) = 3 (constant) Coefficients: P = [ 3 6 9 12 ] Q = [ 3 ]
The matlab code we have is −
% Define the coefficients of the polynomials P = [3 6 9 12]; % Coefficients of P(x) = 3x^3 + 6x^2 + 9x + 12 Q = [3]; % Coefficients of Q(x) = 3 (constant) % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder);
When the code is executed in matlab command window the output is −
>> % Define the coefficients of the polynomials P = [3 6 9 12]; % Coefficients of P(x) = 3x^3 + 6x^2 + 9x + 12 Q = [3]; % Coefficients of Q(x) = 3 (constant) % Perform the polynomial division [quotient, remainder] = deconv(P, Q); % Display the results disp('Quotient coefficients:'); disp(quotient); disp('Remainder coefficients:'); disp(remainder); Quotient coefficients: 1 2 3 4 Remainder coefficients: 0 0 0 0 >>