Tutorial Project 4: A Simple Command Line and Student Reports

In this project, we build a two-page Document called "Explore" on the first page of which, students may exercise the Command Language to explore a variety of mathematical ideas. On the second page, we show how authors may create "Report pages" for student assignments.

Instead of using buttons to move back and forth between the pages, we will add wallpaper and hotspots to the pages. The finished Document is in your Program Files/Bluejay Lispware/Mathwright32 Author/microworlds/explore directory.

Before you begin, be sure that the screen resolution is 800x600 or 1024x768. The Documents that you create may be displayed on reader machines or browsers in any resolution. You have no control over that. But if you create them in 800x600 or 1024x768 resolution, then they will display properly in 640x480, 800x600, or 1024x768 resolutions in the reader's machine or browser. This is especially important because, in the browsers, you may shrink or enlarge the page as you like to fit your web page. Along these lines, we remind you that if you use wallpaper bitmaps (and hotspots) then you may use either bitmaps, GIFs, or JPGs. And these should be 800x600, or 1024x768 pixels to match your screen resolution.

Step 1: Document Directory

We begin, as usual, by creating the "Document Directory". As we mentioned in Project 2, Part 1, each new Document should be placed in its own directory. Therefore, the first step in creating the Explore Document is to create a directory called explore (lowercase) that will hold it.

We use lowercase for all file names and directories because some servers (notably Apache servers) are case sensitive, and may not find a file if the case is wrong. Of course, this is not an issue for Mathwright32 Author or Reader when they read Documents offline, but we follow the practice outlined above because most Documents will be served from web servers.

Another practice that we follow for reasons that will be clear when you read Project A on Packaging and Delivering your Document, is this: The name of the directory should be the same (lowercase) name as the name of your Document ( .lva file). We will create this Document in the C:\My Documents folder, because that is where Mathwright32 looks for them.

Thus, go to the Windows Explorer, select the C:\My Documents directory, then select File, New, Folder: and when asked for a name, type explore. This will create a directory: C:\My Documents\explore\ into which you will place the Document.

Step 2: Adding the "handcursor.cur" resource

If you browse in Windows Explorer to the home directory: Program Files/Bluejay Lispware/Mathwright32 Author you will find a little file called: handcursor.cur. Whenever you create a new Document, copy this file and paste it into your new directory. While it is not needed for offline reading in Mathwright32, it is a necessary resource for MathwrightWeb. Thus, highlight it, and select: Edit, Copy. Then browse to your new directory, and select Edit, Paste. Another resource that we want to bring to your new folder is algebra.lsp. copy and paste that into your directory now. Next, locate the wallpaper: wallpaper.bmp in the Author directory, and copy that and paste it into your new directory. Finally, we will copy two stock sprite files called: "red.bmp" and "blue.bmp" for a simulation later in the project. Locate those and paste them into your new directory also.

The explore directory should now hold:

Step 3: Creating the Document

Next, let's open Mathwright32 to create the explore Document. There are several ways to open Mathwright32 as we saw above. You may click on the Mathwright Author 32 icon above in the MWAuthor32 button on the Start Menu that was set up with the system, or you may go to Windows Explorer and click on mwauthor.exe in the Program Files/Bluejay Lispware/Mathwright32 Author subdirectory, or you may select Run..., then enter C:/Program Files/Bluejay Lispware/Mathwright32 Author\mwauthor.exe.

Any of these will open a blank copy of the program. Now, once the program is open, select WorkBook, New Document from the menu. The screen will turn white, and the page caption will change to: Untitled0: Page 1 of 1 This means that you have created a new Document. It has the temporary name: Untitled0.lva.

The next step is to save this (empty) book into the directory just created. Thus, Select WorkBook, Save As...

And type in the Dialog Box C:\My Documents\explore\explore or, select the C:\My Documents\explore directory, then type explore in the dialog box as below. Save the Document. It is saved as explore.lva.

Step 4: Setting the Wallpaper

Now, instead of setting a page color for the Document, we will add the stock wallpaper called wallpaper.bmp that was created by Mathwright Author Samad Mortabit. The important property of that wallpaper is that it has built-in Title bar and Navigation bar, and it is 800x600 pixels in size. You may of course create your own wallpapers as you like in the future with either BMP, GIF, or JPG files.

