473,549 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

any Python equivalent of Math::Polynomia l::Solve?

While googling for a non-linear equation solver, I found
Math::Polynomia l::Solve in CPAN. It seems a great little module, except
it's not Python... I'm especially looking for its poly_root()
functionality (which solves arbitrary polynomials). Does anyone know of
a Python module/package that implements that?

Just
Jul 18 '05 #1
17 3493
Just wrote:
While googling for a non-linear equation solver, I found
Math::Polynomia l::Solve in CPAN. It seems a great little module, except
it's not Python... I'm especially looking for its poly_root()
functionality (which solves arbitrary polynomials). Does anyone know of
a Python module/package that implements that?

Just


Does SciPy do what you want? Specifically Scientific.Func tions.FindRoot [1] &
Scientific.Func tions.Polynomia l [2]

Regards,
Nick.

[1]
http://starship.python.net/~hinsen/S...entific_9.html
[2]
http://starship.python.net/~hinsen/S...ntific_13.html
--
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #2
In article <ma************ *************** ************@py thon.org>,
Nick Coghlan <nc******@iinet .net.au> wrote:
Just wrote:
While googling for a non-linear equation solver, I found
Math::Polynomia l::Solve in CPAN. It seems a great little module, except
it's not Python... I'm especially looking for its poly_root()
functionality (which solves arbitrary polynomials). Does anyone know of
a Python module/package that implements that?

Just


Does SciPy do what you want? Specifically Scientific.Func tions.FindRoot [1] &
Scientific.Func tions.Polynomia l [2]

Regards,
Nick.

[1]
http://starship.python.net/~hinsen/S...thonManual/Sci
entific_9.html
[2]
http://starship.python.net/~hinsen/S...thonManual/Sci
entific_13.html


(Hm, I had the impression that scipy != Konrad Hinsen's Scientific
module.)

I had played with [1], but it "only" calculates one root, and I need all
roots (specifically, for a quintic equation). [2] doesn't seem to be a
solver?

Just
Jul 18 '05 #3

"Just" <ju**@xs4all.nl > wrote in message
news:ju******** *************** *@news1.news.xs 4all.nl...
Does SciPy do what you want? Specifically Scientific.Func tions.FindRoot
[1] &
Scientific.Func tions.Polynomia l [2]
http://starship.python.net/~hinsen/S...thonManual/Sci
entific_9.html
[2]
http://starship.python.net/~hinsen/S...thonManual/Sci
entific_13.html


(Hm, I had the impression that scipy != Konrad Hinsen's Scientific
module.)


www.scipy.org (first hit on "Python SciPy" google search)

Terry J. Reedy

Jul 18 '05 #4
In article <ju************ ************@ne ws1.news.xs4all .nl>,
Just <ju**@xs4all.nl > wrote:
While googling for a non-linear equation solver, I found
Math::Polynomi al::Solve in CPAN. It seems a great little module, except
Thank you.
it's not Python...
Sorry about that.
I'm especially looking for its poly_root()
functionalit y (which solves arbitrary polynomials). Does anyone know of
a Python module/package that implements that?


Are you looking for that particular algorithm, or for any
source that will find the roots of the polynomial? The
original source for the algorithm used in the module is
from Hiroshi Murakami's Fortran source, and it shouldn't
be too difficult to repeat the translation process to python.

--
-john

February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
Jul 18 '05 #5
In article <cv**********@e 250.ripco.com>,
jg*****@ripco.c om (John M. Gamble) wrote:
In article <ju************ ************@ne ws1.news.xs4all .nl>,
Just <ju**@xs4all.nl > wrote:
While googling for a non-linear equation solver, I found
Math::Polynomi al::Solve in CPAN. It seems a great little module, except
Thank you.
it's not Python...


Sorry about that.


Heh, how big are the odds you find the author of an arbitrary Perl
module on c.l.py...
I'm especially looking for its poly_root()
functionalit y (which solves arbitrary polynomials). Does anyone know of
a Python module/package that implements that?


