Plotter V3.98

\begin{matrix}c \\ ◯ \end{matrix}by Rüdiger Dreier 1988–91 November 25, 1991

Plotter is FREEWARE

Contents

I Introduction 3

1 Important 3

2 What it does 3

3 What you need 4

II The menus 5

4 C-Plot 5 4.1 Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.2 Intervall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.4 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.5 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.6 QUIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

5 Function 6 5.1 Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5.2 Function, 1st/2nd Diff num/symb . . . . . . . . . . . . . . . . . . 6 5.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5.4 Num. Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

6 Graphics 7 6.1 Dim1, Dim2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 6.2 Clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.3 Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.4 Insert text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

7 File 8 7.1 Load/Save functions . . . . . . . . . . . . . . . . . . . . . . . . . 8 7.2 Load/Save macros . . . . . . . . . . . . . . . . . . . . . . . . . . 8 7.3 Load/Save constants . . . . . . . . . . . . . . . . . . . . . . . . . 8 7.4 Load colours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 7.5 Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 7.6 Plot–Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

III Options and inputformats 10

8 Format of functions 10 9 Options 10

IV Some remarks 12

10 Stack–checking 12 11 Known bugs 12 12 Changes 12

12.1 V3.96 – V3.98 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 12.2 V3.71 – V3.96 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

V Tutorial 13

13 Introduction 13 14 preparation 13 15 Enter the functions 14

15.1 Enter the macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 15.2 Enter the functions . . . . . . . . . . . . . . . . . . . . . . . . . . 14

16 Enter the intervall 14 17 Plot the functions 14 18 Change the intervall 14 19 Discussion 14

VI The End 14

20 The End 15 20.1 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Part I

Introduction

1 Important

THE AUTHOR UNDERTAKES NO LIABILITY FOR ANY DAMAGE CAUSED BY THE APPROPRIATE OR NOT APPROPRIATE USE OF THIS PRO-GRAM ! THE AUTHOR UNDERTAKES NO LIABILITY FOR THE FAULTLESSNESS OF THIS PROGRAM ! USE IT AT YOUR OWN RISK !

Plotter is FREEWARE.

The program may be freely copied under the following conditions:

1. Noncommercial use (only a little fee for Disk, postage etc).

2. The program must not be changed.

3. The program must be complete: The following files must be included:

• The complete unchanged documentation

• One working copy of Plotter

4. A version of the mtool.library must be included (at least version 2.05).

5. The copyright text must be included.

6. Everybody who wants to use the Plotter (or a part of it) or the mtool.library (or a part of it) in a commercial sense needs the written permission of the author.

2 What it does

The Plotter is a little program to plot twodimensional functions. You can enter up to 10 functions and plot them all. In addition, you can plot the first and second differentiation of the functions (numerical and symbolic).

3 What you need

You should have 1. An Amiga with at least 512kB (more is better)

2. Kickstart 1.2 or 1.3 (2.0 should work, too)

3. A stack of at least 20000

4. in LIBS:

(a) mathieeedoubbas.library

(b) mathieeedoubtrans.library

(c) tool.library (should be also on this disk)

5. in S:

(a) Funktionen, some example functions

(b) Colours, some example colours

Part II

The menus

4 C-Plot

4.1 Precision

You get a submenu with three items (low, med and high). If you select med or high, the program needs more time to plot and the plot becomes better.

4.2 Intervall

Here you can enter the intervall, the function is plotted for. You are asked for x-min, x-max, y-min and y-max. You can enter everything you can use in a function, too. See chapter (8)

4.3 Constants

You will get a window with two gadgets, the second one disabled. In the first one, you should enter one charater (a-z, lower case, do not use x or e, you can never use them). That is the name of your constant. Press <RETURN>and the second gadget becomes enabled. If there was already a value for this constant, it is displayed. Enter your new constant. That’s it.

4.4 Macros

A window as described in (4.3) appears. Enter the name of the macro (here you can use x and e). Enter your macro–definition in the second gadgets. Macros are used in functions via MACRONAME or MACRONAME(Parameter), e.g. a or a(2*x). If you use the second way, every x in the macro is replaced by paramter.

4.5 About

You get some pice of information about this program. Click in the window to close it.

4.6 QUIT

A requester appears and asks you whether to quit or not.

5 Function

5.1 Change

