Jump to content

Chebyshev coefficients: Difference between revisions

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
numfmt 0 5
a = 0
b = 1
Line 697 ⟶ 698:
len coef[] n
len cheby[] n
for i range= 0 to n - 1
coef[i + 1] = cos (180 / pi * (cos (180 / n * (i + 1 / 2)) * (b - a) / 2 + (b + a) / 2))
.
for i range= 0 to n - 1
w = 0
for j range= 0 to n - 1
w += coef[j + 1] * cos (180 / n * i * (j + 1 / 2))
.
cheby[i + 1] = w * 2 / n
print cheby[i + 1]
.
.</syntaxhighlight>
 
=={{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.
2,058

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.