I was pleased to see that in the October & November issues of QL World they gave considerble space to ARCHIVE, the PSION database program we all have. Those of you who have followed this column know that I have high regard for ARCHIVE and have tried to promote it use by more US QL users. Its programming language is what I do most of my QL software development in. If you are not using a database or running database type programs you are missing out on a lot of what your QL can do for you.
Below we will examine the PSION program EASEL as it can be used for plotting mathematical curves. All QL users should be able to do the example even if the are using a TV as a monitor. If you have never used EASEL give it a try.
PLOTTING CURVES WITH EASEL (Business Graphics)
Easel is the most fun of the PSION programs to play with. EASEL is a very easy to use and powerful graphics program and the QL is a flexible graphics computer. In fact the QL version of EASEL has better graphics than PSION’s PC version of EASEL on a 286 with VGA graphics. Besides simple bar and pie graphs as described in the manual EASEL can be used to plot complex mathematical equations. Multiple curves can be plotted on the same graph to see if they intersect (have solutions). This easy graphical intepretation of equations enables one to solve equations in a couple of minutes that would othewise require fancy software. I realize that most readers don’t need to solve equations but most of us have some interest in math. Its fun to doodle with formulas and watch the curves appear on the screen and its so easy to do with EASEL. Anyone taking a math course will find EASEL a real asset. Graphical interpretations in mathematics often gives insights that are hard to come by otherwise. No need to buy more software or write a SUPERBASIC program. Just follow the suggestions below and you will be plotting curves in no time.
In the examples below I use EASEL version 2.1 as it comes set up for microdrive. You can use your PSION config_bas program to configure EASEL for floppies if you have them and substitute flp references where I use mdv. First I will give a quick overview using EASEL for curve plotting and then a 2 step tutorial with key presses in bold face. Be sure to refer to the manual for more detailed descriptions of the commands and concepts.
Overview of EASEL
Easel works very much like the other PSION programs. There is the help box at the top giving us instructions and informing us of the various commands avaiable. Pressing <F1> always gives us help. Pressing <F2> makes the upper description boxes go away or come back. There are 2 modes, data and formala entry mode and command mode. Pressing <F3> puts us in command mode. Pressing <ESC> cancels commands or input and eventually puts us back in data entry mode. When in data entry mode if we type a number it is interpreted as raw data to go in the current cell and if we type alphabetic characters they are interpreted as a formula to be calculated for all cells. Trying to do a command when in data entry mode or trying to enter data or a formula when in command mode are easy mistakes to make. Just look at the lower left of the screen where the input line is. When in data and formula entry mode you will see ‘?’ and when in command mode you will see ‘COMMAND> ‘. Use <ESC> to cancel mistakes or switch to data input mode and <F3> to switch to command mode.
Easel is always working with a set of data each of which consists of a location (cell) on the horizontal axis (x axis) and a corresponding numeric value up the vertical axis (y axis). EASEL can work with more than one set of data and so each set needs a name. When you first start up a set called ‘figures’ is defined. If you define a new set of data ‘x’ and type in the formula y=sin(x), EASEL uses the name on the left side of the equal sign,y, to be the name of a set of data to be calculated from what is on the right hand side of the equal sign, sin(x). Easel would create the new set of data, y, where each y would equal sin(x) for each x. If the set of data, y, had already existed then each would be recalculated by the formula. Even if more than one curve (set of data) is on the screen at once there is just one active one. You can tell which one it is by seeing what follows the ‘Current Name’ label at bottom of screen.
The horizontal axis is divided into cells. When you first start up there are 12 cells for the months of the year. You can move around the cells with <TAB> and <SHIFT-TAB> and if you move beyond either end EASEL will rescale and add more cells. For simple bar graph applications labels are important for cell identification on the horizontal axis but for mathematical applications the cells will correspond to numbers on our horizontal axis (x axis) and we don’t need labels. In fact we rescale the horizontal axis to have so many cells that there is no room for cell labels.
EASEL provides two special terms to use in formulas that allow us to scale the horizontal axis to our needs. They are cellmax (equals the value of the total number of cells in our current scaling) and cell (ranges from 1 for left most cell to cellmax for right most cell). If we scaled our graph so it had 100 cells then cellmax=100 and cell ranges from 1 to 100. If we define a set of data,ref, by the formula ref=(cell-1)/(cellmax-1) then ref always ranges between 0 and 1 no matter what our cell scale is because cell ranges between 1 and cellmax. Then if we wanted to plot a sine curve in the range -2 to 2 we can set our independent variable x as x = -2 + 4*ref. So x ranges between -2 and 2 as ref ranges between 0 and 1. Then plotting y=sin(x) will give us our sine curve in the range -2 to 2. Note that if you have a mistake in a formula you will get the message ‘formula gave no values’. You can then use the arrow keys to edit the formula.
If the graph is bar graph we can change it to a line with the Change (line) command. We can pick which of our currently defined sets of data we want to see with the View command. We can edit the text on our graph with the Edit command. If there is an area of the graph of interest to us we can use the cross hairs (controlled by arrow keys when in data entry mode) to read the values off the vertical axis. Getting values off the horizontal axis is not directly possible since the values for x are not labeled. The best way I have found is to display the curves of interest plus x (our independent variable) with the view command. Then use the Files (export) command to export the data to a file. The file can then be viewed,printed or imported to ABACUS so the actual values can be read directly.
USING EASEL
Dig out your EASEL (Business Graphics) cartridge and have a another formatted cartridge ready to hold your data. Have all cartridges removed from your QL. Reset your QL and put your copy of EASEL in mdv1_ and your data cartridge in mdv2_ and press <F1> (or <F2>). Easel will load and you will see a graph with the months of the year along the horizontal axis. If you type in numbers then they will be put in the corresponding months.
STEP 1 : Making a master graph for curve plotting
You need do this step only once because we will save the result to a file called ‘curves_grf’. Anytime you want to plot curves you just load ‘curves_grf’ and start at step 2.
First lets remove the months from the horizontal labels. We will use the edit command.
<F3> switch to command mode e edit command l edit labels <F4> delete labels (do <F4> 12 times to delete Jan through Dec)
(note after Dec was deleted the graph rescaled its horizontal axis)
Now let us make 100 cells on our horizontal axis
<ESC> exit edit command <ESC> exit command mode to data entry mode <TAB> move toward end of graph (do many,many <TAB>s until graph rescales 4 times)
We should have 5 total rescales (1 in edit mode, 4 in data entry mode). This makes 100 cells. If you go too far then <F3>v<ENTER><ENTER> and <TAB> through 5 rescales. The examples do not depend on the how many cells we have scaled but up to a point the more cells the better the plot resolution.
Now let us edit the graph title
<F3>et command mode,edit command,edit text (move the cross hairs (with
arrow keys) to the 'T' in Title)
<ENTER>
(Delete 'Title' with <CTRL> up arrow and enter : )
Plotting Curves<ENTER>
(move new title where you want it with arrow keys)
<ENTER> exit edit text
Now let us change the graph paper to remove all those vertical lines
cg5<ENTER> change graph paper to format 5
Now let us define our ‘ref’ set of data that we will always use to define the range of our independent variable x. Ref ranges from 0 to 1.
<ESC> return to data entry mode ref=(cell-1)/(cellmax-1)<ENTER> formula to define ref <F3>cL2 change ref to line style 2
Remove the initial set of data ‘figures’ as we won’t use them
<F3>k kill command figures<ENTER> kill the 'figures' data set
Now save our master graph
s save command curves<ENTER> put on mdv1_ and call curves
STEP 2 : Plotting 2 curves
Let us plot 2 curves to see if they cross (a solution y=w):
y = x*x*sin(x) + x -1 x between -5 and 5 w = x*x - 4*x -1
First lets load our curve plotting master graph. You saved it right?
<F3>L load command curves<ENTER> load curves_grf from mdv2_
Set up x scale. We have already defined ref
<ESC>x=-5+10*ref<ENTER> define x so it goes from -5 to 5 <F3>cL2<ENTER> change x to a line graph style 2
Now plot y and w
<ESC>y=x*x*sin(x)+x-1<ENTER> enter formula y <F3>cL0<ENTER> change to line style 0 <ESC>w=x*x-4*x-1 enter formula for w <F3>cL1<ENTER> change to line style 1
Now see how they look together
<F3>vy,w<ENTER><ENTER> view y and w data together
We see that there are 2 points where they intersect and there may be more. We can rescale x to a bigger interval and enter the y and w formulas again if we want to check for other intersections. Return to the data entry mode with a few <ESC>s and move the horizontal wire with the up or down arrow key to each intersection. You will see that y or w equal about -1 and -2.5 at the intersections. You know that x goes from -5 and 5 on the horizontal axis so you can very roughly estimate it to be about 0 and 3 at the intersections. More exact values can be found by exporting. Typing : <F3>vx,y,w<ENTER><ENTER>fevalues<ENTER> will create an export file values_exp. It contains the data names in the first line and each following line has the cell label (null),x value,y value, w value. You can import it to ABACUS it or copy it to your screen or printer to inspect it.
You can print your curves also
<F3>vy,w<ENTER><ENTER>pp view and print

MORE FUN WITH EASEL
I have only just touched on EASEL and curve plotting. I hope you are inspired to explore further. I recommend reading Warren Fricke‘s excellent articles on curve plotting and polynomials (under the TS-2068 programming section) in the last 2 UPDATE issues (Jul 89, 20-21, Oct 89, 24-26). You can use EASEL to plot the curves he describes and you don’t need to program. Be sure to use repeated multiplication for powers (x*x*x for x cubed, etc) in the formulas. Also the curves he shows have the axes rescaled for better resolution. Your graphs will have slightly different shapes but if you check the details you will see they are indeed the same curves.