Aside from decoration, this wallpaper will be the substrate of our hotspots. Whenever you create hotspots, they "belong" to the background wallpaper. If you remove the wallpaper, the hotspots go too. We will add hotspots to the Navigation bar to move from one page to another.

Select: Page, Wallpaper...

Browse for : wallpaper.bmp, and click OK.

Save the Document. Your page should now resemble:

Step 5: Create a second page

Now, we will want the same wallpaper on page 2 of this Document, so we will

Thus, go to Design mode, and select Page, Copy this page.

Then, from the same menu, select: Page, Insert new Page after this one.... You will find yourself on page 2. And, finally from the same menu, select: Page, Paste Page. Go to Reader mode, and Save the Document. Return to page 1 by selecting: Goto, First Page.

Step 6: Loading "Algebra" and defining a matrix in the Document Script

As was mentioned in Project 2, sometimes it is necessary to initialize books when they first open by loading in File scripts, creating objects of various sorts, etc. The best place to do this is the WorkBook Script, because then the initializations are done just once, before anything else happens. If you want an initialization to affect a screen Display Object (such as draw a graph) then put that in the Page Script, because that is run after all display objects have been created.

When a file script, say Myfile, is created in a script window, Mathwright32 saves two files to disk: Myfile.lsp and Myfile.msp. The command:

load "myfile";

causes the contents of myfile.lsp to be brought into the Lexicon. This latter file has all of the executable content of the script: the command and program definitions, variable declarations, initializations, and so on. The other file is used for later editing and modifications.

Since we are going to do symbolic algebra, we need the system file called Algebra.lsp that you brought earlier into your directory. This file is one of the original files that was placed in the Program Files/Bluejay Lispware/Mathwright32 Author directory, and it is available as a resource for all Documents that will use the built-in Expert System. It is needed generally by any book that will do symbolic algebra. The commands and functions that require it are listed in this MathScript Language Reference.

Now, to edit the WorkBook script, select (from any page) WorkBook, WorkBook Script... The Script window opens.

We are going to load algebra into the Document, and define an 8x8 matrix m. Type the lines:

load "algebra";
make vv [1,2,3,4,5,6,7,8];
make m matrix #8 #8;
do
i=0
until i==8 {
putc vv^i i+1 m;
i := i+1;
}

This script will be run once, when the book opens. Since the book is already open, we should execute it now so that we won't have to close and open the book. Thus click Execute. The script is run, the file is loaded into the Document, just as it will be whenever you open the Document. Now executing the script does not compile, attach, or save it. That must be done separately, since we might be executing it simply to test it. So now select Compile..., and Attach and Exit. The WorkBook Script is in place. This is a good time to Save the Document by selecting WorkBook, Save.

Step 7: Place a MathEdit, Graph2D, and CommandLine on Page 1

Now, we are going to place a MathEdit window, Graph2D window, and a CommandLine on the first page. You should go to Design mode and draw and name them. Use Page, Snap to Grid to get things lined up nicely. Now create these objects on the page, giving them the names indicated below. Remember that you must access the Objects menu in Design Mode to create a new object. Then, select the type of object you want, then draw it, and type the name of the object.

To draw an object, place the cursor where you would like the upper-left corner of the rectangle to be. Press and hold the left mouse button down. Move the mouse to the lower-right corner of the rectangle, while holding the left mouse button down. Release the left mouse button when satisfied. When finished, you may want to move or resize the object (Snap to grid will be helpful). Refer to "Moving and Resizing objects on the screen" in Project 2. Usually, a "ghost rectangle" will be traced as you move the mouse to help you see what you have at any moment, but if you are drawing on the surface of another window, you will not see that ghost rectangle.

Create the MathEdit object Record on the left, the Graph2D object Canvas on the right, and the CommandLine Input below. Then return to Reader mode. Experiment with the menus to get a screen like the one below, except for the Title, which we add momentarily, and the two "sprites" which we shall add later using the Command Line. Notice that we "corrected the Aspect Ratio" in Canvas (selecting: Actions: Correct Aspect Ratio) so that circles look like circles, etc. We did not create a Trace Bar, but you are welcome to do that if you like. When you type commands in the command line and press Enter, they will be executed. Also, for the Command Line, we chose a Courier, Regular, 8 Point font.

