Chebyshev coefficients: Difference between revisions

Chebyshev coefficients en FreeBASIC
(Chebyshev coefficients en FreeBASIC)
Line 586:
print cheby[i]
.</lang>
 
 
=={{header|FreeBASIC}}==
<lang freebasic>Const pi As Double = 4 * Atn(1)
Dim As Double i, w, j
Dim As Double a = 0, b = 1, n = 10
Dim As Double cheby(10), coef(10)
 
For i = 0 To n-1
coef(i) = Cos(Cos(pi/n*(i+1/2))*(b-a)/2+(b+a)/2)
Next i
 
For i = 0 To n-1
w = 0
For j = 0 To n-1
w += coef(j) * Cos(pi/n*i*(j+1/2))
Next j
cheby(i) = w*2/n
Print i; " : "; cheby(i)
Next i
Sleep</lang>
{{out}}
<pre> 0 : 1.647169475390314
1 : -0.2322993716151719
2 : -0.05371511462204768
3 : 0.002458235266981634
4 : 0.0002821190574339161
5 : -7.7222291556156e-006
6 : -5.898556451056081e-007
7 : 1.152142750093788e-008
8 : 6.596299062522348e-010
9 : -1.002201654998203e-011</pre>
 
 
=={{header|Go}}==
2,122

edits