1. Pappas, Poincare, and L'Engle
2. The Kwanzaa Celebrant in My Class
3. Ogilvy and Continued Fractions
4. Coding Continued Fractions in BASIC
5. Coding Continued Fractions in TI-BASIC
6. Continued Fractions and Calendar Reform
7. Continued Fractions and Leap Weeks
8. Calendar Reform and Kwanzaa
9. Continued Fractions and Music
10. Conclusion: "The Twelve Days of Christmath" (Vi Hart)
Pappas, Poincare, and L'Engle
This is what Theoni Pappas writes on page 58 of her Magic of Mathematics:
"There is an astonishing imagination even in the science of mathematics."
-- Voltaire
This is the first page of the section "Mathematical Worlds in Literature." Pappas tells us that several authors write about math in their fiction.
Here are some excerpts from this page:
"Is the tesseract the figment of a mathematical imagination? We learn in Euclidean geometry that a point only shows location, and it cannot be seen since it has zero dimension. A line is infinite in length, yet does such a figure exist in the realm of our lives? A plane is infinite in two dimensions and only one point thick. Consider the pseudosphere of hyperbolic geometry; asymptotic lines of exponential functions, infinities of transfinite numbers. One wonders if these can exist in our world.
"Many writers, artists and mathematicians have ingeniously used these concepts to describe worlds where these ideas come to life."
The first author Pappas mentions in this section is Poincare -- the formulator of a famous conjecture, but also, as I mentioned earlier, the creator of the Poincare hyperbolic disk. Pappas writes:
"In the 19th century, mathematician Henri Poincare created a model of a hyperbolic world contained in the interior of a circle. Here to all things and inhabitants, their circular world was infinite. Unbeknownst to these creatures, everything would shrink as it moved away from the center of the circle, while growing as it approached the center. This meant that the circle's boundary was never to be reached, and hence their world appeared infinite to them."
Here's a link to the Poincare hyperbolic disk:
http://mathworld.wolfram.com/PoincareHyperbolicDisk.html
In past years, I used to write about hyperbolic geometry, because this theory is "neutral," differing from Euclidean geometry merely by denying the Fifth Postulate. (On the other hand, the parallel postulate is true in spherical geometry -- we must change other axioms to obtain spherical geometry.)
I stopped writing about hyperbolic geometry because it's less intuitive than spherical geometry -- for the simple reason that we live on a spherical earth. But since we read about it here and Pappas -- and since it's still vacation time -- let's take some time to learn about hyperbolic geometry.
OK, so objects on the Poincare disk shrink as they approach the boundary. So what exactly does this have to do with denying the Fifth Postulate? Well, if two lines appear to intersect outside the boundary, these lines are in fact parallel (ultraparallel), since the boundary can't be reached. Two lines that would intersect on the boundary are horoparallel. Hence through a point not on a line there are infinitely many lines parallel to that line, and so Playfair fails.
The Wolfram link above contains a picture of MC Escher's representation of the Poincare disk -- Pappas includes such a picture in her book as well. The Wolfram link also shows a short animation of what appears to be a "rotation" about a point on the circle. Since the point lies on the boundary, the so-called "rotation" is actually a horolation -- the fifth isometry that doesn't exist in normal geometry.
Here's a link to a Numberphile video on hyperbolic geometry:
The Poincare disk doesn't appear only the 8:30 mark of this video -- instead another model of hyperbolic geometry is featured (the half-plane model).
Meanwhile, Pappas also writes about Madeleine L'Engle's book A Wrinkle in Time. Even though she writes about this on pages 59-60 rather than 58, I include it in today's post since the movie -- starring Oprah Winfrey -- is coming out in just over two months:
"For her novel A Wrinkle in Time, Madeleine L'Engle uses the tesseract and multiple dimensions as means of allowing her characters to travel though outer space. '..for the 5th dimension you'd square the fourth and add that to the other four dimensions and you can travel though space without having to go the long way around...In other words a straight line is not the shortest distance between two points.'"
(Yes, that last line appears in the movie trailer.) Recall that even though a tesseract is a 4D hypercube, L'Engle labels it as 5D because she's including time as the Einsteinian fourth dimension, so the tesseract must be 5D.
At this point, you may wonder why adding another dimension means that the shortest distance between two points is no longer a straight line. Well, actually the shortest distance between two points is a straight line only in Euclidean geometry. We've already seen that the shortest distance between two points (a "geodesic") in spherical geometry is a great circle.
To understand what L'Engle is doing here, let's bump everything down a dimension. So instead of (counting only the spatial dimensions) using a 4D tesseract to travel across the 3D universe, let's use a 3D cube to travel across 2D Flatland. We can model Flatland using a sheet of paper, except that this paper isn't flat, but folded (or "wrinkled"). The cube then is a tube connecting one folded half of this paper to the other half. It's much shorter, then, for a Flatlander to travel through the cube to the other side than it is to go the long way through Flatland (staying on the sheet of paper).
In fact, it's even possible that L'Engle's universe is hyperbolic like the Poincare disk! In this case, the places where people live are near the boundary of the disk. The circle is small, but people living near the boundary are very tiny, so the universe appears vast to them. Ordinary, people must traverse long distances to travel anywhere else on the disk. But instead, we shorten distances very easily -- travel to the center of the disk (which causes us to grow to a humongous size), walk a single huge step in the correct direction, and then approach the destination (shrinking back to the original size). Notice that the boundary of the Poincare disk is a 1D manifold (the exterior of the 2-ball), and so the people who live in this universe are Linelanders. We then bump it up two dimensions. Then it becomes 3D people living near the image of the 3-sphere, and they travel through the 4-ball across the universe.
Unfortunately, if L'Engle's universe were hyperbolic, it would be incorrect to call the 4-ball through which we travel a "tesseract." Squares don't exist in hyperbolic geometry, hence neither can cubes, and neither can tesseracts. But there might be a way to make the universe the boundary of a tesseract rather than a 4-ball in order to make her story work out.
I've written about L'Engle's universe a couple of times on this blog, but I haven't decided yet whether I'll actually watch the movie when it comes out. I still have over two months to decide -- but I almost have to since I keep writing about it so much!
One thing that annoys me is when I'm searching for something and I stumble upon something I wish I'd found weeks earlier. When I was searching for the hyperbolic geometry video above, I stumbled upon the following Numberphile video on Ricci flow:
I wrote about Ricci flow as we read the Poincare book, but since I gave only excerpts and skipped over large portions of the book, I feel that the readers don't really understand what Ricci flow is (and admittedly, neither do I). This video explains what Ricci flow is and how it was used to prove the Poincare conjecture. (I might as well include it since I already added the "Poincare" label.) There is also a Numberphile video on the Poincare conjecture itself, but I don't link to it here.
The Kwanzaa Celebrant in My Class
Kwanzaa is an African-American holiday, celebrated December 26th-January 1st. (Oops -- I mentioned race in this post, but it's OK because it's vacation time.)
I've written about Jewish holidays in previous posts, especially Rosh Hashanah and Yom Kippur because the LAUSD is closed those days. In New York, schools are closed for both of these Jewish holidays as well as Chinese New Year and the Muslim holiday of Eid al-Fitr. But so far, I've never mentioned Kwanzaa since it has nothing to do with school calendars (except for the fact that all schools are closed for winter break during the seven days of Kwanzaa).
But last year, one of the eighth grade girls in my class celebrated Kwanzaa. (I didn't mention this last year -- even during vacation time, I wanted to write about race in only one post -- and that was the big Hidden Figures post, five days after the last day of Kwanzaa.)
The holiday of Kwanzaa is controversial. Part of this is because it's seen as a "made-up" holiday, due to the recency of its establishment -- the creator, Maulana Karenga, is still alive at age 76. But this post will be mainly about the actual student in my class whose family celebrated the holiday.
How, exactly, does one celebrate Kwanzaa anyway? For my student, the major event during the holiday was a dance recital. She spent the entire month of December preparing for the recital, and she invited me to attend her performance during the holiday itself.
At first I wasn't going to attend, since my home is far from the dance hall. But as it turned out, the December paychecks weren't available before winter break began, and the director (principal) invited the teachers to pick up the paycheck at her house -- which is near the dance hall. And so I decided to drive to the dance hall that afternoon -- even though it was hours before the performance, I thought that I might see her arrive to practice for that evening. If I had seen my student, I would have purchased a ticket, but I never saw her. It was possible that she would have been performing on one of the other six nights of the holiday, and so I decided not to purchase the ticket.
The name Kwanzaa comes from the language of Swahili ("first (fruits)"), and the names of the seven principles associated with the holiday also come from this language. (Swahili is also the language spoken by many characters in the movie Lion King -- the phrase "Hakuna Matata" comes from this language, and the name of the main character, Simba, means "lion.") The principle associated with today, the third day of Kwanzaa is Ujima, which means "collective work and responsibility." (As it turned out, our school also associated each month with a principle, and the December principle, "creativity," was also the sixth principle of Kwanzaa, Kuumba.)
For the sake of my eighth grader, I decided to mention one of the seven principles during each of the last seven school days before winter break (December 6th-14th). The history teacher had announced that there would be a party on the last day of school, December 14th. I was considering hosting my own party in class that day and calling it a Karamu -- the Kwanzaa feast. I might have asked my student what she normally eats during the holiday (probably some sort of soul food), and then I'd bring enough of it for all 14 of my eighth graders to eat.
But then something terrible happened. Ironically, it occurred on December 8th, the day I told my students about the third principle of Ujima, since the students collectively lacked responsibility. (I never mentioned this incident on the blog, since I didn't post on December 8th last year, and I wrote about other things the rest of that week.)
It was during IXL computer time. The eighth graders were supposed to get laptops in order to begin the IXL assignment. But one student -- and I never did figure out who it was -- decided to start flicking the lights on and off. Then a second student started playing with the lights, then a third person, and so on.
While this was happening, two seventh graders from the English class entered the room. The English teacher wanted her students to work on laptops as well, but she didn't have quite enough computers for the large class of seventh graders, so she sent in two boys to borrow laptops from my smaller class of eighth graders. But when they see the eighth graders playing with the lights, they decide to join in and start flicking the lights themselves.
I try to punish my class for playing the lights -- but they claimed that it was unfair to punish them since "only" the two seventh grade boys were guilty. I began to yell -- and this caused the history teacher to leave his classroom and find out what was going on. In the end, he ended up canceling the following week's party -- and since he was no longer having a party, there was no reason for me to hold the Kwanzaa Karamu either.
It's easy to see how this incident was a reflection of my classroom management. Even as a sub, I've never seen students enter the classroom at the beginning of the period play with the lights before. The students don't play with the lights until after they perceive me to be a weak, powerless teacher. So if students are playing with the light switch, it means that I've already lost control of the class.
And it's also easy to see what I did during IXL time that was weak. The most obvious punishment to give students during laptop time is to take away the laptops and forbid them from using them. But I had no back up assignment, and I knew that the students might see the cancellation of IXL as a reward rather than a punishment.
In previous posts, I've mentioned what I should have done with IXL last year -- have an IXL accountability worksheet. Students who have their laptops taken away would be required to copy and answer eleven questions on that worksheet. Since I didn't know which individuals were responsible for turning off the lights, the entire class would be subject to the punishment. I wouldn't have to yell, or even talk about the lights. If anyone asks why they can't use the laptops that day, I would give the stock answer "Because I said so." The first ten questions would be math, while the eleventh question would be, "Will I ever turn off the lights without permission?" with a one-word answer required. (If someone protests, "But I didn't turn off the lights!" I point out that the question begins with the word "Will," indicating the future tense, not the past tense.)
Hopefully, if the two seventh graders enter to see the eighth graders working, they aren't inspired to turn off the lights themselves. But in case I don't stop the eighth graders before two younger boys arrive and they in turn play with the lights, I punish them the next day. This would not be a class punishment but individual, since it's obvious which two boys are involved in the incident. If I had done all of this, the history teacher would never have cancelled the party, and the Karamu could have proceeded as I intended. The day before the party -- Kuumba day -- would have been a good day to have the students show their creativity by doing an art project, perhaps drawing the seven candles (one black, three red, three green) that Kwanzaa celebrants light during the holiday.
By the way, as I mentioned in my Hidden Figures post (dated January 6th), the sixth and eighth grade classes were majority black, but the seventh grade class was mostly Latino. I was considering making up for this by having a Fiesta later in the year. Indeed, one day during a music break, a seventh grader wanted me to open one of my songs with "Uno, dos, tres, cuatro." I didn't that day, but I realized that there was a Square One TV song for which this opening would fit -- "X is the Sign of the Times," which also had Spanish lyrics -- "Equis es el simbolo de los tiempos." The planned date for this song was Cinco de Mayo -- but alas, by May 5th I was no longer in the classroom.
Ogilvy and Continued Fractions
This is the time of year that I post my annual Calendar Reform post. But I promised that I'd post the Ogilvy chapter that we skipped, since there's a relationship between this topic and calendars.
Chapter 10 of Stanley Ogilvy's Excursions in Number Theory is "Continued Fractions." He begins:
"We now take a second look at the Euclidean algorithm which we presented in Chapter 3. On page 29 we confirmed by means of the algorithm that 14 and 45 are relatively prime: they have no common factor except 1."
Ogilvy now revisits the steps of that algorithm, except this time he divides it using fractions:
45/14 = 3 + 3/14
= 3 + 1/(14/3)
= 3 + 1/(4 + 2/3)
= 3 + 1/(4 + 1/(3/2))
= 3 + 1/(4 + 1/(1 + 1/2))
We stop when the last fraction has a numerator of one (which corresponds to a GCF of 1). The multiple-decker expression:
3 + 1/(4 + 1/(1 + 1/2))
is called a continued fraction expansion of the number 45/14.
Ogilvy explains how continued fractions can be used to approximate the original fraction. He deletes the last fraction 1/2:
3 + (4 + 1/1) = 16/5
This is an approximation of the original fraction 45/14, which we verify by subtracting:
45/14 - 16/5 = (45 * 5 - 14 * 16)/(14 * 5) = (225 - 224)/70 = 1/70
Since the error is only 1/70, the two fractions are very close. Ogilvy tries another example:
87/37 = 2 + 13/37
= 2 + 1/(37/13)
= 2 + 1/(2 + 11/13)
= 2 + 1/(2 + 1/(13/11))
= 2 + 1/(2 + 1/(1 + 2/11))
= 2 + 1/(2 + 1/(1 + 1/(11/2)))
= 2 + 1/(2 + 1/(1 + 1/(5 + 1/2)))
Once again, we discard the last fraction:
2 + 1/(2 + 1/(1 + 1/5)) = 40/17
and find the error:
87/37 - 40/17 = (87 * 17 - 37 * 40)/(37 * 17) = (1479 - 1480)/629 = -1/629
This time the difference is smaller and negative.
Ogilvy now writes about the purpose of these continued fractions. One purpose of them is to solve linear Diophantine equations:
45x - 14y = 1
To solve this equation, we take the equation from earlier:
(45 * 5 - 14 * 16)/(14 * 5) = 1/70
and multiply both sides by 70:
45 * 5 - 14 * 16 = 1
which produces (5, 16) as the solution of the Diophantine equation without trial-and-error at all. Here is Ogilvy's next example:
87x - 37y = 1
But this time, we repeat the process to obtain:
87 * 17 - 37 * 40 = -1
Oops -- we wanted +1, not -1. This time, we return to the continued fraction process and replace the last 1/2 by:
1/(1 + 1/1)
And now we can throw out the last 1/1 instead of 1/2:
2 + 1/(2 + 1/(1 + 1/(5 + 1/1))) = 47/20
Finding the difference as usual:
87/37 - 47/20 = (87 * 20 - 37 * 47)/20 = (1749 - 1739)/20 = 1/740
or
87 * 20 - 37 * 47 = 1
Thus the solution is (20, 47). Ogilvy now gives an admittedly trumped up problem related to these Diophantine equations:
"A man finds that he can spend all his money on widgets at 87 cents a piece, or he can buy gadgets at 37 cents a piece and have one cent left over. How much money does he have?"
87W = 37G + 1
87W - 37G = 1
And so W = 20, G = 47 is a solution. Here's how to find other solutions -- add 87 * 37 and then subtract it back:
87 * 20 + 87 * 37 - 37 * 47 - 87 * 37 = 1
87(20 + 37) - 37(47 + 87) = 1
87 * 57 - 37 * 134 = 1
And so another solution is (57, 134). In other words, the line whose equation is:
87x - 37y = 1
passes through the lattice points (20, 47), (57, 134), and others. Ogilvy writes that we can generalize this to solve:
ax - by = c
provided that the GCF of a and b -- say d -- divides c evenly.
At this point, Ogilvy writes about the main purpose of continued fractions. It's not to find fractions to approximate other fractions, but rather to find fractions to approximate irrational numbers.
His first example is sqrt(2). He begins by adding 1 -- that is, floor(sqrt(2)) -- and then subtract it back:
sqrt(2) = 1 + sqrt(2) - 1
We had good luck inverting before, so we try it again:
sqrt(2) = 1 + 1/(1/(sqrt(2) - 1))
Now we perform the Algebra II trick -- rationalize the last denominator by multiplying it and the numerator by its conjugate:
sqrt(2) = 1 + 1/((sqrt(2) + 1)/((sqrt(2) - 1)(sqrt(2) + 1)))
= 1 + 1/((sqrt(2) + 1)/(2 - 1))
= 1 + 1/(1 + sqrt(2))
At this point, we have that sqrt(2) equals something on the right hand side -- and that something itself contains a sqrt(2). So we substitute the entire RHS in for sqrt(2):
sqrt(2) = 1 + 1/(1 + (1 + 1/(1 + sqrt(2))))
= 1 + 1/(2 + 1/(1 + sqrt(2)))
And the RHS still has a sqrt(2), so we substitute in RHS again and again ad infinitum:
sqrt(2) = 1 + 1/(2 + 1/(2 + 1/(2 + 1/(2 + ...
Just as rational numbers have finite continued fraction expansions, it turns out that irrational numbers have infinite continued fraction expansions. At this point, Ogilvy points out that we don't know whether the infinite expansion converges at all, much less to sqrt(2). Here he decides to check the first few approximations, or convergents, to sqrt(2):
C_1 = 1
C_2 = 1 + 1/2 = 3/2
C_3 = 1 + 1/(2 + 1/2) = 7/5
C_4 = 1 + 1/(2 + 1/(2 + 1/2)) = 17/12
1/1, 3/2, 7/5, 17/12, ...
Ogilvy notices a pattern here -- to find the next denominator, add the old numerator and denominator, so for example, 17 + 12 = 29. To find the new numerator, add the new denominator and old numerator, so 12 + 29 = 41. So the next fraction is 41/29, and the pattern continues with 99/70.
Since these numbers should be approaching sqrt(2), their squares should approach 2:
1/1, 9/4, 49/25, 289/144, 1681/841, 9801/4900, ...
Let's find the errors -- their differences from 2:
-1/1, +1/4, -1/25, +1/144, -1/841, +1/4900, ...
Note that the signs alternate, the numerators are all 1's, and the denominators increase rapidly. This suggests that the sequence really does converge to sqrt(2). Ogilvy tells us that if the fractions in the sequence are y/x, then each one satisfies:
(y^2 +/- 1)/x^2 = 2
or
y^2 - 2x^2 = +/- 1
This is a famous Diophantine equation -- Pell's equation.
At this point Ogilvy returns to a problem from Chapter 2 of his book -- what perfect squares are also triangular numbers? The nth triangular number is (n^2 + n)/2, so we write:
(n^2 + n)/2 = m^2
Clearing the fraction, multiplying by 4, and adding 1 gives:
4n^2 + 4n + 1 = 8m^2 + 1
(2n + 1)^2 = 2(2m)^2 + 1
We let y = 2n +1 and x = 2m to obtain:
y^2 - 2x^2 = 1
which is Pell's equation. So each solution to Pell's equation also produces a square triangle -- the solutions to Pell are (2, 3), (12, 17), (70, 99). In each pair, half of the even number is the square and half of one less than the odd number is the triangle. Hence 1^2 is the first triangular number, 6^2 is the eighth triangular number, 35^2 is the 49th triangular number, and so on.
Ogilvy informs us that all irrationals of the form sqrt(a^2 + 1) can be developed the same way:
sqrt(a^2 + 1) = a + 1/(2a + 1/(2a + 1/(2a + ...
But other square roots, such as sqrt(3), are found using a different method that I choose not to include in this post:
sqrt(3) = 1 + 1/(1 + 1/(2 + 1/(1 + 1/(2 + ...
The successive convergents are:
1, 2, 5/3, 7/4, 19/11, 26/15, ...
whose squares are:
1, 4, 25/9, 49/16, 361/121, 676/225, ...
and whose errors are:
-2/1, +1/1, -2/9, +1/16, -2/121, +1/225, ...
This means that we now have solutions to the Diophantine equations:
y^2 - 3x^2 = 1
y^2 - 3x^2 = -2
The first of these is Pell's equation, but the second isn't, since the right hand side is -2, not -1. In fact, Ogilvy tells us that:
y^2 - Nx^2 = 1
has solutions for all N (except perfect squares, of course), but:
y^2 - Nx^2 = -1
has solutions for only certain values of N -- and 3 isn't one of them.
In the rest of this chapter, Ogilvy plays around with some continued fractions for a few special transcendental numbers. He gives us a result from Euler:
c_1 + c_1c_2 + c_1c_2c_3 + ... = c_1/(1 - c_2/(1 + c_2 - c_3/(1 + c_3 - ...
This isn't what's known as a simple continued fraction since the numerators aren't all 1, but this is a sort of generalized continued fraction. Most series aren't of the form given by the LHS, but it turns out that the Taylor series for arctangent is of this form:
arctan x = x - x^3/3 + x^5/5 - x^7/7 + ...
= x + x(-x^2/3) + x(-x^2/3)(-3x^2/5) + ...
= x/(1 + x^2/(3 - x^2 + 9x^2/(5 - 3x^2 + 25x^2/(7 - 5x^2 + ...
Ogilvy now substitutes in x = 1, since arctan 1 is 45 degrees or pi/4 radians:
pi/4 = 1/(1 + 1^2/(2 + 3^2/(2 + 5^2/(2 + ...
Even though pi has a simple continued fraction expansion, it follows no pattern. On the other hand, the simple continued fraction for e does show a pattern:
e = 1 + 1/1! + 1/2! + 1/3! + ...
e = 2 + 1/(1 + 1/(2 + 1/(1+ 1/(1 + 1/(4 + 1/(1 + 1/(1 + 1/(6 + 1/ + ...
According to Ogilvy, two computer programmers comment on why it's faster to calculate digits of e than digits of pi:
"One would hope for a theoretical approach... -- a theory of the 'depth' of numbers -- but no such theory now exists. One can guess that e is not as deep as pi, but try and prove it!"
Coding Continued Fractions in BASIC
Ogilvy doesn't use the following notation in his book, but there's a simpler way to write all of the continued fractions that he mentions in this chapter:
45/14 = [3; 1, 4, 2]
87/37 = [2; 2, 1, 5, 2]
sqrt(2) = [1; 2, 2, 2, 2, 2, 2, ...]
sqrt(a^2 + 1) = [a; 2a, 2a, 2a, ...]
sqrt(3) = [1; 1, 2, 1, 2, 1, 2, ...]
e = [2; 1, 2, 1, 1, 4, 1, 1, 6, ...]
Let's write programs to find continued fractions, in both BASIC and TI-BASIC:
http://www.haplessgenius.com/mocha/
10 INPUT X
20 PRINT INT(X);
30 X=X-INT(X)
40 IF X<=.001 THEN END
50 X=1/X
60 GOTO 20
In this program, only decimals can be entered, not fractions or square roots. So we may require the computer to PRINT 45/14 or PRINT SQR(2) before we RUN the program.
Line 40 ought to say IF X=0, but it's obvious that decimals can't be written exactly -- we can't even express 1/3 exactly, after all -- and so errors are inevitable. So this program has a .001 tolerance. But even with this tolerance, errors are inevitable especially with irrational inputs. The computer displays a few 2's when sqrt(2) is inputted, but soon many spurious values appear. (Press "Esc" to stop the computer as soon as the non-2's appear.)
For the rationals, the computer will often display a list ending with 1. Ogilvy does tell us, after all, that since 1/1 = 1, the two continued fractions are equivalent:
[a; b, c, d, ..., n]
[a; b, c, d, ..., n-1, 1]
Lists ending in 1 appear because of rounding error again -- a final 2, for example, may be stored in the computer as 1.9999 instead. The computer can't convert 1.9999 directly to 2 because of the INT (floor) function -- instead, 1.9999 becomes 1. The extra .9999 is inverted to 1.0001 (or thereabouts), and that's where the final 1 comes from. The last .0001 is within the tolerance .001, and so it ends.
For fractions, it may be annoying to find their decimal values first, so instead we could write:
5 INPUT P,Q
10 X=P/Q
This doesn't allow us to input irrational values -- but since the computer is inaccurate for irrationals, perhaps it's better not to allow irrational inputs.
Coding Continued Fractions in TI-BASIC
In TI-BASIC, we write:
PROGRAM:CONTFRAC
:Input X
:{iPart(X)}->L1
:fPart(X)->X
:2->A
:While (A<99)(X>
.001)
:1/X->X
:iPart(X)->L1(A)
:fPart(X)->X
:A+1->A
:End
:L1
This time, we store our continued fraction in a list variable L1, while A keeps track of the size of the list variable. The program stops when either the list reaches length 99, or the tolerance is met.
Interestingly enough, the calculator gives the correct list for the irrational sqrt(2), with a 1 followed by nothing but 2's. For sqrt(3) and all higher square roots, errors are inevitable. For the number e, the last correct values are 10, 1, 1, but then 13 appears instead of 12. The next two values after 13 are indeed 1's, then all further values are incorrect. On the computer, when we enter e, the last correct values are 8, 1, 1.
Of course, perhaps we should change 99 to a more realistic value, since the calculator will almost never find 99 correct values except for a few special numbers like sqrt(2). For example, since e produced 17 correct values, maybe we should change this to 17, or 19 at the most.
Continued Fractions and Calendar Reform
OK, so now we have learned what continued fractions are. Earlier, I wrote that continued fractions have something to do with calendars, but it's not obvious what the relationship is.
We know that the Gregorian Calendar -- the calendar currently in widespread use -- requires Leap Days in order to keep it accurate. Whenever we see a leap anything (Leap Second, Leap Day, Leap Week, and so on), it means that the ratio of two lengths of time (such as a year and a day) is not a whole number.
The following link gives the number of solar days in a tropical year:
https://mrob.com/pub/math/numbers-11.html
The value given there is 365.242189 days. So let's find a continued fraction for that number:
365.242189 = [365; 4, 7, 1, 3, 40, ...]
As it turns out, these numbers can be converted into the Leap Day rule for a calendar. Here's how we do this:
- The Level-0 cycle is the length of the shorter unit. For example, when trying to determine the number of days in a year, one day is the Level-0 cycle.
- For each value of n, the length of the Level-n cycle is given by the nth value a_n in the continued fraction (CF) found above. In particular, we combine exactly a_n Level-(n - 1) cycles with one Level-(n - 2) cycle.
So let's try this for the continued fraction found above:
0. The Level-0 cycle is one day.
1. The first value in the CF is 365. The Level-1 cycle consists of 365 Level-0 cycles, or 365 days in a year. This is a very basic approximation, used by the ancient Egyptians.
2. The second value in the CF is 4. The Level-2 cycle consists of 4 Level-1 cycles plus one Level-0 cycle, or four 365-days years plus a Leap Day. This is the Julian calendar cycle.
3. The third value in the CF is 7. The Level-3 cycle consists of 7 Level-2 cycles plus one Level-1 cycle, or 28 years (with 7 Leap Days) followed by a 365-day year (no Leap Day). In other words, once every 29 years, Leap Days would be five years apart rather than four.
4. The fourth value in the CF is 1. The Level-4 cycle consists of one Level-3 cycle plus one Level-1 cycle, or the 29-year cycle followed by a simple 4-year Julian cycle. In other words, once every 33 years (instead of 29), Leap Days would be five years apart rather than four.
This corresponds to an actual calendar -- the Dee Calendar. I've mentioned in past years that if our goal is to keep, say, the spring equinox on the same date, then it's better to have Leap Days mostly four and occasionally five years part, rather than go eight years between Leap Days as in the Gregorian Calendar (1896-1904 and 2096-2104, but not 1996-2004 because 400 divides 2000).
Whenever the number 1 appears in the continued fraction, we obtain two cycles of approximately the same length (such as 29 and 33 years). So we could call the 29-year cycle the short Dee cycle, and the 33-year cycle the long Dee cycle.
But in reality, John Dee (the 16th century British astronomer for whom the cycle is named) used only the 33-year cycle. This is because it's inaccurate to cut off the CF just before a 1 -- recall what Ogilvy wrote earlier. Cutting off the CF at 1 means throwing away the fraction 1/1, which is the largest fraction we can cut. It's better to cut off a fraction before any value other than 1. So Dee's calendar cuts off the CF just before a 3. Throwing away 1/3 is much more accurate than discarding 1/1.
By the way, there's also a calendar called the Dee-Cecil Calendar. The Dee and Dee-Cecil Calendars are exactly one day apart -- the difference is that the Dee Calendar seeks to keep the equinox on March 21st and the Dee-Cecil Calendar keeps it on March 20th instead. For most of my lifetime, the Gregorian and Dee-Cecil calendars coincided, and the equinox was always March 20th. For one recent year (March 2016-February 2017), the equinox on the Gregorian Calendar slipped to March 21st, and so the Gregorian Calendar agreed with the Dee Calendar instead of Dee-Cecil. Then the Dee and Dee-Cecil calendars observed February 29th, 2017, which aligned the Gregorian calendar with Dee-Cecil once again.
5. The fifth value in the CF is 3. The Level-5 cycle consists of 3 Level-4 cycles plus one Level-3 cycle, or three (long) Dee cycles followed by a short Dee cycle. Three 33-year cycles plus a 29-year cycle adds up to 128 years.
There are several calendars based on a 128-year cycle, but none of them actually observe Leap Days by combining Dee cycles this way. Instead, all of them simply observe Leap Days once every four years and then skip a Leap Day once every 128 years. This is similar to the Gregorian pattern, except that the skipped Leap Days follow a simpler pattern themselves (once every 128 years, instead of thrice every 400 years). Since 128 = 2^7, this cycle is often used in conjunction with binary, quaternary, octal, or hexadecimal bases. Let's call this cycle the Earth cycle, since it's used in, among other calendars, the Earth Calendar:
6. This sixth value in the CF is 40. The Level-6 cycle consists of 40 Level-5 cycles plus one Level-4 cycle, or 40 Earth cycles followed by one Dee cycle. No known calendar actually uses this cycle, which would span 5153 years. Just as it's inaccurate to cut off a CF before a 1, it's very accurate to cut off a CF before a large number like 40 (discarding 1/40 rather than 1/1).
Notice that none of these cycles corresponds to the Gregorian cycle of 400 years. We can force the Gregorian cycle to appear by finding a continued fraction for 365.2425 -- the average length of the Gregorian year -- instead of 365.242189:
365.2425 = [365; 4, 8, 12]
Here the Level-2 cycle is still the Julian cycle, but now Level-3 skips the short Dee cycle (which is incompatible with the Gregorian] and takes us directly to the long Dee cycle. Level-4 directs us to combine 12 Dee cycles (totaling 396 years) with one Julian cycle to complete the 400 years. This is actually used in a calendar, the Truncated Dee-Cecil Calendar (since the four-year cycle at the end "truncates" the pure Dee cycle):
Continued Fractions and Leap Week Calendars
So far, the Level-0 cycle has always been a day -- the basic calendar unit. We can obtain Leap Week calendars simply by making the Level-0 unit the week rather than the day. All we have to do is divide our tropical year length by seven and feed it into the CF calculator:
52.17745557 = [52; 5, 1, 1, 1, 2, 1, 6, 2]
Since this CF has so many more 1's, our Leap Week calendars won't be quite as accurate as our Leap Day Calendars.
0. The Level-0 cycle is one week.
1. The first value in the CF is 52. The Level-1 cycle consists of 52 weeks in a year, or 364 days.
2. The second value in the CF is 5. The Level-2 cycle consists of 5 Level-1 cycles plus a Level-0 cycle, or a Leap Week every five years. This isn't very accurate (average year length=365.4 days).
3. The third value in the CF is 1. The Level-3 cycle consists of 1 Level-2 cycle plus a Level-1 cycle, or a Leap Week every six years. This isn't very accurate (average year length=365 1/6 days).
4. The fourth value in the CF is 1. The Level-4 cycle consists of 1 Level-3 cycle plus a Level-2 cycle, or two Leap Weeks every 11 years. This isn't accurate (average year length=365.2727 days).
5. The fifth value in the CF is 1. The Level-5 cycle consists of 1 Level-4 cycle plus a Level-3 cycle, or three Leap Weeks every 17 years. This is in the ballpark (average year length=365.2353 days).
5.5 Even though the next value in the CF is 2, let's try combining just 1 Level-5 cycle with a Level-4 cycle anyway. This gives us five Leap Weeks every 28 years (average year length=365.25 days). In other words, this is equivalent to the Julian calendar. It doesn't appear in the CF for a very good reason -- the Level-5 cycle is already more accurate than the Julian calendar (albeit too short, rather than too long like the Julian calendar).
6. The sixth value in the CF is 2. The Level-6 cycle consists of 2 Level-5 cycles plus a Level-4 cycle, or eight Leap Weeks every 45 years. This produces an average year length of 365.2444 days.
7. The seventh value in the CF is 1. The Level-7 cycle consists of 1 Level-6 cycle plus a Level-5 cycle, or 11 Leap Weeks every 62 years. This produces a average year length of 365.2419 days. This cycle is used in the Usher Calendar (mentioned in my Leap Day 2016 post). Usher originally used the shorter Level-5 cycle of 17 years -- and technically, Usher actually combined seven Level-5 cycles with one Level-2 cycle of five years to obtain a 124-year cycle, but this is shown to be equivalent to two Level-7 cycles of 62 years each.
8. The eighth value in the CF is 6. The Level-8 cycle consists of 6 Level-7 cycles plus a Level-6 cycle, or 74 Leap Weeks every 417 years. This produces an average year length of 365.2422 days, and it is used by Brij Vij (the inventor of the Earth Calendar) in one of his other calendars.
9, The ninth value in the CF is 2. This Level-9 cycle consists of 2 Level-8 cycles plus a Level-7 cycle, or 159 Leap Weeks every 896 years. This produces an average year length of 365 + 31/128 days and is thus equivalent to the 128-year cycle for Leap Days. It is used in the Bonavian Calendar:
Just like the Earth Calendar, the Bonavian Calendar doesn't actually follow the CF-suggested cycle (two 417-cycles plus a 62-cycle), but instead uses Level-5.5 Julian cycles and then drops the extra Leap Week at the end of the 896-cycle. And since we've already reached the accuracy of the Earth Calendar, there's no reason to consider Level-10 or beyond.
Once again, the Gregorian cycle has been skipped. We can force it to appear by dividing 365.2425 by 7 and then finding its CF:
52.1775 = [52; 5, 1, 1, 1, 2, 1, 2, 2]
The first seven levels agree with the CF above, but this time we changed Level-8:
8. The eighth value in the CF is now 2. The Level-8 cycle consists of 2 Level-7 cycles plus a Level-6 cycle, or 30 Leap Weeks every 169 years. This produces an average year length of 365.2426 days.
9. The ninth value in the CF is 2. The Level-9 cycle consists of 2 Level-8 cycles plus a Level-7 cycle, or 71 Leap Weeks every 400 years. This is now equivalent to the Gregorian cycle. This cycle is used in the Hermetic Leap Week Calendar:
Another calendar, the New Earth Calendar, has a Gregorian-like Leap Week Rule. Leap Weeks are held every five years (Level-2 cycle), except they are skipped every 40 years, and then they are added back every 400 years:
It's possible to make Leap Week Calendars for weeks that are six days, eight days, or any other length, simply by dividing 365.242189 or 365.2425 by six, eight, or whatever.
Calendar Reform and Kwanzaa
Since I already opened a can of worms by mentioning Kwanzaa, an interesting question is, what happens to this holiday under the various versions of Calendar Reform? Assuming that we define Kwanzaa as December 26th-January 1st, for example:
- On the 13-Month International Fixed Calendar (with Sol as the extra month in the middle of the year), each month has 28 days, so Kwanzaa is shortened to four days. Usually, the blank days are at the end of December, so Kwanzaa would be either five or six days.
- Two Leap Week calendars listed above (Bonavian and New Earth) give December 28 days, so that Kwanzaa would have only four days. But the Leap Week is added to the end of December, so the month would have 35 days, with 11 days of Kwanzaa, in such years.
- On the other hand, Kwanzaa wouldn't change much under the World Calendar. December already has 30 days with a blank day on the 31st, so it would remain a seven-day festival.
Of course, Kwanzaa is significant to me in that I had a Kwanzaa celebrant in my class last year. But it also matters to all teachers since that is our winter break. Recall that in New York, the only nine days that are guaranteed are Christmas Eve, Christmas Day, and the seven days of Kwanzaa. Exactly one of December 23rd and January 2nd is a school day. (This year there is school on January 2nd, since December 23rd was a Saturday.)
Thus shortening Kwanzaa really means shortening winter break, especially in New York. Depending on how the calendar is set up, all 28-day months begin on the same day, either Sunday or Monday. In the former case, Christmas falls on a Wednesday. Even New Yorkers don't attend school on the 23rd if it's a Monday (to avoid a one-day week), and so the last day of school is the 20th. If January 1st is New Year's Day, then Monday the 2nd is a holiday, and so students return on the 3rd. This means that schools are closed for a week and a day (possibly two days, if there's a blank day).
It's much worse if the months begin on Monday. Then the 23rd is a Tuesday, and students would have to attend school on the 22nd and 23rd -- and then they return on Tuesday, January 2nd! So schools aren't even closed for a full week as schools are open both Tuesdays. Well, actually there would be seven days off if there's a blank day, but even seven days is too short for a "winter break."
I also once saw a (not-so-serious) calendar proposal that reduced December to only 26 days. The author (who's probably neither African-American nor a teacher/student) figures that the days between Christmas and New Year's are wasted days, so we jump directly from Christmas to New Year's Eve. I point out that Kwanzaa is now reduced to four days, and New York winter break (depending on the day of the week) could be reduced to a mere four-day weekend. (Actually, this calendar might be made more appealing of we give the the first 11 months 31 days each and the rest to December. But then the last month would have only 24 days. Christmas Eve suddenly becomes New Year's Eve and Christmas itself disappears. Of course, December 25th could become the Leap Day. Those who are fed up with Christmas might not mind celebrating it only once every four-year Julian cycle!)
I also once saw a (not-so-serious) calendar proposal that reduced December to only 26 days. The author (who's probably neither African-American nor a teacher/student) figures that the days between Christmas and New Year's are wasted days, so we jump directly from Christmas to New Year's Eve. I point out that Kwanzaa is now reduced to four days, and New York winter break (depending on the day of the week) could be reduced to a mere four-day weekend. (Actually, this calendar might be made more appealing of we give the the first 11 months 31 days each and the rest to December. But then the last month would have only 24 days. Christmas Eve suddenly becomes New Year's Eve and Christmas itself disappears. Of course, December 25th could become the Leap Day. Those who are fed up with Christmas might not mind celebrating it only once every four-year Julian cycle!)
There are a few other calendars that change the dates of Christmas and Kwanzaa. For example, there is the Fixed Festivity Calendar:
There are actually two calendars listed there, a Leap Day and a Leap Week calendar. (Notice that the Leap Day version explicitly mentions both Kwanzaa and Hanukkah!) Apparently all holidays are reduced to one day of the week, a special "Holiday" that appears only in weeks where there's a holiday -- which is more than half the weeks! The implication is that Christmas, Kwanzaa, and Hanukkah are all on December 24th, with Kwanzaa losing six of its days and Hanukkah losing seven of its days. The Leap Week version squeezes all holidays into four weeks, one each season,
Another calendar similar to Fixed Festivity is International Liturgical Calendar:
This is another Leap Week Calendar that seeks to redefine Christmas and other church holidays, but keeping them close to their original times of the year. It's designed to fit with the Gregorian Calendar and is thus similar to the Usher Calendar and its treatment of Christian holidays.
Continued Fractions and Music
Continued fractions can be applied to music as well as the calendar. For example, the Bohlen Pierce site has a continued fractions page:
http://www.huygens-fokker.org/bpsite/contfract.html
The goal here is to convert just ratios into EDO's (for octaves) and EDT's (for tritaves), and justify why Bohlen-Pierce is a 13-note scale.
Just ratios, of course, are rational numbers, but when converted to cents (or divisions of an octave or tritave) they become irrational numbers. Continued fractions are used to find an EDO or EDT that would approximate the just ratio.
The point being made here is that all six major consonant intervals based on the 3:5:7 chord (9/7, 7/5, 5/3, and their inversions) have 13 in the denominator of one of their convergents. Thus 13EDT is a great scale in which to approximate BP. On the other hand, if we do the same with the 4:5:6 major chord and octaves, 12EDO only approximates the perfect fourth and fifth well. Other EDO's with good fourths and fifths are 41EDO and 53EDO. Meanwhile, 19EDO estimates minor thirds the best, while 28EDO and 59EDO estimate major thirds the best. No single EDO plays all the consonant intervals well, while a single EDT sounds all of the BP consonances well. As the link points out, "Small wonder that this regime [the 12EDO "regime," that is] is under siege.
The following link at Dozens Online is doing the opposite:
http://z13.invisionfree.com/DozensOnline/index.php?showtopic=1724
Here we are taking the 12EDO scale and converting it to just intonation. The task is to convert each note into hertz (where A is 440 Hz, and each semitone has ratio 2^(1/12)) and then entering the number of hertz into a CF calculator. Even if we just use the Level-1 approximations, we are already finding just ratios for the 12EDO notes. For example, Bb is approximately 466 Hz, and so the interval from A to Bb is approximately 466/440 (= 233/220).
Now this is the second time today that I'm looking up something -- in this case, the application of continued fractions to music -- and I stumble upon something else. There is a link into this thread to a BASIC program written for another old computer, the Atari:
https://www.atariarchives.org/c3ba/page045.php
I've written before about the limitations of computer music based on Bridge 261. It's nice that we can play a just major scale, but we can only play one just major scale, based on green Bb. This is because the least common numerator of all the intervals of the just major scale is 180, and 180 * 2 is 360, which is already too big. Hence only one just major scale can be played.
Now according to this link, the Atari also has the same limitations -- but there is a special method to extend the range. In addition to 8-bit music, which is based on 2^8 = 256, there is apparently 16-bit music, based on 2^16 = 65536.
It's difficult to interpret the tables here. Apparently, even though there is a SOUND command, the values appear to be based on degrees, with no subtraction from a bridge needed. A side effect is that higher values correspond to lower notes, and vice versa.
Lowering a note an octave should double the degree, but the ratios between two notes an octave apart aren't exactly 2/1. So C#3 is listed under 8-bit as Degree 230, but C#4 is given as Degree 114 instead of the expected 115 (230/2). The 16-bit table has the same problem -- C#3 is Degree 6450, but C#4 is Degree 3422 instead of 3425, and so on. (Also, we notice that the 8-bit Degrees on the Atari are not the same as those on the Color Computer. On the Atari Middle C4 is Degree 121, but on the Color Computer we found Middle C to be Degree 162.)
But let's assume that these are approximations and that the degrees really are based on just intonation and exact ratios like 2/1. Then even though the link above was trying to convert 12EDO into degrees, consider what this implies for just intonation and other scales:
Continued fractions can be applied to music as well as the calendar. For example, the Bohlen Pierce site has a continued fractions page:
http://www.huygens-fokker.org/bpsite/contfract.html
The goal here is to convert just ratios into EDO's (for octaves) and EDT's (for tritaves), and justify why Bohlen-Pierce is a 13-note scale.
Just ratios, of course, are rational numbers, but when converted to cents (or divisions of an octave or tritave) they become irrational numbers. Continued fractions are used to find an EDO or EDT that would approximate the just ratio.
The point being made here is that all six major consonant intervals based on the 3:5:7 chord (9/7, 7/5, 5/3, and their inversions) have 13 in the denominator of one of their convergents. Thus 13EDT is a great scale in which to approximate BP. On the other hand, if we do the same with the 4:5:6 major chord and octaves, 12EDO only approximates the perfect fourth and fifth well. Other EDO's with good fourths and fifths are 41EDO and 53EDO. Meanwhile, 19EDO estimates minor thirds the best, while 28EDO and 59EDO estimate major thirds the best. No single EDO plays all the consonant intervals well, while a single EDT sounds all of the BP consonances well. As the link points out, "Small wonder that this regime [the 12EDO "regime," that is] is under siege.
The following link at Dozens Online is doing the opposite:
http://z13.invisionfree.com/DozensOnline/index.php?showtopic=1724
Here we are taking the 12EDO scale and converting it to just intonation. The task is to convert each note into hertz (where A is 440 Hz, and each semitone has ratio 2^(1/12)) and then entering the number of hertz into a CF calculator. Even if we just use the Level-1 approximations, we are already finding just ratios for the 12EDO notes. For example, Bb is approximately 466 Hz, and so the interval from A to Bb is approximately 466/440 (= 233/220).
Now this is the second time today that I'm looking up something -- in this case, the application of continued fractions to music -- and I stumble upon something else. There is a link into this thread to a BASIC program written for another old computer, the Atari:
https://www.atariarchives.org/c3ba/page045.php
I've written before about the limitations of computer music based on Bridge 261. It's nice that we can play a just major scale, but we can only play one just major scale, based on green Bb. This is because the least common numerator of all the intervals of the just major scale is 180, and 180 * 2 is 360, which is already too big. Hence only one just major scale can be played.
Now according to this link, the Atari also has the same limitations -- but there is a special method to extend the range. In addition to 8-bit music, which is based on 2^8 = 256, there is apparently 16-bit music, based on 2^16 = 65536.
It's difficult to interpret the tables here. Apparently, even though there is a SOUND command, the values appear to be based on degrees, with no subtraction from a bridge needed. A side effect is that higher values correspond to lower notes, and vice versa.
Lowering a note an octave should double the degree, but the ratios between two notes an octave apart aren't exactly 2/1. So C#3 is listed under 8-bit as Degree 230, but C#4 is given as Degree 114 instead of the expected 115 (230/2). The 16-bit table has the same problem -- C#3 is Degree 6450, but C#4 is Degree 3422 instead of 3425, and so on. (Also, we notice that the 8-bit Degrees on the Atari are not the same as those on the Color Computer. On the Atari Middle C4 is Degree 121, but on the Color Computer we found Middle C to be Degree 162.)
But let's assume that these are approximations and that the degrees really are based on just intonation and exact ratios like 2/1. Then even though the link above was trying to convert 12EDO into degrees, consider what this implies for just intonation and other scales:
- In 8-bit, there is only one just major scale. In 16-bit, we have 65536/180 = 364 major scales. So we can play a different major scale every day of the year (except blank day of course).
- It's easy to modulate a song like Dolly Parton's "Hard Candy Christmas" up a whole tone -- by which we mean a justly tuned 9/8. The original scale must begin on a multiple of 180 * 9 (or 1620) and the new scale begins on a multiple of 180 * 8 (or 1440). There are still 65536/1620, or 40, different ways we can modulate a major scale by 9/8. It's even possible to play a song that can be modulated up by 9/8 twice -- begin on a multiple of 180 * 81 = 14580, which can be played in 65536/14580, or four, different ways.
- To play a 4:5:6:7:8 harmonic seventh chord required starting on a multiple of 210. There are now 65536/210 = 312 different harmonic seventh chords.
- In fact the New 7-Limit Scale was created around the limitations of 8-bit music. It's possible to create more 7-limit scales that have more otonal (or happier-sounding) notes since 16-bit can accommodate the higher numerators.
- The least common numerator of the Bohlen-Pierce scale is 3^3 * 5^2 * 7^2 = 33075. Hence a full just BP scale is playable in 16-bit. If we restrict ourselves only to the notes of the Lambda mode, then the least common numerator is only 1575. So there are 65536/1575 = 41 different Lambda scales that can be played. The easiest way to play a mode other than Lambda (such as Walker I) is to play Lambda starting from another note (F in this case).
- It's easier to extend beyond the 7-limit into the 11- and 13-limits. Multiples of 11 and 13 grow quickly in 8-bit but can be accommodated in 16-bit, as the product of all the primes up to 13 is only 30030, a 16-bit number.
- Just as 12EDO sounds better in 16-bit, it's possible to estimate other EDO's as well. EDL-based music isn't designed to accommodate EDO's, but with 65536 notes available it's easier to approximate any scale, including EDO's. With 8-bit, only lower EDO's are easy to approximate with only 16-EDO sounding reasonable of the EDO's past 12. In 16-bit, we expect to be able to go well beyond 16-EDO.
- According to the chart, 16-bit music goes deeper into the baritone and bass ranges. (I assume that the octaves are piano notation, so middle C is in Octave 4.) This is especially important for tritave music, since my strong tritave is from A2 to E4.
But all of this is for the Atari, not the Color Computer. The BASIC programs listed here can't be run on the Color Computer emulator, such as:
SOUND 0,0,0,0
This is an error on my computer. My SOUND command can only take two arguments, not four -- and none of those arguments are permitted to be zero. Still, I recognize the POKE command, which implies that machine language is being used. I wonder whether any of the music .BIN files on the Color Computer emulator are written in 16-bit.
Conclusion: "The Twelve Days of Christmath" (Vi Hart)
This is still the 12 days of Christmas, which run from December 25th-January 5th and end only at Epiphany on January 6th. (Yes, the 12 days of Christmas overlap the seven days of Kwanzaa.) And so I feel justified in posting another version of "The Twelve Days of Christmas" today. And besides, Vi Hart didn't post her version until the tenth day of Christmas, January 3rd. (Notice that the two religious calendars from earlier, Fixed Festivity and International Liturgical, accommodate Epiphany as well.)
But in these holiday posts, I want to fix/correct the songs I sang in my class last year. Last December I didn't write any original songs -- everything was either a Square One TV song, or a parody of a known song (either "Row, Row, Row Your Boat" or a Christmas song).
I tried to play Vi Hart's "The Twelve Days of Christmath" in class. The song didn't go too well, because many of the concepts she sings about are high school level or above. I really should have created my own version of the song with middle school math topics:
Vi's first verse is "the multiplicative identity." Even though many middle school students don't know what a multiplicative identity, the concept itself is simple -- even second graders should know that one times anything is the number itself.
Of course, Vi changes the words on every verse. Let's keep it simple and make it more like the original song, where the songs repeat each verse.
THE 12 DAYS OF CHRISTMATH
1. On the first day of Christmas, my true love gave to me,
The multiplicative identity. (same as Vi)
2. ...The only even prime,... (same as Vi)
3. ...The number of spatial dimensions... (same as Vi)
4. ...The number of sides of a square...
5. ...Give me a high-five! (not mathematical, but a nice mid-song pick-me-up)
6. ...The smallest perfect number...
7. ...The most common lucky number... (same as Vi)
8. ....The number of corners of a cube...
9. ...The number it all goes back to... (reference to Square One's Nine, Nine, Nine)
10. ...The base of Arabic numerals (same as Vi)
11. ...The number the amp goes up to... (same as Vi)
12. ...The number in a dozen...
Now let's program the Color Computer emulator. Because so many parts of the song repeat, let's just just use PLAY for this song. Actually, I notice that the Atari link above has lines like RESTORE 20140, which presumably means that only the DATA in line 20140 is restored. Hey, even the RESTORE command works better on the Atari. (I must find that Atari emulator!)
10 FOR V=1 TO 4
20 PLAY "O2;L8;CC;L4;C;L8;FF;L4;F"
30 PLAY "L8;EFGAB-G;L2;A"
40 IF V=1 THEN 80
50 FOR X=V TO 2 STEP -1
60 PLAY "O3;L4;C;O2;L8;GA;L4;B-"
70 NEXT X
80 PLAY "O3;L4;C;L8;D"
90 PLAY "O2;B-AF;L4;G;L2.;F"
100 NEXT V
110 FOR V=5 TO 12
120 PLAY "O2;L8;CC;L4;C;L8;FF;L4;F"
130 PLAY "L8;EFGAB-G;L2;A"
140 IF V=5 THEN 180
150 FOR X=V TO 6 STEP -1
160 PLAY "O3;L4;C;O2;L8;GAB-G"
170 NEXT X
180 PLAY "O3;L2;C;L4;D;O2;B;O3;L1;C"
190 PLAY "L8;C;O2;B-AG;L4;F"
200 PLAY "B-DF;L8;GFED;L4;C;L8;AB-"
210 PLAY "O3;L4;C;L8;D"
220 PLAY "O2;B-AF;L4;G;L2.;F"
230 NEXT V
Happy third day of Kwanzaa! Happy fourth day of Christmas! My next post will be New Year's Eve.
No comments:
Post a Comment