Tuesday, September 18, 2018

Lesson 2-4: Converses (Day 24)

Chapter 2 of Eugenia Cheng's The Art of Logic in an Illogical World is called "What logic is." Here's how it begins:

"If I eat chocolate then I am happy. Is that logical?"

Cheng asks several similar questions about what is or isn't logical -- how touching wood makes her feel better, and how it's often cheaper to fly to a suburb of London than the capital itself, even though the plane actually lands in London en route to the suburb. But then Cheng's next example is:

"If you are white, then you have white privilege. Are these things logical?"

Again, I remind you that Cheng writes about race and politics throughout her book. If you prefer not to read this, then I suggest that you avoid this blog for the next three weeks and skip all posts that have the "Eugenia Cheng" label.

Cheng proceeds:

"The innocuous little word 'if' has a whole range of slightly different means. Some of them, but not all of them, encapsulate the most important building block of logical argument -- logical implication."

Again, I'm glad that our side-along reading of Cheng's book lines up with Chapter 2 of the U of Chicago text -- didn't we just read about "if" in Lessons 2-2 and 2-3? Anyway, the author shows us how important logic is to the study of mathematics:

"Logic is to mathematics as evidence is to science."

But Cheng provides us many uses of "if" in English that aren't logical. "If I eat chocolate then I am happy" is a personal taste, not logic. "If you eat your broccoli then you can have ice cream" is a bribe, not logic. "If you walk my dog for me then I'll pay you twenty quid" is an agreement, not logic. "If you are over 75 then you don't have to take your shoes off when going through airport security" is a rule, not logic:

"The difference is a bit blurry in real life, but we can try and find the distinction by thinking about examples."

The author tells us that the above examples are better described as "non-logical" or "alogical" rather than illogical. For examples of logical statements, Cheng returns to the contentious example:

  • If you have white privilege then you have privilege.
  • If you are white then you have white privilege.
  • If you are white in Europe or the US then you have white privilege.
  • If you are white in a place that has white privilege then you have white privilege.
Cheng points out that the last statement is logical because it's almost tautological (or pointless). The statements above depend on the definition of "white privilege," which she will discuss in more detail in a later chapter.

"If we continue to use normal everyday language we are doomed to have problems being completely logical because the words we use are not completely logically defined, but we can get close enough that to call it anything other than logical would, in my opinion, be pedantry rather than precision."

Cheng next writes about social services. Here she distinguishes between false negatives -- those who deserve help but don't get it -- and false positives -- those who don't deserve help but do get it:
  • If you care more about false negatives than false positives you will believe in expanding social services.
  • If you care more about false positives than false negatives you will believe in expanding social services.
I've thought about this myself (but never blogged about it, since such politics is usually off-topic for this blog), but I could never express myself as elegantly -- or logically -- as Cheng does here. And in fact, she compares social services to jetlag:
  • If you're better at staying awake tired than falling asleep not tired you should deprive yourself of sleep in advance of crossing time zones.
  • If you're better at falling asleep not tired than staying awake tired you should deprive yourself of sleep in advance of crossing time zones.
Cheng writes that these two ideas are similar. Staying awake when tired is a false positive, while falling asleep when not tired is a false negative. She writes that she herself is a false positive, so she stays awake before she travels across the pond.

The author proceeds to write about how logic leads to discovery:

"If a statement follows from pure logic then it has to be true, automatically. Saying it out loud doesn't exactly add new information, but it does add new insight."

To illustrate this, Cheng returns to her white privilege example again:
  1.  If you are white then you have white privilege.
  2. If you have white privilege then you have privilege.
From these two statements we now have the implication "if you are white then you have privilege."

Now Cheng tells the remarkable story of Kyle MacDonald, an internet legend who ultimately traded a paper clip for a house. Here's how he did it:

paper clip -> pen shaped like a fish -> hand-sculpted doorknob -> camping stove -> 1000-watt generator -> "instant party" (beer keg with neon sign) -> snowmobile -> two-person trip to Yakh, British Columbia -> a large van -> a recording contract with Metalworks -> a room for a year in Phoenix, Arizona -> an afternoon with rock star Alice Cooper -> a part in a Corbin Bernsen film -> a house in Kipling, Saskatchewan

Of this story, the author writes:

"But I am really fascinated by this mental version of an optical illusion, where you can take tiny steps that don't seem too surprising, and get somewhere that is extremely surprising and a very long way from where you started. This is how logic works."

And of course, we do this all the time in Geometry classes -- we call it a "proof." Cheng writes about another example -- in his book The Power of Habit, Charles Duhigg argues that requiring a higher level of science achievement in teachers would eventually reduce birth defects in babies:

"It is an example of a masterful construction of a long chain of implications in normal life."

Now Cheng introduces the formal notation for implications. We've seen this notation a few days ago in Lesson 2-2 of the U of Chicago text -- "A => B" means "If A then B" or "A implies B." (Even though the notation appears in Lesson 2-2, I don't use it on a worksheet until tonight's lesson.)

She tells us that a proof is basically a whole series of implications strung together like this:

A => B
B => C
C => D

We can then conclude that A => D. Here are some longer chains of implications given by Cheng:

  1. If you say women are inferior, that is insulting to women.
  2. If you think that "feminine" is an insulting way to describe a man, you are saying that women are inferior.
  3. Therefore if you think that "feminine" is an insulting way to describe a man, you are insulting women.
Here is another:
  1. If you don't stand up for minorities being harassed then you are letting bigotry flourish.
  2. If you let bigotry flourish you are complicit with bigotry.
  3. If you are complicit with something bad then you are almost as bad as it.
  4. Therefore if you don't stand up for minorities being harassed you are almost as bad as a bigot.
Cheng points out that whether A is true for a particular person has no effect on whether the entire implication A => B is true:

"'If you are a US citizen or permanent resident you are required to have health insurance' is true whether or not you are in fact a citizen or resident. The implication doesn't tell us whether or not someone needs health insurance; we only know they do if we already know they are a citizen or resident."

The author tells us that there are several things we must check before we attempt to start a proof:
  1. We should carefully define the concepts we're talking about.
  2. We should carefully state the assumptions we're making.
  3. We should carefully state exactly what we're going to prove, in an unambiguous way.
Here Cheng writes about something I've mentioned a few times on the blog -- the gender pay gap:

"For example, in arguments about why women earn less than men, on average, sometimes people assume that women don't care about earning money as much as men do."

But, as the author goes on to point out, she doesn't accept the implication that if women don't care about making money then they should be paid less for the same job. Cheng puts it succinctly and flatly: "I think that is exploitation."

Cheng warns us that arguments might break down due to problems of knowledge:
  • Unstated assumptions, or using stated assumptions incorrectly.
  • Incorrect definitions, or incorrect use of definitions.
Here is an example from the book: "...in arguments about clinical depression when people assume that depression is caused by circumstances and therefore there is no reason a successful person should be depressed."

Proofs also break down due to problems of logic:
  • Gaps in the logic; leaping from one statement to another without justifying it, or leaving out too many steps in between.
  • Incorrect inferences: this is when a logical step is made that is actually incorrect, where you say something follows from something else, but it doesn't.
  • Handwaving: arriving at a conclusion without true use of logic, but by metaphorically waving your hands around enough that people think you are.
  • Incorrect logic: there are many subtle ways that incorrect logic can get slipped into arguments as logical fallacies....
"An example of an incorrect inference is the view that 'scientists agree with each other, which shows there is a conspiracy.'"

Cheng repeats a story first told by Stephen Hawking -- an audience member insists that the world is standing on the back of a turtle, and in fact, "it's turtles all the way down." But we must be sure that our proofs start somewhere rather than stand on an infinite stack of turtles:

"Where does all this originate from? As I have mentioned, I think the process of working backwards is just like small children who ask 'Why?' repeatedly."

There are some questions that logic can't answer, like "Do I exist?" or "What is the meaning of life?":

"To be a moderately functioning adult, we have to stop asking those questions at some point -- not necessarily permanently, but at least for some part of every day."

And so in logic we must start with some basic assumptions -- which the author calls "axioms" -- with which everyone agrees beforehand. Another word for "axiom" is "postulate" -- and that's the word that appears in most Geometry texts, including Lesson 1-7 of the U of Chicago text.

Cheng concludes with a preview of the next chapter:

"The logic must all flow out of that starting point. In the next chapter we'll talk about the direction of that flow. Like time, logic has a direction and we must not try to violate it."

Lesson 2-4 of the U of Chicago text is called "Converses." (It appears as Lesson 2-3 in the modern edition of the text.)

This is what I wrote last year about today's lesson. 

There is a little bit of politics near the end of this post, because I'd perceived one of the examples of fallacious reasoning (assuming that a statement and its converse are equivalent) as one often committed by Republicans. So I added a similar fallacy made by Democrats in order for this post to remain politically balanced -- the point being made that both parties are prone to making logical fallacies. But only the example from the text actually appears on the worksheet:

[2018 update: When I wrote this last year, I was worried posting too much about politics. But the examples I gave in this post are tame compared to what Cheng writes in Chapter 2 of her book! It all goes to show that the easiest examples of logical vs. illogical statements to find are political.]

Lesson 2-4 of the U of Chicago text deals with an important concept in mathematical logic -- converses. We know that every conditional statement has a converse, found by switching the hypothesis and conclusion of that conditional.

The conditional "if a pencil is in my right hand, then it is yellow" has a converse, namely -- "if a pencil is yellow, then it is in my right hand." The original conditional may be true -- suppose all the pencils in my right hand happen to be yellow -- but the converse is false, unless every single yellow pencil in the world happens to be in my right hand. A counterexample to the converse would be a yellow pencil that's on the teacher's desk, or in a student's backpack, or even in my left hand -- anywhere other than my right hand.

If converting statements into if-then form can be confusing for English learners, then writing their converses is even more so. Here's an example from the text:

-- Every one of my [Mrs. Wilson's] children shall receive ten percent of my estate.

Converting this into if-then form, it becomes:

-- If someone is Mrs. Wilson's child, then he or she shall receive ten percent of the estate.

Now if a student -- especially an English learner -- blindly switches the hypothesis and the conclusion, then the following sentence will result:

-- If he or she shall receive ten percent of the estate, then someone is Mrs. Wilson's child.

But this is how the book actually writes the converse:

-- If someone receives ten percent of the estate, then that person is Mrs. Wilson's child.

In particular, we must consider the grammatical use of nouns and pronouns. In English, we ordinarily give a noun first, and only then can we have a pronoun referring to that noun. Therefore the hypothesis usually contains a noun, and the conclusion usually contains a pronoun. (Notice that grammarians sometimes refer to the noun to which a pronoun refers as its antecedent -- and of course, the text refers to the hypothesis of a conditional as its antecedent. So the rule is, the antecedent must contain the antecedent.)

And so when we write the converse of a statement, the hypothesis must still contain the noun -- even though the new hypothesis may be the old conclusion that contained a pronoun. So the converse of another conditional from the book:

-- If a man has blue eyes, then he weighs over 150 lb.

is:

-- If a man weighs over 150 lb., then he has blue eyes.

Saying the converse so that it's grammatical may be natural to a native English speaker, but may be confusing to an English learner.

Now let's look at the questions to see which ones are viable exercises for my image upload. An interesting one is Question 9:

A, B, and C are collinear points.
p: AB + BC = AC
q: B is between A and C

and the students are directed to determine whether p=>q and q=>p are true or false. Now notice that the conditional q=>p is what this text calls the Betweenness Theorem (and what other books call the Segment Addition Postulate). But p=>q is the converse of the Betweenness Theorem -- and the whole point of this chapter is that just because a conditional is true, the converse need not be true. (Notice that many texts that call this the Segment Addition Postulate simply add another postulate stating that the converse is true.)

Now the U of Chicago text does present the converse of the Betweenness Theorem as a theorem, but the problem is that it appears in Lesson 1-9, which we skipped because we wanted to delay the Triangle Inequality until it can be proved.

Here, I'll discuss the proof of this converse. I think that it's important to show the proof on this blog because, as it turns out, many proofs of converses will following the same pattern. As it turns out, one way to prove the converse of a theorem is to combine the forward theorem with a uniqueness statement. After all, the truth of both a statement and its converse often imply uniqueness. Consider the following true statement:

-- Donald Trump is currently the President of the United States.

We can write this as a true conditional:

-- If a person is Donald Trump, then he is currently the President of the United States.

The converse of this conditional:

-- If a person is currently the President of the United States, then he is Donald Trump.

This converse is clearly true as well. By claiming the truth of both the conditional and its converse, we're making a uniqueness statement -- namely that Trump is the only person who is currently the President of the United States.

So let's prove the converse of the Betweenness Theorem. The converse is written as:

-- If A, B, and C are distinct points and AB + BC = AC, then B is on AC.
(I explained why segment AC has a strikethrough back in Lesson 1-8.)

Proof:
Let's let AB = x and BC = y, so that AC = x + y. To do this, we begin with a line and mark off three points on it so that B is between A and C, with AB = x and BC = y. This is possible by the Point-Line-Plane Postulate (the Ruler Postulate). By the forward Betweenness Theorem, AC = x + y.

Now we want to show uniqueness -- that is, that B is the only point that is exactly x units from A and y units from C. We let D be another point that is x units from A, other than B. By the Ruler Postulate again, D can't lie on AC -- it can only be on the same line but the opposite side of A (so that A is between D and C), or else off the line entirely (so that ACD is a triangle).

In the former case, the forward Betweenness Theorem gives us AC + AD = DC. Then the Substitution and Property of Equality give us DC = (x + y) + x or 2x + y, which isn't equal to y (unless 2x = 0 or x = 0, making A and D the same point when they're supposed to be distinct).

In the latter case, with ACD a triangle, we use the Triangle Inequality to derive AD + DC >AC. Then the Substitution Property gives us x + CD > x + y, and then the Subtraction Property of Inequality gives us the statement CD > y, so DC still is not equal to y.

So B is the only point that makes BC equal to y -- and it lies on AC. QED

(The explanation in the book is similar, but this is more formal.) Later on, we're able to use this trick to prove converses of other theorems. So the converse of the Pythagorean Theorem will be proved using the forward Pythagorean Theorem plus a uniqueness statement -- and that statement is SSS, which tells us that there is at most one unique triangle with side lengths a, b, and c up to isometry. And, more importantly, the converse to the what the text calls the Corresponding Angles Postulate (the forward postulate is a Parallel Test, while the converse is a Parallel Consequence) can be proved using forward postulate plus a uniqueness statement. The uniqueness statement turns out to be the uniqueness of a line through a point parallel to a line -- in other words, Playfair's Parallel Postulate. This explains why the forward statement can be proved without Playfair, yet the converse requires it.