Are you looking for that particular algorithm, or for any
source that will find the roots of the polynomial?


Any will do. As I wrote in another post, I'm currently only looking for
a quintic equation solver, which your module does very nicely.
The
original source for the algorithm used in the module is
from Hiroshi Murakami's Fortran source, and it shouldn't
be too difficult to repeat the translation process to python.


Ah ok, I'll try to locate that (following the instruction in Solve.pm
didn't work for me :( ).

Just
Jul 18 '05 #6
In article <ju************ ************@ne ws1.news.xs4all .nl>,
Just <ju**@xs4all.nl > wrote:

Heh, how big are the odds you find the author of an arbitrary Perl
module on c.l.py...

Hey, that's why it's called lurking.

Any will do. As I wrote in another post, I'm currently only looking for
a quintic equation solver, which your module does very nicely.
The
original source for the algorithm used in the module is
from Hiroshi Murakami's Fortran source, and it shouldn't
be too difficult to repeat the translation process to python.


Ah ok, I'll try to locate that (following the instruction in Solve.pm
didn't work for me :( ).


Ouch. I just did a quick search and found that that site has undergone
a few changes, and the code that i reference is missing. A few other
links in the docs are stale too. I need to update the documentation.

Anyway, doing a search for 'hqr' and Eispack got me a lot of sites.
In particular, this one is pretty friendly:

<http://netlib.enseeiht .fr/eispack/>

Look at the source for balanc.f (does the prep-work) and hqr.f
(does the solving). Minor annoyance: the real and imaginary
parts of the roots are in separate arrays. I combined them into
complex types in my perl source, in case you want to make a
comparison.

Of course, all this may be moot if the other suggestions
work out.

--
-john

February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
Jul 18 '05 #7
In article <cv**********@e 250.ripco.com>,
jg*****@ripco.c om (John M. Gamble) wrote:
The
original source for the algorithm used in the module is
from Hiroshi Murakami's Fortran source, and it shouldn't
be too difficult to repeat the translation process to python.
Ah ok, I'll try to locate that (following the instruction in Solve.pm
didn't work for me :( ).


Ouch. I just did a quick search and found that that site has undergone
a few changes, and the code that i reference is missing. A few other
links in the docs are stale too. I need to update the documentation.

Anyway, doing a search for 'hqr' and Eispack got me a lot of sites.
In particular, this one is pretty friendly:

<http://netlib.enseeiht .fr/eispack/>

Look at the source for balanc.f (does the prep-work) and hqr.f
(does the solving). Minor annoyance: the real and imaginary
parts of the roots are in separate arrays. I combined them into
complex types in my perl source, in case you want to make a
comparison.


Thanks! I'll check that out.
Of course, all this may be moot if the other suggestions
work out.


SciPy indeed appear to contain a solver, but I'm currently stuck in
trying to _get_ it for my platform (OSX). I'm definitely not going to
install a Fortran compiler just to evaluate it (even though my name is
not "Ilias" ;-). Also, SciPy is _huge_, so maybe a Python translation of
that Fortran code or your Perl code will turn out to be more attractive
after all...

Just
Jul 18 '05 #8
Just wrote:
<snip>

SciPy indeed appear to contain a solver, but I'm currently stuck in
trying to _get_ it for my platform (OSX). I'm definitely not going to
install a Fortran compiler just to evaluate it (even though my name is
not "Ilias" ;-). Also, SciPy is _huge_, so maybe a Python translation of
that Fortran code or your Perl code will turn out to be more attractive
after all...

Just


The GNU Scientific Library has a nice root finder for polynomials with
real coefficients. I have wrapped this with Pyrex to work with my
ratfun module see:

http://calcrpnpy.sourceforge.net/ratfun.html

