how to do polynomial division

hi...
i wanna do polynomial divison given numerator=x^5+x^4+x^3 and
denominator=x^3+x+1 ;remainder should be x...how to implement it in matlab..

2 Kommentare

Walter Roberson
Walter Roberson am 3 Nov. 2011
Will the coefficients always be either 0 or 1 ? A binary polynomial?
faa nad
faa nad am 5 Nov. 2011
yes ,it is a binary polynomial

Melden Sie sich an, um zu kommentieren.

Antworten (4)

Daniel Baboiu
Daniel Baboiu am 3 Nov. 2011

0 Stimmen

You have two choices: 1. Use the Symbolic Math Toolbox 2. Store all coefficients as a vector (including the coefficients which are 0), then use this representation to implement division steps as described below: http://en.wikipedia.org/wiki/Polynomial_long_division

2 Kommentare

faa nad
faa nad am 5 Nov. 2011
hi..
thanks for ur reply.is there any other options for dividing the polynomial directly ?what we do in mathematics.without extracting the coefficients.
Walter Roberson
Walter Roberson am 5 Nov. 2011
In mathematics, we mentally extract the coefficients in order to do the division.

Melden Sie sich an, um zu kommentieren.

Andrei Bobrov
Andrei Bobrov am 5 Nov. 2011

0 Stimmen

[a,b]=deconv([1 1 1 0 0 0],[1 0 1 1])
add
p1=[1 1 1 0 0 0]
p2=[1 0 1 1]
[a b] = deconv(p1,p2)
syms x
k = cellfun(@(y) y*x.^(numel(y)-1:-1:0).',{a b p2},'un',0)
k = [k{:}]
out = k(1) + k(2)/k(3)

1 Kommentar

faa nad
faa nad am 5 Nov. 2011
the answer given by u works well..but my aim is to divide two polynomial expressions[1+x+x^2]/[1+x] directly.the output must be polynomial expression

Melden Sie sich an, um zu kommentieren.

Walter Roberson
Walter Roberson am 5 Nov. 2011

0 Stimmen

As you have restricted this to symbolic expressions without ever extracting the coefficients (at least not in code you write, even if it gets done "under the hood"), then the solution is to use the MuPAD Standard Library function pdivide
I could offer a very nice and efficient calculation for polynomials up to order 52 where the coefficients are all 0 or 1, if we are allowed to extract the coefficients in the code (which you could stuff in to a subroutine and never look at again), but I gather that efficiency and simplicity are not important for your purposes.

5 Kommentare

faa nad
faa nad am 6 Nov. 2011
i tried with pdivide function..it shows an error as "Undefined function or method 'pdivide' for input arguments of type 'sym'".
why such a problem occurs.?
Walter Roberson
Walter Roberson am 6 Nov. 2011
pdivide is a member of the MuPAD Standard Library, and must be invoked within MuPAD. There is no direct interface between it and MATLAB. You can access it using evalin(symengine) or feval(symengine)
feval(symengine, 'pdivide', x^5+x^4+x^3, x^3+x+1)
faa nad
faa nad am 6 Nov. 2011
sorry...error in symengine..
Walter Roberson
Walter Roberson am 6 Nov. 2011
Do you have the symbolic toolbox installed and licensed? If not, then you cannot do what you are asking for, as only the symbolic toolbox hides extracting the coefficients of polynomials.
Maria Maximina
Maria Maximina am 21 Feb. 2014
hi! o have one question for you! i know it is long time ago.. but anyway.. jajaja if u do that operation that you suggested, and you get a vector like:
[a,b,polinom]
what do actually a and b mean??? thanks!

Melden Sie sich an, um zu kommentieren.

Ahmed J. Abougarair
Ahmed J. Abougarair am 18 Nov. 2022

0 Stimmen

syms x y
p = x^3 - x*y^2 + 1;
d = x + y;
[r,q] = polynomialReduce(p,d)

Gefragt:

am 3 Nov. 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by