MathPlot V1.04

\begin{matrix}c \\ ◯ \end{matrix}by Rüdiger Dreier 1991

November 25, 1991

MathPlot is SHAREWARE

Contents

I Introduction 3

1 Important 3 1.1 Copying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Shareware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3 Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 What it does 4

3 What you need 4

II The menus 6

4 Project 6 4.1 New . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.2 IFF Save as . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.3 Load/Save functions . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.4 Load/Save macros . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.5 Load/Save constants . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.6 Load colours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.7 Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.8 Iconify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.9 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.10 QUIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

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

6 Edit 9 6.1 Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.2 Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.3 Insert text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.4 Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.5 Intervall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.6 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.7 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.8 Plot–Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

III Options and inputformats 11

7 Format of functions 11 8 Options 11

IV Some remarks 13

9 Stack–checking 13 10 Known bugs 13

V Tutorial 14

11 Introduction 14 12 Preparation 14 13 Enter the functions 15

13.1 Enter the macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 13.2 Enter the functions . . . . . . . . . . . . . . . . . . . . . . . . . . 15

14 Enter the intervall 15 15 Plot the functions 15 16 Change the intervall 15 17 Discussion 15

VI The End 15

18 The End 16 18.1 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

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 !

MathPlot is SHAREWARE.

1.1 Copying

This version is a demo version (with some options disabled). It may be freely copied under the following conditions:

1. The copyright text must be included (unchanged).

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

3. The program must not be changed.

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

• The complete unchanged documentation

• One working copy of MathPlot

• A version of mtool.library

5. Everybody who wants to use MathPlot (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.

6. It is allowed to translate the text of the menu item etc. (file TextDaten) into other languages and include it into any copy of this program.

1.2 Shareware

MathPlot is ShareWare. If you use this program, you may want to pay the registration fee. It is $ 20,– or DM 30,–. Please send this money to the address below and add the name and version of the program (and perhaps where you found this program). ’Why should I’, you may ask. Well, you will get

1. The newest (full) version of MathPlot . This Version must not be given to others.

2. A printed manual (this here, please tell me, if you want to have the german or english version).

3. Updateservice. You may get new versions of MathPlot by sending a disk, envelope, postage and your registration number to me. If there is no newer version, I will wait until there is one. So it may take a little time until you get the newest version. Please tell me, which version you have.

1.3 Source

The source is not freely distributable. The source is available (for registrated users only) by sending $ 20,– or DM 30,– to the address below. To use the source in a commercial sense, you need the written permisson of the author.

2 What it does

MathPlot 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). A discussion and numerical integration is also possible. So the program can be used i.e. to control your own results.

3 What you need

The program only works on Amigas with Kickstart 2.0 or higher !. 512kB memory should be enough (I hope), 1MB chip mem and new custom chips are very nice for big screen (productivity mode etc.). The stack should be 20000 bytes or more. In LIBS:, you need

1. mathieeedoubbas.library

2. mathieeedoubtrans.library

3. asl.library

4. mtool.library (should be also on this disk)

In S: you can (but need not) have 1. Funktionen, some example functions

2. Colours, some example colours

3. MPlotDef.info, this icon is used for Iconify and iff–files.

Part II

The menus

4 Project

4.1 New

You are asked whether to clear the screen or not. A HP–output ends (see 6.8). The screen clears automatically after changing the intervall.

4.2 IFF Save as

To use this item, you need the ilbm.library in libs:. If the program cannot find this library, a requester appears (ilbm.library ?). Otherwise, you are asked for the name of the file. If an error occurs, another requester appears. If a file s:MPlotDef.info exists, the icon is used for your iff–file.

4.3 Load/Save functions

You are asked for the name of the file to save or load. The lines in the file are loaded as functions or the functions are saved in a file. Look at the demo–file to see the format of this files, it is very simple.

4.4 Load/Save macros

Here you can load or save the macro definitions.

4.5 Load/Save constants

See (4.4). But here with constants …

4.6 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). All file that are loaded must end with a Return (0x0a). Most editors produce this return at the end of a file automatically.

4.7 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 6.8)

4.8 Iconify

The window is closed and an icon appears on workbench. A doubleclick on this icon starts the program again. The last functions are still available. If there is not enough memory to open a screen, the program terminates. As icon, the file S:MPlotDef is used, so this option only works, if this file is available.

4.9 About

You get some pice of information about this program (Version, my address). Click in the gadget or hit any key to close the window.

4.10 QUIT

A requester appears and asks you whether to quit or not. If you agree, the program terminates.

5 Plot

5.1 Change function

A submenu with the ten functions (you entered or loaded) appears (only the first 14 characters are displayed). Here you can select one of the functions. A window appears and you can change it. The function should be a correct expression. If you enter something like sin((x), the window appears again as long as there is one bracket too much. See (7) for a short description of those things, you may enter. If you hit Return or select OK, the changed functions is used, otherwise the changes are ignored. Please enter only lower case.

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. So it may be not very good. Even the first differentiation may be very unprecise. 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 sin(x) 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. Symbolic differentiations are calculated in a recursive way, so the stack should be at least 20000 bytes. If you get a guru, just try a larger stack. When an error was found during plotting (division by zero for example) a requester appears with the message ”There was an error” and the number of the error is displayed. See table (2) for a description of the errors. The number may be the sum of some different errors.

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 ...)

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. You are first asked, whether the program has to stop after every part of the diskussion. If so, you are asked after every part whether to continue or clear the screen and continue. For some functions, the differentiation is not correct for all values. Table (1) shows the differentiations that are used. Some of them are not correct for all values and it is a good idea to test sometimes the result. The differentiations are not optimized (i.e. you will see things like x^{2−1}). THE AUTHOR UNDERTAKES NO LIABILITY FOR THE CORRECTNESS OF THE DIFFERENTIATION !! BEFORE YOU USE ANY OF THE RE-SULTS, RECALCULATE THEM BY HAND !!!

