Roots of unity: Difference between revisions

adding lambdatalk
m (→‎{{header|REXX}}: re-instated a glyph for the title.)
(adding lambdatalk)
Line 959:
[1, 1.0i, -1.0, -1.0i]
[1, 0.30901699437494745 + 0.9510565162951535i, -0.8090169943749473 + 0.5877852522924732i, -0.8090169943749475 + -0.587785252292473i, 0.30901699437494723 + -0.9510565162951536i]</pre>
 
=={{header|Lambdatalk}}==
<lang scheme>
// cleandisp just to display 0 when n < 10^-10
{def cleandisp
{lambda {:n}
{if {<= {abs :n} 1.e-10} then 0 else :n}}}
-> cleandisp
 
{def uroots
{lambda {:n}
{S.map {{lambda {:n :i}
{let { {:theta {/ {* 2 {PI} :i} :n}}
} {cons {cleandisp {cos :theta}}
{cleandisp {sin :theta}}}}} :n}
{S.serie 0 {- :n 1}}} }}
-> uroots
 
{S.map {lambda {:i} {hr}i = :i -> {uroots :i}} {S.serie 2 10}}
-> i = 2 -> (1 0) (-1 0) i = 3 -> (1 0) (-0.4999999999999998 0.8660254037844388) (-0.5000000000000004 -0.8660254037844384)
i = 4 -> (1 0) (0 1) (-1 0) (0 -1)
i = 5 -> (1 0) (0.30901699437494745 0.9510565162951535) (-0.8090169943749473 0.5877852522924732) (-0.8090169943749475 -0.587785252292473) (0.30901699437494723 -0.9510565162951536)
i = 6 -> (1 0) (0.5000000000000001 0.8660254037844386) (-0.4999999999999998 0.8660254037844388) (-1 0) (-0.5000000000000004 -0.8660254037844384) (0.5 -0.8660254037844386)
i = 7 -> (1 0) (0.6234898018587336 0.7818314824680297) (-0.22252093395631434 0.9749279121818236) (-0.900968867902419 0.43388373911755823) (-0.9009688679024191 -0.433883739117558) (-0.2225209339563146 -0.9749279121818235) (0.6234898018587334 -0.7818314824680299)
i = 8 -> (1 0) (0.7071067811865476 0.7071067811865475) (0 1) (-0.7071067811865475 0.7071067811865476) (-1 0) (-0.7071067811865477 -0.7071067811865475) (0 -1) (0.7071067811865475 -0.7071067811865477)
i = 9 -> (1 0) (0.7660444431189781 0.6427876096865393) (0.17364817766693041 0.984807753012208) (-0.4999999999999998 0.8660254037844388) (-0.9396926207859083 0.3420201433256689) (-0.9396926207859084 -0.34202014332566866) (-0.5000000000000004 -0.8660254037844384) (0.17364817766692997 -0.9848077530122081) (0.7660444431189779 -0.6427876096865396)
i = 10 -> (1 0) (0.8090169943749475 0.5877852522924731) (0.30901699437494745 0.9510565162951535) (-0.30901699437494734 0.9510565162951536) (-0.8090169943749473 0.5877852522924732) (-1 0) (-0.8090169943749475 -0.587785252292473) (-0.30901699437494756 -0.9510565162951535) (0.30901699437494723 -0.9510565162951536) (0.8090169943749473 -0.5877852522924732)
 
</lang>
 
=={{header|Liberty BASIC}}==