// Plots the sine (in red) and cosine (in green),
// and tangent (in blue) with text.

GRAPH   LANDSCAPE, VSCALE=2.1/7.5, VOFFSET=1.05
//  (don't auto-scale vertically, since tangent gets huge)

PLOT COLOR=(255,0,0)			// Starts a new plot - red
FOR angle = 0 TO 4 * PI + .1 STEP .1
   PLOT X=angle, Y=SIN(angle)		// plots the Sine
NEXT

PLOT COLOR=(0,255,0)			// starts a new plot - green
FOR angle = 0 TO 4 * PI + .1 STEP .1
   PLOT X=angle, Y=COS(angle)		// plots the Cosine
NEXT

PLOT COLOR=(0,0,255)			// starts a new plot - blue
// Note- the tangent is discontinuous at multiples of pi/2.
// We will plot the function in periods of pi.
// At the discontinuities, we will stop the plot just a tiny
//  fraction before and resume a tiny fraction after the 
//  discontinuity to avoid going infinite.
FOR period = 0 TO 3
  start_angle = period * PI
  angle_90    = start_angle + PI / 2
  end_angle   = start_angle + PI

  FOR angle = start_angle TO angle_90 - 1e-15 STEP .1
     PLOT X = angle, Y = TAN (angle)
  NEXT
  PLOT X=angle_90 - 1e-15, Y=tan (angle_90 - 1e-15)
  PLOT X=angle_90 + 1e-15, Y=tan (angle_90 + 1e-15)
  FOR angle = angle_90 + 1e-15 TO end_angle STEP .1
     PLOT X = angle, Y = TAN (angle)
  NEXT
  PLOT X = end_angle, y = TAN (end_angle)
NEXT

// Now put some titles on the graph.
v$ = "Value of Function"
TEXT YAXIS, STRING=v$
a$ = "Angle in Radians"
TEXT XAXIS, STRING=a$, COLOR=(0,0,255)  // blue
s$="Sine"
TEXT STRING=s$, COLOR=(255,0,0), X=3, Y=.55
c$="Cosine"
TEXT STRING=C$, COLOR=(0,255,0), X=1.6, Y=-.65
t$="Tangent"
TEXT STRING=T$, COLOR=(0,0,255), X=4.2, Y=.4
title$="Sine, Cosine\nand Tangent"  // 2-line title
TEXT STRING=title$, H=45, COLOR=(0,150,150), BOXED, SIZE=24
