Chebyshev coefficients: Difference between revisions
Content deleted Content added
Add Julia language |
m →{{header|REXX}}: changed a comment and some whitespace, changed comments in the REXX section header, used a template for the output sections. |
||
Line 772:
=={{header|REXX}}==
{{trans|C}}
This REXX program is a translation of the '''C''' program plus added optimizations.
Pafnuty Lvovich Chebysheff: Chebyshev [English transliteration]▼
▲Pafnuty Lvovich Chebysheff: Chebyshev [English transliteration]
▲ Tschebyscheff [ " " ]
<lang rexx>/*REXX program calculates N Chebyshev coefficients for the range 0 ──► 1 (inclusive)*/
numeric digits length( pi() ) - 1
parse arg a b N . /*obtain optional arguments from the CL*/
if a=='' | a=="," then a= 0 /*A not specified? Then use default.*/
if b=='' | b=="," then b= 1 /*B " " " " " */
if N=='' | N=="," then N=10 /*N " " " " " */
fac=2 / N;
Dma= (b-a) /
Dpa= (b+a) /
do k=0 for N
f.k=cos( cos( pin * (k + .5) ) * Dma + Dpa)
end /*k*/
$=0
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 815 ⟶ 814:
/*──────────────────────────────────────────────────────────────────────────────────────*/
pi: pi=3.1415926535897932384626433832795028841971693993751058209749445923078164;return pi
▲r2r: return arg(1) // (pi()*2) /*normalize radians ───► a unit circle.*/</lang>
▲'''output''' when using the default inputs:
<pre>
0 Chebyshev coefficient is: 1.647169475390313686961473816798
Line 830 ⟶ 828:
9 Chebyshev coefficient is: -1.002259170944625675156620531665E-11
</pre>
<pre>
0 Chebyshev coefficient is: 1.647169475390313686961473816799
|