Tuesday, June 4, 2019

day-knights and night-knights

In his book To Mock a Mockingbird, Raymond Smullyan provides another variation on his classic 'knights and knave' puzzles, in which he imagines the puzzle solver not visiting an island, but exploring a bizarre underground city.

Illustration from The Child of the Cavern:
Or, Strange Doings Underground (sometimes published as
The Underground City) by Jules Vern

In the strange community of Subterranea, visitors cannot tell day from night, but the residents can. The residents are of two types: day-knights or night-knights. Day-knights tell the truth during the day and lie at night, while night-knights tell the truth at night and lie during the day.

Several Subterranea puzzles are presented in To Mock a Mockingbird, but we want more. If we consider a long enough list of statements that Subterraneans might make and  the possibilities presented if we have two inhabitants speaking, we should be able to generate quite a few puzzles.

Let's use these 22 statements:

0: I am a day-knight, and it is day
1: The other person is a day-knight, and it is day
2: I am a day-knight, and the other person is a day-knight
3: I am a day-knight, and it is night
4: The other person is a day-knight, and it is night
5: I am a night-knight, and the other person is a day-knight
6: I am a night-knight, and it is day
7: The other person is a night-knight, and it is day
8: I am a day-knight, and the other person is a night-knight
9: I am a night-knight, and it is night
10: The other person is a night-knight, and it is night
11: I am a night-knight, and the other person is a night-knight
12: It is day
13: I am a day-knight
14: It is not night
15: It is night
16: I am a night-knight
17: It is not day
18: At least one of us is a night-knight
19: At least one of us is a day-knight
20: We are both night-knights
21: We are both day-knights

Some of these are simple statements about the day or the type of one of the inhabitants, others are compound 'and' statements that combine two simple statements. When a compound statement uses "and" to join two simple statements, both simple statements need to be true in order for the compound statement to be true, but only one simple statement needs to be false in order for the compound statement to be false.

truth table for A and B

If the first inhabitant make statement 1, and the second inhabitant make statement 8, we get puzzle 5 (shown below). You can try to solve it here.

It turns out (not surprisingly, as we will see below) that both inhabitants are lying, at least somewhat.  It must be that it is night, and that both inhabitants are day-knights.

Here's one way to puzzle it out:

  • If the first person was telling the truth, there is one possibility: it is day, the first person is a day-knight, and the second person is a day-knight. There are 3 ways they could be lying.  If it is day, then they would have to be a night-knight, and the other person would also have to be a night-knight. If it is night, then they have to be a day-knight, and the other person could be either a day-knight or a night-knight.
  • If the second person is telling the truth, there is one possibility: it is night, the first person is a night-knight, and the second person is a night-knight. As with the first person, there are 3 ways the second person could be lying. If it is night, second person must be a day-knight, and the first person could either be a day-knight or night-knight. If it is day, then the second person must be a night-knight, and the first must be a day-knight.
  • The only option from both sets of possibilities is that it is night and that both inhabitants are day-knights.
In the set of 22 x 22 combinations of two statements how many lead to puzzles with unique solutions? It turns out that only 90 puzzles emerge - the graph below shows white squares for all combinations that lead to valid puzzles, black squares for those that do not.  It doesn't matter which inhabitant is making a particular statement, leading to the symmetry in the graph and duplication in the puzzles (if you don't care about statement order).

puzzles generated by the 22 statements

We can see that two statements in particular lead to almost complete horizontal and vertical lines of well-formed puzzles. These lines are puzzles that involve statements 3 and 6:

3: I am a day-knight, and it is night
6: I am a night-knight, and it is day
Each of these statements on its own narrows the field of possible solutions considerably. For example, if an islander says "I am a day-knight, and it is night," they must be lying. Moreover, we know that they cannot be a day-knight in the day, or a night-knight in the night. This leaves one possibility: that it is day and that they are a night-knight.

As expected from the symmetry of the statements, in the valid puzzles it is just as likely for it to be day as night, and it is just as likely for the inhabitants to be day-knights or night-knights.

day and night are equally likely

But not everything is balanced in Subterranea. In the example above (puzzle 5), and in puzzles generated by statements 3 and 6, we find the inhabitants of Subterranea being less than truthful. In fact, in all the puzzles generated, at least one of the inhabitants is lying - never do both tell the truth at the same time. The graph below shows puzzles where one inhabitant is lying in light blue, and where both inhabitants are lying in white.

Subterranea: not great for tourists

Perhaps it is their preference for AND conjunctions that leads the Subterraneans to have problems with telling the truth?

