|
` Calculate square and sawtooth waves
` as sums of sine waves
x = 0..2*pi len 200 ` one period
y = 0 ` initial square
z = 0 ` initial sawtooth
for n = 1 to 21
|
|
w = sin(n*x)/n ` current term
if odd(n)
|
|
y += w ` square: accumulate odd orders
z += w ` sawtooth: accumulate odd orders
|
else
|
|
z -= w ` sawtooth: accumulate even orders
|
refresh ` update viewers
wait 1 ` wait 1 sec
|
|
|
|