Code covered by the BSD License

### Highlights from Polynomials with multiple roots solved

5.0
5.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 1.63 KB File ID: #25375 Version: 1.9

# Polynomials with multiple roots solved

### Feng Cheng Chang (view profile)

21 Sep 2009 (Updated )

Solving multiple roots polynomial, using simple elementary arithematic operations mostly.

File Information
Description

A given polynomial having multiple roots is solved by the routine
Z = poly_roots(p)
where
Input p: polynomial coefficient vector
Output Z: root-multiplicity pairs

The MATLAB source code is very simple and compact (fewer then 50 lines) and amazingly gives the expected results for any test polynomials of very high degree and multiplicities.

In this simple routine 'poly_roots.m', except for a MATLAB built-in function 'roots.m', all the required computations involve only simple elementary arithematic operations (such
as additions, subtractions, multiplications, divisions, and integer exponations), without applying any high mathematics. The only routine 'roots.m' is used here mainly to solve a simple roots polynomial (not any multiple roots polynomials).

Most of the calculations in this routine involve elementary arithematic operations, therefore, it is fairly easy to improve the expected results from the existing double precision to vpi' multiple precision.

For detail description, please refer to

F.C. Chang, "Solving multple-root polynomials" IEEE Antennas and Propagation Magazine, Vol.51, No.6, pp. 151-155, Dec. 2009.

Acknowledgements

This file inspired Solving Multiple Root Polynomials.

MATLAB release MATLAB 6.5 (R13)
02 Aug 2014 Feng Cheng Chang

### Feng Cheng Chang (view profile)

Reply to pippo: In the 7x2 matrix:
1st column --- polynomial roots
2nd column --- root's multiplicities

Comment only
01 Aug 2014 pippo

### pippo (view profile)

Hi, I have a polynomial with 34 orders, but this function gives me roots of 7x2 matrix. Why is that? I copied my polynomial coefficients as below. Could anyone help me out? Thanks!

1 -26.7479290179817 346.353790281681 -2891.79278087362 17494.1298230978 -81695.4463236101 306371.295805817 -947699.866103653 2464717.23435414 -5466000.43064478 10447379.3286537 -17350483.7757060 25192808.9914633 -32131544.3997781 36120714.4912932 -35872219.7954520 31515357.4741505 -24504114.0520695 16854492.5963053 -10241648.1386483 5485377.96325360 -2580928.16918672 1061956.10387350 -379845.324952006 117197.882178068 -30882.3382140184 6860.29267091761 -1262.93321056908 188.263121608582 -21.9982275506094 1.92027369835658 -0.115917764563237 0.00419847428401219 -6.48118467521201e-05

Comment only
14 May 2014 Bor Plestenjak

### Bor Plestenjak (view profile)

The correction works for the reported problem, but, there is more. For instance, for p=[3e-04 1e-09 1e-09 5e-08 2e+04] results are wrong and in addition multiplicities appear as complex numbers.

Comment only
14 May 2014 Feng Cheng Chang

### Feng Cheng Chang (view profile)

Thank you for your pinpoint the bug.

It should be OK if the file is correct as follows: In line 15, change
from
" if npo == 1, return, end;"
to
" if npo == 0, return, end;"

I will update this file later. But please try again now!

Comment only
14 May 2014 Bor Plestenjak

### Bor Plestenjak (view profile)

There seems to be a bug when it comes to linear polynomials (which of course can not have multiple zeros). poly_roots([1 2]) does not return a zero and poly_roots([1 1 0 0 0]) returns just the triple zero 0.

Comment only
29 Apr 2012 John D'Errico

### John D'Errico (view profile)

Well done.

27 Apr 2012 Andrew Mendelsohn

### Andrew Mendelsohn (view profile)

Nice little file finds multiple roots much more accurately than built in routine. Used it in an inverse Laplace transform application.

23 Oct 2009 Feng Cheng Chang

### Feng Cheng Chang (view profile)

Self comment:

Amazingly, the revised routine can find the desired roots of test polynomials p(x) -- expanded, such as
p(x) = (x+987654321)^N,
where N=any positive integers, such as 10, 100, 1000, 10000, ....

For example, find the roots of the following polynomial expanded
p(x) = (x+987654321)^12345.

>> format long g
>> p = poly([-987654321*ones(1,12345)]);
>> Z = poly_roots(p)
Z =
-987654321 12345

It takes about 2 min total time. Most is to create polynomial coefficient vector p, and only 0.5 sec to get the desired root-multiplicity pairs Z.

Of course, any numerical algorithm is not fool prove, neither is mine.

Foe example,it does work for p(x)=(9876x+12345)^70, but fails for p(x)=(9876x+12345)^80.

I hope someone would like to try it for some other existing test polynomials, and give me any valuable comments.

Comment only
23 Oct 2009 1.1

Update the m-file, the very small roots can thus be solved.

04 Jan 2010 1.2

Update m-file -- improve help description

26 Feb 2010 1.5

Update the m-file to speed up operations. Also present 17 typical examples for test polynomials in MATLAB script file.

09 Mar 2010 1.6

21 May 2012 1.7

Update the original source code. It involves only simple elementary operations, except 'roots.m'. It may easily convert into multiple precision later.

22 May 2012 1.8

Minor correction to poly_roots.m

15 May 2014 1.9

Correct a tiny bug, pinpointed by a reader.