The Subterraneans might remind you of the inhabitants of the Isle of Dreams - a key difference between the Subterranean puzzles and the Isle of Dreams puzzles presented on this page is that the islanders do not link their statements using AND - each statement is distinct.

Both Subterranea and the Isle of Dreams are examples of a puzzle category that also includes standard Knights and Knaves, the Lion and the Unicorn, the Unreliable Guards, Tiger or TreasurePortia's Caskets, and many others. A bunch of these puzzles are collected here.

Thursday, May 9, 2019

star polygon fun

Star and compound polygons are pretty mathematical objects that are fun to draw or create in code.
star and compound polygons
on 2 to 9 vertices

You might draw ten pointed polygons while exploring the multiplication table, for example. In the picture below, skip counting by 6 while drawing a line between the last digits of consecutive numbers gives us a pentagon: counting 0, 6, 12, 18, 24, 30 we draw lines connecting 0, 6, 2, 8, 4, and 0.

skip counting by 6 draws {5/2}

When drawing star and compound polygons by hand, you start with n points spaced evenly around a circle, and then from each point connect to another, always skipping over the same number of points. If you skip over 0 points, you get the regular n-gon. If you skip over k points, and k+1 is relatively prime with n, you will get a star polygon, if n and k+1 share factors, you get a compound of several regular or star polygons.

On 9 points, skipping over 0, 1, 2, and 3

It is interesting how an easy to describe algorithm like this, skipping around points on a circle, translates into a program.

The polygons on this page are drawn using some JavaScript (code here), which includes some use of trig functions to place the initial vertices (like points around a unit circle) and modular arithmetic to help traverse the list of points in a circular way. It's a nice example of how math makes its way into how we implement even simple algorithms.

When we go fully over to a mathematical way of expressing how to draw these by using desmos, we can see how mathematics can, in this case, express the algorithm in a surprisingly compact way. You can check out the graph here.

desmos sketch of {7/2},
graph here

Related links and posts
star polygon page
star polygons in desmos
polygons in the multiplication table

Wednesday, May 8, 2019

Desmos Chladni

Like Lissajous figures, Chladni figures provide a surprising and aesthetically engaging example of wave interaction.

Named for Ernst Chladni, these figures represent nodal patterns formed by vibrating surfaces. Traditionally, these are formed placing fine particles on a surface, like a sheet of metal that is set vibrating (a violin bow against an edge of the metal plate is one popular method). The particles settle in the areas of the surface that have the least motion - the nodes. When you achieve a resonant frequency, a characteristic pattern emerges.

In past posts I've pointed to code that draws Chladni figures using R (here and here), and using JavaScript. Maybe not surprisingly, you can also play around with Chladni-like figures using Desmos, and this may be the most accessible way to explore them them and appreciate how they are generated from the sinusoidal functions.

Chladni-like figure generated in R

Chladni-like figure generated using JavaScript

In Desmos, you can create images similar to these using inequalities. The equations are reasonably straight forward - the graph here will draw the figure across the whole plane - best results are seen when zooming in on a small region.

Chladni-like figure generated in Desmos,
graph here

More Chladni-like figures in Desmos

Try playing around with the desmos graph here, R scripts for generating figures are found here, the JavaScript Chladni generating page is here.

After posting on Twitter, the desmos sketches were improved by   and @PaulaKrieg. Here are some other graphs inspired by their changes:

A Chladni-like pattern with
two distinct inequalities

A Chladni-like pattern with three distinct

With the added layers, the Chladni patterns are approaching an abstract William Morris appearance.

Another Update
This other graph allows you to experiment more directly with the Chladni figures, similar to the web page mentioned above.

graph for building 
Chladni figures

Wednesday, April 17, 2019

why horizontal transformations are tricky

Both the Common Core and Ontario curricula ask students to look at families of functions that are connected to each other through simple transformations, and to build new functions from existing functions.

In Ontario as with the Common Core, students get an understanding of function families "by playing around with the effect on the graph of simple algebraic transformations of the input and output variables." In the Ontario curriculum (MCR3U), students spend a significant amount of time graphing complicated examples from a function family by relating them to transformed graphs of a simple base function.

The base quadratic (purple) and a transformed
member of the quadratic family.

When working on these these ideas with students, I've had to ask myself a few questions.

  1. What is a valid 'transformation' of the graph of a function, and how are these related to more familiar transformations of the plane?
  2. How are the transformations connected to the function definition?
  3. Why are horizontal transformations tricky? As noted in the Common Core progression document, "students may find the effect of adding a constant to the input variable to be counterintuitive, because the effect on the graph appears to be the opposite to the transformation on the variable."

