PROGRAM plot_function ! plot analytical solution CALL initial(t,tmax,r,Ts,T0) CALL set_up_window(t,tmax,Ts,T0) CALL show_plot(t,tmax,r,Ts,T0) END SUB initial(t,tmax,r,Ts,T0) LET t = 0 LET T0 = 83 ! initial coffee temperature (C) LET Ts = 22 ! room temperature (C) INPUT prompt "cooling constant r = ": r ! cooling constant INPUT prompt "duration = ": tmax ! time (minutes) CLEAR END SUB SUB set_up_window(xmin,xmax,ymin,ymax) LET mx = 0.01*(xmax - xmin) ! margin LET my = 0.01*(ymax - ymin) SET WINDOW xmin - mx,xmax + mx,ymin - my,ymax + my ! default background color black on all computers except Macintosh PLOT xmin,ymin; xmax,ymin ! abbreviation for PLOT LINES: PLOT xmin,ymin; xmin,ymax END SUB SUB show_plot(t,tmax,r,Ts,T0) DECLARE DEF f ! declare use of external function SET COLOR "red" DO while t <= tmax PLOT t,f(t,r,Ts,T0); ! abbreviation for PLOT LINES LET t = t + 0.1 LOOP END SUB DEF f(t,r,Ts,T0) LET f = Ts - (Ts - T0)*exp(-r*t) END DEF