Roots of unity: Difference between revisions

m
→‎{{header|REXX}}: changed whitespace, aligned an IF/THEN/ELSE statement, changed wording in the REXX section header.
(Added 11l)
m (→‎{{header|REXX}}: changed whitespace, aligned an IF/THEN/ELSE statement, changed wording in the REXX section header.)
Line 1,616:
 
Note: &nbsp; this REXX version only &nbsp; ''displays'' &nbsp; '''5''' &nbsp; significant digits past the decimal point, &nbsp; but this can be overridden by specifying the 2<sup>nd</sup> argument when invoking the REXX program. &nbsp;
(See the value of the REXX variable &nbsp; '''frac''', &nbsp; 45<sup>th</sup> line).
<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, frac+4)Ip'i' /*display the real and imaginary part. */
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 * x; z= x; _= x; $x= 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=&nbsp; when using the input of: &nbsp; &nbsp; <tt> 5 </tt>}}
<pre>