These seemed to be what I expected:

p. 1 1 _1
┌──┬─────────────────┐
│_1│1.61803 _0.618034│
└──┴─────────────────┘
   p. _1 _1 1
┌─┬─────────────────┐
│1│1.61803 _0.618034│
└─┴─────────────────┘
   
Linda

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Linda A Alvord
Sent: Thursday, January 7, 2016 5:59 AM
To: [email protected]
Subject: Re: [Jprogramming] the p. equation solver

Roger,

If I type in fresh jqt:

p. 1 2 3 4 5
┌─┬───────────────────────────────────────────────────────────────────────────┐
│5│0.137832j0.678154 0.137832j_0.678154 _0.537832j0.358285 _0.537832j_0.358285│ 
└─┴───────────────────────────────────────────────────────────────────────────┘
   p.. 1 2 3 4 5
2 6 12 20

However I get the same answer when I copied the example in the vocabulary in 
the second example.

What explains this?

Linda

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Roger Hui
Sent: Thursday, January 7, 2016 2:20 AM
To: Programming forum
Subject: Re: [Jprogramming] the p. equation solver

p. uses Laguerre's Method with polishing on the original polynomial using 
Newton iteration.  It can no doubt be simplified and/or improved.

A couple of examples of using p. :

   c=: p. <1+i.20
   $c
21
   3 7$c
2432902008176640000 _8752948036761600000 13803759753640704000
_12870931245150988800 8037811822645051776 _3599979517947607200
1206647803780373360
_311333643161390640    63030812099294896   _10142299865511450
 1307535010540395    _135585182899530       11310276995381
_756111184500
        40171771630          _1672280820             53327946
 _1256850               20615                 _210                   1

c are the coefficient's of Wilkinson's polynomial 
<https://en.wikipedia.org/wiki/Wilkinson%27s_polynomial>, whose roots are

   p. c
┌─┬──────────────────────────────────────────────────┐
│1│20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1│ 
└─┴──────────────────────────────────────────────────┘



On Wed, Jan 6, 2016 at 10:53 PM, 'Bo Jacoby' via Programming < 
[email protected]> wrote:

> Dear experts.
> The equation solver (p.) is marvelous! However I do not know how it is 
> implemented.
> Computing the complex roots of algebraic equations should be 
> considered basic. If you can do that, then you need not to learn about 
> division or square roots.
> I made this elementary equation solver in J. (Durand-Kerner method).
>
> poly =.+/@([*]^~/~i.@#@[)
>
> step=.]-poly*[:*/-/~@]^<:@=/~@i.@<:@#@[
>
>  iter =.](step^:_)_0.4j0.9^i.@<:@#    norm =.[:(% {:)]}.~[:-[:+/[:*/\0=|.
> solv =.iter@norm
> A polynomial is represented by an array of coefficients, the constant 
> term first.
> poly computes values of a polynomial.
>    0 40 0 _10 0 0 poly i:4
> 480 150 0 _30 0 30 0 _150 _480
> norm normalizes a polynomial such that the leading coefficient is one, 
> without changing the roots.
>    norm 0 40 0 _10 0 0
> 0 _4 0 1
> step improves a set of approximate roots to a normalized polynomial.
>    0 _4 0 1 step _0.4j0.9^i.3
> 1.98849j0.159402 _0.860465j_0.735105 _1.12803j0.575703 iter makes a 
> sufficient number of steps.
>    iter 0 _4 0 1
> 2 0 _2
> solv solves even non-normalized polynomials
>    solv 0 40 0 _10 0 0
> 2 0 _2
> My questions:
> 1. Is this how (p.) is implemented?
> 2. Can it be simplified or improved?
> Thanks!  Bo.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to