Polynomial Roots Reloaded (yes, seriously...)

02122017, 05:07 PM
(This post was last modified: 02132017 06:44 AM by Ángel Martin.)
Post: #1




Polynomial Roots Reloaded (yes, seriously...)
Yes I now, this has been rehashed a few dozen times and yet some more  but I didn't want to let this pass go unnoticed since it's also a nice application of the function set on the 41Z module  which packs so many functions that even I lose track of them.
The routine below is not a new conceptual method or a cleverly design algorithm, not at all. If anything it's a straight application of the oldest "brutishforce"approach there is, i.e. the Newton method  with a deflation method after each root is found using approximations. Why bother then? Well, for once as a nice example of the 41Z function set, which includes MCODE functions to evaluate polynomials, their primitives and their first & second derivatives (see program steps 12 & 15 below). If anything this should make the implementation much faster than other previous attempts. Second this is a nice tribute to JM Baillard's continuous dedication to the 41 legacy. The routine is a straight adaptation of his program dealing with real roots of polynomials, as can be seen at paragraph #1f of this page.. If you compare both versions you'll see a direct translation from "standard" functions into 41Zbased, for the complex domain. The original routine only works to obtain real roots, but the complexversion doesn't have that limitation and works equally for real and complex cases  even if the coefficients are all real. Here's the core routine, which assumes the polynomial coefficients are stored in Complex Data registers CR(bbb) to CR(eee)  the initial guess is the {Z,Y} stack registers, and the polynomial control word bbb.eee in the Xregister (using Complex Data register indexes). Code: 01 LBL "ZPRT bbb,000(eee) As an example let's use the same 5degree polynomial from the 41Z manual, page. P(x) = (1+2i)*z^4 + (12i)*z^3 + (33i)*z^2 + z – 1 First store the five coefficients in complex registers CR03 to CR07, (can use the subfunction ZINPT). Then using (1+i) as initial guess and the control word 3,007 in the Xregister, the four solutions are obtained in a few seconds on the 41CL. 1, ENTER^, 1, 3.007, XEQ "ZPLRT" 1,698+J0,802 0,400J0,859 0,358+J0,130 0,656J0,073 Not bad for a (roughly) 44step routine, won't you agree? Happy root finding in the Complex realm... ÁM. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)