--- title: "SQ Notes: Math Functions" type: "article" slug: "sq-notes-math-functions" url: "http://localhost/article/sq-notes-math-functions/" markdown_url: "http://localhost/article/sq-notes-math-functions.md" published_at: "2022-10-07T12:26:53+00:00" modified_at: "2026-08-02T02:06:05+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Some more ramblings about things not fully covered in the TIMEX MANUAL this month. Looks like the time between newsletters is shrinking, or else I am to busy with other things. A look at what the Sinclair Manual has to say about mathematical functions which are also only covered in the Timex Manual in Appendices.…" category: - name: "SMUG Bytes" slug: "smug-bytes" taxonomy: "category" url: "http://localhost/category/periodicals/smug-bytes/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Reference" slug: "reference" taxonomy: "post_tag" url: "http://localhost/tag/reference/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Rudy A. Hilsmann" slug: "r-a-hilsmann" taxonomy: "indiv" url: "http://localhost/indiv/r-a-hilsmann/" publication_r: id: 37935 title: "SMUG Bytes" type: "periodical" url: "http://localhost/periodical/smug-bytes/" authors: "R. A. Hilsmann" authors_r: - name: "Rudy A. Hilsmann" slug: "r-a-hilsmann" taxonomy: "indiv" url: "http://localhost/indiv/r-a-hilsmann/" volume: "5" issue: "10" issues_articles: - id: 39713 title: "SMUG Bytes v5 n10" type: "issue" url: "http://localhost/issue/smug-bytes-v5-n10/" pages: "3-6" pubdate: "October 1988" archive_link: false --- # SQ Notes: Math Functions Some more ramblings about things not fully covered in the TIMEX MANUAL this month. Looks like the time between newsletters is shrinking, or else I am to busy with other things. A look at what the Sinclair Manual has to say about mathematical functions which are also only covered in the Timex Manual in Appendices. Perhaps you feel that this is a waste of time, since most of you have paid attention in High School, and know all about those, but what about the ones of you who did not? Well do not be surprised if you learn something anyways. Chapter 10 of the Sinclair Manual deals with the mathematics that your computer can handle. It covers the operation ↑ (raising to the power), the functions EXP and LN, and the trigonometrical functions SIN, COS, TAN and their inverses ASN, ACS, and ATN. ### ↑ and EXP 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 normaly shown by writing the second number just above and to the right of the first number; but obviously this would be difficult to do on a computer so the ↑ symbol was selected instead. For example, the power of 2 are ``` 2 ↑ 1 = 2 2 ↑ 2 = 2*2 = 4 2 ↑ 3 = 2*2*2 = 8 2 ↑ 4 = 2*2*2*2 = 16 ``` At its most elementary level, “a↑b” means “‘a’ multiplied by itself ‘b’ times”, but this only makes sence if ‘b’ is a positive number. To find a definition that works for other values of ‘b’, consider the rule ``` a ↑ (b+c) = a↑b*a↑c ``` Notice that ↑ has 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 you decide that you want it to work even when they are not, then you find yourself compelled to accept that ``` a ↑ 0 = 1 a ↑ (-b) = 1/a↑b a ↑ (1/b) = the bth root of 'a', which is 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 now; just try to remember that ``` a ↑ (-1) = 1/a ``` and ``` a ↑ (1/2) = SQR a ``` 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 I gave earlier is true, then each time around, 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.) An example of what this function can be used for is that of compound interest. Suppose you keep some of your money in a savings account which pays 15% interest per year (what a deal). Then after one year you will have not just the 100% that you had anyway, but also the 15% interest your money has earned, making altogether 115% of what you had originally. To put it another way, you have multiplied your sum of money by 1.15. After another year, and if the sum of money you have put in the account originally has not changed, the same will have happened again, so that you will then have 1.15*1.15=1.15↑2=1.3225 times your original sum of money. In general, after ‘y’ years, you will have 1.15↑y times what you started out with. If you try this line ``` FOR y=0 TO 100: PRINT y,10*1.15↑y: NEXT y ``` you will see that even starting out with just $10, it all adds up quite fast, and what’s more, it increases faster and faster as time goes on. (Although, you might still find that it doesn’t keep up with inflation.) This type of behaviour, where after a fixed interval of time some quantity multiplies itself by a fixed proportion, is called exponential growth, and it is calculated by raising a fixed number to the power of the time. Suppose you did this: ``` 10 DEF FN a(x)=a↑x ``` Here, ‘a’ is more or less fixed by LET statements: its value will correspond to the interest rate, which changes only ever so often. There is a certain value for ‘a’ that makes the function FN ‘a’ look especially pretty to the trained eye of a mathematician: and this value is called ‘e’. Your computer has a function called EXP defined by ``` EXP x = e↑x ``` Unfortunately, ‘e’ itself is not an especially pretty number: it is an infinite non-recurring decimal. You can see its first few decimal places by doing ``` PRINT EXP 1 ``` because EXP 1 = e↑1 = e. Of course, this is just an approximation. You can never write down ‘e’ exactly. ### LN The inverse of an exponential function is a logarithmic function: the logarithm (to base ‘a’) of a number ‘x’ is the power to which you have to raise ‘a’ to get the number ‘x’, and it is written log a\x, normally shown by writing ‘a’ just below and to the left of ‘x’. Thus by definition ‘a↑log a\x=x’; and it is also true that ‘log (a↑x)=x’. You may already know how to use base 10 logarithms for doing multiplications; these are called common logarithms. Your computer has the function LN which calculates logarithms to the base ‘e’; these are called natural logarithms. To calculate logarithms to any other base, you must divide the natural logarithm by the natural logarithm of the base: ``` log a\x = LN x / LN a ``` ### PI Given any circle, you can find its perimeter (distance around its edge; called circumference) by multiplying its diameter (width) by a number called PI (Pi is a Greek p, and is used because it stands for the word perimeter). Like ‘e’, PI is an infinite non-recurring decimal; it starts off as 3.141592653589…The function PI on your computer returns this number. Try PRINT PI. ### SIN, COS & TAN; ASN, ACS & ATN The trigonometrical functions measure what happens when a point moves round a circle. Here is a circle of radius 1 (1 what? It does not matter, as long as you keep the same unit all the time. You could also pick any other number!) and a point moving around it. The point started at the 3 o’clock position, and then moves in a counter clockwise direction. I have also drawn in two lines called axes through the center of the circle. The one from 9 o’clock to 3 o’clock is called the x-axis, and the one from 6 o’clock to 12 o’clock is called the y-axis. To specify where the point is, or how far it has moved around the circle from its 3 o’clock position, let’s call this distance ‘a’. It is known that the circumference of the circle is 2*PI (because its radius is 1 and its diameter is thus 2): so when it has moved a quarter way around the circle, a=PI/2; when it has moved half way around, a=PI; and when it has moved all the way, a=2PI. Given the curved distance around the circle ‘a’, two other distances you may like to know are how far the point is to the right of the y-axis, and how far it is above the x-axis. These are called, respectively, the cosine and sine of ‘a’. The function COS and SIN on your computer will calculate these. Note that if the point goes to the left of the y-axis, the cosine becomes negative; and if the point goes below the x-axis, the sine also will become negative. Another property is that once ‘a’ has reached 2PI, the point is back where it started from and the sine and cosine starts with the same values all over again: ``` SIN (a+2*PI) = SIN a COS (a+2*PI) = COS a ``` The tangent of ‘a’ is defined to be the sine divided by the cosine; the corresponding function is called TAN. Sometimes we have to work these functions out in reverse, finding the value of ‘a’ that gives the sine, cosine or tangent. The functions to do this are called arcsine (ASN), arccosine (ACS) and arctangent (ATN). In the diagram of the point moving around the circle, look at the radius joining the center to the point. You should be able to see that the distance called ‘a’, the distance that the point has moved around the circle, is a way of measuring the angle through which the radius has moved away from the x-axis. When a=PI/2, the angle is 90 degrees; when a=PI the angle is 180 degrees; and around to when a=2PI (a=2*PI), and the angle is 360 degrees (a full circle). You might as well forget about degrees; and measure the angle in terms of ‘a’ alone: say then that you are measuring the angle in radians. Thus PI/2 radians = 90 degrees and so on. Remember that on your computer SIN, COS etc. use radians and not degrees. To convert degrees to radians, divide by 180 and multiply by PI; to convert back from radians to degrees, divide by PI and multiply by 180.