(p.) is OK, but I do not know how it works.
Thanks to Raul Miller and to R.E.Boss, my home-cooked equation solver looks
like this.
p1=.+`*/&}:&|:@(,@,."_ 0) NB. evaluate polynomial x at point y
p2=.*/&|:&(+0&=)&(-/~) NB. multiply differences between approximate roots
p3=.]-p1%p2@:] NB. iteration step
p4=.](p3^:_)0.8j0.6^i.@:<:&$ NB. solve a normalized equation
p5=.p4&(%{:)&({.~>:&{:&(-.&(0&=)#i.&#)) NB. normalize and solve
NB. This J code can probably be further compacted.
NB. test runs:
load'plot'
pl=:[:'dot;pensize 5'&plot 0j1*] NB. vertical real axis
a=. 0 1 2 3 4 5 0 NB. test coefficients
pl p5 a NB. show complex roots using (p5)
pl >}.p.a NB. show complex roots using (p.)
p5 1 NB. show no roots using (p5)
p.1 NB. show no roots using (p.)
|domain error
| p.1
Thanks! Bo.
Den 20:53 onsdag den 7. marts 2018 skrev R.E. Boss <[email protected]>:
a |:@:(,@,."_ 0) b
R.E. Boss
> -----Original Message-----
> From: Programming <[email protected]> On
> Behalf Of 'Bo Jacoby' via Programming
> Sent: maandag 5 maart 2018 14:35
> To: Programming Forum <[email protected]>
> Subject: [Jprogramming] (,a,.2),.,a,.3
>
> Let (a =. _1 _1 0 0 0 1) and (b =. 2 3).
> For my own education I am trying to make a homecooked version of (p.).
>
> (+`*/}:(,a,.2),.,a,.3) produces the same result as (a p. b) I need a nice
> verb (f)
> such that (a f b) produces ((,a,.2),.,a,.3) 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