Step 8: Create a Title for the Page

Now, at the very top of the page, you see an empty rectangle. We will place a Label in that rectangle that says: "Command Line Exploration" The background color of the Label should, of course, match the green background of the rectangle, so that the Label will appear to be a part of that rectangle.

Next Save the Document, go to Reader Mode. We will experiment with the Command Line.

Step 9: Viewing the Lexicon

There are over 200 built-in commands and functions. In a given session, you may create new commands, functions, vectors, matrices, and so on. To see what objects exist in the current environment, you may view the Lexicon. The Lexicon has a listing (with definitions) of all commands, functions, and objects currently available to a given page.

Much more detailed information on syntax and properties of the built-in Commands and Functions is available elsewhere in this online MathScript Reference, but the Lexicon gives a quick way to check the syntax and spelling of built-in commands, and it is the only way to learn about the User-defined commands, programs, and objects available to a page.

To get to the Lexicon, you may select it on the Objects Menu, as indicated below, or you may use any Script Window. Once you do that, select Lexicon:

Select Commands from the Popup, and you will see the Lexicon Dialog Box listing the Commands. Double-click on a command to see its syntax and an example. To see the built-in commands, scroll through the list on the left. At the end of the list, the entry: User-Defined announces that commands following are defined by the Author or Reader. To get information on any command, double-click on the entry at the left. The text, with syntax and possibly examples of use will appear on the right. That text may be copied and pasted, by following the instructions at the top of the dialog box.

 

Step 10: Executing Commands on the Command Line

First, let's do some simple numeric calculations. You should check the Reading mode for numbers before you do this. You can set the reading mode by right-clicking on any Command Line, TextBox or on any MathEdit. Right-click the Yellow Command Line to get its menu. Choose: Settings, Read Numbers As... The Exact mode should be checked, because we loaded "algebra". Turn that off. Since nothing is checked, the reading mode is Long, that is, our arithmetic will be with Java integers for now. There are 4 basic reading modes for numbers:

And you can form various combinations of these, such as BigLong, BigDecimal, and so on. Long reading mode is most like what you find in ordinary calculators, but we'll need other settings shortly. This reading mode affects the way that MathScript interprets all numbers, even those entered in dialog boxes! A full discussion of the modes for numbers appears in the Manual under Mathematical Objects. The settings can also be made by command in a script.

Now type (and press Enter)

calc 2^300;

2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376

calc 2^300/2^299;

2

MathScript did both exponentiations and then did the division.

Now try:

calc (2/3)^2;

The answer 0 is reported. Why? Because in long reading mode, 2/3 is projected to the integer 0. But try

calcexact (2/3)^5;

The correct answer: 32/245 is reported now. The calcexact command always does the operations in Exact reading mode, and it further simplifies (normalizes) its answer, so that for example, fractions are always reduced. Try

calcexact 1/2 + 1/3 + 1/4;

Now, what if we wanted a big number, say 2^1000

calc 2^1000;

10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376

This is not a Java Integer! It is a Java BigInteger. MathScript automatically translates an exponentiation: long^long to the BigLong type. How about decimal calculations? These are controlled by the Precision setting in the TextBox menu, or by the precision command.

We will approximate Euler's number. We want to raise 1.005 to the 200th power. For this, set the Reading mode to Decimal and Big Numbers. Precision doesn't matter. When you raise a BigDecimal number to a Long Power, you get a BigDecimal. So we have to "force" the exponent to be a Long (and not a BigDecimal) number. The long() function does that for us. Try:

calc 1.005^long(200);

2.711517122929374798548993970162904126526518928644110795200316719640032643402744567213293657847576911476661005810375684732378108536732604601258470790763638451088983895523161501985631641801197795841778086132512422265559938985999011553329697932214739934805195065365565151315129980218926828980282037148147546706589558889754307981330477509263316998007613817489136065440330345011099089410024333665326201346344332661117568574734808872400274808070840733451211604885052614250123433999781244813386531818584586647380000029483550529360099606801320095333032710887389716961949626128358659116202034056186676025390625

To see this number, the simplest thing is to copy it from the Mathedit and to paste it into a text editor, like NotePad. (Do not paste it into the Command Field.)

Some Algebra:

We do a few algebraic calculations. For symbolic algebra, it is good to be in Exact Reading mode. We could do this from the menu, but let's use a command. Type: (then press Enter, of course.)

readexact;

If you check the menu, you'll see that it has been done.

Now, let's do a simple calculation:

calc (x+1/2)^2;

You see that no expansion was done. The 1/2 was read as a fraction, but the multiplication was not done. But try:

calcexact (x+1/2)^2;

That is more like it! Now let's play with the binomial theorem.

calcexact (x+y/2)^10;

Or the trinomial theorem:

calcexact (x+y+z)^10;

The answer in the Mathedit is prettier than this (if we select a small font), but until MathML is generally available, we're stuck with "telegraphic" output on this web page.

x^10+10*x^9*y+45*x^8*y^2+120*x^7*y^3+210*x^6*y^4+252*x^5*y^5+210*x^4*y^6+120*x^3*y^7+45*x^2*y^8+10*x*y^9+y^10+10*x^9*z+90*x^8*y*z+360*x^7*y^2*z+840*x^6*y^3*z+1260*x^5*y^4*z+1260*x^4*y^5*z+840*x^3*y^6*z+360*x^2*y^7*z+90*x*y^8*z+10*y^9*z+45*x^8*z^2+360*x^7*y*z^2+1260*x^6*y^2*z^2+2520*x^5*y^3*z^2+3150*x^4*y^4*z^2+2520*x^3*y^5*z^2+1260*x^2*y^6*z^2+360*x*y^7*z^2+45*y^8*z^2+120*x^7*z^3+840*x^6*y*z^3+2520*x^5*y^2*z^3+4200*x^4*y^3*z^3+4200*x^3*y^4*z^3+2520*x^2*y^5*z^3+840*x*y^6*z^3+120*y^7*z^3+210*x^6*z^4+1260*x^5*y*z^4+3150*x^4*y^2*z^4+4200*x^3*y^3*z^4+3150*x^2*y^4*z^4+1260*x*y^5*z^4+210*y^6*z^4+252*x^5*z^5+1260*x^4*y*z^5+2520*x^3*y^2*z^5+2520*x^2*y^3*z^5+1260*x*y^4*z^5+252*y^5*z^5+210*x^4*z^6+840*x^3*y*z^6+1260*x^2*y^2*z^6+840*x*y^3*z^6+210*y^4*z^6+120*x^3*z^7+360*x^2*y*z^7+360*x*y^2*z^7+120*y^3*z^7+45*x^2*z^8+90*x*y*z^8+45*y^2*z^8+10*x*z^9+10*y*z^9+z^10

Let's try some other algebraic operations:

factor 144;

2^4*3^2

OK, how about a tougher one:

factor 2^(2^5)+1;

641*6700417

Now we can also factor polynomials in a single variable. Try:

factor y^10+y^5+1;

(y^2+y+1)*(y^8+y^3-1*y^7+y^5+1-1*y^4-1*y)

Let's check that. You may copy the result and paste it into the command line:

calcexact (y^2+y+1)*(y^8+y^3-1*y^7+y^5+1-1*y^4-1*y);

y^10+y^5+1

Some Graphing:

We can easily graph the built-in functions, like sine, cosine, etc.

graph sin;

graph cos;

graph sin+cos;

draw the graph of sin+2*cos using color red, width 2;

graph sin#cos color color(0,0,128), width 1;

