Old Newsletter Archive


THE MATHWRIGHT LIBRARY NEWSLETTER, March 1999, VOL 1, #3

A publication of Bluejay Lispware
James E. White, Editor
The monthly publication of the Mathwright Library: http://www.mathwright.com


IN THIS ISSUE:
1] LISPing Numbers

1] LISPing Numbers

    One of the ways in which Mathwright WorkBooks distinguish themselves from ‘applets’ is best described with an example. There are many programs that can generate numeric problems for students, and then tell the students whether or not they answered those problems correctly. Programs of this sort may or may not have the capability of allowing the student to pose her own questions, or even of recognizing (for example) that the answer: 1/2 is equivalent to the answer 0.50, or that (x+y)^2 means the same thing as x^2 + 2*x*y + y^2, or that sin(t)^2+ cos(t)^2 is another way to write the number 1.

    To recognize that 1/2 is the same number as 0.50, a program must be prepared to do rational arithmetic, and not just decimal arithmetic. Sometimes, it is important to be able to do rational arithmetic, if only because students may well write their answer in a variety of equivalent ways, and the WorkBook should not mislead a student because it fails to recognize a correct answer. Such programming practice would only contribute to the common misconception that there is only one correct approach to a problem, and only one correct answer. Mathwright WorkBooks have a built-in rational number type, and so they can recognize equivalent ways of writing numbers. An example is the WorkBook Work Problems   that asks the simple question:

“If you have two workers working together, then the rate at which the task is completed in the sum of their two rates. For example, if Billy Bob's rate is 1/8 of a task per hour and Bobbie Sue's rate is 1/6 of a task per hour, then in one hour working together how much of the task have they completed?”

    If the student answers 7/24, the program responds: “That is right, 7/24 of the task is completed.” If the student answered on the other hand: 14/48, the program still reports that the answer is correct (It might have suggested reducing the fraction, but that is up to the author of the book.) If the student had answered: .2916666 the WorkBook would still report a correct answer. But if the student had written .2916 this WorkBook would say “Try again!”

    When the focus of the WorkBook is on fractions (rational numbers) then it is important that the book be flexible enough to make such distinctions. It is difficult (but not impossible) to build applets that have this flexibility, because the rational number type requires a fair amount of code to download. In these simple examples, it would be feasible, but we shall describe others in a moment where it would not be.

    Should a mathematics learning environment sacrifice this flexibility for convenience ? Obviously, the answer is no. Especially when the aim to to teach younger readers (who may not have clear ideas about the relations among fractions, decimals, and mixed numbers), it would be a mistake to do that. Another example is the WorkBook: Fraction Marathon  in the Young Players’ Section.

    That WorkBook might ask for the product of mixed fractions: 1 1/9 by 1 1/4 and if the student answered 25/18 it would report the answer correct. But 1 7/18 would also be recognized as correct, as would 1 14/36. It is easy to see how the student might arrive at any of these answers, and (unless the intention was also to teach reduction to lowest terms) all should be recognized as correct.

    Now, the ability to do rational arithmetic is not only useful for grade-school mathematics. The Command Line WorkBook has an example 8x8 matrix M:

|1 1 1  1   1    1      1      1        |

|1 2 4  8   16   32     64     128      |

|1 3 9  27  81   243   729     2187     |

|1 4 16 64  256  1024  4096   16384     |

|1 5 25 125 625  3125  15625  78125     |

|1 6 36 216 1296 7776  46656  279936     |

|1 7 49 343 2401 16807 117649 823543     |

|1 8 64 512 4096 32768 262144 2097152   |

If we create the inverse of M, and call it P, it looks like (but is printed more legibly):

|8       -28         56         -70      56       -28        8          -1     |

|-481/35 621/10     -2003/15   691/4   -141      2143/30  -103/5     363/140 |

|349/36  -18353/360 2391/20  -1457/9    4891/36 -561/8    3689/180 -469/180 |

|-329/90 15289/720 -268/5    10993/144 -1193/18 2803/80  -469/45   967/720 |

|115/144 -179/36    213/16    -179/9    2581/144 -39/4     427/144    -7/18  |

|-73/720 239/360    -149/80   209/72    -391/144  61/40   -343/720    23/360 |

|1/144   -17/360    11/80     -2/9      31/144   -1/8      29/720     -1/180 |

|-1/5040 1/720      -1/240    1/144     -1/144    1/240    -1/720     1/5040 |

Then if we ask for the value of the product: M*P the WorkBook prints:

|1 0 0 0 0 0 0 0 |

|0 1 0 0 0 0 0 0 |

|0 0 1 0 0 0 0 0 |

|0 0 0 1 0 0 0 0 |

|0 0 0 0 1 0 0 0 |

|0 0 0 0 0 1 0 0 |

|0 0 0 0 0 0 1 0 |

|0 0 0 0 0 0 0 1 |

If we did this as a decimal calculation, then instead of 0s we would find numbers like: -.00000000000002, .000000000000001, .000000000000009 and so on.

    Obviously, exact rational arithmetic is required to get the correct product, the identity matrix. When performing row operations to row-reduce a matrix as the WorkBook Row Reduction   does, it is important that the operations be exact rational, and not decimal if we are to obtain the correct answer.

    But of course, the real place where exact rational arithmetic becomes important is in algebra. Returning to the Command Line WorkBook  if we type at the command line:

Make a exact x+1/2;

Factor a*(a-1)*(a-2)*(a-3)+1;

The result is (in more legible form):

1/16*(4*x^2 -8*x-1) ^2

Without exact calculation, it would be very difficult to see that the result is a perfect square. In fact, in general, the WorkBook shows that

a*(a-1)*(a-2)*(a-3)+1 = (a^2 -3*a+1) ^2

    Exact rational arithmetic and exact symbolic algebra were first successfully prototyped in LISP environments. And languages such as MACSYMA, Reduce, MuMath (later, Derive), Maple, Mathematica, and Mathwright, either evolved from or are still implemented in LISP. Mathwright’s MathScript is based on LISP, and has full access to that language. The reason for this is that symbolic algebra requires very flexible data structures, structures that can grow and shrink as various transformations are applied to them. LISP was designed specifically to manipulate “list structures” which are arguably the simplest data structures on which exact algebraic operations may be performed efficiently.

    It is easy, therefore, for an author to “teach” a Mathwright WorkBook about algebraic transformations (called ‘rewriting rules’) that represent various functional identities. For example, the Expert System WorkBook contains a set of trigonometric identities that automatically transform expressions like:

cos(4*t)

to

(cos(t))^4-6*(cos(t))^2*(sin(t))^2+(sin(t))^4

by successively applying half-angle rules for sine and cosine. Similar identities for rationalizing denominators that contain radicals, or for giving step-by-step solutions for cubic equations (using Cardano’s method) can be found in that book. Authors of Mathwright WorkBooks may create and include a great variety of transformations of this sort to illuminate and illustrate various algebraic strategies in equation solving.

    We finish with two example books that have been added recently to the Library Collection, and that illustrate the power of symbolic algebra in a masterful way. Those books are: Linear Functions   and Quadratic Functions   by Profs. Samad Mortabit and Juan Estrada.

The WorkBook Linear Functions solves linear equations or inequalities in one variable, and solves linear systems (2 equations in 2 variables). It either creates the problem for the student, or it allows the student to create her own problem. In either case, it gives a detailed step-by-step explanation of how to solve the equation. An example follows, starting with the pair of equations:

x+6*y=12

6*x+7*y=2

    The WorkBook steps through the solution, one step at a time, explaining each step. It must be emphasized that these explanations are not built-in. A student could propose any such system she liked, and it would solve it in the same way, or report that there are infinitely many solutions, or report that the system is inconsistent! The strategy the authors used to do this was to call upon the built-in Expert System in the MathScript Language. When the system is solved, the graphs are drawn also, so that the reader can compare the algebraic solution with its graphical interpretation. Such a thing would be extremely difficult to do with an ‘applet’ for the reasons already mentioned. The red text represents what the WorkBook prints...

Step 0 . Solving the linear system:

equ 1: x+6*y=12

equ 2: 6*x+7*y=2

Step 1 . Solving equation 1 for x:

x=12-6*y

6*x+7*y=2

Step 2 . Substituting 12-6*y for x in equation 2:

x=12-6*y

72-29*y=2

Step 3 . Simplifying equation 2:

x=12-6*y

72-29*y=2

Step 4 . Solving for y in equation 2:

x=12-6*y

y=70/29

Step 5 . Substituting 70/29 for y in equation 1:

x= -72/29

y=70/29

Step 6 . The solution of the system is:

x= -72/29

y=  70/29

Another example (an under-determined system that I made up) follows:

x+6*y=12

2*x+12*y=24

Step 0 . Solving the linear system:

equ 1: x+6*y=12

equ 2: 2*x+12*y=24

Step 1 . Solving equation 1 for x:

x=12-6*y

2*x+12*y=24

Step 2 . Substituting 12-6*y for x in equation 2:

x=12-6*y

24=24

Step 3 . Simplifying equation 2:

x=12-6*y

24=24

Step 4 . Solving for y in equation 2:

Equation 2 is always true.

The solution of the system is:

All ( 12-6*y ,y) where y is any real number.

The Quadratic Functions WorkBook  has similar tools. One example should suffice to illustrate what it does:

Solving Inequality:

9*x^2 +2*x-3 < 0

Dividing both sides by 9 , we get:

x^2 +2/9*x+-1/3 < 0

Completing the square on the left hand side, we get:

(x+1/9) ^2 -(1/9)^2+-1/3 < 0

That is, (x+1/9) ^2 +-28/81 < 0

Adding 28/81 to both sides, we get:

(x+1/9) ^2 < 28/81

This means that:

-2/9*sqrt(7) < x+1/9 < 2/9*sqrt(7)

Subtracting 1/9 from all the sides, we get:

-2/9*sqrt(7)-1/9 < x < 2/9*sqrt(7)-1/9

Any real number between

-2/9*sqrt(7)-1/9 and 2/9*sqrt(7)-1/9

(not including -2/9*sqrt(7)-1/9 nor 2/9*sqrt(7)-1/9 )

is a solution !

After this, a graph of the quadratic function is drawn and the solution interval is shown. You may learn more about Mathwright by visiting our About Mathwright  page at the Library.

James E. White Editor

If you came here from the old building,

click on the picture below to check out our new location...