Short Answers

Here are some short answers to those questions.

  1. The 'transformations' we want to restrict ourselves to are ones that preserve the main characteristics of the graph, these are a reduced set of the affine transformations of the plane: translation, scaling, and reflection. The transformations we want to consider do not include rotation, projection, or shearing. The simple transformations that are included are ones where the x and y coordinates do not 'interact' with each other (the original x value has no impact on the transformed y value, and the original y value has no impact on the transformed x value).
  2. It turns out that the transformations of the graph we want (simple affine transformations with no rotation or shearing) are obtained by pre-composition and post-composition of the parent function with single variable linear functions.
  3. Horizontal transformations are tricky because they are the result of pre-composition with the inverse of the linear function responsible for the horizontal component of the transformation. When we look at the complicated function and "read off" the transformations, it is akin to looking at linear function and reading off its inverse. 

Long Answer, with matrices and diagrams!

We often represent transformations of the plane using matrices. In this case, we would represent dilations, translations, or reflections like this:

There is no interaction between the x and y coordinates - no rotation or shearing. This results in a diagonal matrix, and allows us to represent the transformation as a pair of single variable linear functions.

If a function g is thought of as the result of this transformation applied to the points of the function f, then the diagram below commutes.

But in order to write g in terms of the transformation and f, we need to invert the part of the transformation that is operating on the x values.

And we can write g as:

Spelling this out with our formulas for the components of the transformation, we can see the messiness that results from composing with the inverse of our original transformation.

What to take away

It helps me to think along these lines, but is there anything here that may help when working on transformed graphs of functions with high school students?

I find that in presenting 'transformations of graphs' to students, we generally don't relate it back to  the transformations they learned about in elementary school, where they explored translations, reflections, dilations, ans rotations. It might be good to make stronger connections with that prior learning, noting that when transforming graphs within a function family, we only use dilation, reflection, and translation.

Function composition is a unifying and clarifying concept. Maybe it makes sense to talk about sooner than is generally done. It is surprising that in grade 11 we talk about inverse functions without exploring function composition. If you are willing to use function composition, you can use arrow diagrams to explore function transformations using a method like the one described here.

Looking more at inverses of linear functions may help provide a way to explain the strange backwardness of the horizontal transformations, even if the connection is not formally demonstrated.


The Common Core Standards Writing Team. (2013). Progressions for the Common Core State Standards in Mathematics (draft). Retrieved from http://commoncoretools.me/wp-content/uploads/2013/07/ccss_progression_functions_2013_07_02.pdf

Ontario Ministry of Education. (2007). The Ontario Curriculum Grades 11 and 12, Mathematics, Revised. Retrieved from http://www.edu.gov.on.ca/eng/curriculum/secondary/math1112currb.pdf

Related Post: understanding transformed functions with arrows

Monday, April 15, 2019

LaTeX for high school math teachers

TLDR: Please check out the online workshop I am developing for high school math teachers who want to learn about LaTeX. That this community needs  something like LaTeX raises questions about teaching and learning math in online situations.
I have been using LaTeX a lot recently, but not in the way I first used it a long time ago when writing my master's thesis. (Not sure what LaTeX is? Check out the first module of the online workshop here.)

Now I am using it daily to provide feedback to students in the LMS that I teach an online course in (Brightspace), include bits of math on webpages, and avoid the Google Docs equation editor.

With the inclusion of little bits of LaTeX in various digital platforms, the availability of cloud-based authoring systems like Overleaf, and the ability to include LaTeX on any webpage with MathJaX, LaTeX seems everywhere these days (once you start looking). It's not just the Baader-Meinhof phenomenon - the ubiquity of LaTeX is real, and a response to important problem with teaching and learning mathematics on digital platforms.

With the increasing use of digital technology and online learning in secondary schools, knowing a little bit of LaTeX can  help high school math teachers communicate effectively with both students and colleagues. Most LaTeX resources are aimed at researchers and grad students, and are not focused on the use of LaTex in these new situations. So, I am working on an short online "Introduction to LaTeX" workshop  for high school math teachers that focuses on the more on the specific uses that matter to them (please take a look, any feedback is appreciated).

LaTeX is great, but finding ways to get equations into documents do not address the essential challenges that these digital platforms raise for teaching and learning. High school teachers once used hand-written overheads, drew on blackboards, and scribbled in notebooks - now we share discussion posts, emails, and send documents back and forth in our LMSs. In these new digital forums, how do we show messy "live" examples of doing mathematics, rather than presenting an overly polished finished product?