A python library and a simple CLI program to generate and manipulate polynomials, with roots simple to find by hand. The degree of the polynomial, the number of roots and the multiplicities of these roots, are all tweakable to generate polynomials with different grades of difficulty.
I started this library while studying for a math exam where it was required to be able quickly find the roots of a polynomial of degree 3 or 4. It helped me pass it.
The polynomials in this library are all represented as arrays, in which the element at position i
in the array is the coefficient of x^i
. I chose this representation because its simple to understand and manipulate. I didn't wrap it in a class because I think it would only create unnecessary complexity.
The genpo library modules are mainly divided in 2 section: manipulation and random generators.
These modules provide functions to manipulate polynomials: creation, arithmetic operations and string representations
Pure functions for creating polynomials from parameters. For example, parabolas.
Arithmetic operations on polynomials.
Operations actually supported:
- sum between polynomials
- multiplication between polynomials
- multiplication of a polynomial by a factor (numeric or fraction)
- evaluation of a polynomial and its derivative in one point
Utilities functions to work with roots and multiplicities.
String representations of polynomials. The functions provided here were all thought to print their output in the terminal
All modules under genpo.random
have the scope of generating random roots and polynomials. All values generated are roots and values simple to find and to calculate for a person that is resolving a polynomial by hand.
Generators for intervals of values, simple fractions or expanding randomly a list of items. This module is used internally in more complex generators
Generators for random polynomials roots and multiplicities. All generated roots are integers numbers not too big, simple to find by hand.
Generators for polynomials, with or without roots. This is the core of the genpo library, where many parts of the library are used. The functions in this file are divided in two categories, based on the generated polynomials:
-
generators for polynomials in which the sum of multiplicities of their zeroes equals its degree;
-
generators for polynomials with an arbitrary sum of zeroes' multiplicity.
Functions in the genpo.random.polynomials
with fz
in the name, are functions that returns polynomials that I defined full zeroes, polynomials in which the sum of multiplicities of their zeroes equals its degree.
Coming soon. Stay tuned ;)