PROGRAMS
Ace Sine Wave Generator
by M Stewart 

'Sine Wave Generator' is a utility for the Jupiter Ace. The word SIN calculates successive values of sine and cosine in order to generate a sine wave. This should run on any Forth system, while the demonstration program (defined as DEMO) is specific to the Ace. 
sin(n+1) = sin(n) + (1/m)cos(n) and
cos(n+1) = cos(n) – (1/m)sin(n+1)
where m is the value supplied by the user.
The word SIN uses the top three numbers on the stack to calculate the next members of the series, replacing the top of the stack with the next sine and the second to top with the next cosine. This gives the equation SIN(m,cos(n), sin(n) –m, cos(n+1),sin(n +1)). 
: SIN ( m,cos(n),sin(n)  m,cos(n+1),sin(n+1)) 3 PICK 3 PICK SWAP / + SWAP 3 PICK 3 PICK SWAP /  SWAP ; : DEMO ( plot a sinewave on screen using SIN) INVIS CLS 4 20 0 ( set m=4,cos(0)=20,sin(0)=0) 63 0 DO DUP 20 + ( set zero 20 pixels up) I SWAP 1 PLOT ( PLOT point at I,sin(I)) SIN ( calculate next point) LOOP ; The choice of cos(0)=20 and sin(0)=0 ensures that the maximum and minimum values taken by the sine series are +20 and 20 respectively The choice of m; gives approximately 2½ waves which fit on the screen well. These definitions were tried and tested on an unexpanded Jupiter Ace. 