Jump to content

Chebyshev coefficients: Difference between revisions

Chebyshev coefficients en BASIC256
(Chebyshev coefficients en Yabasic)
(Chebyshev coefficients en BASIC256)
Line 99:
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
Given the limitations of the language, only 8 coefficients are calculated
<lang BASIC256>a = 0: b = 1: n = 8
dim cheby(n)
dim coef(n)
 
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
end</lang>
{{out}}
<pre>0 : 1.64716947539
1 : -0.23229937162
2 : -0.05371511462
3 : 0.00245823527
4 : 0.00028211906
5 : -0.00000772223
6 : -5.89855645106e-07
7 : 1.15214275009e-08</pre>
 
==={{header|QBasic}}===
{{works with|QBasic}}
Line 134 ⟶ 164:
9 : -0.000000070922546058227
</pre>
 
 
==={{header|FreeBASIC}}===
2,136

edits

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