This chapter deals with the mathematics that the ZX Spectrum Next can handle. Quite possibly you will never have to use any of this at all, so if you find it too heavy going, don't be afraid of skipping it. It covers the operation ↑ (raising to a power), the functions EXP and LN, and the trigonometrical functions SIN, COS, TAN and their inverses ASN, ACS, and ATN.
You can raise one number to the power of another – that means: multiply the first number by itself the second number of times. This is normally shown by writing the second number just above and to the right of the first number like so 2³; but since this gets unnecessarily complex to write and display on a computer, we use the symbol ↑ instead. For example, the powers of 2 are:
| 2↑1=2 | |
| 2↑2=2*2=4 | (2 squared) |
| 2↑3=2*2*2=8 | (2 cubed) |
| 2↑4=2*2*2*2=16 | (2 to the fourth power) |
Thus at its most elementary level, a↑b means a multiplied by itself b times, but obviously this only makes sense if b is a positive whole number. To find a definition that works for other values of b, we consider the rule:
a↑(b+c) = a↑b*a↑c
(Notice that we give ↑ a higher priority than * and / so that when there are several operations in one expression, the ↑s are evaluated before the *s and /s.) You should not need much convincing that this works when b and c are both positive whole numbers; but if we decide that we want it to work even when they are not, then we find ourselves compelled to accept that:
| a↑0 | = | 1 |
| a↑(-b) | = | 1/a↑b |
| a↑(1/b) | = | the bₜₕ root of a, which is to say, the number that you have to multiply by itself b times to get a. |
and:
a↑(b*c) = (a↑b)↑c
If you have never seen any of this before then don't try to remember it straight away; just remember that:
a↑(-1) = 1/a
and:
a↑(1/2) = SQR a
and maybe when you are familiar with these the rest will begin to make sense.
Experiment with all this by trying this program:
10 INPUT a,b,c
20 PRINT a↑(b+c),a↑b*a↑c
30 GO TO 10
Of course, if the rule we gave earlier is true, then each time round the two numbers that the computer prints out will be equal. (Note – because of the way the computer works out ↑, the number on the left – a in this case – must never be negative.)
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.