A submenu with the ten functions appears (only the first 14 characters are displayed). Here you can select one of the functions and change it. Therefore, a window with a gadget appears. If you enter something like sin((x), the window appears again as long as there is one bracket too much. See (8) for a short description of those things, you may enter.

5.2 Function, 1st/2nd Diff num/symb

Each of this five items has the same submenu as Change. Selecting one of the functions plots it (or its 1st or 2nd differentiation). Numerical differentiations are calculated using the secant method. Symbolic differentiations are calculated first and then the new function is plotted (e.g. for sin(x): first cos(x) is calculated as the differentiation of sin(x) and then it is plotted). Symbolic differentiations are more precise but there are problems with some function (abs, sgn, ln). E.g. for ln you get the function 1/x plotted even for negativ x. When an error was found during plotting (division by zero for example) a requester appears with the message ”There was an error”. To stop plotting, click in the window. A requester appears and you can select whether to continue or stop.

5.3 Discussion

Here you can get some pice of information about the function: The intervall is displayed as well as the first and second differentiation. Also the points where the function is zero, has a min or max or a turning point. For some functions, the differentiation is not correct for all values. Table 1 shows the differentiations that are used. During a discussion, you can stop it with a mouse–click. You are asked whether to continue or stop. You can do this for every one of the three parts of a discussion. THE AUTHOR UNDERTAKES NO LIABILITY FOR THE CORRECTNESS OF THE DIFFERENTIATION !!

5.4 Num. Integration

A window appears and shows the first part of the selected function. You are asked for the intervall and the number of steps to use for the numerical integration. Press <RETURN>in the third gadget or click on OK to start the integration. The result is displayed in the window. If an error was detected, the number is displayed, too. See table 2 for a description of the codes. To close the window, select QUIT.

Table 1: The differentiations

1.  + − ∗/ The usual
2.  x^{a} a ∗ x^{(a−1)}
3.  a^{x} a^{x} ∗ ln a
4.  f(x)^{g(x)} (g(x) ∗ ln(f(x)))′ ∗ f(x)^{g(x)}
5. trigonometr. Functions The usual
6.  abs(x) sgn(x) (For x=0 not correct)
7.  int(x) 0 (Well ...)
8.  sgn(x) 0 (Well ...)

Table 2: Errorcodes

DIVBYZERO  1 You tried to divide by zero
LOGNEG  2 You tried log(≤ 0)
SQRTNEG  4 You tried \sqrt{< 0}
ATRIG  8 You tried asin, acos with arg > 1 or < 1
UNPAKLAM  16 Too much brackets
TEST  32 Not used
NOFUNC  64 No function given
NO KONST  128 No such constant
NO MEM  256 No memory
POWERROR 512 You tried (< 0) ↑ (a/b)
NO FUNC  1024 No function found

Before any of these actions it done (except change), the used macros are expanded. During this action, the colour of the screen is changed. You can stop the macro–expansion (e.g. because you produced a recursion), just click the mouse. You are asked whether to continue or stop.

6 Graphics

6.1 Dim1, Dim2

Plotter offers two plot–areas. Here you can select, on which one you want to plot. Normaly, the big one does not fit on the screen, so you can use the cursor–keys to scroll through it. With ESC, you jump to the upper left corner. Plotter’s preset is 640x200 for Dim1 and 1000x300 for Dim2. To change this, see chapter 9.

6.2 Clear

You are asked whether to clear the screen or not. A HP–output ends (see 7.6)

6.3 Zoom

You get a rubberbanding and can select the part of the intervall which will be plottet next. Using Dim2 (see above) you can scroll through the screen using the cursor–keys and ESC. A HP–output ends (see 7.6)

6.4 Insert text

You can enter a text and place it with your mouse. Click at the right place and a requester appears to ask you for the colour to use. Normaly, you can choose between four colours, but if HP–Output is active, you can choose between eight colours.

7 File

7.1 Load/Save functions

You are asked for the name of the file to save or load. Look at the demo–file to see the format of this files

7.2 Load/Save macros

Here you can load or save the macrodefinitions.

7.3 Load/Save constants

See (7.2).

7.4 Load colours

You are asked for the name of the file to load. Look at the demo– file to see the format of this file (it should have 12 lines)

7.5 Print

Prints the screen on your preferences printer (as big as possible). While printing, the colour of the screen is changed. A HP–output ends (see 7.6)

7.6 Plot–Output

This item has two subitems (on,off). >On< asks you for a name for a file to write the data in. >Off< switches HP–Output off (automatically done when changing the intervall, dimension or printing). After selection off, the file contains HP– Plotter compatible data to plot all those functions and text you plottet after selection >on<. I have no HP–Plotter, I used the PLT:–Device and it works.

Part III

Options and inputformats

8 Format of functions

The functions can consist of ()+-*/↑, sin, cos, tan, log, int, sgn, abs, sqr, asin, acos, atan, ln and the constants a-z (without x and e) and the variable x. e (2.7...) and pi (3.14...) are already set. Numbers must be in a usual format (1; 1.1; .1; 3e5; 5d-7...). Macros are used as NAME. All characters must be lower case !! Use brackets to make sure, Plotter calculates the function, you want. It uses the normal mathematical rules (↑ before ∗, / before +, −).

9 Options

Plotter load S:Colours and S:Funktionen on startup. See table 3 and 4 for some examples. When you start Plotter from Workbench, you can change the dimension of the plot–area via the .info–File. Plotter knows the following keyword: WIDTH1, WIDTH2, HEIGHT1, HEIGHT2, TEXT1 and TEXT2. WIDTH2 should be greater than WIDTH1 and HEIGHT2 > HEIGHT1. With TEXT1 and TEXT2 you can change the itemtext Dim1 and Dim2. Add two leading spaces, look at the example .info–File. Plotter opens a screen with the Dimension WIDTH1/HEIGHT1 and allocates memory for a bitmap of the dimension WIDTH2/HEIGHT2. So you should have enough memory for the second dimension.

Table 3: Example for a Colours–File

fff Printing Background
f0f  TitleBar
5f0  Title
000  Plotting
aaa Normal   Background
679  TitleBar
fff  Title
000  Plotting
09e HP-Out   Background
0b0  TitleBar
fff  Title
000  Plotting

Table 4: Example for a Funktionen–File

sin(x) Will be the first function
cos(x) Will be the second function
tan(x) etc.
x  etc.
x ↑ 2 etc.
x ↑ 3 etc.
sqr(x) etc.
log(x) etc.
sgn(x) etc.
abs(x) etc.

Part IV

Some remarks

10 Stack–checking

This version of Plotter is compiled using the –v Option of the Lattice–Compiler that is without stack–checking. The program will not detect a stack overflow. Use a stack of at least 20k, that should be enough.

11 Known bugs

1. The value of a function is sometimes calculated to zero (even when it is not). This bug is not reproducible. (I did not see it for a long time)

2. Sometimes I get a TrapV-exeption. Also not reproducible.

3. Using the HP–Output I get sometimes files, that can be displayed via the s–option of the PLT:–device, but cannot be printet.

12 Changes

Here is a list of changes between the published versions of Plotter.

12.1 V3.96 – V3.98

• Plotter now works correct on FPU–Amigas.

12.2 V3.71 – V3.96

• Two known bugs in Ableitung.c are corrected. Now x^{x} and one more sort of functions are differentiated correctly.

• A new feature are macros (see 4.4).

• Now you can load and save functions, macros and constants. You can also load a palette.

• Numerical integration is now possible.

• Plotter can do HP–Output, so together with the PLT:–device, you get good prints.

• Entering text in the plot–area is now possible.

• The dimension of the plot–area can be changed via the .info–file (see 9).

Part V

Tutorial

13 Introduction

This Tutorial tries to help you to work with the Plotter. Let’s say, you want to plot the following functions:

sin(x) + cos(x)
2 ∗ sin(x)
sin(2 ∗ x)

As intervall, you want [−π, π].

14 preparation

Make sure, that you have the following files in LIBS:

1. mathieeedoubbas.library

2. mathieeedoubtrans.library

3. tool.library

If you work often with Plotter, copy the following files to S:

1. Colours

2. Funktionen

You should also enter the dimension of the plot–area. Click one time on the Plotter–icon an select Workbench/info. Modify the text in Tool–Types until you have the following:

            WIDTH1=640
            WIDTH2=1000
            HEIGHT1=200
            HEIGHT2=300
            TEXT1=   640x200
            TEXT2=  1000x300

That is except TEXT1 and TEXT2 the preset, if you start Plotter from CLI. Then select SAVE and start the Plotter.

15 Enter the functions

Well, the three functions are quite short, but to make clear how to use it, use the macros:

15.1 Enter the macros

Select the item Macros. A window should appear with two gadgets. In the first, enter a. Press <RETURN>. In the second gadget, enter sin(x) and press <RETURN>. Select Macros again. Enter b and cos(x).

15.2 Enter the functions

Now you can enter the functions. Select three subitems of the item Change. A window should appear with a gadget. If there is already some text, delete it with right–Amiga–x. Then enter _a+_b. Press <RETURN>. The window disappears and appears right again. Enter the second function (that is 2*_a). After <RETURN>, you can enter the last function (that is _a(2*x), see (4.4)). If you look at the subitem of Change, you should see your functions.

16 Enter the intervall

Select Intervall. Enter for x–min -pi, for x–max pi, for y–min -20 and for y–max 20.

17 Plot the functions

Select at Function/… your three functions. They will be plotted. You will see, that -20/20 was too much.

18 Change the intervall

You could select Intervall and change it. But you can also use the mouse: Select Zoom, select one corner of your new intervall, move the mouse and select the second corner. The screen should be cleaned.

19 Discussion

If you want to know more about one of the functions, select Discussion/function.

Part VI

The End

20 The End

If you have hints, questions (please add postage for the answer), bug–reports (wrong differentiation) or money for me, here is my address:

20.1 Address

Ruediger Dreier
Gustav-Winkler Str. 40
W-4800 Bielefeld 18
Germany

Have fun with my program !!