In the end, I decided to throw out Question 9 -- I don't want to confuse students by having a statement whose converse requires the Triangle Inequality that we skipped (and the students would likely just assume that the converse is true without proving it) -- and used Question 10 instead.

But now we get to Question 13 -- and here's where the controversy begins. I like to include examples in this lesson that aren't mathematical -- doing so might engage students who are turned off by doing nothing but lifeless math the entire period. This chapter on mathematical logic naturally lends itself to using example outside of mathematics. But the problem is that Question 13 is highly political. Written in conditional form, Question 13 is:

-- If a country has communist, then it has socialized medicine.

and its converse is:

-- If a country has socialized medicine, then it is communist.

[2018 update: Here I snip out the long discussion -- once again, if I were too worried about what I'm including in this post, then I would have skipped Cheng's book altogether.]

In the end, I will include Question 13 on the worksheet. But I left a space so that if a teacher feels that the question is politically slanted, then he or she could add another question to balance it. For example, that teacher can add a fallacious argument often made by Democrats, for example:
  • If a white person is racist, then he or she opposes Obama.
  • If a white person opposes Obama, then he or she is racist.
Of course, this question adds a new layer of controversy (race) to the mix. Teachers who want to add a balancing question should just write in their own question, or just throw out the question about socialized medicine altogether.

In the review section, I'd have loved to include Question 15, a review of the last lesson on programming (and of course changed it to TI-BASIC). But in deference to those classes that skipped the lesson because not every student has a graphing calculator, I've thrown it out and included only questions from the fully covered Lessons 2-2, 1-8, and 1-6.



Monday, September 17, 2018

Lesson 2-3: If-then Statements in Computer Programs (Day 23)

Today I subbed in my old district -- believe it or not. Thus it really is Day 23 in this district. (In my new district, today is Day 15.)

It's a special ed class -- in fact, it's for the exact same teacher whose class I covered the last time I subbed in this district -- which was May 18th. Thus you can refer back to my May 18th post in order to recall some information about this class. Again, I won't bother to do a "Day in the Life" for this special ed class (since I didn't do one for May 18th either).

Notice that May 18th was a Friday, while today is Monday. This school has a block schedule, with all classes on Fridays (which are also late days) so that the schedule aligns with days of the week. Then Mondays become odd period days. Thus first, third, and fifth periods meet today.

Also, this is a new school year, so the teacher's schedule is slightly different -- though many of the special ed students are the same as last year. But like last year, first period is observing (co-teaching) Algebra I -- which marks only the second time I've been in a math class in this district (with the first being observing this same class in May)!

And as it turns out, the resident teacher for this class is also out with a sub. He informs me that he's not a math teacher, and so I help out with the math while he takes attendance, passes out the worksheets, and collects them. The worksheets are labeled as Lessons 2-1 and 2-2 -- but recall that this text isn't exactly the same as the Glencoe text. In particular, Chapter 2 of Glencoe is on solving equations while second chapter of this text is on inequalities.

One student in particular struggles with graphing simple inequalities and converting English sentences into inequalities. I believe that I'm able to help him understand the material better. One of the questions ask the student to set up the inequality for "For an upcoming marathon, the qualifying time for males age 18-34 is three hours." I inform him that yesterday, a world record was set in the marathon -- 2:01:39, set by Eliud Kipchoge of Kenya. (By the way, another world record was also set yesterday -- Kevin Mayer of France scored 9,126 points in the decathlon.)

In this class, I see vertical non-permanent surfaces (VNPS) -- three small whiteboards are mounted on the walls. But I suspect that the whiteboards are for fifth period AVID meetings, not math class -- though more often than not, the subject the AVID tutors help the students out with is math. (Some math problems are still written on each VNPS.) The students also have Interactive Notebooks in which to cut and paste their notes.

The other two blocks are both Academic Enrichment. Another teacher is supposed to come in for a special 30-minute lesson, but she doesn't show. So instead, the classes just study independently for the entire time. A special aide is there -- she keeps the students working the whole block. I help out any students who are working on math.

One senior is enrolled in Algebra II -- yes, it's a rarity when a special ed student makes it that far. And most of the other students are enrolled in an Algebra I class spread out to two years. The senior is working on graphing parabolas in vertex form. He must also identify the transformations to obtain each parabola starting from the parent function y = x^2.

In some ways, it might have been more logical for me to sub for the actual math teacher while the other non-math sub covered my Academic Enrichment. But actually, on odd days it makes little difference, since the math teacher has third period conference and fifth period AVID. If today had been an even block day, then yes -- I really should have been assigned the math class.

As far as classroom management is concerned, I notice that the non-math sub -- since the math teacher doesn't leave a seating chart -- takes attendance by writing each student's name on a little makeshift chart of his own. This is a lot of work, but he must think it's worth it -- the chart helps him manage the class better. Thus I decide to do the same in the Academic Enrichment classes -- great classes to try it out in, since they're small special ed classes with about ten students each. I also notice that my regular teacher writes each name on the board along with the subject (math, English, etc.) the student claims to be working on during the entire block, so this fits with my list of names.

