Anonymous user
Chebyshev coefficients: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace and comments.
m (→{{header|REXX}}: added/changed whitespace and comments.) |
|||
Line 989:
numeric digits length( pi() ) - 1 /*DIGITS default is nine, but use 71. */
parse arg a b N . /*obtain optional arguments from the CL*/
if a=='' | a=="," then a=
if b=='' | b=="," then b=
if N=='' | N=="," then N=
fac= 2 / N;
Dma= (b-a) / 2 /*calculate one─half of the difference.*/
Dpa= (b+a) / 2 /* " " " " sum. */
do k=0 for N; f.k= cos( cos( pin * (k + .5) ) * Dma + Dpa)
end /*k*/
do j=0 for N; z= pin * j
$= 0
do m=0 for N /* the non─negative values with
$= $ + f.m * cos(z*(m +
end /*m*/ /* ┌─────◄──────┘ */
cheby.j= fac * $
say right(j, length(N) +3) " Chebyshev coefficient is:" left('', cheby.j >= 0),
format(cheby.j, , 30) /*only show 30 decimal digits of coeff.*/
Line 1,011 ⟶ 1,010:
/*──────────────────────────────────────────────────────────────────────────────────────*/
cos: procedure; parse arg x; numeric digits digits()+9; x=r2r(x); a=abs(x); numeric fuzz 5
return z
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 1,052 ⟶ 1,051:
18 Chebyshev coefficient is: -3.976201538410589537318561880598E-27
19 Chebyshev coefficient is: 2.859065292763079576513213370136E-29
=={{header|Scala}}==
{{Out}}Best seen running in your browser either by [https://scalafiddle.io/sf/DqRNe2A/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/M5Ye6h8ZRkmTCNzexUh3uw Scastie (remote JVM)].
|