1. Introduction
2. Another Mocha Quine
3. A Rapoport Math Problem
4. Calculating the Cosmos Chapter 4: The Clockwork Cosmos
5. Shapelore Learning 13-7: Outside Nooks
6. Shapelore Learning 13-8: Outside Nooks of Manynooks
7. Lemay Chapter 7 Part 2: More About Methods
8. More About Quadrilaterals in Java
9. Music: "What's the Best Advantage?" "Earth, Moon, and Sun," "Constant Multiply"
10. Conclusion
Introduction
Today is June 18th. As it turns out, this is the first time that I've ever posted on June 18th. And so there is no reblog today.
And that's good -- because I'm not supposed to be reblogging in summer posts anyway. Reblogging was a habit I started in the spring when the schools closed and there was nothing else to write. But I usually don't reblog in the summer.
So let's forget all about reblogging today. I want today's post to contain as much new content as possible as we proceed with our summer projects.
Another Mocha Quine
I was still thinking about the quine that I wrote for Mocha BASIC in my last post:
10 LIST
To see that this is indeed a quine, enter this line into Mocha -- here's the link:
https://www.haplessgenius.com/mocha/
After you finish entering the program, list the program by entering in LIST. Then run the program by entering in RUN. The same thing appears on the screen in both cases -- therefore it's a quine:
10 LIST
OK
But some people might consider this to be cheating. A non-trivial quine shouldn't just use LIST, but actually use PRINT instead.
I did make one more attempt to make a "quine" on BASIC, if we can really call this a quine. In the immediate mode, if we make an error (such as RUB instead of RUN), we get an error message:
?SN ERROR
My hope was that typing in ?SN ERROR would produce this error, thus making it a quine. But believe it or not, the command ?SN ERROR is not an error! The symbol ? in BASIC is used as an abbreviation for PRINT, so ?SN means print the value of the variable SN. Since SN hasn't been initialized, it has the default value of 0.
The word ERROR also has an meaning in BASIC -- it's sort of an "exception" or error code. I'm surprised that typing in ERROR in this situation doesn't cause an error -- but even if it did, the fact that a zero already printed would still prevent this from being a quine.
I actually found a link to two quines in BASIC. One of them is 10 LIST, but the other is non-trivial:
https://rosettacode.org/wiki/Quine
The quine listed here is in Visual Basic (or another version), since it lacks line numbers. It also uses a DO...LOOP that doesn't exist in Mocha Basic. We'll fix both of these problems by inserting line numbers and changing it to a FOR...NEXT loop:
100 READ D$
110 FOR L=100 TO 200 STEP 10
120 READ X$
130 PRINT RIGHT$(STR$(L),3);X$
140 NEXT L
150 RESTORE
160 FOR L=210 TO 320 STEP 10
170 READ X$
180 PRINT RIGHT$(STR$(L),3);D$;CHR$(34);X$;CHR$(34)
190 NEXT L
200 END
210 DATA " DATA "
220 DATA " READ D$"
230 DATA " FOR L=100 TO 200 STEP 10"
230 DATA " READ X$"
250 DATA " PRINT RIGHT$(STR$(L),3);X$"
260 DATA " NEXT L"
270 DATA " RESTORE"
280 DATA " FOR L=210 TO 320 STEP 10"
290 DATA " READ X$"
300 DATA " PRINT RIGHT$(STR$(L),3);D$;CHR$(34);X$;CHR$(34)"
310 DATA " NEXT L"
320 DATA " END"
All quines of this type need a way to produce the quote symbol " that delimits strings. Both the BASIC and Java quines use the ASCII code for a quote, which is 34. In BASIC, CHR$(34) is used to produce the quote.
There's another problem with printing the line numbers. Mocha usually prints a blank space in front of all positive numbers. (A minus sign appears in this space for negative numbers.) But it wouldn't be a true quine if we had all those extra spaces there, since spacing counts.
So instead of printing the line number L, we print RIGHT$(STR$(L),3). First, STR$ converts the number into a string, and then RIGHT$ prints the rightmost three digits. This is why my quine starts with Line 100 instead of Line 10 -- I needed all the line numbers to contain exactly three digits.
This quine contains two complete loops. The first loop prints all the strings in the DATA lines for Lines 100-200, and the second loop prints DATA in front of those lines for Lines 210-320. We actually need a blank space to print after all the line numbers, so we accomplish this by placing a space after the opening quote in each DATA line. Each line needs a space after the word DATA, and so we accomplish this by placing a space before the last quote in Line 210. The original version of this quine from the link ends with the empty string "", which is used as a sentinel to determine when all the DO...LOOPs end. Since we're using FOR loops instead, a sentinel isn't needed.
There are a few ways we could have shortened this. The line END isn't really needed. Also, we could have started at Line 10 and then counted by 1's instead of 10's -- then all line numbers would have two digits and STEP 10 isn't needed for FOR. But it doesn't truly look like BASIC unless we follow the tradition of counting by 10's.
By the way, under "PureBasic" above, there is another quine that works in immediate mode:
s$="s$= : Debug Mid(s$,1,3)+Chr(34)+s$+Chr(34)+Mid(s$,4,100)" : Debug Mid(s$,1,3)+Chr(34)+s$+Chr(34)+Mid(s$,4,100)
This almost works in Mocha, except I don't know what Debug is for -- if we simply change it to PRINT, then it works. Oh, and we must add $ after the words MID$ and CHR$.
And there's one thing we must do first -- type in CLEAR 1000. Mocha doesn't automatically allow us to use long strings like this one unless we clear some string space first. Since CLEAR 1000 isn't actually part of this line, it doesn't really spoil the quine. (And if you think that it does, then just clear the screen with CLS so that you don't see that line on the screen.)
This could be converted to a one-line program as well, though to be fair we really would need the line CLEAR 1000 to be part of this program. Just count the correct number of characters for MID$ so that the entire line prints.
A Rapoport Math Problem
There is no Geometry on the Rapoport calendar this week. So I'll only do the problem for today, which is very tricky.
Of course, you might ask should I be doing any Rapoport problems at all today -- we're now fully in summer vacation mode, and I ordinarily don't post non-Geometry calendar problems in summer. Well I decided to post today's problem anyway, since I find it so interesting.
Today on her Daily Epsilon of Math 2020, Rebecca Rapoport writes:
(31809 nCr 30784) mod 31
This is our second straight problem with "nCr" as ASCII for "choose" (binomial coefficient). Last time, we had 8 nCr 4 = 70, but today's coefficient is a whole lot more than 70. In fact, it's much too big to fit on our calculator.
We do see that this is a "mod" problem. And we already know that there are many tricks involving modular arithmetic that help make problems smaller:
(a + b) mod m = a mod m + b mod m
(a - b) mod m = a mod m - b mod m
(ab) mod m = (a mod m)(b mod m)
But we can't just naively assume that for any operation, we can simply mod both of the operands and then perform the operation. We can for addition, subtraction, and multiplication because the integers mod m form a ring, and these three operations can be performed in any ring.
For exponentiation, we can simply reduce the base mod m, but not the exponent. Instead, by Fermat's Little Theorem, we reduce the exponent mod phi(m) (Euler's totient function). And this generalizes -- so if we wish to find a^b^c mod m, we reduce a mod m, b mod phi(m), and c mod phi(phi(m)).
OK, so how do we reduce a binomial coefficient mod m? I could try looking it up, but I really want to try this problem myself before just Googling the answer. So I decided to try a simpler problem -- what if we start writing out Pascal's triangle, but reducing mod 2 (instead of 31) along the way?
When I try this, several patterns immediately jump out at me. For the nth row where n is a power of 2, the zeroth and last terms are 1 (as is the case for every row), but all of the terms in between this pair are 0. It follows that the rows above the powers of 2 must be all 1's (so that 1 + 1 = 0 can produce all the 0's in the power of 2 row), while the rows below the powers of 2 must start with 1 1 and end with 1 1, with 0's in between.
So unlike other mod operations, it's not merely multiples of 2, but powers of 2 that matter. Indeed, it appears that it might even be related to number bases, specifically binary. We know that powers of 2 consist of 1 followed by a lot of 0's -- and that's exactly what we see in the n = power of 2 rows. And numbers less than a power are all 1's in binary, and their rows consist of all 1's.
I also wanted to look at the "columns" of the triangle -- that is, we keep r constant and vary n. I notice that in column r, there are always exactly r consecutive 0's. Column 0 contains all 1's, so it obviously doesn't contain any 0's at all. Column 1 alternates between 1's and 0's, Column 2 has two 1's followed by two 0's, and Column 3 has a single 1 followed by three 0's. It's tricky for me to determine how many 1's there are between the r 0's. But in the case where r is a power of 2, there are exactly r 1's followed by r 0's.
I decided to try mod 3 next. Some of the same patterns from the mod 2 triangle emerge. For the nth row, the powers of 3 follow the same pattern as powers of 2 in the mod 2 triangle -- between the initial and final 1 are all 0's. This means that the rows above the powers of 3 must alternate between 1's and 2's (since 1 + 2 = 2 + 1 = 0).
I also notice that some rows contain 2's while others don't. When I write the row number n in ternary, I see that the row contains a 2 only when n itself contains a 2. Thus Row 2 and Rows 5-8 (12, 20, 21, 22 in ternary) contain 2's, while Rows 3, 4, 9, and 10 (10, 11, 100, 101 in ternary) don't.
Strangely enough, the columns follow a different pattern. Columns 2, 6, 8 (2, 20, 22 in ternary) are the columns that don't contain a 2. Meanwhile, the 0's follow the same pattern as in the mod 2 triangle, with Column r containing r consecutive 0's.
You might notice that these patterns can't possibly hold up for the mod 4. For example, Row 4 of the triangle is 1 4 6 4 1, or 1 0 2 0 1 mod 4. There's a 2 in that row, so it can't be all 0's between the 1.
It should be evident that it has something to do with prime numbers -- after all, all the numbers between the 1's in Row 5 are multiples of 5, and all values in Row 7 except 1 are multiples of 7. We can see why this is the case when we write out the coefficients using n!/(r!(n - r)!):
7 nCr 3 = (7 * 6 * 5)/(3 * 2 * 1)
There's a 7 in the numerator and smaller numbers in the denominator. Since 7 is prime, those smaller numbers can't cancel out the 7, so the answer to 7 nCr 3 is a multiple of 7. On the other hand:
6 nCr 3 = (6 * 5 * 4)/(3 * 2 * 1)
Since 3 * 2 = 6, the 3 and 2 on the bottom cancel the 6 on top, leaving 5 * 4, which isn't a multiple of 6 at all. This is why the 6 row doesn't need to contain multiples of 6, while the 7 row does contain all multiples of 7 (between the 1's).
Today's Rapoport problem is about mod 31, which is prime. Therefore we expect mod 31 to act more like mod 2 and 3 than mod 4 or 6. And just as we used binary and ternary to analyze the mod 2 and 3 cases, we can use base 31 to analyze the mod 31 case.
{v} (default base 31)
(Why do we use the letter {v} to denote this base? It's because {a} is decimal, {b} is undecimal, {c} is dozenal, and so on up to {v} for this base.)
(1233 nCr 1111) mod 10
Let's now write this out using n!/(r!(n - r)!):
1233 * 1232 * 1231 * 1230 * ... * 1114 * 1113 * 1112
122 * 121 * 120 * ... * 4 * 3 * 2 * 1
Division mod m is like addition, subtraction, and multiplication -- we can just do the mod first before performing the division. But there's one exception -- we can't divide by 0. Therefore we can't divide by any multiple of the base.
Well, let's ignore the 0's for now. We see in the division above that paying attention to the last digits only, they all cancel except an extra 3 in the denominator and an extra 1 in the denominator. Thus so far, ignoring all the 0's, we have 3/1 or just 3
So what do we do about the 0's? Well, these are multiples of the base -- and there are just as many multiples in the numerator as in the denominator. So we can just cross out the final 0's and look at the remaining digits in these multiples:
1230 * 1220 * 1210 * 1200 * ... * 1140 * 1130 * 1120
120 * 110 * 100 * ... * 40 * 30 * 20 * 10
= 123 * 122 * 121 * 120 * ... * 114 * 113 * 112
12 * 11 * 10 * ... * 4 * 3 * 2 * 1
And we notice that once again, we have an extra 3 on top and an extra 1 on the bottom. Thus after the second step, we have 3/1 or just 3. So far, we get 3 * 3 -- 3 from the first step and 3 from the second.
But there are still 0's to deal with. These came from multiples of 100 in the original problem, so even after we divided by 10 they still ended in 0. Fortunately, there's just one multiple left on the top and the bottom -- 120/10 = 12/1 = 12. This reduces to 2 mod the base.
Therefore our final answer is 3 * 3 * 2. This works out to be, um, ...
{a} (default decimal)
...18 -- and of course, today's date is the eighteenth.
After I solve the problem, I finally do the research and find out how to find n choose r mod p:
https://stackoverflow.com/questions/10118137/fast-n-choose-k-mod-p-for-large-n
Notice that this describes how to solve this problem using C++. These methods should work (with a few tweaks) in Java. They use variables of type long long, which I suspect is the same as simply long in Java.
But if we scroll down, we can see the trick for finding the answer without C++ or Java. We do see that the trick does use base p -- recall that our original problem in base 31 was:
(1233 nCr 1111) mod 10
So we break it up and do one digit at a time, and then multiply:
(1 nCr 1)(2 nCr 1)(3 nCr 1)(3 nCr 1)
= (1)(2)(3)(3) (since n nCr 1 = n for any n)
= 18
This trick now explains the patterns we see in the binary triangle. For example, for 1 less than a power of 2, we get then n is all 1's in binary. So breaking up the digits means that we're multiplying a bunch of (1 nCr 0) and (1 nCr 1) together, and since (1 nCr 0) = (1 nCr 1) = 1, we're multiplying all 1's, so the product is 1.
We know that (0 nCr 0) = 1 (the 1 at the top of the triangle). But for this trick to work, we must define (0 nCr 1) -- and indeed, what exactly is (n nCr r) in the cases where n < r? It's logical to assume that (0 nCr 1) = 0, and (n nCr r) = 0 for n < r. After all, if we have n objects, we can't choose r of them if r is greater than n, and so n choose r must be 0. (The TI does give 0 for n nCr r if n < r.)
Then this explains the power of 2 rows as well. Since a power of 2 is 10...0 in binary, we'll eventually have to multiply by (0 nCr 1) = 0, and anything times 0 is 0. The only way not to get 0 is if r has 0's everywhere that n does, since (0 nCr 0) = 1. And since n = 10...0, r must be either 00...0 or 10...0, which corresponds to the 1's on either end of the row.
The rule for (n nCr r) for n < r explains why there are r 0's in a row in Column n -- if n < r, then n in its binary form must have a 0 in some place where r has a 1, so again we multiply by (0 nCr 1) = 0.
And this explains why only certain rows and columns in the ternary triangle contain 2's. The only way to get 2 with one-digit numbers for n and r is (2 nCr 1). Thus unless n contains a 2 in its ternary form and r contains a 1 in its ternary form, we'd be multiplying only 0's and 1's together -- and it's impossible to get 2 by multiplying only 0's and 1's. This explains why Rows 2, 6, 8 (2, 20, 22) contain 2's, while Columns 2, 6, 8 don't -- for Column r, we're looking for 1's in the ternary, not 2's.
This is a very thought-provoking Rapoport problem. I learned a lot about the hidden patterns that lurk in Pascal's triangle.
Calculating the Cosmos Chapter 4: The Clockwork Cosmos
Chapter 4 of Ian Stewart's Calculating the Cosmos is called "The Clockwork Cosmos." As usual, it begins with a quote:
But should the Lord Architect have left that space empty? Not at all.
-- Johann Titius, in Charles Bonnet's Contemplation de la Nature
And the proper chapter begins:
"Newton's Principia established the value of mathematics as a way to understand the cosmos. It led to the compelling notion of a clockwork universe, in which the Sun and planets were created in their present configuration."
This chapter is all about whether the planets move together "like clockwork" -- that is, whether there's a pattern between the year lengths of the planets, or their distances from the sun. For example, the 18th century French mathematician Pierre Laplace noticed that five Jovian years are approximately equal to two Saturnine years:
"Measuring their positions in orbit as angles, the difference 2 * angle for Jupiter - 5 * angle for Saturn is close to zero -- but, as Laplace explained, it's not exactly zero."
But astronomers searched for patterns anyway.
"The orbital distances of the six classical planets, in astronomical units, are:
Mercury 0.39
Venus 0.72
Earth 1.00
Mars 1.52
Jupiter 5.20
Saturn 9.54
"The numbers are a bit irregular, and at first it's hard to find a pattern, even if it occurs to you to look."
But Johann Titius, the 18th century German astronomer quoted at the start of this chapter, was able to find a pattern. He took the sequence 0, 3, 6, 12, 24, 48, 96, ... (0 followed by a geometric sequence), and added 4 to each to obtain 4, 7, 10, 16, 28, 52, 100. Then this gives the relative distance of the planets from the sun -- Mercury is 4 units from the sun, Venus 7, Earth 10, and so on. If we divide these by ten, these become AU, so Mercury is 0.4 AU from the sun, Venus 0.7 AU, and Earth by definition is 1 AU from the sun. The opening quote is that there was a "missing" planet that should have been 2.8 AU from the sun, since Mars was 1.6 AU and Jupiter was 5.2 AU.
"However, no one took it seriously until Uranus was discovered in 1781, and it also fitted the pattern."
Later astronomers were able to fill in the gap between Mars and Jupiter with the discovery of Ceres, which we now consider to be a dwarf planet (like Pluto) in the asteroid belt. Stewart tells us that Ceres will be the topic of his next chapter.
According to what we now call the Titius-Bode Law (Johann Bode, another German astronomer), Uranus is 19.6 AU from the sun and the next planet, Neptune, should be 38.8 AU from the sun. But Neptune is much closer than predicted -- in fact, it's Pluto that's near 38.8 AU, not Neptune.
Therefore Titius-Bode is no longer considered a valid law, since we have to include two dwarf planets (Ceres and Pluto) and exclude Neptune to make it work. Still, I once saw a middle school science project that takes advantage of the Titius-Bode law, that each planet is approximately twice as far away as the previous planet. This wasn't from the Illinois State text, but from a science class that I subbed for a few months ago.
Students begin with a long strip of paper, with one end marked "sun" and the other "Pluto." This strip is folded in half, and the midpoint is marked "Uranus" (since Uranus and Pluto follow Titius-Bode, skipping over Neptune). Then students fold again so that Saturn is halfway between sun and Uranus, and then fold yet again so that Jupiter is halfway between sun and Saturn, and so on. For that rogue planet Neptune, it was placed halfway between Uranus and Pluto.
Returning to the book, the author wonders why Titius-Bode works for some of the planets:
"Is the law a coincidence, a sign of an underlying pattern, or a bit of both? The first step is to reformulate the Titius-Bode law in a more general and slightly modified way."
Basically, we start the geometric sequence with 1.5 instead of 0, and ignore the + 0.4. This gives us an exponential model, d = 0.075 * 2^n, where n is the nth planet (including Ceres/Pluto). If we graph this using logarithms, it becomes a straight line. But the pattern breaks down if we were to graph masses instead of distances from the sun:
"No sign of a straight line -- or of any other clear pattern. The orbital periods? A nice straight line again: see the left-hand picture."
Yes, Stewart includes several graphs here. The first: log/log plot of planetary distances lies close to a straight line. The second: log/log plot of planetary masses doesn't look like a straight line. The third: log/log plot of planetary periods lies close to a straight line. The fourth: log/log plot of distances of moons of Uranus lies close to a straight line.
We read that there are some possible reasons for Titius-Bode and the linear graphs. It has something to do with gravity, starting with the fact that the orbits of planets are approximately ellipses:
"At the next level of approximation, the ellipse precesses: its major axis slowly rotates. Approximating even more accurately, the dominant terms in formulas for the motions of celestial bodies comes from secular resonances -- more general types of resonant relation among the periods with which the orbits of several bodies precess."
The gas giants with their many moons satisfy a Bode-like law. We can also check out exoplanets, some of which follow a Bode-like law, but there are many which break the law:
"On the other hand, the known exoplanets are an imperfect sample of those that actually exist; often only one planet is known for a given star, even though it probably has others."
And sometimes it's easier to see a new object in the sky than to determine what it is:
"Exactly this problem confronted William Herschel in 1781, when he pointed the telescope in the garden of his house in Bath towards the constellation Taurus and noticed a faint spot of light near the star zeta Tauri, which at first he thought was either 'a Nebulous Star or perhaps a Comet.'"
We now know that what Herschel had discovered was a new planet -- Uranus:
"Indeed, it's just visible with good eyesight, and it was plausibly one of the 'stars' in Hipparchus's catalogue of 128 BC, and, later in Ptolemy's Almagest."
It's also possible to discover new planets by what affect they have on the known planets -- this is known as perturbation. For example, air resistance perturbs the oscillations of a pendulum:
"Instead, they die down and eventually the pendulum stops. Perturbations lead to more complex equations, which are usually harder to solve."
It was perturbations in the orbit of Uranus that led 19th century British astronomer James Challis to suspect that there is another planet beyond it:
"Later, Challis found that he'd observed the new planet twice, but didn't have an up-to-date star map and had generally been a bit sloppy, so he'd missed it."
That new planet was named Neptune. But there were still more perturbations in the orbits of Uranus and Neptune, which led 20th century American astronomer Clyde Tombaugh to continue searching for new planets:
"Early in 1930, he was examining an area in Gemini and something blinked. It was within 6 degrees of a location suggested by Percival Lowell, whose prediction appeared to be upheld."
And this new planet was named Pluto. But Pluto turned out to be a mere dwarf planet, and further calculations showed that the perturbations in the Uranus and Neptune orbits were due to errors in calculation, not another large planet.
Still, more distant objects in the solar system continued to be discovered -- after Pluto and its moon Charon, the next was one object known as (15760) 1992 QB1:
"It was so obscure that this is still its name (a proposal to call it 'Smiley' was rejected because that name had already been used for an asteroid), but it proved to be the first of a gaggle of trans-Neptunian objects (TNO's), of which more than 1500 are known."
Actually, a Google search reveals that it finally received a name two years ago -- Albion. We learn that these new objects like Uranus and Neptune were originally discovered by scientific tricks:
"Tried on Pluto, it seemed to work brilliantly as well, until astronomers realized that Pluto is too small to create the anomalies used to predict it. The trick failed dismally for a planet named Vulcan."
And no, the author doesn't mean the home planet of Spock and his most logical species. Instead, the 19th century French astronomer Urbain Le Verrier thought that Mercury's orbit was too perturbed:
"Le Verrier suggested that some undiscovered planet, orbiting closer to the Sun than Mercury, was responsible, and he named it Vulcan, after the Roman god of fire."
As it turned out, it's Einstein's theory of relativity that explains the perturbations, not another planet close to the sun. But still, some astronomers today believe that asteroids near the sun exist. Stewart concludes the chapter as follows:
"Their orbits couldn't be determined, and the claims haven't been confirmed. But the search for vulcanoids, as they're named, continues."
Shapelore Learning 13-7: Outside Nooks
Lesson 13-7 of the U of Chicago text is called "Exterior Angles." The word "exterior" has a very obvious equivalent in Anglish -- outside. In fact, I didn't even waste time looking it up on the Anglish website -- the word "exterior" simply means outside, period.
Since I'm titling the lessons on the blog in Anglish, "angles" must become nooks. But in Plain English, we'll keep the word "angles," so it's outside angles.
And so let's begin our translation of the mathematical words of Lesson 13-7:
Above is pictured a threeside. At each corner (The word "corner" is French. But let's grandfather it in and use it instead of "vertex," which is Latin.), one of its sides has been lengthened. The angles formed in this way are the outside angles of the threeside. In this lesson and the next one, various techniques (That's obviously French, but it's a non-mathematical word.) are applied to determine laws of outside angles of threesides and other manysides ("polygons").
And here's the definition of outside angle:
An angle is an outside angle of a manyside if and only if it forms a linear pair with one of the angles of the manyside. (As for "linear pair," the French word "pair" is simple enough the grandfather in. I've already said that we're keeping the French word "line," but what about "linear"? Many students stumble with "linear" even if they understand what a "line" is. Perhaps we can combine line with a Anglish suffix, such as line-ish, or even the Orwellian suffix lineful.)
Above, the outside angles are ABE, ACD, and FAC. To distinguish outside angles of a manyside from the manyside's own angles, the angles of the manyside are called inside angles.
Let's get to the first theorem of this lesson:
Outside Angle Provedsaying:
In a threeside, the breadth of an outside angle is equal to the adding ("sum") of the breadths of the two unneighboring ("nonadjacent" or "remote") inside angles.
Proof:
Draw: A threeside is shown here.
Given: Threeside ABC, outside Angle 4.
Prove: Angle 4 = Angle 2 + 3
Write: By the Threeside-Adding Theorem (Threenook-Adding Theorem), Angle 1 + 2 + 3 = 180. Since Angle ACB and ACD form a lineful pair, Angle 1 + 4 = 180. So these addings of angle breadths are equal to each other: Angle 1 + 4 = Angle 1 + 2 + 3. Taking away ("subtracting" -- we will also grandfather in "minus" as it's simple enough), Angle 4 = Angle 2 + 3.
Here's a corollary of this theorem:
Outside Angle Unequalness ("inequality" -- equal is Latin grandfathered, with English affixes):
In a threeside, the breadth of an outside angle is greater than the breadth of either unneighboring inside angle.
Proof:
There is a finding which follows straight from this provedsaying. Since Angle 4 = 2 + 3, use the Equalness to Unequalness Law to find Angle 4 > 2 and Angle 4 > 3. The finding is called the Outside Angle Unequalness. (The word for "equation" on the Anglish website is worthlink. But since we're grandfathering in "equal," let's use equalness and unequalness for "equation" and "inequality," since these words sound alike.)
This is, of course, the famous TEAI that I've mentioned on the blog in years past. There was a whole discussion about how TEAI was proved by Euclid without using a Parallel Postulate, and so it's possible to derive the remaining theorems of this lesson in neutral geometry. I'm no longer presenting Geometry this way on the blog, so this is irrelevant.
I could translate the examples here, but I'd rather go to the theorems and their proofs.
Unequal Sides Provedsaying:
If two sides of a threeside are not allsame ("congruent"), then the angles withering ("opposite" -- the word overright is also suggested at the Anglish website. On one hand, I like it because "opposite" and overright begin with the same letter. On the other, I'm not sure whether I want a word with right in it, since that sounds like a right angle. It might be best just to keep "opposite" as being simpler than any of its alternatives.) them are not allsame, and the broader angle is withering the longer side.
Proof:
First we draw a shape and state the given and to prove in terms of that shape.
Given: Threeside ABC, with BA > BC.
Prove: Angle C > A.
Angles withering sides have already been explored in sameside ("isosceles") threesides. To use these findings, draw a sameside threeside as at the left by locating (or perhaps "placing" -- "place" is French, yet might be better understood than "locating") C' on Ray BA ("ray" is French, but like "line" it's simple enough to grandfather) so that BC' = BC. Then C' is between A and B because BA > BC'.
Findings Reasons
1. Find point C on Ray BA 1. On a ray, there is exactly one point
with BC' = BC. at a given length from an endpoint.
2. Angle 1 = 2 2. Sameside Threeside Provedsaying
3. Angle 2 > A 3. Outside Angle Unequalness
(with Threeside CC'A)
4. Angle 1 > A 4. Swapping ("Substitution," 2 into 3)
[Comment: Now all that is left is to show that Angle BCA > 1.]
5. Angle 1 + 3 = BCA 5. Angle Adding Guessedsaying
6. Angle BCA > Angle 1 6. Equalness to Unequalness Law
7. Angle BCA > Angle A 7. Threefollowing Law of Unequalness
(steps 4 and 6)
I'm actually mulling over whether to keep the phrase "exactly one" -- the phrase one and only one is more easily understood (and is pure Anglish to boot). Recall that earlier we used one-off to mean "unique," so one and one-off would also be acceptable for "exactly one."
Here is the last theorem of this lesson:
Unequal Angles Provedsaying:
If two angles of a threeside are not allsame, then the sides withering them are not allsame, and the longer side is withering the broader angle.
Proof:
The othernotway of any provedsaying is true, as you know. The othernotway of the Sameside Threeside Provedsaying is: if two angles in a threeside are not allsame, then the sides withering them are not allsame. But which side is withering the broader angle? Because of the Unequal Sides Provedsaying, the longer side cannot be withering the smaller angle. All maybehoods but one have been ruled out. The longer side must be withering the broader angle.
Shapelore Learning 13-8: Outside Nooks of Manynooks
Lesson 13-8 of the U of Chicago text is called "Exterior Angles of Polygons." We've already seen that the word "exterior" is replaced with outside, but what about "polygons"? Once again, there's a debate over whether to use sides or nooks ("angles") in our new word.
The word "polygon" is Greek -- "poly-" means many, and "-gon" means "angle." Thus a true calque of the word would be something like manynook (since nook means "angle"). Indeed, we see that like "triangle," all polygons ending in "-gon" refer to the number of angles. The only shape word that mentions sides is "quadrilateral," where "lateral" is Latin for side.
But we've already decided to avoid nook as much as possible. We're calling a "triangle" a threeside, not a threenook, and a "hexagon" is a sixside, not a sixnook. Therefore a "polygon" is a manyside, not a manynook. (Again, the one place where nook might be better than side is Triangle-Sum Theorem, where Threenook Adding emphasizes that we're adding angles, not sides.) I'll keep the pure Anglish calque manynooks in the title on the blog, but our preferred word will be manysides.
Let's begin translating this lesson:
Think of walking around a wholelink manyside. (The word "convex" was a hard one for me -- a set is convex if it fully contains all segments linking, or connecting, two points in the set. There should be a better word than wholelink, but I can't think of one right now.) At each corner, you must change direction (Anglish word for "direction" is heading). The amount of change in direction is measured (Anglish word for "measured" is meted) by an outside angle at that corner.
The total amount of change in direction, as you walk around, is the adding of the breadths of the outside angles of the manyside, where one outside angle is picked at each corner.
Since the adding of the inside breadths gets broader as the number of sides of the manyside increases, you might think that the adding of outside angle breadths also increases. What is surprising is that the adding of the outside angles does not increase. The adding is constant ("stillscore" in Anglish). It is the same as one turn ("revolution," even though "turn" is French/Greek), 360. It is the same amount as you turn in going around a circle (grandfathered).
Here is the only theorem of this lesson:
Outside Angles of a Manyside Sum Provedsayings:
In any wholelink manyside, the adding of the breadths of the outside angles, one at each corner, is 360.
Proof:
Think of any wholelink n-side. It has n corners. At each corner, the breadths of the inside angle and one outside angle add to 180. So the adding of the inside and outside angles at the n corners is (180n). But we know the adding of the inside angle breadths is 180(n - 2) degrees. So the sum of the inside and outside angle breadths is 180(n - 2) degrees. So form this equalness (all breadths are in degrees):
Adding of inside angles + adding of outside angles = adding of all inside-outside pairs
180(n - 2) + x = 180n
Solving this equalness for x,
180n - 360 + x = 180n
-360 + x = 0
x = 360
By the way, this is 360 "degrees." Recall that the Anglish website uses bowlengthworth as its word for "degree." But this word is so complex that I'd much rather grandfather in "degree."
Here is the only example of this lesson:
The allsame ("regular") manyside at the left has 18 sides.
a. How many degrees are in each outside angle?
b. How many degrees are in each inside angle?
Answer:
a. The adding of the outside angles is 360. Since the manyside is allsame, all of the inside angles have the same breadth. So all the outside angles do also. There are 18 outside angles, so each must have breadth 20.
b. Each inside angle forms a lineful pair with an outside angle. Thus each inside angle has breadth 160.
The rest of this lesson is all about turtle graphics in Logo. There's no point in discussing this section in detail, especially when there's already so much Java and BASIC in this post.
I will say a little about Logo commands and Anglish. The commands forward, back, and so on are already Anglish, though repeat is not. The best equivalent would be again -- but of course, the computer doesn't care about Anglish, so we must type in repeat whether we like it or not.
Here's an interesting command that is Anglish -- setheading. This command is used to force the turtle to point in a certain direction (such as "up"), when we can't use left or right (when we don't already know which what it's pointing, so we don't know where to turn to get to "up"). Hmm -- perhaps the fact that Logo uses setheading is enough to justify replacing "direction" with the word heading throughout our Plain English lessons.
Oh, before we leave Logo, there's also a quine for Logo at the above link as well:
make "a [ 116 121 112 101 32 34 124 109 97 107 101 32 34 97 32 91 124 10 102 111 114 101 97 99 104 32 58 97 32 91 32 116 121 112 101 32 119 111 114 100 32 34 124 32 124 32 63 32 93 10 112 114 105 110 116 32 34 124 32 93 124 10 102 111 114 101 97 99 104 32 58 97 32 91 32 116 121 112 101 32 99 104 97 114 32 63 32 93 10 98 121 101 10 ] type "|make "a [| foreach :a [ type word "| | ? ] print "| ]| foreach :a [ type char ? ] bye
All the numbers in the first line are ASCII codes.
Lemay Chapter 7 Part 2: More About Methods
Here is the link to today's lesson:
http://101.lv/learn/Java/ch7.htm
Lesson 7 of Laura Lemay's Teach Yourself Java in 21 Days! is called "More About Methods." Here's where we left off:
Overriding Methods
When you call an object's method, Java looks for that method definition in the class of that object, and if it doesn't find a match with the right signature, it passes the method call up the class hierarchy until a definition is found. Method inheritance means that you can use methods in subclasses without having to duplicate the code.However, there may be times when you want an object to respond to the same methods but have different behavior when that method is called. In this case, you can override that method. Overriding a method involves defining a method in a subclass that has the same signature as a method in a superclass. Then, when that method is called, the method in the subclass is found and executed instead of the one in the superclass.
Here is the first listing of the day:
Listing 7.5. The PrintClass class.
And here is the second listing -- a subclass of the first class:1: class PrintClass { 2: int x = 0; 3: int y = 1; 4: 5: void printMe() { 6: System.out.println("x is " + x + ", y is " + y); 7: System.out.println("I am an instance of the class " + 8: this.getClass().getName()); 9: } 10: }
Listing 7.6. The PrintSubClass class.
Here's what's going on here:1: class PrintSubClass extends PrintClass { 2: int z = 3; 3: 4: public static void main(String args[]) { 5: PrintSubClass obj = new PrintSubClass(); 6: obj.printMe(); 7: } 8: }
In the main() method of PrintSubClass, you create a PrintSubClass object and call the printMe() method. Note that PrintSubClass doesn't define this method, so Java looks for it in each of PrintSubClass's superclasses-and finds it, in this case, in PrintClass. Unfortunately, because printMe() is still defined in PrintClass, it doesn't print the z instance variable.
Again, the first class PrintClass is not an application, because it lacks a main() method. When I compiled it on my computer, it automatically ran the last completed application -- which turned out to be the quine from my last post!
Here is the third listing:
Listing 7.7. The PrintSubClass2 class.
This class overrides the printMe() method from the superclass PrintClass. On my compiler, a tiny green threeside -- uh, I meant "triangle" -- appears to indicate that a method is being overridden.1: class PrintSubClass2 extends PrintClass { 2: int z = 3; 3: 4: void printMe() { 5: System.out.println("x is " + x + ", y is " + y + 6: ", z is " + z); 7: System.out.println("I am an instance of the class " + 8: this.getClass().getName()); 9: } 10: 11: public static void main(String args[]) { 12: PrintSubClass2 obj = new PrintSubClass2(); 13: obj.printMe(); 14: } 15: }
The next thing Lemay shows us is how to avoid duplicating lines in the two methods. The next listing is just a repeat of the two methods as already written. Let's skip that listing and just get to the changes that she wants us to make:
// from PrintClass void printMe() { System.out.println("I am an instance of the class" + this.getClass().getName()); System.out.println("x is " + x); System.out.println("y is " + y); }
// From PrintSubClass2 void printMe() { super.printMe(); System.out.println("z is " + z); }
So the word super forces the compiler to do the superclass method first, and it returns to the new method to print the value of z.
Here is the last listing of the lesson:
Listing 7.9. The NamedPoint class.
This class not only extends the built-in class Point, but it calls its constructor super, since the class Point is the superclass.1: import java.awt.Point; 2: class NamedPoint extends Point { 3: String name; 4: 5: NamedPoint(int x, int y, String name) { 6: super(x,y); 7: this.name = name; 8: } 9: public static void main (String arg[]) { 10: NamedPoint np = new NamedPoint(5, 5, "SmallPoint"); 11: System.out.println("x is " + np.x); 12: System.out.println("y is " + np.y); 13: System.out.println("Name is " + np.name); 14: } 15:}
We now move on to finalizers:
Finalizer methods are almost the opposite of constructor methods; whereas a constructor method is used to initialize an object, finalizer methods are called just before the object is garbage-collected and its memory reclaimed.
The finalizer method is named simply finalize(). The Object class defines a default finalizer method, which does nothing. To create a finalizer method for your own classes, override the finalize() method using this signature:
The author tells us that she'll explain protected and throws later on. Hmm, in C++ we have something similar to finalizers, called "destructors."protected void finalize() throws Throwable { super.finalize(); }
Lemay ends the lesson as follows:
Congratulations on completing your first week of Teach Yourself Java in 21 Days! Starting next week, you'll apply everything you've learned this week to writing Java applets and to working with more advanced concepts in putting together Java programs and working with the standard Java class libraries.
And it only took us almost two months to complete our first "week" of Java! I know, I know -- I'm intentionally taking my time to learn the language rather than speed through it in a few weeks.
More About Quadrilaterals in Java
Let's get back to our Quadrilateral Hierarchy and apply what we learned today. Our quadrilateral classes have subclasses and superclasses, and now we know that we can call super-constructors on these classes.
Here is our quadrilateral class from last time:
class Quad {
double a = 0;
double ab = 0;
double b = 0;
double bc = 0;
double c = 0;
Quad(double a, double ab, double b, double bc, double c) {
this.a = a;
this.ab = ab;
this.b = b;
this.bc = bc;
this.c = c;
}
double d() {
return 360-a-b-c;
}
The constructor for this class takes the parts of the quadrilateral in ASASA format, so we require three angles (a, b, c) and two sides (ab, bc).
OK, so let's write constructors for the other quad classes using our super-constructor:
class Kite extends Quad {
Kite(double a, double ab, double b) {
super(a,ab,b,ab,a);
}
}
class Trap extends Quad {
Trap(double a, double ab, double b, double bc) {
super(a,ab,b,bc,180-b);
}
}
class IsoTrap extends Trap {
IsoTrap(double a, double ab, double bc) {
super(a,ab,a,bc);
}
}
class Pgram extends Trap {
Pgram(double a, double ab, double bc) {
super(a,ab,180-a,bc);
}
}
The constructors for Kite and Trap are based on their super, Quad. Notice that while the constructor for Quad takes five arguments, the constructor Trap takes only four arguments because it fills in the fifth argument with 180-b.
Then the constructors for IsoTrap and Pgram are based on their super, Trap. Notice that while the constructor for Trap takes four arguments, the constructors IsoTrap and Pgram take only three arguments because they fills in the fourth argument. Neither one needs to fill in the fifth argument because their super is Trap, not Quad. And so the super requires only four arguments, not five.
All of these new classes derive the fourth angle method d() from their super, Quad. But we might wish to add in a new function, Perimeter().
We only have two sides of the quad available, ab and bc. So our Quad class would need to access the trig methods (available in Math) to get the other two sides. On the other hand, in Pgram, the perimeter is easier to calculate because opposite sides of a pgram are congruent. It would waste time to use the perimeter method in Quad to find the perimeter of a pgram.
So this is where overriding comes in. Quad.perimeter() will be some complicated trig formula that we don't know yet, while Pgram.perimeter() will be much simpler:
//from Pgram
double perimeter () {
return 2*(ab+bc);
}
Likewise, for area, Quad.area will be the most complex. Pgram.area will be simpler, but we'll still need trig to calculate the height since we're given two sides (with one side the base, but the other side isn't the height). But the simplest will be Rect.area:
//from Rect
double area () {
return ab*bc;
}
This solves the problem with the single inheritance of the Rect, Rhom, and Square classes. We will want Rect and Rhom to extend Pgram, and Square to extend Rect, in order to take advantage of these perimeter and area methods:
class Rect extends Pgram {
Rect(double ab, double bc) {
super(90,ab,bc);
}
}
class Rhom extends Pgram {
Rhom(double a, double ab) {
super(a,ab,ab);
}
}
class Square extends Rect {
Square(double ab) {
super(ab,ab);
}
}
Music: "What's the Best Advantage?" "Earth, Moon, and Sun," "Constant Multiply"
There are four songs that I performed at my old charter school during Weeks 7-8. The first is "Unit Rate" -- but not only do I not recall the original tune of this song, I actually replayed the song a few weeks later and set it to the tune of the UCLA fight song. So we'll return to this song later.
The second song is "What's the Best Advantage?" But this really isn't a different song from "The Need for Speed" -- the mousetrap car song. This is because "What's the Best Advantage?" was the second project from the Illinois State text that involved mousetrap car.
I found out later on, unwittingly, that there was a third mousetrap car project in the text -- "Learning to Communicate." In the first project the students are to build a simple mousetrap car, in the second project they add a few parts to improve it, and in the third they build one from scratch.
And so it's possible to write three verses for this song -- one for each of the three projects. Each project builds from the previous project -- and so the students really are to "build a better mousetrap, mousetrap car," just as the song implores them.
The third song is "Earth, Moon, and Sun." It's one of my few songs for science rather than math:
EARTH, MOON, AND SUN
I know of how the earth goes,
It revolves around the sun every year.
I know of how the earth goes,
It revolves around the sun every year.
The earth's tilt is the reason,
That we have four seasons.
Winter, spring, summer, and fall,
That is all.
In the north, remember,
Winter's in December.
Tilts toward the sun in June,
It'll be summer soon.
I know of how the earth goes,
I know of how the earth goes,
I know of how the earth goes,
It revolves around the sun every year.
I know of how the moon goes,
It revolves around the earth every month.
I know of how the earth goes,
It revolves around the sun every year.
That's why every 30 days,
We can see every phase.
New moon, waxing crescent,
Half moon, waxing gibbous.
That's why every 30 days,
We can see every phase,
Full moon, waning gibbous,
Half moon, waning crescent.
I know of how the moon goes,
I know of how the moon goes,
I know of how the moon goes,
It revolves around the earth every month.
Note: In honor of Rosh Hashanah, this song is sung to the tune of the Hebrew song Hava Nagila.
Remember -- for this karaoke version, sing my science lyrics, not the original Hebrew lyrics.
The last song is "Constant Multiply":
CONSTANT MULTIPLY
A girl makes jewelry,
Four red for every white bead.
If there are ten white,
How many red beads will she need?
The proportionality constant is four,
It is no less and no more.
It is what you multiply,
The number of white beads by
To get forty red beads.
A girl writes a big two,
The four next to it is small.
What is this equal to,
Hey what does it mean at all?
The number exponent is four,
It is no less and no more.
It's how many times you multiply,
The number base itself by
To get the answer 16.
This song needs a new tune. I should be coming up with new tunes for these songs, but I've been squeezing so much stuff into my summer posts that I haven't had time to compose it. I do know that I'll probably return to 12EDL for this song.
Technically, my summer project was to post the lyrics, not compose new tunes. But still, I do wish to compose a tune for at least one of these songs this summer.
Conclusion
I made pains not to make this into traditionalists yet again, but believe me, they're still posting. In particular, SteveH added one more comment to the long thread I mentioned in my last post, and then Garelick posted several times more. None of those posts have generated many comments yet, and so I believe that I can avoid traditionalists today.
No comments:
Post a Comment