Good news -- my copy of Eugenia Cheng's newest book indeed arrived over the weekend. And so let's start our side-along reading! (This is another reason why I didn't make Ruth Parker's Number Talks the side-along reading book -- I'd already known by then that Cheng's book was forthcoming!)

By the way, many traditionalists might not like what Cheng has to say in her book. And as I warned earlier, she also gets into politics -- including race -- as well. I've said in the past that I avoid race and politics in school-year posts unless the "traditionalists" label appears. Today, I'll extend that to the "Eugenia Cheng" label as well. Traditionalists who prefer to skip these controversial subjects should avoid all "Eugenia Cheng"-labeled posts -- and stay away from this blog for the next three weeks.

When we read her first two books, I skipped around and covered only some chapters. My goal this time is to discuss her entire book during the three-week library loan period. So let's dive right in:

Chapter 1 of Eugenia Cheng's The Art of Logic in an Illogical World is called "Why Logic?" It's the first chapter of Part I, "The Power of Logic." Here's how it begins:

"The world is a vast and complicated place. If we want to understand it we need to simplify it. There are two ways to make something simpler -- we can forget parts of it, or we can become cleverer so that things that used to seem incomprehensible become clear to us."

Cheng tells us that logic involves both aspects of making something simpler. She continues:

"Anyone can make claims about what they think is true, but unless they back up their claims in some way, maybe no one will believe them, and rightly so. So different subjects have different ways of accessing truth."

But she points out that many people believe their arguments are logical when they really aren't:

"Instead of simply lamenting the misunderstanding of logic and mathematics, I choose to address it, in the hope that their power might actually be used to good purpose. That's why I've written this book."

The author explains that logic establishes clear rules so that the same conclusions can be arrived at by different people:

"This is wonderful in theory, and perhaps here 'in theory' means in the abstract world of mathematics. Mathematics has a remarkable ability to make progress."

She tells us that its logical grounding is the reason that, while science is always being updated, math remains a constant. The Pythagorean Theorem is just as valid now as it was when the ancient Greek mathematician first devised it:

"We are going to show that accessing the logical abstract world enables us to get further in the real world, just as flying through the sky enables us to travel further and faster in real life. In essence, this is the whole point of mathematics."

First, Cheng seeks to define what math is -- and isn't. Her ideas here echo the big traditionalists' debate that has heated up in recent weeks. This example hits home, since it's a Geometry example:

"Show that angle A is half of angle B."

The diagram shows a bunch of lines drawn at random, with two angles marked A and B. The author warns -- or reassures -- us that this example is a spoof and can't be solved. She tells us that math is:

"Not a series of hoops to jump through, not an attempt to get the 'right answer,' but a world to explore, discover and understand: the logical world. At this point some people realize that the thing they liked about 'math' up until then was jumping through hoops and getting the right answer."

And those people are called "traditionalists." Anyway, here is Cheng's definition of mathematics:

"Mathematics is the logical study of how logical things work."

Anyway, logic has rules, just as sports have rules:

"One problem with logic, as with sport, is that the rules can be baffling if you're not very used to them. I am pretty baffled by the rules of American football."

And Cheng points out that her being British has nothing to do with it -- she's confused by the rules of soccer as well.

Similarly, many people are confused by the rules of logic. Part of the confusion has to do with the meaning of the word "theory":

"In science, a 'theory' is an explanation that is rigorously tested according to a clear framework, and deemed to be statistically highly likely to be correct. In mathematics, though, a 'theory' is a set of results that has been proved to be true according to logic."

While math is all about certainty, the real world is uncertain:

"Some of the disagreement around arguments in real life is unavoidable, as it stems from genuine uncertainty about the world. But some of the disagreement is avoidable, and we can avoid it by using logic."

And indeed, the real world isn't completely logical. Cheng gives a real-world example:

"If you give a child a cookie and another cookie, how many cookies will they have? Possibly none, as they will have eaten them."