(The # means composition, and we have the choice of 16,000,000 RGB colors with the color(R,G,B) function. Each of the three arguments varies from 0 to 255.)

It is easy to clear the screen.

clear;

If there was more than one window, we would say:

clear in "graph";

to clear the Graph2D named "graph". We might also have used the Actions, Clear Screen menu.

Let us define a few new functions and look at their graphs.

make f(x) (x+1)^2;

To see that the system knows the name "f" of this new function, right-click on the background and select from the menu: Objects, Lexicon, functions... Scroll down the bottom to the User-defined functions, where you see F, and click on it. The system shows:

Definition: F(X) is (X+1)^2

All new mathematical objects are stored in the Lexicon and may be checked in this fashion.

graph f width 2 color red;

We may solve an equation using f for any variable, say y:

solve f(y)+y = 3, y;

We see y = sqrt(17/4) -3/2

There is no explanation. If you want to see a step-by-step solution, type:

make doexplain true;

Now, if you type:

solve f(y)+y = 3, y;

You see:

Rewriting: y^2+3*y-2
Applying subrule: 3 : completing_the_square
of Rule: basic to transform the equation to the equation:
sq(y+3/2)+-17/4 = 0
The answer is
y = sqrt(17/4)+-3/2

Or, we may ask for a numeric approximation using the roots() function. Here, the first argument is the equation (the variable must always be x), the second is the refinement for the initial partition of the interval, and the third is the interval to search for roots. It is entered as a MathScript vector, and so uses square brackets.

calc roots(f(x)+x=3, 50, [-5,5]);

A vector of two approximate solutions is reported: [-3.561552812808803, 0.5615528128088066]

Now let's experiment with graphing compositions of functions.

clear in "graph";

make g(x) 1/(1-x);

(Here's another way to define a function.)

h(x) := 1-1/x;

graph g color green;

graph g#g;

(It didn't do a good job with the singularity, but we'll come back to that in a moment..)

graph h color red;

graph h#h;

graph h#h#h;

This may be a surprise. It is essentially the identity function.

make u h(h(h(x)));

calc u;

Now, you'll notice that the built-in graph command did not handle the singularity well. This may be a good time to discuss user-defined commands. One way to "solve" the problem of singularities is to define a function that graphs by drawing a sequence of disconnected points.

Execute the following command definition in the Page Script. You may copy and paste it there. No need to attach it.

The command is called Pgraph. If you right-click on the background and select from the menu: Objects, Lexicon, commands... Scroll down the bottom to the User-defined commands, where you see PGRAPH, and click on it.

The definition is:

command pgraph (fn f) (ex ref) [color ex col set pencolor to col] [width ex wid set penwidth to wid]
{ local (ve #2 xlims) (ex y)
{
let xlims be getabscissa();
let range be xlims(2)-xlims(1);
make step range/ref;
do i = 0
cur = xlims(1)
until i > ref
{ let y be evaluate(list(f, cur));
point [cur, y];
i := i+1;
cur := cur+step;
}
}
}

This command takes two mandatory arguments: first the function object, and next an integer refinement (ref). It also may take two optional arguments: color and width (for the pencolor and penwidth). These may be supplied or not, and in any order or placement. But if they are supplied, the pencolor must be preceded immediately by the word "color" and the penwidth must be preceded by the word width. Try it out:

clear;

pgraph g, 150, color green;

pgraph g 150, width 2, color green;

pgraph g#g, 200, color red, width 3;

And so on... There are better ways to avoid singularities, but we will leave you to experiment with them. You may see the definition of pgraph in the WorkBook script if you get the WorkBook menu by right-clicking on the background. Then click on WorkBook Script. Scroll down to it, then click Cancel.

Some Calculus:

Next, let's create a curve, a vector-valued function of a single variable. We'll define an ellipse as a function of a single variable t. The use of square brackets in the definition tells MathKit that the values that this function takes are vectors. Type:

c(t) := [5*cos(t), 3*sin(t)];

To draw the image of this as t varies from 0 to 2*pi, use the Curve command.

curve c;

or, more informally,

Draw the curve c;

will cause the curve to be drawn. Next, define a map tr: R2 -> R2 that takes

(x,y) -> (x2 - y2 + x, 2xy - y)

Type:

tr(x,y) := [ x^2 - y^2 + x , 2*x*y -y ];

Next shrink the curve c

cc(t) := c(t)/3;

curve cc;

The image of cc is the image of c scalar-multiplied by 1/3. Now, draw the curve which is the composition of tr with cc.

curve tr#cc;

Next we look at the partial differentiation operator:

calcexact (x+y/2)^5;

d(expr, var1, var2, ...) the partial differentiation operator. Follow the expression with the desired differentiation variables. If you supply no variables, you have the 0th order operator, which is the identity. This has the handy property of normalizing expressions to make it possible to compare them. Thus, in a script, the return value of d(x^2 - y^2 -(x+y)*(x-y)) is the same as the value printed by

calcexact x^2 - y^2 -(x+y)*(x-y);

That is, 0. Since calcexact does not actually return a value (but prints one as a side-effect) the 0th order differentiation operator is very useful in scripts.

calcexact d((x+y/2)^5,x);

calcexact d((x+y/2)^5,y);

calcexact d((x+y/2)^5,x,y);

The numeric integration function is integrate( expression in x, refinement, interval).

calc integrate(x^3,10,[1,2]);

calc integrate(x^3,20,[1,2]);

Some Matrix calculations:

This WorkBook has an 8x8 matrix called m defined in the WorkBook script. It is a rational matrix, and so we get into exact reading mode to operate on it. With matrices, we use calc and not calcexact. Just follow along below.

readexact;

calc m;

make n m^2;

calc n;

calc n*inv(m);

calc inv(m);

calc m*inv(m);

calc transpose(m);

calc det(inv(m));

readlong;

Now select, say the upper 4x4 submatrix of m. Select Actions, Copy. Place the caret at the bottom line of "mathedit" and select Actions, Paste. You may assign that matrix a name in the following way:

make u getmatrix(false);

Getmatrix(n) returns the nth matrix in the window. Getmatrix(false) simply returns the last one. Thus u is the 4x4 matrix you just selected. Type:

calc u^2;

calc det(u);

calc det(u^2);

And so on... You may also create matrices from the command line or from scripts.

readexact;

make mymatrix zmatrix(2,3);

calc mymatrix;

Now, modify the matrix by changing a few entries to nonzero values. Just click on an entry to highlight it, and then type in a new number. Type a fraction as say 2/3. To change your mind, navigate with the arrow keys. It takes a little getting used to, but is very intuitive. Put only numeric entries in the matrix (fractions, whole numbers, or decimals). When you are finished, type.

make mynewmatrix getmatrix(false);

This assigns the name mynewmatrix to the modified matrix.

calc mynewmatrix;

Now create a row matrix.

make myrow zmatrix(1,2);

make myrow(1,1) 2;

make myrow(1,2) 3;

calc myrow;

You may read more about formatted output in the section on Mathedit windows.

output "/v * /v", myrow, mynewmatrix;

calc myrow* mynewmatrix;

Just a little sprite animation:

First, create two sprites for the "Canvas" Graph2D.

The command is: sprite <spritename> <path to bitmap> <initial position>.

sprite "red" "red.bmp" [2,0];

sprite "blu" "blue.bmp" [-2,0];

Now, let's move them around. For that we create a curve, a circle of radius 2.

make c(t) 2*[cos(t), sin(t)];

curve c;

Set decimal mode.

readfloat;

do i=0 until i>6.3 {movesprite "red" to c(i); movesprite "blu" to c(pi-i) ; i := i+pi/20}

Loops like this ought to be run in scripts, but this may be short enough to demonstrate the idea. (You can execute this in a Script Window if it doesn't fit on one line of your Command Line. Otherwise, you may reduce the size of the font in the Command Line until it does fit.) On the command line, you will get a warning that the object i already exists. In scripts, you would not.

Step 11: Create a HotSpot to get to the next page

Our last topic for this page is to create a hotspot on the navigation bar at the right arrow to get to the next page. We could also create a popup hotspot on the question mark to give instructions, but will forego that. We want to arrange that when the mouse is brought over the right arrow on the navigation bar, the cursor becomes a "pointing finger" and when clicked, takes us to page 2.

For that, go to Design mode, and select Objects, HotSpot Gadget... Then draw a small rectangle (just as you would draw an object) around the right arrow, like so:

Then, return to Reader mode, and select: Page, Edit a Hotspot... You will see small blue rectangles appear around all the hotspots. Click within the one shown above, and voila! You have a Script Window for the hotspot. Type: goto page 2; Then Compile... and Attach and Exit. That's all there is to it!

Step 12: Student Report Page

Our next topic is Student Report Pages. We show how a Document may contain a Report Page that Authors may use to allow students to make reports on their projects. This strategy works best with the Disk Version of a Document if the student reads it online in the Browser, or with Mathwright32 Reader, used offline. The reason is that the reports need to be saved to disk, and so the reader needs a "Resource Directory" to save them to.

First, we observe that the contents of MathEdit objects are always saved as resources (.MEW files) on disk. When a MathEdit object "wakes up", it loads the disk resource (associated .MEW file if there is one) into itself, otherwise it is blank. But at any time, Readers may open a new .MEW file in any MathEdit. Thus, they may save such files and open them later, or pass them along to others. If a Reader changes the .MEW file associated to a WorkBook, then she has changed the WorkBook. For this reason, authors might like to make .MEW files that are not meant to be changed read-only.

To start, click the HotSpot to go to page 2. Remember that? Create now a MathEdit Window called MyReport on this new page. And while you are at it, create a Title: Report Page, and a HotSpot over the left arrow with the script, (You guessed it.) goto page 1;

The screen should resemble:

The MathEdit object: MyReport may be used by students to create reports. In order to see how that should happen, we make some observations about how MathEdit windows work.

Attaching text to a MathEdit object

The text in a MathEdit may come from two sources. It may be written by MathScript into the window, as the text that the command line placed in the Record window was, on the previous page. Or it may be typed into the window by the reader or author. In either case, such text is "volatile" in the sense that it is not automatically stored in the window. If you change pages, or if you switch from Reader to Author mode, for example, the text will be destroyed.

The only way to keep text in a MathEdit window is to associate a file with the window. This means that you must save the MathEdit window contents to a file on the disk. Do that in the following way. Get the MathEdit Window menu by right clicking on the window.

Then select File, Save As... After you do that, a Dialog Box will appear asking for the name of the file to associate with the MathEdit Window. Type the name without extension, this file will be saved with extension .mew.

If the MathEdit window already has a file associated with it, and you want that file to be available after the current file is saved, then you (or your reader) must not overwrite that file. They should choose a different name here. The effect of saving the contents of the MathEdit Window to a file will be to attach that file to the MathEdit Window. If you change pages, or switch modes from this point on, the text will reappear in the MathEdit.

If you add to, or delete from the contents of the window, you will be asked if you want to save the new file before leaving the page or switching modes. In order to make these changes permanent, you must still save the Document, of course. Now place the following text in the MyReport window:

Name: ______________________ Project: _____________________ and save this, as described above, as: myreport, then Save the Document.

Once this Document is saved, Page 2 will always look like this when it opens: that is, the MyReport window will be associated to the file just saved.

The screen should resemble the following when you are finished, after it is filled in and saved as a Report like: MyReport1.

When a student writes a Report, she does not save it as MyReport, but saves it under a different name so that when the Document is opened again, it is ready for a new report to be created. What can reports contain? They can contain:

We give an example now of a short report with some of those elements. The report will discuss the example, created above of transforming an ellipse cc by a planar transformation: tr. The work is done on page 1, and the report is written on page 2. On page 1, do the following sequence on page 1 on the Command Line.

c(t) := [5*cos(t), 3*sin(t)];
tr(x,y) := [ x^2 - y^2 + x , 2*x*y -y ];
cc(t) := c(t)/3;
curve cc;
curve tr#cc color blue;

Then, take a "snapshot" of the central part of the screen. Select: WorkBook, Snapshot... and when the cursor becomes a "pointing finger" draw a rectangle around the part of Canvas that you want to show. Place the cursor where you would like the upper-left corner of the rectangle to be. Press and hold the left mouse button down. Move the mouse to the lower-right corner of the rectangle, while holding the left mouse button down. Release the left mouse button when satisfied. The snapshot is now in the clipboard.

Go to page 2, (use the HotSpot) and paste it into MyReport, using Actions, Paste. Select File, Save As...to save this file to MyReport1. Moving back and forth, fill out this short report. Thus, type your name and project title: Transformation of curves, and write the following text in the MyReport window:

Let cc be the curve cc(t) = Stop here, and select File, Save As...to save this file again to MyReport1. MyReport1.mew will be the name of the student report file for this example. The screen should resemble: We want to write the definition of cc(t): [5*cos(t) , 3*sin(t)] / 3 as a displayed formula.

Thus, with the caret to the right of the equal sign, type a couple of spaces, then select from the menu: Actions, New Expression. A small box should appear with the caret in it. Then type:

vector( 5*cos(t) , 3*sin(t) ) / 3

Use the arrow keys to determine what is selected when, for example, you type the comma, when you close the vector, and in particular when you type the / for the division. These are places where the system cannot decide automatically what to do, and you have to help it along. The screen should resemble: (This may take some practice).

This concludes the exercise. Save the book.

Save the Document.

End of Project 4