Anonymous user
Roots of unity: Difference between revisions
m
→{{header|REXX}}: changed whitespace, aligned an IF/THEN/ELSE statement, changed wording in the REXX section header.
Alextretyak (talk | contribs) (Added 11l) |
m (→{{header|REXX}}: changed whitespace, aligned an IF/THEN/ELSE statement, changed wording in the REXX section header.) |
||
Line 1,616:
Note: this REXX version only ''displays'' '''5''' significant digits past the decimal point, but this can be overridden by specifying the 2<sup>nd</sup> argument when invoking the REXX program.
(See the value of the REXX variable '''frac''',
<lang rexx>/*REXX program computes the K roots of unity (which usually includes complex roots).*/
numeric digits length( pi() ) - length(.) /*use number of decimal digits in pi. */
Line 1,632:
if Ip>=0 then Ip= '+'Ip /* " " " " " " plus " */
if Ip =0 then say Rp /*Only real part? Ignore imaginary part*/
else say left(Rp,
end /*angle*/
end /*#*/
Line 1,647:
/*──────────────────────────────────────────────────────────────────────────────────────*/
sin: procedure; parse arg x; x= r2r(x); numeric fuzz min(5, digits() - 3)
if abs(x)=pi then return 0; $x= x *
do k=2 by 2 until p=z; p=z; _= -_ * $x / (k*(k+1)); z= z + _; end; return z</lang>
{{out|output|text= when using the input of: <tt> 5 </tt>}}
<pre>
|