5.4 Num. Integration

Here you can integrate a function numerically. A window appears and shows the selected function (you can even change the function or enter a new function). You are asked for the intervall and the number of steps to use for the numerical integration. If you use more steps, the result becomes better but you have to wait longer. 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. The cursor should be in the first gadget again. So you can start from the beginning. To close the window, select QUIT.

Before any of these actions it done (except change), the used macros are expanded. During this action, the colour of the screen is changed. A recursion in the macros is not detected. So it is on your own responsibility to detect such things (therefore the different colour).

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

Some of the actions (plotting, discussion, macroexpansion) can be stop. A little window with a gadget (stop action) is displayed. Just click in the window.

6 Edit

6.1 Axis

Selection this item plots the axis. If the axis are from −1 to 1 and there is some text like 10 ↑, this means that the intervall [0.1 , 10] is displayed (log–plot).

6.2 Zoom

You get a rubberbanding and can select the part of the intervall which will be plottet next. A HP–output ends (see 6.8).

6.3 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.

6.4 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.

6.5 Intervall

A window with four stringgadgets, two cyclegadgets and two normal gadgets appears. In the text gadgets you can enter the intervall, with the cyclegadgets, you can tell the program how to use this values, e.g.: you want to plot [−π, π]. You can enter −pi and pi and ∗1 in the cyclegadget. But you can also enter −1, 1 and ∗pi in the cyclegadget. Try both and plot axis, you will see the difference. To get a log/log plot, choose 10 ↑ in both cyclegadgets and so on.

6.6 Constants

A window with an active cyclegadget and an inactive stringgadget appears. Choose a character with the cyclegadgets or press a key, then hit <RETURN> . The stringgadget should become active. Now you can enter the definition for the constant, you named before. You can use constants in other functions by their name, e.g: define a constant z by entering pi. Then you can use z in any function instead of pi. Do not use x or e as name of a constant because they cannot be used later (e is defined as 2.7 ⋯).

6.7 Macros

A similar window as decribed in (6.6) appears. Enter your macro–definition in the stringgadget. 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.

6.8 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 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.

Table 3: Some values for ViewModes

NTSC MONITOR ID  69632
PAL MONITOR ID  135168
HIRES KEY  32768
SUPER KEY  32800
INTERLACE  4
VGAPRODUCT KEY  233508
VGAPRODUCTLACE KEY 233509

Part III

Options and inputformats

7 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 or. NAME(parameter). All characters must be lower case !! Use brackets to make sure, MathPlot calculates the function, you want. It uses the normal mathematical rules (↑ before ∗, / before +, −).

8 Options

MathPlot load S:Colours and S:Funktionen on startup. See table 4 and 5 for some examples. When you start MathPlot from Workbench, you can change the dimension of the plot–area via the .info–File. MathPlot knows the following keyword: WIDTH, HEIGHT, TEXT, VIEW and ROUND. WIDTH and HEIGHT define the dimension of the screen. TEXT must be followed by the name of the file containing the textdefinitions for menus etc. (so you can translate them). ROUND may be TRUE or FALSE. Here you can define, whether discussion can round little number to zero or not. With VIEW you define the ViewMode of the screen. Table (3) shows some values, you may enter. You can add the values (except the vga… ones) to get your favorite one.

Table 4: Example for a Colours–File

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

Table 5: 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

9 Stack–checking

This version of MathPlot is compiled using the –v Option of the SAS–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.

10 Known bugs

I do not know any bugs yet. Please write me if you find one. The text at the axis sometimes overwrites itself. Perhaps I will find a solution. The program and all windows are Font–independent (I hope). With Fonts > 15 and a 640–Screen you get problems mit the menus (they are too wide, they may become too high). Some window become too big to be opened. But there will be no message to tell you that it is not possible to open a special window. It is always possible to quit the program using Amiga − Q (I hope). There should be no guru because of a too big font…

Part V

Tutorial

11 Introduction

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

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

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

12 Preparation

Make sure that you have the following files in LIBS:

1. mathieeedoubbas.library

2. mathieeedoubtrans.library

3. asl.library

4. tool.library If you work often with MathPlot , 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 MathPlot –icon an select Icons/information. Modify the text in Tool–Types until you have the following:

            WIDTH=640
            HEIGHT=200
            TEXT=TextDaten_E
            VIEW=32768

Then select SAVE and start MathPlot .

13 Enter the functions

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

13.1 Enter the macros

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

and cos(x).

13.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 (6.7)). If you look at the subitem of Change, you should see your functions.

14 Enter the intervall

Select Intervall. Enter for x–min -pi, for x–max pi, for y–min -20 and for y–max 20. Both cyclegadgets should be ∗1.

15 Plot the functions

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

16 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 cleared.

17 Discussion

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

Part VI

The End

18 The End

If you have hints, questions (please add postage for the answer), bug–reports or want to pay the registration fee, here is my address:

18.1 Address

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

Have fun with my program !!