Chebyshev coefficients: Difference between revisions
→{{header|EasyLang}}
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
|||
Line 691:
0.950 0.58168308946388349416 0.58168308946388349403 -1.63e-19</pre>
=={{header|EasyLang}}==
<syntaxhighlight lang="text">
numfmt 0 5
a = 0
b = 1
Line 697 ⟶ 698:
len coef[] n
len cheby[] n
for i
coef[i + 1] = cos (180 / pi * (cos (180 / n * (i + 1 / 2)) * (b - a) / 2 + (b + a) / 2))
.
for i
w = 0
for j
w += coef[j + 1] * cos (180 / n * i * (j + 1 / 2))
.
cheby[i + 1] = w * 2 / n
print cheby[i + 1]
.
=={{header|Go}}==
Wikipedia gives a formula for coefficients in a section [https://en.wikipedia.org/wiki/Chebyshev_polynomials#Example_1 "Example 1"]. Read past the bit about the inner product to where it gives the technique based on the discrete orthogonality condition. The N of the WP formulas is the parameter nNodes in the code here. It is not necessarily the same as n, the number of polynomial coefficients, the parameter nCoeff here.
|