Technical Correspondence
Vector 21:2, page 116
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 116
In J the primitive verb p. is for Polynomial. The monadic case of p. is for finding the roots of algebraic equations. This is implemented in J after Release 3 or in versions 3, 4 and 5.
For example, the solution to the cubic equation
is coded in J as
The three roots are given as the second item in the boxed notation
+------+-----------------------------------------+
| 5625 | 24 _17.3179j24.3248 _17.3179j_24.3248 |
+------+-----------------------------------------+
5625, the first item in the box, is the multiplier or the leading coefficient of the equation. That is very useful! But the use of p. seems to be not so popular for J users.
As far as we know, official instruction appeared only twice in the texts J Exploring Math (Iverson Software Inc., 1996) and J Introduction and Dictionary (K.E. Iverson, 1996). We suppose Dr Iverson considered that finding roots is simply an inverse of polynomials.
We, the members of the Japan APL Association and great fans of math, use the p. verb a great deal, because we can use it to solve algebraic equations of up to the 23rd degree.
For the cyclotomic polynomials \(x^n-1\), we have already solved them for values of \(n\) up to 143.
But recently, we found that the verb p. leads at times to fatal limit errors. For example, solving a simple cubic equation such as
by J notation
causes a limit error.
To search for such examples more easily, we defined here a verb
instead of using the p. directly.
For example, sol 1 _3 6 _4 gives a limit error.
Similar results obtain in the following examples:
- in the Cubic
(1 _3 9 _9),(1 _6 6 _2),(1 _6 18 _18),(1 _9 9 _3),(1 _9 18 _12),(1 _12 6 _1),(1 _12 12 _4),(1 _12 18 _9),(1 _15 15 _5),(1 _15 30 _20); - in the Quartic
(1 _10 27 _30 12); - the Quintic
(1 _2 _2 4 1 _2),(1 2 1 _1 _2 _1); - the Sextic
(1 _3 0 6 _3 _3 2); - the 8th
(1 0 1 _10 _33 _40 88 210 175);
and many others from polynomials derived from them.
To escape instantly from this limit error, we propose here some trials.
-
A very, very small shift in the next leading coefficient of the equation: e.g.
y3s=.1 _3.00001 6 _4. And we solve this withy3sinstead ofy3byp.. The smaller the shift the better; even a shift as small as1e_9works. -
Shift coordinate (x − r) or f(x−r) so as to reduce the next leading coefficient to zero; we made a verb coded in J
znc. Then,We solve the new equation
y3zusingp., and afterwards returnrto recover roots for the old equationy3. The final roots are1 1j1.73205 1j_1.73205. This procedure is expressed as the verbsol0r. Our verbs are shown below. The names are suggestive of the roles. -
Of course, a combination of the above two methods might be more useful. If the next leading coefficient of the equation is already zero, as above, in the 8th
(1 0 1 _10 _33 _40 88 210 175), we must adopt the first method i.e. the item 1. -
We have already written several more trial verbs to replace the J primitive
p., and should like to contribute their details gradually in the coming journals.
J program of an example verb sol1 among the sol 0r is displayed below.
In the verb sol1, r is a shift in the coordinate variables x, and the z means f(x + r). Accompanying verb horn is omitted here, as it is a simple Horner method.
Y. Nakano
K. Yamashita
T. NishikawaJapan APL Association
http://homepage3.nifty.com/asagaya_avenue/apl/eng_index.html