|
|
Polynomial roots
I'm trying to find the roots of 100 random polynomials of degree 5 and I need help with finding the roots. I know that I can gernerate 100 polynomials by using
>> x=rand([100 6])
I know that I can't do
>> roots(x)
because the the input must be a vector. Is there anyway to to find all the roots of 100 random polynomials without generating each polynomial one by one.
|
|
0
|
|
|
|
Reply
|
Mark
|
4/29/2010 9:15:22 PM |
|
Mark wrote:
> I'm trying to find the roots of 100 random polynomials of degree 5 and I
> need help with finding the roots. I know that I can gernerate 100
> polynomials by using
> >> x=rand([100 6])
> I know that I can't do >> roots(x)
> because the the input must be a vector. Is there anyway to to find all
> the roots of 100 random polynomials without generating each polynomial
> one by one.
Not for degree 5. For degree 4, there would be exact solutions you could
plug the coefficients into, but for degree 5 unless you are lucky enough
to be able to factorize, you need to use something like a binary search
for sign changes over a hypothesized interval.
I'm not saying that it would not be possible to build a routine that did
this kind of search in parallel, but it isn't the way the built-in
routines are set up.
|
|
0
|
|
|
|
Reply
|
Walter
|
4/29/2010 9:29:11 PM
|
|
"Mark " <bobbb909@yahoo.com> wrote in message
news:hrcsta$g22$1@fred.mathworks.com...
> I'm trying to find the roots of 100 random polynomials of degree 5 and I
> need help with finding the roots. I know that I can gernerate 100
> polynomials by using
> >> x=rand([100 6])
> I know that I can't do >> roots(x)
> because the the input must be a vector. Is there anyway to to find all the
> roots of 100 random polynomials without generating each polynomial one by
> one.
Loop over the rows of x and call ROOTS on each row, storing the roots back
into rows or columns of another matrix or into a cell array (depending on
how you need them.)
--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
|
0
|
|
|
|
Reply
|
Steven
|
4/29/2010 9:43:18 PM
|
|
"Mark " <bobbb909@yahoo.com> wrote in message <hrcsta$g22$1@fred.mathworks.com>...
> I'm trying to find the roots of 100 random polynomials of degree 5 and I need help with finding the roots. I know that I can gernerate 100 polynomials by using
> >> x=rand([100 6])
> I know that I can't do
> >> roots(x)
> because the the input must be a vector. Is there anyway to to find all the roots of 100 random polynomials without generating each polynomial one by one.
a hint:
help num2cell;
help cellfun;
us
|
|
0
|
|
|
|
Reply
|
us
|
4/29/2010 9:46:04 PM
|
|
"Steven Lord" <slord@mathworks.com> wrote in message <hrcuhl$1r6$1@fred.mathworks.com>...
>
> "Mark " <bobbb909@yahoo.com> wrote in message
> news:hrcsta$g22$1@fred.mathworks.com...
> > I'm trying to find the roots of 100 random polynomials of degree 5 and I
> > need help with finding the roots. I know that I can gernerate 100
> > polynomials by using
> > >> x=rand([100 6])
> > I know that I can't do >> roots(x)
> > because the the input must be a vector. Is there anyway to to find all the
> > roots of 100 random polynomials without generating each polynomial one by
> > one.
>
> Loop over the rows of x and call ROOTS on each row, storing the roots back
> into rows or columns of another matrix or into a cell array (depending on
> how you need them.)
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
How would I wrtie the for loop? Here is what I got so far
N=100;
x=zeros(100, 6); % cretes an empty 100 x 6 matrix
for k=1:N
x(k)=roots(rand([1 6]));
end
x
I know that this won't work so how can I get it to work.
|
|
0
|
|
|
|
Reply
|
Mark
|
5/1/2010 10:10:08 PM
|
|
"Mark " <bobbb909@yahoo.com> wrote in message <hri8s0$gjm$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote in message <hrcuhl$1r6$1@fred.mathworks.com>...
> >
> > "Mark " <bobbb909@yahoo.com> wrote in message
> > news:hrcsta$g22$1@fred.mathworks.com...
> > > I'm trying to find the roots of 100 random polynomials of degree 5 and I
> > > need help with finding the roots. I know that I can gernerate 100
> > > polynomials by using
> > > >> x=rand([100 6])
> > > I know that I can't do >> roots(x)
> > > because the the input must be a vector. Is there anyway to to find all the
> > > roots of 100 random polynomials without generating each polynomial one by
> > > one.
> >
> > Loop over the rows of x and call ROOTS on each row, storing the roots back
> > into rows or columns of another matrix or into a cell array (depending on
> > how you need them.)
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> >
> How would I wrtie the for loop? Here is what I got so far
>
> N=100;
> x=zeros(100, 6); % cretes an empty 100 x 6 matrix
>
> for k=1:N
> x(k)=roots(rand([1 6]));
> end
>
> x
> I know that this won't work so how can I get it to work.
-----------
You're almost there. Just add a colon. And use 100 x 5 size.
N=100;
x=zeros(100, 5); % creates an empty 100 x 5 matrix
for k=1:N
x(k,:) = roots(randn([1 6]));
end
Roger Stafford
|
|
0
|
|
|
|
Reply
|
Roger
|
5/2/2010 2:55:23 AM
|
|
|
5 Replies
191 Views
(page loaded in 0.101 seconds)
Similiar Articles: Using fuzzy logic to solve a third degree polynomial function ...... sys.math.mathematica Using fuzzy logic to solve a third degree polynomial function ... Using fuzzy logic to solve a third degree polynomial function ... How to find roots ... root finding routine - comp.soft-sys.math.mathematicaMath logic - comp.lang.asm.x86 Using fuzzy logic to solve a third degree polynomial function ... How to find roots of ... root finding routine - comp.soft-sys.math ... Unit Root tests: ADF. Econometrics toolbox - comp.soft-sys.matlab ...> > I am trying to work out which order of time polynomial in the null-hypothesis this ... 'ar' means that you are just testing for a unit root. 'ard' indicates unit root ... Minimum Phase Impulse Response - comp.dspIf so, I think Matt's original problem in principle can be solved, though with the already stated practical caveat about finding roots of "large" polynomials. Newton's interpolation formula - comp.soft-sys.matlabThis is it: Using Newton's interpolation formula plot a graph of the polynomial ... Roots - Bisection method - comp.soft-sys.matlab Newton's interpolation formula ... Polynomial division modulo 2 - comp.sys.hp48Hello, I need to calculate Polynomial division modulo 2 on HP49G in order to calcule CRC. Can anyone help me please? thanks Rui ... Unit root test using adf - comp.soft-sys.matlab"Unit Root Tests in ARMA Models with Data-Dependent Methods for the Selection of ... Differentiating or fitting a polynomial expansion. Now I'm looking at the function and I ... Direct form II transposed filter implementation - comp.dsp ...Second, as polynomial order goes up the roots become exceedingly sensitive to variations in the coefficients. This creates all sorts of numerical havoc with direct ... Suitable Integer Square Root Algorithm for 32-64-Bit Integers on ...So, normalize your number and then do polynomial or piecewise linear approximation. ... for sqrt(), and some other inverse functions, too, > is to treat it as a root ... fsolve help!!! - comp.soft-sys.matlab- - - - - - - - - - You can convert your equations to a quartic polynomial equation in x(3). Using the 'roots' function on this, from each of its real roots (if any) you can determine the ... Polynomial Roots -- from Wolfram MathWorldA root of a polynomial P(z) is a number z_i such that P(z_i)=0. The fundamental theorem of algebra states that a polynomial P(z) of degree n has n roots, some of ... Properties of polynomial roots - Wikipedia, the free encyclopediaIn mathematics, a polynomial is a function of the form where the coefficients are complex numbers and. The fundamental theorem of algebra states that polynomial p has ... 7/14/2012 3:51:41 PM
|
|
|
|
|
|
|
|
|