!************************************************************
! Param1
!
! Graphs the parametric equations (x(t),y(t)), which the
! user can vary.
! User can also sets values for tmin, tmax, and dt.
! If the picture goes off the screen, adjust the size of the
! window determined by the value of "s".
!Calculates the length of the curve
DEF x(t)
LET x = cos(t) !definition of x(t)
END DEF
DEF y(t)
LET y= sin(t) !definition of y(t)
END DEF
LET tmin = 0 ! min and max time interval
LET tmax = 2*pi ! for graphing function
LET dt = .001 ! time step
!sets the background variables for the program
LET s=4
LET xmin=-s !dimensions of the window
LET xmax =s
LET ymin =-s
LET ymax =s
LET length =0 !keeps track of the length
SET WINDOW xmin,xmax,ymin,ymax !produces window
PLOT LINES: 0,ymin;0,ymax !plots x,y axis
PLOT LINES: xmin,0;xmax,0
!plots the graph
FOR t = tmin to tmax step dt
PLOT x(t), y(t);
LET length_segment = sqr( (x(t+dt) - x(t))^2 + ( y(t+dt) - y(t))^2)
Let length = length + length_segment
NEXT t
PRINT "the approximate length of the curve with dt =", dt, "is", length
END