--- title: "Five-line Function Plotter" id: 77404 type: "computer_media" slug: "five-line-function-plotter" url: "http://localhost/computer_media/five-line-function-plotter/" markdown_url: "http://localhost/computer_media/five-line-function-plotter.md" published_at: "2026-11-15T18:38:31+00:00" modified_at: "2026-11-15T18:38:31+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/11/five-line-function-plotter-1.png" excerpt: "Graph any function you type in, in five lines of TS2068 BASIC, thanks to VAL of a string expression." post_tag: - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Steve Gunhouse" slug: "steve-gunhouse" taxonomy: "indiv" url: "http://localhost/indiv/steve-gunhouse/" genre: - name: "Mathematics" slug: "mathematics" taxonomy: "genre" url: "http://localhost/type/mathematics/" media_type: "Program" programmers: - name: "Steve Gunhouse" slug: "steve-gunhouse" taxonomy: "indiv" url: "http://localhost/indiv/steve-gunhouse/" mediadate: "1989" images: - url: "http://localhost/wp-content/uploads/2026/11/five-line-function-plotter-1.png" - url: "http://localhost/wp-content/uploads/2026/11/five-line-function-plotter-2.png" article_media: - id: 23469 title: "Letters from Steve Gunhouse" type: "article" url: "http://localhost/article/letters-from-steve-gunhouse/" media_type_tags: "Mathematics" license: false --- # Five-line Function Plotter Steven Gunhouse’s five-line program to graph any function you type in, from a letter quoted by George Chambers. It reads f(x) as a string and works it out with VAL f$ for each x, something few other computers’ BASICs could do, then draws the curve in short DRAW steps from x = -10 to 10, keeping y between -8.5 and 8.5. There is no error checking, so avoid dividing by x or taking powers or roots: type x*x, not x^2, for a parabola. As printed, line 30 starts the loop at 9.9 instead of -9.9 (the minus sign is missing), so the program draws only one stray line. The author also notes that line 40 should check y0 as well as y. Published in Sinc-Link March-April 1989 ([Letters from Steve Gunhouse](https://timexsinclair.com/article/letters-from-steve-gunhouse/)). ## Source Code ``` 10 INPUT "f(x) = "; LINE f$ 20 LET x = -10: LET y0 = VAL f$: LET x0 = x 30 FOR x = 9.9 TO 10 STEP .1: LET y = VAL f$ 40 IF y > -8.5 AND y < 8.5 THEN PLOT 10 * x0 + 128, 10 * y0 + 88: DRAW 1, 10 * (y - y0) 50 LET x0 = x: LET y0 = y: NEXT x ```