Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
creating a polynomial from given roots and multiplicies

Subject: creating a polynomial from given roots and multiplicies

From: Luke

Date: 3 Feb, 2012 07:48:11

Message: 1 of 2

Hello, I need help creating a polynomial. This is the criteria,
given the roots and multiplicities of the polynomial, the function I create needs to be able to produce a polynomial, the catch is my teacher is not letting me use built in matlab functions. This is what I have so far, I created the multplicites for the polynomial but that is all.
function polycontr = poly_construct(p,m);
if m <=0;
    m=1;
    p=p
    end
m1 = ones([1 length(m)]);
bigm= dot(m,m1);
am = bigm
for k=1:bigm;
    am=am-1
end
    end

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test case... if p=[1 -2 -3] and m=[3 2 1] from (x-1)^3(x+2)^2(x+3)
it should produce the polynomial X^6+4X^5-2X^4-16X^3+5X^2+20X-12

Subject: creating a polynomial from given roots and multiplicies

From: Roger Stafford

Date: 3 Feb, 2012 09:04:30

Message: 2 of 2

"Luke " <l.jpeterson@yahoo.com> wrote in message <jgg3fr$m6f$1@newscl01ah.mathworks.com>...
> given the roots and multiplicities of the polynomial, the function I create needs to be able to produce a polynomial, the catch is my teacher is not letting me use built in matlab functions.
> .......
> test case... if p=[1 -2 -3] and m=[3 2 1] from (x-1)^3(x+2)^2(x+3)
> it should produce the polynomial X^6+4X^5-2X^4-16X^3+5X^2+20X-12
- - - - - - - -
  I think none of us will do your homework for you, Luke. However, I will leave you with the following hint. Represent your polynomial as simply the set of coefficients appearing in the polynomial. That is, the final result in your test case should be: [1,4,-2,-16,5,20,-12]. Start with a coefficient vector of [1]. When a student in algebra would multiply it by X minus the first root, this should give you two elements in your coefficient vector representation, namely [1,-root]. Then work out the rules for how each successive student multiplication would affect this set of coefficients, until you have brought in all roots, each with its required multiplicity. (Piece of cake!)

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us