Chebyshev coefficients: Difference between revisions
m
→{{header|Perl}}: formatted output
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: did not need .list coercion) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: formatted output) |
||
Line 1,375:
{{trans|C}}
<lang perl>use constant PI =>
sub chebft {
Line 1,382:
my @pin = map { ($_ + 0.5) * (PI/$n) } 0..$n-1;
my @f = map { $func->( cos($_) * $bma + $bpa ) } @pin;
my @c = (0) x $n;
for my $j (0 .. $n-1) {
$c[$j] += $f[$_] * cos($j * $pin[$_])
$c[$j] *= (2.0/$n);
}
@c
}
{{out}}
<pre>+1.
-2.3229937e-01
-5.3715115e-02
+2.4582353e-03
+2.8211906e-04
-7.
-5.
+1.
+6.
-1.
=={{header|Phix}}==
|