Maths Master Colin Carruthers and a Spectrum teach you a thing or two about quadratic equations. Are you bored solving systems of equations with five unknowns? Want a hand to invert a couple of matrices? Shouldn't you check that difficult integration problem you've just spent four hours doing? Well, the computer's ability to plough through tedious calculations at high speed is used in this program to provide a useful maths package. The program will run on both the 16K and 48K Spectrums, but since it is written entirely in Basic it should be quite a simple task to implement the package on other micros. As far as possible, each part of the program has been made self-contained enabling the individual to just type in the routines he or she requires. However, the Matrix Operations section demands that the System of Equations routines be present - this is due to the fact that matrix inversion and solving systems of equations can be done by similar techniques and therefore have common program blocks. In any case, the program must have the menu, input a number and hit any key routines - see figure 1. Figure 1 Program breakdown 500- 580: Input a number routine. Extensive use is made of this routine, so it is placed near the beginning to speed execution. 1000-1180: Menu. 2000-2970 System of Equations. 3000-3500: Quadratic Equation. 4000-4500: Equation of third degree. 6000-6650: Matrix Determinant and Inverse. 7000-7500: Simpson's Rule. 9000-9030: Hit any Key to Return. There now follows a brief description of each part of the program and examples of the kind of mathematical problem they solve. These examples can be used to check that the routines have been typed in correctly. System of Equations: Solved using Gaussian Elimination, each problem can have a maximum of five equations and five unknowns. The coefficients are held within a two-dimen- sional array - called "a". The user is prompted for each coefficient of x in turn, with the whole array of values shown on the screen at all times to enable checking. Ex (n=3) x1 + 3x2 - 4x3 = -11 2x1 - x2 + 3x3 = 10 4x1 + x2 - 2x3 = 3 This has the solution x1 = 2, x2 = -3 and x3 = 1. Quadratic equation: The roots are found using the classic formula: -bą b˛ - 4ac x = 2a This routine allows for both real and imaginary roots. Ex 1 x˛ - 3x + 2 = 0 gives x = or 2 Ex 2 x˛ 6x + 10 = 0 gives x = 3+/- i Ex 3 x˛ - 6x + 9 = 0 gives x = 3 (double root? [Sic, sic, sic and sic! Allow me, as a former employee of a publisher, to bewail the horrendous state of scientific and mathematical knowledge among type-setters and, more impor- tantly, correctors. They'd never have allowed themselves to get away with such nonsense if the subject had been, say, the arts, or gardening, or even celebrity gossip. But maths? That's just for nerds, and they don't care. Bah and double bah.] Roots of a polynominal Equation of third degree: This routine gives the roots of a polynominal with a term in xł. Again, imaginary roots are catered for, giving four types of possible solution. Ex1 xł - 6x˛ + 11x - 6 = 0 gives x = 1,2,3 Ex2 xł - 3x˛ -[sic! another error!] 3x - 1 = 0 gives x = 1,1,1 Ex3 -xł - 9x˛ + 81x + 729 = 0 gives x = 9,-9,-9 Ex4 xł - 5x˛ + 7x + 13 = 0 gives x = -1, 3 +/- 2i Matrix Operations: The determinant of the given square matrix is calculated and displayed. Assuming that this is non-zero, the inverse is computed using Gaussian Elimina- tion. A matrix with zero determinant has no inverse. The main "invert" routine is the same as that for the System of Equations. Ex (n=3) 3 1 2 2 1 0 2 1 1 has determinant 1 and inverse 1 1 -2 -2 -1 4 0 -1 1 Note that only real matrix elements are allowed. Simpson's Rule: The function entered must be a valid expression in 'x', for example 'y = 3x + 2' must be entered as: y = 3*x+2 Also, functions such as Sin, Tan or Ln must be entered as single-stroke key words. Any invalid expression typed in response to the prompt will result in an error at line 7100, statement 3. If this should happen, simply type: GO TO 7000 and re-type the expression correctly. Ex y = 3*x + 2 lower x = 0 upper x = 4 samples = 10 Value of the integral As can be seen by looking at figure 2, the value of the integral - or shaded part of the graph - should be 32. ^ / | |/ y=3x+2 14+ + | /| | /#| | /##| | /###| 2|/####| -----+-----+---- /|#####| ---------+-0-----+-------> / | |4 / | | / | | Figure 2. Area of triangle + rectangle. = ˝ x 4 x 10 + 2 x 4 = 20 + 12 = 32