[q-lang-users] qix 0.4 - polynomial mathematics library
Brought to you by:
agraef
From: Rob H. <hub...@gm...> - 2007-03-31 23:32:31
|
Dear All, Albert has very kindly uploaded the latest version of my polynomial q module "qix". It can be downloaded from the Grab Bag <http://q-lang.sourceforge.net/examples.html#Miscellaneous> as <http://q-lang.sourceforge.net/qix-0.4.tar.gz> This file includes some fairly extensive documentation. [Thanks are also due to Albert for all his help during development.] So, what is this thing? Well, it's a somewhat miscellaneous collection of functions to manipulate (univariate) polynomials and to solve polynomial equations. [I have been primarily interested in polynomials with rational or complex rational coefficients, but the module also has some routines targeted at polynomials over the real and complex numbers.] Obviously, there are routines to construct polynomials (including by fitting a polynomial to given points), to perform arithmetic, and a little calculus, on them. Examples: =3D=3D> monic_poly_with_roots [1,2,3] poly_lambda '(\X . X^3-6*X^2+11*X-6) =3D=3D> poly_thru_points [(1,1),(2,4),(3,9),(4,16)] poly_lambda '(\X . X^2) For those of you who know a little algebra, there are the "usual" routines to solve (that is, find the roots or zeroes, or to factorise) linear, quadratic, cubic and quartic equations; that is, polynomials of degree up to four. The quadratic solver is "numerically stable". The cubic and quartic routines are real "gems" amongst the many and varied routines in the literature. However, there are some other routines with which to solve polynomials: the "rational root theorem" is implemented to find *all* rational roots of any polynomial (of any degree) with rational coefficients. Example (finding all rational roots): =3D=3D> def P =3D (monic_poly_with_roots [1,1,4,7%12,i,4+3*i]); P poly_lambda '(\X . 2*X^5-67%6*X^4+107%6*X^3-27*X^2+83%3*X-28%3) =3D=3D> poly_rat_roots_rem P; ([(4,1),(1,2),(7%12,1)],poly_lambda '(\X . X^2+(-4-4*i)*X+(-3+4*i))= ) I have extended this for complex rational roots also. Use is also made of the "square-free part" and the "fundamental theorem of palindromic polynomials". There are routines to find approximations of roots. I describe "difference systems", which is finite for a polynomial. This allows a little simple finite calculus to be performed (sums and differences of polynomials considered as series). There are some other miscellaneous features of the module that might be of interest to some: "B=E9zier parametrisations", DFT, transformations, operators, ... For more details, and many examples, please see the documentation. [All examples in the documentation have real responses from the Q interpreter.] In a separate file, I have provided some matrix functions as an example, and in case you wish to try some polynomials with non-numeric coefficients. Support for these is, unfortunately, only partial. All this is still work in progress. If you find any bugs, then please let me know. Similarly, if anything in the documentation is unclear, incorrect, missing, or poorly styled, please let me know. If my code is unclear, incorrect, insufficiently commented, particularly sub-optimal, poorly styled, or you just know of a good Q technique I could use, again please let me know. I'm always happy to try to improve the quality of my code and documentation. More importantly, if you know of any interesting mathematics relevant to (univariate) polynomials that I have missed, please tell me about it. Thanks, Rob. |