at2 should be arctan from ratio of 2 numbers so that the domain
of at2 is an array with the last dimension being 2, ie, $y = ... 2

or at2=: (12&o.)@(j./)
or at2=: (12&o.)@(j./)"1

at2 working on a longer list of number is not its original
intention.

J is sometimes difficult to read because its context or domain
cannot be deduced from J sentences alone. Just my 2 cents.

Ср, 30 июл 2014, Linda Alvord написал(а):
> At2 is a function Cliff Reiter developed. The  at  is  arctan.  I'm not sure
> what the 2 means.
> 
> Your version  at3  simply incorporates the  i:  of this example.  However  y
> in his version allows different domains:
> 
>     at2=: 13 :'([:{:"1 *.) j./"1 y'
>    
>    at2 4
> 0
>    
>    at2 i.4
> _2.35619
>    
>    at2 i:4
> _1.5708
>    
> Without realizing it, I was getting a result without \
> 
>     i.0
>    
>    i:0
> 0
>    
>    i."0 >:i.5
> 0 0 0 0 0
> 0 1 0 0 0
> 0 1 2 0 0
> 0 1 2 3 0
> 0 1 2 3 4
>    
>    +/"1 i."0 >:i.5
> 0 1 3 6 10
>    
>    i:"0 i.5
>  0  0  0  0 0 0 0 0 0
> _1  0  1  0 0 0 0 0 0
> _2 _1  0  1 2 0 0 0 0
> _3 _2 _1  0 1 2 3 0 0
> _4 _3 _2 _1 0 1 2 3 4
>    
>    +/"1 i:"0 i.5
> 0 0 0 0 0
>    
>    +/"1 +\ i.5
> 0 1 3 6 10   
> So now you can probably see where I was going with this:
> 
> i:"0 i.7
>  0  0  0  0  0  0 0 0 0 0 0 0 0
> _1  0  1  0  0  0 0 0 0 0 0 0 0
> _2 _1  0  1  2  0 0 0 0 0 0 0 0
> _3 _2 _1  0  1  2 3 0 0 0 0 0 0
> _4 _3 _2 _1  0  1 2 3 4 0 0 0 0
> _5 _4 _3 _2 _1  0 1 2 3 4 5 0 0
> _6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6
>    
>    at2
> [: ([: {:"1 *.) j./"1
>    
>    ([: ([: {:"1 *.) j./"1)i:"0 i.7
> 0 3.14159 _1.5708 3.14159 _1.5708 3.14159 _1.5708
>  
> An infinite alternating series!
> 
> Linda  
> 
> -----Original Message-----
> From: programming-boun...@forums.jsoftware.com
> [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Raul Miller
> Sent: Tuesday, July 29, 2014 10:33 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Analyze an alternating series
> 
> Taking a look at this, I'm not quite sure where you are going.
> However, a few observations:
> 
> The first thing I notice when I try to read
>    at2=: 13 :'([:{:"1 *.) j./"1 y'
> is that those parenthesis are not really necessary. We could instead go:
>    at2=: 13 :'{:"1 *. j./"1 y'
> and let 13 : put in the parenthesis and [: to make it all work.
> 
> Next,  I'm noticing that you are using i: n each time you use at2, so
> maybe instead:
>    at3=: 13 :'{:"1 *. j./"1 i: y'
> 
> After that, I start thinking about what this is really doing. You've
> got j./"1 on a list which is typically longer than length 2. And, at
> the very bottom you had:
>    at2 i:"0 i.7
> 
> I think my change is consistent, though, because you'll get padding on
> the right which are zeros, and n j. 0 is n, so skipping the padding
> step doesn't change anything.
> 
> So let's take a look at j./ on a list:
>    j./\ i: 3
> _3 _3j_2 _2j_2 _2j_2 _1j_2 _1 _4
>    j./\ i: 4
> _4 _4j_3 _2j_3 _2j_2 _2j_2 _2j_1 _4j_1 _4j_4 0j_4
>    j./\ i: 5
> _5 _5j_4 _2j_4 _2j_2 _3j_2 _3j_2 _4j_2 _4j_4 _1j_4 _1 _6
> 
> Or, skipping the scans:
>    j./i:3
> _4
>    j./i:4
> 0j_4
>    j./i:5
> _6
> 
> It looks like odd numbers give a real valued result and even numbers
> give a complex valued result.
> 
> And then you are using *. to get the angle of the complex number, so
> that's where your final result comes from.
> 
> I imagine there's a variety of other ways of getting that final result?
> 
> Thanks,
> 
> -- 
> Raul
> 
> 
> 
> 
> 
> On Tue, Jul 29, 2014 at 4:33 AM, Linda Alvord <lindaalv...@verizon.net>
> wrote:
> > As I  am just heading for the airport after a delightful conference  I
> seem
> > to have captured a way to analyze alternating series.  What do you think
> > about this?
> >
> > We stayed on the 7th floor of our hotel and had a great time.
> >
> >
> >
> >    f=:+/"1
> >
> >
> >
> >    f i."0 i.7
> >
> > 0 0 1 3 6 10 15
> >
> >
> >
> >    f i:"0 i.7
> >
> > 0 0 0 0 0 0 0
> >
> >
> >
> >    at2=: 13 :'([:{:"1 *.) j./"1 y'
> >
> >
> >
> >    ]at2 i:2
> >
> > _1.5708
> >
> >
> >
> >    at2 i:5
> >
> > 3.14159
> >
> >
> >
> >    at2 i:600
> >
> > _1.5708
> >
> >
> >
> >    at2 i:601
> >
> > 3.14159
> >
> >
> >
> >    at2 i:"0 i.7
> >
> > 0 3.14159 _1.5708 3.14159 _1.5708 3.14159 _1.5708
> >
> >
> >
> > Linda
> >
> >
> >
> >
> >
> > ----------------------------------------------------------------------
> > 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

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to