Jump to content



Photo

All Roots Of A Polynomial


  • Please log in to reply
11 replies to this topic

#1 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 26 July 2007 - 01:47 PM

LAC version 0.01

This is a program to find all real and imaginary roots of a polynomial.

It's based on Durand-Kerner method. This method has a drawback: if a root is
double, triple... (multiple root) the method is slightly efficient. Fortunately, there is an algorithm
to find multiple roots. The program first find multiple roots, if any the polynomial is deflated
and then are found the remainder of the roots.


The program is a part of a automatic control project even in development.

To run this program you will need the 'LNAutils' by PAP.

Example: To find the roots of the polynomial: x5-14x4+162x3-652x2+2145x+8450 and to measure
the elapsed time you would have to write:



require ("LACutils/RootP","LNAutils/MatPrint","LNAutils/TimeElap")local r,h,m,slocal a={1,-14,162,-652,2145,8450}h,m,s=gettime()r=RootP(a)TimeElapsed(h,m,s,1)print("roots=")MatPrint(r,"%.8")

The roots are stored in a table of two dimensions:

r1<span class=1' /> -> real part root 1, r1<span class=2' /> -> imaginary part root 1
r2<span class=1' /> -> real part root 2, r2<span class=2' /> -> imaginary part root 2 ... and so on.

#2 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 26 July 2007 - 02:48 PM

This is a program to find all real and imaginary roots of a polynomial.

Interesting, I would like to see the source code for "RootP". Your program is able to find all roots of polynomials only (while LNA's function KroneRoots is not restricted to polynomials). On the other hand, your program also finds imaginary roots, while KroneRoots (and LNA, in general) is restricted to real numbers.

#3 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 26 July 2007 - 04:00 PM

The program is in the File sharing. I have directly written it in the CP300.
I need to know all roots of the polynomials (and only polynomials for the present) because I'm developing a program for automatic control LCA(Lua Automatic Control). There are several techniques to solve systems of automatic control: Root locus method, Bode diagrams... In a elementary level we only need polynomials and its roots.

I've written the program directly on the CP300 because there isn't a external compiler for CPLua but also I have written it in Wordpad to be able to print it. Is this the file(s) that you want?

#4 girdeux

girdeux

    Casio Addict

  • Members
  • PipPipPip
  • 88 posts
  • Location:Spain / Castell?n

  • Calculators:
    casio fx-115ms;
    casio classpad 300

Posted 26 July 2007 - 06:51 PM

Good program I was looking for someting like this, only two mini bugs:

- in the program LACutils/DivPoly in side of require put "LACutils/RmvLeadZ" (it's write bad)
- in the code that you have puted in the post, at the last line: MatPrint(r,"%.8f") (you forgot the "f")

#5 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 27 July 2007 - 06:42 PM

Both bugs are solved of the way that you propose: in the program LACutils/DivPoly within the 'require' statment it must change "LGRutils/RmvLeadZ" by "LACutils/RmvLeadZ". (LGRutils was a previous working directory).
The code of example needs an 'f' in the last line: 'MatPrint(r,"%8f)' to run correctly.

I'm sorry and thanks for your comprehension.

#6 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 28 July 2007 - 09:02 AM

The code of example needs an 'f' in the last line: 'MatPrint(r,"%8f)' to run correctly.

To avoid similar typos in the future, transfer your program to the PC, open it with CPLua.exe, then copy and paste it here. You don't need to type it directly (thus inserting unavoidable typos).

#7 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 28 July 2007 - 09:07 AM

Speaking about that, I'm a little bit worried concerning CPManager 3.0... :unsure:
I can be wrong, but I think it cannot save *.mcs files anymore :blink: It uses another file format (*.vcp) that CPLua.exe cannot read <_<
It isn't the right topic to speak about that anyways, but still we (or I?) will have to find a solution :rolleyes:

#8 unique33

unique33

    Casio Freak

  • Possibly hacked
  • PipPipPipPip
  • 229 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    classpad 300 , fx5500

Posted 28 July 2007 - 09:54 AM

LAC version 0.01

The program is a part of a automatic control project even in development.

I need to know all roots of the polynomials (and only polynomials for the present) because I'm developing a program for automatic control LCA(Lua Automatic Control). There are several techniques to solve systems of automatic control: Root locus method, Bode diagrams... In a elementary level we only need polynomials and its roots.


Nice Project .
nice to see another mechanical software for classpad .
which book you are using for that ? does the book contain any code for this kind of plots ?
The book that I have , just contain Matlab Codes . If you know , Matlab has several functions for control theory and can plot such diagrams using the eguations of state.
but there was no code to program such plots

#9 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 28 July 2007 - 11:20 AM

To avoid similar typos in the future, transfer your program to the PC, open it with CPLua.exe, then copy and paste it here. You don't need to type it directly (thus inserting unavoidable typos).


Thanks, I have proven it and works. Note that I am a novice in this forum.

#10 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 28 July 2007 - 11:55 AM

Speaking about that, I'm a little bit worried concerning CPManager 3.0... :unsure:
I can be wrong, but I think it cannot save *.mcs files anymore :blink: It uses another file format (*.vcp) that CPLua.exe cannot read <_<
It isn't the right topic to speak about that anyways, but still we (or I?) will have to find a solution :rolleyes:


The first time that I saw the CP300 it seemed to me, with its great screen, the Ferrari of the calculators. After buying it, I realized that its motor was like a Trabant motor (3 cylinders car of old RDA). Thanks to Orwell's Lua implementation the motor was upgraded a lot and I saved my investment.
Orwell, continue working because we are in your hands. :(

#11 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 28 July 2007 - 12:23 PM

Nice Project .
nice to see another mechanical software for classpad .
which book you are using for that ? does the book contain any code for this kind of plots ?
The book that I have , just contain Matlab Codes . If you know , Matlab has several functions for control theory and can plot such diagrams using the eguations of state.
but there was no code to program such plots


I know Matlab and Scilab. The first function that would try to implement is 'rlocus' of Matlab (or 'evans' of Scilab).

The book I'm using is 'Modern control systems' of Dorf & Bishop.

I haven't any book with Matlab codes.

#12 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 28 July 2007 - 02:05 PM

The first time that I saw the CP300 it seemed to me, with its great screen, the Ferrari of the calculators. After buying it, I realized that its motor was like a Trabant motor (3 cylinders car of old RDA). Thanks to Orwell's Lua implementation the motor was upgraded a lot and I saved my investment.
Orwell, continue working because we are in your hands. :(

You have a point here, Aristos. I was also greatly disappointed with CP's built-in Basic. I was considering to sell it, and buy something more powerful, but CPLua saved my money.:)

I know Matlab and Scilab. The first function that would try to implement is 'rlocus' of Matlab (or 'evans' of Scilab).

Obviously, you need to use LNA a lot to do that (not only LNAutils).
Note that the new version of LNA (1.70) has a slightly different syntax, so you might need to modify your programs based on LNA 1.60. I hope I will be able to release LNA 1.70 soon.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users