If this will suit your needs, I can send you an alpha release of the
package with the root finder. It is not pure Python. I requires Pyrex
and a C compiler to install. My guess is that it will work on OSX as
well as it does on Linux. This functionality will be included in the
next release of the ratfun package but I still have to unit test a
number of components and update the documentation. Consequently, an
official release will not happen soon.

Ray
Jul 18 '05 #9
In article <I6************ ***@twister.rdc-kc.rr.com>,
"Raymond L. Buvel" <le******@wi.rr .com> wrote:
Just wrote:
<snip>

SciPy indeed appear to contain a solver, but I'm currently stuck in
trying to _get_ it for my platform (OSX). I'm definitely not going to
install a Fortran compiler just to evaluate it (even though my name is
not "Ilias" ;-). Also, SciPy is _huge_, so maybe a Python translation of
that Fortran code or your Perl code will turn out to be more attractive
after all...

Just


The GNU Scientific Library has a nice root finder for polynomials with
real coefficients. I have wrapped this with Pyrex to work with my
ratfun module see:

http://calcrpnpy.sourceforge.net/ratfun.html

If this will suit your needs, I can send you an alpha release of the
package with the root finder. It is not pure Python. I requires Pyrex
and a C compiler to install. My guess is that it will work on OSX as
well as it does on Linux. This functionality will be included in the
next release of the ratfun package but I still have to unit test a
number of components and update the documentation. Consequently, an
official release will not happen soon.


Thank you, I'll check this out. I had come across GSL, but not Python
bindings. (GPL is probably a problem for my project, but it's very good
to know anyway.)

On the other hand, I just finished translating the relevant portions of
Math::Polynomia l::Solve to Python, so I'm probably all set, at least for
now. Thanks everyone for the responses, especially to John Gamble!

Just
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
33350
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it...
21
2817
by: Glen Wheeler | last post by:
Hello all, My program uses many millions of integers, and Python is allocating way too much memory for these. I can't have the performance hit by using disk, so I figured I'd write a C extension to define a new type. Problem is, my C knowledge is years old and regardless of my attempts distutils will not recognise my installation of the MS...
4
2985
by: Kyler Laird | last post by:
I'm trying to do some georeferencing - using points of known location (ground control points, GCPs) on an image to develop a polynomial that can be used to approximate the locations of other points. I usually use the Python bindings to GDAL http://www.remotesensing.org/gdal/ to manipulate geospatial data but there are no Python bindings...
9
49582
by: Joseph Aldred | last post by:
I am new to C and I am writing a program for a class I am taking. I need to use a exponent but I can not figure how to do it. I figure I need to use exp() or pow() but I can not figure out how to do it. Any help that anyone can give me would be appreciated greatly. Thanks, Joseph
2
1716
by: sekitoleko | last post by:
c program for bisection method to find roots of a polynomial
5
8806
by: MathNewbie | last post by:
Hi, I'm trying to do get my head around some, probably basic, math calculations. I checked some .net math libs, but the only thing I learn from studying those is humility ;-). Anyway, i have an array of points on a basic 2 dimensional axis. They are all points of a sine shaped line. (not a perfect sine though, as it's actually tide...
116
35721
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused problems elsewhere in another part of the system where that figure was used for some calculation and some eventual truncation led to the system going...
270
7929
by: Jordan | last post by:
Hi everyone, I'm a big Python fan who used to be involved semi regularly in comp.lang.python (lots of lurking, occasional posting) but kind of trailed off a bit. I just wrote a frustration inspired rant on my blog, and I thought it was relevant enough as a wider issue to the Python community to post here for your discussion and...
9
28911
by: curiously enough | last post by:
I need a practical method to find the eigenvalues of a matrix in C++ because the one I know(the only one I know) is to subtract the elements of the diagonal by the eigenvalue and then find the determinant of this matrix: |A-xI|=0, and in C++ I do this by checking every float value with one digit after the decimal between -10000.0 and 10000.0, and...
0
7450
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.