! GIBBS3 The square wave
!4/17/1996
!=============================================
! Number of terms in sum
LET N = 999
! Multiplier
LET M = .01
! Multiplier adjusts left and right of window
SET WINDOW -M*PI, M*PI, -2, 2
!=============================================
! Horizontal lines of grid
FOR J = -2 to 2 STEP 1
PLOT -M*PI, J; M*PI, J
NEXT J
! Vertical lines of grid
FOR J = -1*M to 1*M STEP .25*M
PLOT J*PI, -2; J*PI, 2
NEXT J
!=============================================
! Plot square wave
FOR X = -M*PI TO M*PI STEP 0.01*M
LET Y = 0
FOR I = 1 TO N STEP 2
LET Y = Y + (4/PI)*SIN(I*X)/I
NEXT I
PLOT X,Y
NEXT X
END
top Return to index
back Tables of results
next References and links