Skip to main content
added 590 characters in body
Source Link
flawr
  • 43.9k
  • 7
  • 104
  • 249

#MATL, 16 14 bytes

As I'm not terribly fluent with MATL I expect that this is somewhat more golfable. (Would be nice to at least beat Mathematica :-) I.e. the use of clipboards is not optimal as well as the flip w whichis not optimal, it could probably be avoided...

:G/4*Jw^2Z^!XG

Test it Online! (Thanks @Suever for this service, thanks @DrMcMoylex for -2 bytes.)

Explanation (for N=3):

  :               Generate Range 1:input:       [1,2,3]
   G/             Divide By the first input     [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

#MATL, 16 14 bytes

As I'm not terribly fluent with MATL I expect that this is somewhat more golfable. (Would be nice to at least beat Mathematica :-) I.e. the use of clipboards is not optimal as well as the flip w which could probably be avoided...

:G/4*Jw^2Z^!XG

Test it Online!

Explanation (for N=3):

  :               Generate Range 1:input:       [1,2,3]
   G/             Divide By the first input     [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

#MATL, 16 14 bytes

As I'm not terribly fluent with MATL I expect that this is somewhat more golfable. (Would be nice to at least beat Mathematica :-) I.e. the the flip w is not optimal, it could probably be avoided...

:G/4*Jw^2Z^!XG

Test it Online! (Thanks @Suever for this service, thanks @DrMcMoylex for -2 bytes.)

Explanation (for N=3):

  :               Generate Range 1:input:       [1,2,3]
   G/             Divide By the first input     [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

added 590 characters in body
Source Link
flawr
  • 43.9k
  • 7
  • 104
  • 249

#MATLMATL, 1616 14 bytes

As I'm not terribly fluent with MATL I expect that this is somewhat more golfable. (Would be nice to at least beat Mathematica :-) I.e. the use of clipboards is not optimal as well as the flip w which could probably be avoided...

XH:HG/4*Jw^2Z^!XG

Test it Online!Test it Online!

Explanation (for N=3):

XH                Take input and store it in H: 3
  :               Generate Range 1:Hinput:           [1,2,3]
   HG/             Divide By H            the first input     [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

#MATL, 16 bytes

XH:H/4*Jw^2Z^!XG

Test it Online!

Explanation (for N=3:

XH                Take input and store it in H: 3
  :               Generate Range 1:H:           [1,2,3]
   H/             Divide By H                   [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

#MATL, 16 14 bytes

As I'm not terribly fluent with MATL I expect that this is somewhat more golfable. (Would be nice to at least beat Mathematica :-) I.e. the use of clipboards is not optimal as well as the flip w which could probably be avoided...

:G/4*Jw^2Z^!XG

Test it Online!

Explanation (for N=3):

  :               Generate Range 1:input:       [1,2,3]
   G/             Divide By the first input     [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

added 590 characters in body
Source Link
flawr
  • 43.9k
  • 7
  • 104
  • 249

#MATL, 16 bytes

XH:H/4*Jw^2Z^!XG

Test it Online!

Explanation (for N=3:

XH                Take input and store it in H: 3
  :               Generate Range 1:H:           [1,2,3]
   H/             Divide By H                   [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

#MATL, 16 bytes

XH:H/4*Jw^2Z^!XG

Test it Online!

#MATL, 16 bytes

XH:H/4*Jw^2Z^!XG

Test it Online!

Explanation (for N=3:

XH                Take input and store it in H: 3
  :               Generate Range 1:H:           [1,2,3]
   H/             Divide By H                   [0.333,0.666,1]
     4*           Multiply by 4                 [1.33,2.66,4.0]
       Jw^        i ^ (the result so far)       [-0.49+ 0.86i,-.5-0.86i,1.00]
                  (This results in a list of the n-th roots of unity)
          2Z^     Take the cartesian product with itself (i.e. generate all 2-tuples of those points)
             !XG  Transpose and plot

It is worth noting that for generating the N-th roots of unity you can use the formula exp(2*pi*i*k/N) for k=1,2,3,...,N. But since exp(pi*i/2) = i you could also write i^(4*k/N) for k=1,2,3,...,N which is what I'm doing here.

Source Link
flawr
  • 43.9k
  • 7
  • 104
  • 249
Loading