Michal, Your original post had | which you meant as ]

Here is how I got to Kip's final result. He mentioned   you needed to add 1

 

 f=: 13 :' 1 + *:@|A=: (]j.1:)^:(<y) 0j1' 

   f 10

2 5 10 17 26 37 50 65 82 101

   A

0j1 0j2 0j3 0j4 0j5 0j6 0j7 0j8 0j9 0j10

   |A

1 2 3 4 5 6 7 8 9 10

   *:|A

1 4 9 16 25 36 49 64 81 100

   g=: 13 :' 1 + *:|0 j.1 + i.y' 

   (f 10)-:g 10

1

   5!:4 <'f'

      ┌─ 3                                 
── : ─┴─ ,:' 1 + *:@|A=: (]j.1:)^:(<y) 0j1'

   5!:4 <'g'

  ┌─ 1                    
  ├─ +                    
──┤   ┌─ [:               
  │   ├─ *:               
  └───┤    ┌─ [:          
      │    ├─ |           
      └────┤    ┌─ 0      
           │    ├─ j.     
           └────┤    ┌─ 1 
                └────┼─ + 
                     └─ i.

   f

3 : ' 1 + *:@|A=: (]j.1:)^:(<y) 0j1'

   g

1 + [: *: [: | 0 j. 1 + i

 

 

I tend to write most code in an explicit fashion and then see the J translation.

 

Linda

 

-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Michal Wallace
Sent: Friday, February 26, 2016 3:17 PM
To: [email protected]
Subject: Re: [Jprogramming] Imaginary Squares

 

Er... I guess I didn't explain that as clearly as I thought.

 

The first diagonal (| 1j1) has length (%:2).

 

The idea was to rotate this segment down to the real line and then make another 
right triangle by drawing the line up to ((%:2) j. 1).

Pythagoras tells us the hypotenuse of this triangle is (%: +/ *: (%2), 1) which 
is (%: +/ 2 1) or (%: 3).

 

So basically it's just generating the square roots of each natural number in 
turn, and then you just square those to get the area.

 

The line at the end was actually the answer:

 

   *:@| (|j.1:)^:(<n) 0j1 [ n=. 10

1 2 3 4 5 6 7 8 9 10

 

Not really a puzzle. I just thought it was cool. :)

 

 

 

On Fri, Feb 26, 2016 at 1:51 PM, Kip Murray < <mailto:[email protected]> 
[email protected]> wrote:

 

>    areas =: 1 + [: *: 1 + i.

>    areas 10

> 2 5 10 17 26 37 50 65 82 101

> 

> --Kip Murray

> 

> On Friday, February 26, 2016, Michal Wallace 

> < <mailto:[email protected]> [email protected]>

> wrote:

> 

> > Imagine a compass rooted at the origin of the complex plane.

> >

> > Starting at the point 0j1, draw the arc down to the real line, and 

> > then from this point, draw vertical line segment extending upwards 1 

> > unit, to arrive at the point 1j1.

> >

> > Repeat this process of drawing the arc down to the real line and 

> > moving

> up

> > 1 unit N times, creating a series of points along the horizontal 

> > line  (] j. 1:).

> >

> > For each point, draw a line segment from the origin to the point, 

> > and

> then

> > draw a square (*:) whose sides are the length (|) of this segment.

> >

> > What is the area of each square?

> >

> >     *:@| (|j.1:)^:(<n) 0j1 [ n=. 10

> > --------------------------------------------------------------------

> > -- For information about J forums see 

> >  <http://www.jsoftware.com/forums.htm> http://www.jsoftware.com/forums.htm

> 

> 

> 

> --

> Sent from Gmail Mobile

> ----------------------------------------------------------------------

> For information about J forums see  <http://www.jsoftware.com/forums.htm> 
> http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------

For information about J forums see  <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to