Hi,
I am a new user and I want to show you my Python library.

pypol
pypol is a Python library that allows you to manipulate monomials, polynomials and algebraic fractions.
An example:

``````>>> import pypol
>>> a = pypol.polynomial('3xy - 3a^2 + 2b')
>>> a
- 3a² + 3xy + 2b
>>> a.append('-2')
>>> a.right_hand_side
-2
>>> del a[-1]
>>> a.right_hand_side
False
>>> a.append('-2')
>>> a.letters
('a', 'b', 'x', 'y')
>>> a.powers()
{'a': [2, 0], 'b': [1, 0], 'x': [1, 0], 'y': [1, 0]}
>>> a.iscomplete('x')
True
>>> a.iscomplete('a')
False
>>> a._make_complete('a')
True
>>> a.iscomplete('a')
True
>>> a.monomials
((-3, {'a': 2}), (0, {'a': 1}), (3, {'x': 1, 'y': 1}), (2, {'b': 1}), (-2, {}))
>>> a
- 3a²  + 3xy + 2b - 2
>>> a.max_power('a')
2
>>> a.min_power('a')
0
>>> a.isordered('a')
True
>>> b = pypol.polynomial('3a - 1')
>>> b.zeros
()
>>> b.print_format = False
>>> b
+ 3a - 1
>>> b.append('2x2')
>>> b
+ 2x^2 + 3a - 1
>>> b.print_format = True
>>> b
+ 2x² + 3a - 1
>>> p = pypol.Polynomial(((3, {'a': 2}), (-2, {'a': 1}), (2, {})))
>>> p
+ 3a² - 2a + 2
>>> a
- 3a²  + 3xy + 2b - 2
>>> p
+ 3a² - 2a + 2
>>> a + p
+ 3xy + 2b - 2a
>>> a - p
- 6a² + 3xy + 2b + 2a - 4
>>> a * p
- 9a⁴ + 6a³ + 9a²xy + 6a²b - 12a² - 6axy + 6xy - 4ab + 4b + 4a - 4
>>> p(2)
10
>>> pp = pypol.polynomial('3x4 - 2x3 + x - 4')
>>> ppp = pypol.polynomial('x - 2')
>>> divmod(pp, ppp)
(+ 3x³ + 4x² + 8x + 17, + 30)
>>> c, d = divmod(pp, ppp) # quotient and remainder
>>> c * ppp + d
+ 3x⁴ - 2x³  + x - 4
>>> c * ppp + d == pp
True``````

There are many others features...
The project is at http://github.com/rubik/pypol
and
Python Package Index
and here is the documentation:
http://pypol.altervista.org/

What do you think?

Thanks,
rubik-pypol

## All 11 Replies

What do you think?

Up

Up

You don't have questions, nowone cared about this, so just let it sink, till someone finds it attractive.

Cheers and Happy coding

Released version 0.2.

Released version 0.3

I note that your module computes the roots of polynomials by bisection. This is a primitive way to find the roots and there are many other methods (see for example this article http://en.wikipedia.org/wiki/Root-finding_algorithm). I hope you intend to strengthen pypol on this point. I once reviewed a few methods available in python to get the roots of polynomials: see http://www.daniweb.com/code/snippet271301.html.

I think it's a good idea to write a module for polynomials and algebraic fractions, but you should include in the doc a small review of other existing modules for such tasks. Especially, a pure python implementation may have performance issues that other implementations don't have. See for example the C based ratfun.

Thank you! I use the quadratic equation for the polynomial of degree 2 and bisection is temporary, I'm implementing the newton method and durand-kerner method.
Algebraic fractions are still very weak, and I will strengthen them when I will finish the root-finding algorithm.

If you are willing to collaborate, you are welcome.

P.S. I'm adding series-generator too, like Fibonacci polynomials, hermite polynomials, chebyshev polynomial... ecc.

Implemented quadratic, cubic and quartic Formeln! Now we can solve any polynomial up to degree 4! And I have added the newton's method, halley's method and householder's method too!!
:cool: :cool:

I need to update a link (can someone edit my first post?):
Python Package Index

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.