(Yes, it's only Chapter 1 and Cheng has already mentioned her favorite example -- baked foods.) Now she compares this to the world of the abstract:

"If I add one and one under exactly the same conditions in the abstract world repeatedly, I will always get 2. (I can change the conditions and get the answer as something else instead, but then I'll always get the same answer with those new conditions too.)

The author tells us that math is all about searching for the similarities between different things:

"When we look for similarities between things we often have to discard more and more layers of outer details, until we get to the deep structures that are holding things together. This is just like the fact that we humans don't look extremely alike on the surface, but if we strip ourselves all the way down to our skeletons we are all pretty much the same."

In her next example, Cheng writes about the newly painted green lines near subway tracks in London:

"The aim was to try and improve the flow of people and reduce the terrible congestion, especially during the rush hour. This sounds like a good idea to me, but it was met with outcry from some regular commuters."

And this is because they liked the "competitive edge" they'd gained from knowing exactly where to stand so that the doors opened right in front of them. Now those green lines gave away their secrets!

Here's the first of many references to politics and race in Cheng's book:

"This complaint was met with ridicule in return, but I thought it gave an interesting insight into one of the thorny aspects of affirmative actions: if we give particular help to some previously disadvantaged people, then some of the people who don't get help are likely to feel hard done by."

Cheng tells us that logic is all about the inherent, not the coincidental:

"The inherentness means that we should not have to rely on context to understand something. We will see that our normal use of language depends on context all the time, as the same words can mean different things in different contexts, just as 'quite' can mean 'very' or 'not much.'"

Because of this, if we start with ambiguous concepts, we end up with ambiguous results:

"We can use extremely secure building techniques, but if we use bricks made of polystyrene we'll never get a very strong building. However, understanding mathematical logic helps us understand ambiguity and disagreement."

At this point Cheng summarizes the contents of her third book:

"In the first part of this book we are examining what logic is as a discipline for building arguments, and as a piece of mathematics. In the second part we'll see what the limitations of logic are. And in the third part we'll see how important it is, given those limitations, to take our emotions seriously."

But the English language contains many ambiguities -- after all, it's being spoken by humans, not the super-logical Vulcans of Star Trek:

"As adults we develop the ability to become more relaxed about figurative language, and more relaxed about how precise we need things to be in order to get on with our lives. This is a bit like how accurately you need to measure things."

(And here comes Cheng's second baking example already!) The author tells us how she can be a little off in measuring sugar to bake a cake, but when she's making macaroons she must be more precise.

In conclusion, Cheng tells us that the purpose of logic is to shine a light on something:

"In all cases the aim should be illumination of some kind. First we need some light, and then we can decide where, and how, to shine it."

It's perhaps fitting that our reading of Cheng's book on logic lines up with Chapters 2 and 3 of the U of Chicago text. After all, these chapters focus on the logical foundation of Geometry. (In my old Second Edition, Chapter 13 also contains some logic, but in the modern Third Edition, much of the logic from Chapter 13 has been moved to Chapters 2-3.)

Lesson 2-3 of the U of Chicago text is called "If-then Statements in Computer Programs." It does not appear in the modern Third Edition of the U of Chicago text, and we can see why when we look a little at what I wrote last year on the subject:

Lesson 2-3 of the U of Chicago text discusses computer programs written in BASIC. We must remind ourselves that this book was written over 20 years ago, back when BASIC was a popular language. But now, BASIC has been derided as "spaghetti code" and isn't as widely used anymore.

And so the Third Edition avoids this issue by leaving out this lesson entirely. Two years ago, I changed the lesson to use TI-BASIC, the language of the TI graphing calculator, instead. But today I have do access to something that runs BASIC programs -- the emulator of my old 1980's computer:

http://www.haplessgenius.com/mocha/

[2018 Update: Whereas human languages such as English are illogical, computer languages are supposed to be logical. Yet according to Cheng, even her computer doesn't always act logically.]

So for today, I'll post the old TI-BASIC worksheets from last year. But I'm actually going to write about BASIC itself using the emulator.

Let's start by writing the four BASIC programs used in the U of Chicago text. All four of these programs run on the emulator:

Program #1: Number of Diagonals in Polygon

10 PRINT "COMPUTE NUMBER OF DIAGONALS IN POLYGON"
20 PRINT "ENTER THE NUMBER OF SIDES"
30 INPUT N
40 IF N>=3 THEN PRINT "THE NUMBER OF DIAGONALS IS "; N*(N-3)/2
50 END

Program #2: Inventory of Electro-Robots

10 PRINT "INVENTORY OF ELECTRO-ROBOTS"
15 PRINT "ENTER THE NUMBER OF ELECTRO-ROBOTS"
20 INPUT N
25 PRINT "PROFIT EQUALS";5*N-1500
30 IF N<300 THEN PRINT "ORDER MORE ELECTRO-ROBOTS."
35 END

Program #3: Area of Circle

10 INPUT R
20 LET A=3.14159*R*R
30 IF R>0 THEN PRINT R,A
40 END

Program #4: Diagonals in Many Polygons

10 PRINT "NUMBER OF DIAGONALS IN POLYGONS"
20 FOR N=3 TO 20
30 PRINT "THE NUMBER OF SIDES IS";N
40 PRINT "THE NUMBER OF DIAGONALS IS";N*(N-3)/2
50 NEXT N
60 END

All of these programs work on the emulator. Actually, my computer doesn't require the last line of the program to be END -- we could omit each of those final lines. Also, my computer doesn't require line 20 of Program #3 to begin with LET -- just 20 A=3.14159*R*R is sufficient. Don't forget to type in NEW to erase the old program before entering the new one.

Now let's write some programs of our own. Earlier when we were reading Ogilvy, there was mention of a GCD algorithm. Let's try to write it in BASIC.

The main problem here is that BASIC doesn't do long division with quotient and remainder -- instead it only does decimal division (or "floating-point division"). Remainders, as we see above, are critical to the algorithm. But it's possible -- though not easy -- to use floating-point division for remainders.

Let's go back to the example above -- the GCD of 30 and 108. We need the remainder of 108/30, but if we ask BASIC to find 108/30, it calculates it as 3.6. We need to convert 3.6 into a remainder.

The key function is the INT function. INT represents the ceiling function in mathematics (as in the greatest-integer function). So INT(3.6)=3. Well, this gives us the quotient, but we need the remainder.

Hmmm, the part that relates to the remainder is the fraction part. We can find this by subtracting the integer part from the original number: 3.6-INT(3.6)=.6. This fractional part is 18/30, so we must multiply it back by 30 to obtain the remainder -- 18.

Theoretically, this should work. The problem is that all this division produces rounding errors -- and such rounding can lead to incorrect answers. For example, let's go back to Program #3 that calculates the area of a circle. If we try entering a radius of 4 or 5, there is a rounding error that becomes obvious after trying a radius of 1, 2, or 3 first:

r     Area (as given by emulator)
1    3.14159
2    12.56636
3    28.27431
4    50.2654401
5    78.5397501

That "01" at the end of the areas for 4 and 5 stick out like a sore thumb. And no, the "01" has nothing to do with using pi to more accuracy, since it would be 50.2654825 instead (and besides, we never gave the program those extra digits of pi).

The reason for the inaccuracy is that computers work in binary, not decimal. The decimal 3.14159 actually means 3+14159/100000, but fractions with a denominator of 100000 (or anything other than a power of two) can't be expressed exactly in binary. The difference between 3.14159 and whatever binary fraction the computer uses is small enough not to appear when multiplying by 4 or 9, but when we multiply by 16 or 25 it appears. This problem never occurs if we only use binary fractions such as .5, .125, and so on.

And this is just multiplication -- in division, we're even more likely to have rounding errors. We know that fractions like 1/3 trip us up in both decimal and binary. Here, we must multiply .6 by 30 to obtain our remainder 18, but .6 isn't a binary fraction. Therefore, we'll obtain something like 17.9999999 or 18.0000001 instead of 18 as the remainder. This will trip up the algorithm -- it's supposed to stop when the remainder is zero, but it'll never reach zero if we have 17.9999999 or 18.0000001.

Using INT will work if we have 18.0000001, but INT(17.9999999)=17 instead of the desired 18. To solve this problem, we implement 4/5 rounding by adding .5 to the number before taking INT. This works, since both INT(18.4999999) and INT(18.5000001) are equal to 18.

Here is our GCD program, written in BASIC:

10 PRINT "INPUT TWO NUMBERS"
20 INPUT A,B
30 IF B=0 THEN PRINT "THE GCD IS";A: END
40 Q=A/B
50 R=INT((Q-INT(Q))*B+.5)
60 A=B
70 B=R
80 GOTO 30

You may notice a few things about how this program is written:

-- The program doesn't end with END. In fact, END appears at the end of line 30, because we really want the program to end after printing the GCF rather than proceed to line 40.
-- LET is omitted, as my computer allows.
-- INPUT A,B allows us to enter both numbers using a comma.
-- The strange part is that the IF statement (which is the subject of Lesson 2-3) appears near the start of the program. Actually, most GCD programs are written this way, in order to safeguard against the user entering 0 as one of the numbers. The program ends before reaching line 40 and thus avoids division by zero.
-- After the division, if the remainder R=0, then the final answer is in B. But the values in B and R have moved to A and B before we reach the GOTO and IF statements. Therefore B is the value that we test for zero, and A contains the final answer.

Notice that in TI-BASIC, we have a fPart function that gives us the fractional part directly without needing int. To avoid rounding error, we use the round function -- 0 here means no decimal places (nearest integer):

PROGRAM:GCD
:Disp "2 NUMBERS"
:Input A
:Input B
:While B
:round(fPart(A/B)B,0)->R
:B->A
:R->B
:End
:A

In this program, both Goto and If are avoided because we used a While loop instead. The While loop does the testing -- the loop is executed while B is true (nonzero) and stops when it is false (0). Here the word End ends the While loop, not the program.

In other languages, such as C++, there is a % operator that gives us remainder directly. Here is how we'd write the gcd function:

int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

Here we replaced "if" with the ternary operator ?: -- it means "If b is true (nonzero), then recursively call gcd on b and a%b (the remainder), else the answer is a."

OK, let's get back to BASIC. It's a shame that I didn't stumble onto the emulator back when I was writing about music over the summer on the Pappas music pages. Now that I have the emulator, I can't help but try to play microtonal music using the SOUND command in BASIC.

In an earlier post, we discovered that the most important number when making music using SOUND on the computer is 261. As it turns out, SOUND is based on EDL, or equal divisions of length, where the length of the string is the number of steps it takes to get to 261, the "bridge." For example, Sound 61 is 200 steps away from the bridge, while Sound 161 is 100 steps away from the bridge. Thus the interval between Sounds 61 and 161 is 200/100 or 2/1, which is an octave. (To make it easier to understand, the word "Sound" refers to the actual number used in the SOUND command, while "Degree" refers to the number of steps from away from Bridge 261.)

[2018 Update: Obviously, last year I used today's BASIC post as an excuse to go back to Mocha music written in BASIC. Since then I've written too many Mocha music posts. So let me cut most of this out except for the part that actually relevant to today's lesson -- using the IF command.]

10 INPUT "EDO";N
20 DIM R(N), D(N)
30 FOR S=0 TO N
40 R(S)=2^(S/N)
50 NEXT S
60 M=N
70 FOR L=12 TO 260 STEP 2
80 PRINT "TESTING EDL";L
90 E=0
100 FOR S=0 TO N
110 D=L/R(S)
120 E=E+ABS(D-INT(D+.5))
130 NEXT S
140 IF E>=M THEN 190
150 FOR S=0 TO N
160 D(S)=INT(L/R(S)+.5)
170 NEXT S
180 M=E
190 NEXT L
200 CLS
210 PRINT "PLAYING SCALE"
220 FOR S=0 TO N
230 PRINT "DEGREE";D(S);"SOUND";261-D(S)
240 SOUND 261-D(S),4
250 NEXT S
261 END

(Note: Line 40 requires an up-arrow where you see the ^ caret.)

Here's how the program works -- the user inputs the desired EDO in line 10. Lines 30-50 set up the correct ratios for your EDO -- so if you choose 12EDO, then the ratios are 2^(0/12), 2^(1/12), 2^(2/12), all the way up to 2^(12/12).

Lines 70-190 set up a loop to test every EDL, from the shortest (12EDL) to the longest (260EDL). It calculates the error E between the correct ratio and closest possible degree available (notice how INT(D+.5) is used to round D to the nearest degree). The IF statement in line 140 is used to see whether E is less than the minimum error M encountered so far. If E>=M, then we skip to line 190 and check the next EDL. If E<M, then we have a new "best EDL so far," and lines 150-170 set up a loop to replace the list of "degrees of the best EDL so far" with the new list.

Afterwards, the final loop from lines 220-250 actually play the best scale on the computer. (Don't forget to click the "Sound" box in order to hear the sound!) I decided to make the length 4 because just as the magic number for pitch is 261, the magic number for duration is 32 (whole note). As today's the start of the second quaver, let's make it play quavers, so 32/8 = 4. The final END line isn't needed, but I include it just as an excuse to honor Bridge 261 with a line 261.

Here are the best possible scales the computer found for some EDO's:

5EDO: use 256EDL (Degrees 256, 223, 194, 169, 147, 128 -- Sounds 5, 38, 67, 92, 114, 133)
7EDO: use 156EDL (Degrees 156, 141, 128, 116, 105, 95, 86, 78)
10EDO: use 256EDL (add Degrees 239, 208, 181, 158, 137 in between 5EDO)
12EDO: use 232EDL (Degrees 232, 219, 207, 195, 184, 174, 164, 155, 146, 138, 130, 123, 116)
16EDO: use 214EDL (Degrees 214, 205, 196, 188, 180, 172, 165, 158, 151, 145, 139, 133, 127, 122, 117, 112, 107)

I actually recommend not going past 12EDO, since the error E rises sharply. If you must try a higher EDO, then use 16EDO as it has the least error. Other multiples of 4 (20EDO, 24EDO, 28EDO) have lower errors for their size, while 22EDO and 31EDO (mentioned in earlier posts) also have lower errors for their size. Beyond 31EDO, all scales are about equally bad (with the odd EDO's marginally better than the even EDO's).

It's interesting that 232EDL is the best for 12EDO, since the EDL link I mentioned in an earlier post recommended 120EDL and 196EDL (among others) to make a 12EDO scale.

But to me, making EDO scales is such a waste. The computer uses EDL's, which are based on exact divisions of length, so we should be playing sounds in just intonation, not EDO's.

[2018 Update: OK, let's skip to the end of this old music post.]

We can go on and on with 11- and 13-limit scales, but this post is getting long enough.

Anyway, I decided to go back to Tall Kite's website for any updates on his color notation for the 11- and 13-limit scales. Recall that Kite is now using "to-"/"fu-" -- topaz and fuchsia -- for the otonal and utonal 11-limit. For the 13-limit he uses "jo-"/"ku-" for otonal and utonal, but he never actually specifies any colors for the 13-limit.

http://www.tallkite.com/forum/index.php/topic,86.195.html

The only color starting with "j" mentioned in this thread is "jade" -- but notice that "jade" is Kite's old name for the 11-limit, not the 13-limit. He also mentions that it might not be important to have separate names for otonal/utonal in the 11-limit, since these sound very similar (with each being about a quarter-tone away from the corresponding white notes). On the other hand, we might need to distinguish between otonal/utonal in the 13-limit, as these notes sound distinct.

To me, it would have been more logical to use "jo-"/"ku-" for 11-limit and "to-"/"fu-" for 13-limit. If we did this, then "jade" could remain 11-limit under both the old and new names, while "ku-" doesn't need a color since 11-limit otonal/utonal are difficult to distinguish. And for 13-limit where otonal and utonal are more easily distinguished, we have the colors "topaz" and "fuchsia" ready for us.

But that would be too logical. Music -- like most human endeavors -- isn't logical.