Roots of unity: Difference between revisions
Content added Content deleted
m (→[[Roots_of_unity#Python]]: restructure) |
m (→[[Roots_of_unity#Perl]]: refmt) |
||
Line 229: | Line 229: | ||
{{libheader|Math::Complex}} |
{{libheader|Math::Complex}} |
||
<perl>use Math::Complex; |
<perl>use Math::Complex; |
||
foreach $n ( |
foreach $n (2 .. 10) { |
||
printf "%2d |
printf "%2d", $n; |
||
foreach $k (1 .. $n) { |
foreach $k (1 .. $n/2) { |
||
$ret = cplxe(1, 2 * pi * $k / $n); |
$ret = cplxe(1, 2 * pi * $k / $n); |
||
$ret->display_format('style' => 'cartesian', 'format' => '%.3f'); |
$ret->display_format('style' => 'cartesian', 'format' => '%.3f'); |
||
print " |
print " $ret"; |
||
} |
} |
||
print "\n"; |
print "\n"; |
||
}</perl> |
}</perl> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
2 -1.000+0.000i |
|||
3 -0.500+0.866i |
|||
4 0.000+1.000i -1.000+0.000i |
|||
5 0.309+0.951i -0.809+0.588i |
|||
4 (0.000+1.000i)(-1.000+0.000i)(-0.000-1.000i)(1.000-0.000i) |
|||
6 0.500+0.866i -0.500+0.866i -1.000+0.000i |
|||
7 0.623+0.782i -0.223+0.975i -0.901+0.434i |
|||
6 (0.500+0.866i)(-0.500+0.866i)(-1.000+0.000i)(-0.500-0.866i)(0.500-0.866i)(1.000-0.000i) |
|||
8 0.707+0.707i 0.000+1.000i -0.707+0.707i -1.000+0.000i |
|||
9 0.766+0.643i 0.174+0.985i -0.500+0.866i -0.940+0.342i |
|||
8 (0.707+0.707i)(0.000+1.000i)(-0.707+0.707i)(-1.000+0.000i)(-0.707-0.707i)(-0.000-1.000i)(0.707-0.707i)(1.000-0.000i) |
|||
10 0.809+0.588i 0.309+0.951i -0.309+0.951i -0.809+0.588i -1.000+0.000i |
|||
10 (0.809+0.588i)(0.309+0.951i)(-0.309+0.951i)(-0.809+0.588i)(-1.000+0.000i)(-0.809-0.588i)(-0.309-0.951i)(0.309-0.951i)(0.809-0.588i)(1.000-0.000i) |
|||
</pre> |
</pre> |
||