Chebyshev coefficients: Difference between revisions
Content added Content deleted
(Chebyshev coefficients en Yabasic) |
(Chebyshev coefficients en BASIC256) |
||
Line 99: | Line 99: | ||
=={{header|BASIC}}== |
=={{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}}=== |
==={{header|QBasic}}=== |
||
{{works with|QBasic}} |
{{works with|QBasic}} |
||
Line 134: | Line 164: | ||
9 : -0.000000070922546058227 |
9 : -0.000000070922546058227 |
||
</pre> |
</pre> |
||
==={{header|FreeBASIC}}=== |
==={{header|FreeBASIC}}=== |