Showing posts with label Mathematical Oddities. Show all posts
Showing posts with label Mathematical Oddities. Show all posts

Monday, July 4, 2022

The Weirdest Chess Move, Part 2

This is the second part of a two-part post. For the first, see here.

In the previous post, I discussed some candidates for chess's weirdest move, where "move" here means a move written in algebraic chess notation. Our first two candidates, while rare, have come up in some historical games. Without further ado, here is chess's (notationally) weirdest move:

The weirdest move: Bf3g2#

At first glance, this looks rather innocent. It is a checkmate, but other than that it's just a bishop move, right? However, there's something strange here: both the starting square f3 and destination square g2 are listed for the bishop. Usually, only the destination square is listed in algebraic chess notation. But I'm not changing the notation rules here! There is a technicality that we'll use to our advantage.

The position above comes about in is a very common line in the Queen's Gambit Declined opening: 1. d4 d5 2. c4 e6 3. Nc3 Nf6 4.Bg5 Nbd7. Black has just played the move "Nbd7", moving the queen's knight from its home on b8 to d7, where it reinforces the pinned knight on f6. The notation "Nbd7" is used instead of "Nd7" because there are two black knights that could legally move to d7 on this fourth move! The other knight move would be denoted Nfd7 (a very bad move since white would win the queen). When additional information is required to disambiguate a move, chess notation rules hold that information must be provided about the piece's initial square. The way this information is provided is as follows:

Suppose that a player may move two or more of the same piece to the same square. Then the notation for the move must include one of the following three pieces of information:
  1. The file (column on the chess board, labeled a-h) where the piece originated, such as in the example Nbd7 above
  2. The rank (row on the chess board, labeled 1-8) where the piece originated, if specifying the file does not disambiguate the move
  3. Both the rank and file, only if neither the rank or the file alone can disambiguate the move
We saw an example of (1). As an example where (2) applies, see the following diagram:
Special notation disambiguating moves happens very frequently for rooks, because they are often "connected" on the same rank or file. In the above position, white has just played "R1h5". Both white rooks could move to h5, and they are both on the h file, so the originating rank (the first rank in this case) is provided before the destination square instead.

Though situations (1) and (2) are common enough, applying (3) is almost never necessary. This is because this would require one player to have at least three of the same piece, requiring a promotion of some kind. How rare is it for a player to have three of the same piece? Let's take a look at a few notable examples. There's a line where this can occur straight out of the opening: the famous Lasker Trap.

The game begins 1. d4 d5 2. c4 e5 3. dxe5 d4 4. e3 Bb4+ 5. Bd2 dxe3, arriving at the following position.


So far, only white's fourth move e3 can be considered a mistake, and not a major one. It appears that white can win a free piece by taking the bishop on b4, but this falls right into the Lasker trap! After 6. Bxb4, black responds with exf2+. In this position, white can't take the pawn, and must move the king to e2 (see below).



White has just played 7. Ke2. If white instead took the pawn with Kxf2, the king would no longer be protecting the queen and black wins with Qxd1. The winning move for black is now 7. ...fxg1=N+, underpromoting to a knight! This remarkable underpromotion occurs only seven moves into the game. If black promotes to a queen, the position is equal after white inserts Qxd8+, since after the white queen is captured, white can take the promoted piece on g1, leaving roughly equal material. This means that black must promote with check. After 7. ...fxg1=N+, If white takes the new knight with 8. Rxg1, the skewer 8. ...Bg4+ wins the white queen, so white plays 8. Ke1.



Black can then play 8. ...Qh4+, as shown above. White is lost here: they are down a piece, their king is completely exposed, and black's new knight will be saved. Most importantly for us, the final position features three black knights! They're nowhere near each other, though, so there's no need for disambiguating notation.

A few other quick examples of extra pieces: there have been a few historical games where a player had three queens (requiring two promotions!), and only one game I could find where a player had three rooks, see below. The game was a tournament game between Grigory Serper and Catalin Navrotescu in 1988.



In this position, black can promote and gain a huge material advantage. However, promotion to a queen results in a draw! This is because of a neat stalemate trick: white can perpetually check the black king with their two rooks. If the black king actually captures both, it's stalemate because the new queen on g1 takes away all squares from white's king, and both pawns are locked! Therefore, the winning move is "g1=R", which leaves five rooks on the board! The rook promotion was actually the last move of that game: white resigned. None of the games I found required rule (3) above to disambiguate a move, however.

Moreover, I could not find a single historical game in which one side had three bishops, which is the situation required for our candidate weirdest move. In fact, even more is required than that: one side needs to have three bishops of the same color for rule (3) to apply, which requires at least two bishop underpromotions!

This is the main idea behind my candidate for weirdest move, but I'll quickly run through the other features that led me to the specific choice of "Bf3g2#". First: the choice of squares.



In order for rule (3) to be required to disambiguate, at least three bishops must be able to access the destination square. This means the square in question cannot be a corner or an edge square. The next most unusual choice is a square close to the corner such as g2, since this greatly constrains the positions of the bishops (all three must start among the four squares h1, h3, f1, f3; we'll use the configuration above). Further, the bishop that moves must be on the same file and the same rank as another bishop. We can't have the bishop move from h1, however, because it is impossible to deliver a checkmate with Bh1g2 if it is not a capture. This follows from the fact that the bishop does not attack any square it didn't before, and also could not have gotten out of the way of another piece. Therefore, if we stick to a checkmate without capture, the bishop that moves must start on f3, as shown.

The choice of corner (g2 instead of say, b2) is not particularly important, but with the white pieces is marginally weirder since the promoted bishops would have to retreat back toward white's side of the board and occupy the king's most common position (after kingside castle). Finally, let's consider the checkmate. In a similar vein to the comment above, after moving the bishop from f3 to g2, it doesn't attack any squares (not occupied by white pieces) that it didn't before. Since the move to g2 wasn't a capture, in particular, the bishop already saw the h1 square on the previous move. But then, how can this be a checkmate?

One can see that these conditions force the move to be a discovered checkmate, which is the final bit of weirdness; the bishop on f3 must be blocking a piece that then delivers checkmate to the enemy king. This setup feels even more contrived than having the bishop capture a piece to deliver checkmate, hence my choice of "Bf3g2#". Finally, just to prove that the move could happen, here's a (highly artificial) chess position using the move.

In this image, white has just delivered checkmate with our weirdest move, Bf3g2#.

This example serves to illustrate the huge variety of chess positions that have never been seen in a game before. Maybe this "weirdest move" will appear in a game someday. But I wouldn't bet on it.

Thursday, June 30, 2022

The Weirdest Chess Move

This post will attempt to answer the question: "What is the weirdest possible chess move?"

More specifically, we'll consider all possible chess move notations, using standard algebraic chess notation. So among possible written moves such as "Ne6", "Qxd7", etc., we want to decide which is the most unusual. I could imagine two different ways of making "weirdest" more precise.

  1. Consider the list of all possible chess games (using standard rules), written down using standard chess notation. Which move notation occurs the fewest number of times in all possible games?
  2. Look at all tournament chess games (with standard rules, etc.) that have occurred in history. Alternatively, let a powerful chess engine such as Stockfish play itself many times and write down all the games. Which move notation occurs with the lowest frequency?
Approach (1) is at least a well-defined question, because the number of chess games is finite, though incredibly large. The reason for this is that by the 50-move rule, any chess game in which there is no capture or pawn advance in 50 moves in automatically a draw; thus pieces cannot shuffle around the board forever and every game must end. One estimate for the number of possible chess games is known as the Shannon number, named after the mathematician Claude Shannon. The estimate is 10120, which vastly exceeds even the number of atoms in the observable Universe! Therefore, it's impossible in practice to enumerate all chess games.

Approach (2) is a little better, but if we use only games that have actually occurred, or a computer sample size small enough to be computationally feasible, it might be too small for any of the "weirdest" moves to appear (we'll see this later). Moreover, we've made some choices about what a sample of representative "good" chess games might look like. I prefer approach (2), though, since the spirit of the challenge is to find what moves come up the least often in a game where both players play sensibly. In any case, my proposed "weirdest move" has not happened in any game that I could find.

The question I'm considering is a little unusual. Instead of looking at possible chess positions, the problem only asks about how a particular move is written down, so the only information we get about the position is from what the notation conveys. This includes the piece moving, the destination square, whether the move is a capture, whether it delivers a check or checkmate, etc.



For example, in the above position, black has just made the move "Nxf3+". The "N" indicates the knight has moved, "f3" is the destination square, "x" means the move was a capture, and the "+" means that the move delivers a check (but not checkmate). However, if we only see the symbols "Nxf3+" in isolation, we don't know what other pieces are on the board, where the knight came from, or where exactly the enemy king is (just that it's in range of the knight's attack).

There are some other notations for special moves in chess, such as castling: kingside castling is denoted "O-O", and queenside castling "O-O-O". The promotion of a pawn is denoted by an "=" sign, for example "e8=Q". In constrast, en passant does not have a special symbol in standard notation.



The above image shows a position after black plays "a5". This is an opportunity for white to capture en passant, meaning that white's b-pawn can move to a6 and capture the black pawn on a5 on the next move as if it had moved one square instead of two. However, this is notated simply "bxa6", so if we only know the notation and not the position, we can't distinguish en passant from an ordinary pawn capture.

Let's try a few weird moves. We'll start with castling. Castling on its own happens in almost every game, but it is usually a move to improve king safety in the opening, so it is almost unheard of to check or checkmate with a castling move. Hence, we have our first candidate weirdest move:

Candidate 1: O-O-O#

The notation here means: queenside castle and checkmate. It's an incredibly rare move, but it (nearly) happened in a high-profile historical game! In a 1912 game between international master Edward Lasker (distantly related to world chess champion Emanuel Lasker) and twice British chess champion George Alan Thomas, the following position was reached after black's 17th move, "Kg1".



Lasker had the opportunity to play checkmate in one move with "O-O-O#", our candidate weirdest move! He instead played "Kd2#", which is still checkmate since it allows the white rook on a1 to see the enemy king. Moving the king to deliver checkmate is already a bit uncommon, but the queenside castle would have been stranger still. You might be wondering how on earth the black king arrived on g1 in this game! It was in fact the culmination a remarkable series of forced moves in which the black king went from g8 to g1. The full game is well worth checking out (see here for an explanation of the full game).

Therefore, queenside castle checkmate is rare, but it did almost occur in a game involving two very high caliber players, so maybe we can do better. There's another uncommon move type that's natural to try: underpromotion.

When a pawn reaches the end of the board, it can become a queen, but the player also has the option to trade their pawn for a different piece instead (rook, knight, or bishop). This is called an underpromotion. Since the queen is the most powerful piece in chess, there are very few cases in which a player would "legitimately" underpromote, i.e. where the underpromotion is a superior move to promotion to a queen. Most occurrences of underpromotion in real games are "just for fun", for example when the promoted piece would be captured either way. However, there are some exceptions.



The above position occurred in a game between Vladlen Zurakhov and Alexander Koblents in a 1956 USSR semifinal event. Koblents has just played his knight to f5 and is threatening to win the pawn on g7, which would bring the game to a knight vs. two pawns position that is a theoretical draw. Therefore, white must promote the g pawn. However, if white plays "g8=Q", black will simply win the queen by forking the queen and king with the move "Ne7+". The only move that wins for white is "g8=N", an underpromotion to a knight. This defends against the fork, and the new knight can go on to help one of the two remaining pawns to queen promotion (this is still a difficult win, but Zurakhov did end up winning the game). Since knights can move and attack in ways that queens cannot, it makes sense that knight underpromotions are sometimes practical. Indeed, promoting to a knight is next most common after promoting to a queen. This leads us to our second candidate:

Candidate 2: Bishop underpromotion (e.g., "a8=B")

The rarest underpromotion of all is to a bishop. The bishop's value in chess is roughly equal to the knight's as the lowest of the (non-pawn) pieces, and unlike a knight, the bishop does not move in a way that the queen cannot. In particular, I didn't include a "#" (checkmate symbol) on the example move in Candidate 2, because if a bishop promotion move comes with checkmate, the same move with a queen promotion instead would also be mate. Therefore, no "legitimate" underpromotion occurs that way. I could also have made the move a check or capture, but this makes relatively little difference.

Though some endgame compositions have featured this type of move, there are once again precious few examples in real games. One of the only ones on record is in the following game between Aron Reshko and Oleg Kaminski in the 1972 Leningrad chess championship.



In this position, it's white to move. Though Reshko has a pawn close to promotion, Kaminski has a trick up his sleeve. First, if white does not address the threat on the a7 pawn, the black queen will simply win it in the next move, leading to equal material and a likely draw. If white moves to protect the pawn on its current square by taking the queen to a4 or b8, black can play the queen to f7 for checkmate!

Therefore, white must promote the pawn (or throw in a check with "Qg6+", but the queen must simply return and this gains nothing). However, promotion to a queen or a rook lead to an immediate draw because of black's defensive resource "Qf7+", sacrificing the queen! White's only move is to take the queen, and the resulting position is stalemate, a draw.



The above image shows the hypothetical variation 61. a8=Q Qf7+ 62. Qxf7. Though white is now up two full queens, black has no legal moves and the game is a draw by stalemate. A rook on a8 would also guard the h8 square, so it's again stalemate. Promoting to a knight in the initial position avoids this problem, but it's not too hard to see that the knight can't escape the corner without black's queen capturing it. The only winning strategy, which Reshko found in this position, is to promote to a bishop. Soon after, the players traded queens, and with an extra bishop, white went on to win.

While the bishop underpromotion is the rarest type of move in chess, it is not the weirdest move in terms of notation. I'll reveal my pick for the game's weirdest move in the next post.

Thursday, March 6, 2014

Exceptions to Continuity 3

This is the final part of a three-part post. For the first, see here.

In the previous post, it was stated that every function has an Fσ set of discontinuities. We cannot prove this fact, since the proof is beyond the scope of this blog, but we can demonstrate its converse, which is also true, namely that for any Fσ set S, there exists a function f: RR (a real-valued function defined on all reals) with a set of discontinuities S.

Expand S into its subsets in the following way:



where each Si is closed (this is just the definition of an Fσ set, i.e. a countable union of closed sets). We wish to define this set as an Fσ set in a slightly different way as a countable union of closed sets. We define a new series of sets Tj, where



In other words, T1 = S1, T2 = S1S2, and in general the Tj is the union of the first j sets of the collection of S-sets, {Si|iZ+}. Note that each Tj is a closed set, being a union of a finite number of closed sets (since j is finite), and that the union of all of the Tj is the same as the union of all of the Si, since each Tj is simply formed from a union of the Si. However, this new collection of sets possesses a useful feature in constructing our desired function f: each Tj is contained within the next member of the sequence Tj + 1.

Before defining the function itself, we need one more collection of sets based off of the Tj. These sets, for each j, essentially carry information about the differences between consecutive sets among the Tj. Symbolically, they are defined in the following way:



What this means is that Uj contains those real numbers which are contained in the set difference of Tj and Tj - 1, or the set of numbers in Tj but not Tj - 1 (note in fact, that this set difference might be empty; we will return to this later). Note also that for j = 1, the definition of U1 makes use of a set "T0". We define this to be the empty set. Finally, among the real numbers contained in the set difference, only those which are on the boundary of the set (the condition preceding the "or" symbol, ∨) or are rational (the second condition, which states that such numbers are contained within the intersection of the set difference and the rational numbers, Q) are in Uj. The importance of these conditions will be made clear, but first we must finally define our long-sought function f:



Thus f takes a different constant value on each of the Uj, namely 2-j. This definition is well-defined because no two Uj intersect. If some member x of Um were a member of Un for n > m, then x would have to be contained in the set difference Tn - Tn - 1. However, since mn - 1, x must also be within Tn - 1, since the T's are nested. This is a contradiction, so the Uj are disjoint. Finally, the function f is defined as 0 outside of all of the Uj. Next, to illustrate how this definition works and is applied to sets, we consider a few examples.

Let S be the set {1/5,2,π}. To illustrate the concepts above, we initially assign S1 = {1/5}, S2 = {2}, S3 = {π}, and Sn = Ø for n ≥ 4 (note that this is not the only way to divide S into sets Si and that different divisions may yield different functions with the same discontinities). Clearly the union of the Si is indeed S. Next, T1 = S1 = {1/5}, T2 = S1S2 = {1/5,2}, T3 = S1S2S3 = {1/5,2,π}, and Tn = {1/5,2,π} for n ≥ 4, since the Si are empty above i = 3 and empty sets do not contribute to a union. Also, by definition, T0 is the empty set. Now we shall determine what form the Uj take. U1 takes elements from the set difference T1 - T0 = {1/5} - Ø = {1/5}. Since 1/5 is rational, it satisfies at least one of the additional conditions above and is indeed in U1. There are no other elements in T1 - T0, so U0 = {1/5}. Similarly, T2 - T1 contains one member, 2, and since it is rational, it is also the sole member of U2. Finally, T3 - T2 = {π}. Though π is not rational and so is not a member of (T3 - T2)∩Q, it still is contained within U3 because it is on the boundary of the set difference (the boundary of a set containing a single point is merely the same set). Thus U3 = {π}.

Using these facts, our previous definitions yield the following formula for f:



This formula yields the graph below:



Clearly this function has exactly our desired set S = {1/5,2,π} as its set of discontinuities. Note also the importance of the condition that those elements on the boundary of the set difference Ti - Ti - 1 are in Ui, as this was crucial in having π as a discontinuity, since it is irrational.

For a more intricate example, we now allow the set S to be the half-open interval (0,1]. S is Fσ because it is the union of the sets [1/2,1], [1/3,1/2], [1/4,1/3],..., each of which is closed. We therefore let Si = [1/(i + 1), 1/i] for every positive integer i. Clearly each number between 0 and 1 is contained in one of these sets, and 1 is contained in S1. However, the union of the infinite collection of sets is (0,1] because it does not include 0; if 0 were a member of the union, it would have to be a member of some Si. However, 0 is strictly less than 1/i for any positive integer i, and therefore cannot be in the union of the Si.

From these definitions for the Si, we see that T1 = S1 = [1/2,1], T2 = S1S2 = [1/3,1], and in general, Tj = [1/(j + 1),1]. Each set difference Tj - Tj - 1 is of the form [1/(j + 1),1/j), except for T1 - T0, which equals [1/2,1] and includes its right endpoint, since T0 is the empty set. As before, we select certain elements from each set difference to form the Uj, namely those which are rational (the boundary condition offers nothing new, since ∂(Tj - Tj - 1) = ∂[1/(j + 1),1/j) = {1/(j + 1)}, and 1/(j + 1) is rational). Thus each Uj contains exactly the the rationals between 1/(j + 1) and 1/j, including 1/(j + 1) but not including 1/j. Restricting our attention briefly to just one of these intervals, we see, for example in the vicinity of 2/3, which is in U1, that our function f will assume positive values at rationals and a value of zero at irrationals, since no irrational is a member of any Uj for this function. Our entire function will then consist of several smaller "copies" of the nowhere continuous Dirichlet function, which is 1 at rationals and 0 at irrationals. Before presenting a visualization of this function, we give its definition:



The image below "graphs" this function. Due to the Dirichlet construction, the function jumps infinitely many times within every interval between 0 and 1. Therefore, when the function is split among the rationals and irrationals, the function's value at the rationals is given as a short-dashed line, and the function's value at the irrationals a long-dashed line. Note that at the value 2/3 below, the long-dashed line is at 0 and the short-dashed line at 2-1. Additionally, the segments on which the rationals are situated continued to shrink and move towards 0 as one approaches the origin, as indicated by the ellipsis.



It is easy to see that the function f is discontinuous on the entire interior of the unit interval, (0,1), because member of this set is surrounded arbitrarily closely by rational numbers, for which f is nonzero, and irrational numbers, for which f is zero. Additionally, since f(1) = 2-1, and f(x) = 0 for x > 1, f is additionally discontinuous at 1. However, to see that f is indeed discontinuous at exactly the set S, we must show the the function is not discontinuous, that is, continuous, at x = 0.

Consider the behavior of f(x) as x approaches 0. Given an arbitrarily small positive number ε, we can find a positive integer n such that 2-n < ε. As we know, on the interval [0,1/n), the largest value f can take is 2-n. Thus we have that for |x| < 1/n = δ, f(x) will be less than ε. Thus f is continuous at 0, and f has all the desired properties.

We have seen, for two examples, that the process above does yield a function f with discontinuities on exactly the members of a given Fσ set. After the above motivational examples, we finish the post by proving that this fact holds in the general case.

Let S be an Fσ set, f its corresponding function by the above scheme, and let the {Tj} be defined as above. We consider first the case of a point belonging to one of the set differences Tj - Tj - 1. If a point x is in the interior of this set difference f is discontinuous at x for the same reasons that the Dirichlet function is, since f behaves in the same manner as the Dirichlet function on the interiors of the set differences. If x is on the boundary of a set difference, f(x) = 2-j. However, neighboring points outside of the set difference must differ from this value by at least 2-(j + 1), since the closest possible value to 2-j that the function can take outside of Tj - Tj - 1 is 2-(j + 1), namely on the set difference Tj + 1 - Tj. Thus f is discontinuous at x. We have proven that f is discontinuous at every point of every set difference of the Tj. Since the union of the {Tj} is S, we see that S is exactly the union of all the set differences of the {Tj}. Thus f is discontinuous on S.

To finish the proof, we must show that f always continuous outside S. Let x now be any point outside of S, and therefore outside of every set difference. Since each Tj is closed, it contains its boundary, so x cannot be on the boundary of any Tj. Thus there is some neighborhood surrounding the point x that does not contain any member of Tj for some fixed value of j. For example, in the second example above, any set containing 0 in its interior contains part of a set Tj for some j, since the left endpoints of the {Tj} in that example, 1/(j + 1), become arbitrarily small. However, for any fixed Tj, say T3 = [1/4,1], we can choose a neighborhood of 0, for example (-1/5,1/5) which excludes all the {Tj} up to T3. This is the most difficult subtlety of the proof. Having found a neighborhood U of x (in the example, 0) that excludes the first n of the {Tj}, we note that the function must take values less than 2-n on U. Since this can be done for any finite n, we see that the function approaches 0 as one approaches x and that f is continuous at x. Therefore f is discontinuous on exactly the set S.

The above series describes a complete classification of discontinuities for real-valued functions. Also, this and related results give additional insight into the structure of real numbers, for example the distinction between rational numbers, on exactly which set a function can be discontinuous, and the irrational numbers, which are not Fσ. Such a classification demonstrates the power of mathematical techniques, as it provides simple conditions on all of the strange functions and sets which can exist on the real numbers.

Sources: Sources: Counterexamples in Analysis by Bernard R. Gelbaum and John M. H. Olmsted, Froda's Theorem on Wikipedia, http://holdenlee.wordpress.com/2010/04/26/can-a-function-be-continuous-only-on-rationals/, http://samjshah.com/2009/10/03/sin1x/,

Wednesday, February 26, 2014

Exceptions to Continuity 2

This is the second post of a three-part post. For the first, see here.

The question arose in the previous post whether for any set S in R, the real numbers, there exists a function f such that S is the set of discontinuities of f, or, in our previous notation, D(f) = S. Note that solving this problem is exactly equivalent to solving the problem of whether every set can be the set of points at which a function is continuous, since every function f is continuous at exactly the points that it is not discontinuous. Before tackling the whole problem, we solve it for a more limited class of functions, called the monotone functions.

A monotonically increasing function on an interval (image from wikipedia)
A function is monotone if it is either always increasing or always decreasing (such a function is called a monotonically increasing or monotonically decreasing function). A function f is increasing if for any real numbers a and b, ab means that f(a) ≤ f(b), with a similar definition for decreasing. The function above increases, then stays constant for awhile, and then continues to increase. It is thus a monotonically increasing function. Some common examples of monotonically increasing functions are y = x, y = c (for any constant c), y = xn (where n is an odd integer), and y = ex.

Next, it is important to note that there is a one-to-one correspondence between monotonically increasing and monotonically decreasing functions caused by flipping sign, that is, the negative of a monotonically increasing function is monotonically decreasing, and the negative of every monotonically decreasing function is monotonically increasing. Thus y = -x, etc., are monotonically decreasing.

A theorem in mathematics called Froda's theorem after the Romanian mathematician Alexandru Froda completely classifies the possible sets of discontinuities over the monotone functions. We outline the proof of the theorem, noting that, due to the one-to-one correspondence discussed above, the result for monotonically increasing functions will hold for all monotone functions. The statement runs thus: For any monotone function f defined on closed interval [a,b], D(f) is at most a countable set in [a,b], that is, the set is empty (for an everywhere continuous function), finite, or countable (can be put in a one-to-one correspondence with the natural numbers).

The first step in the proof is noting that, for a monotonically increasing function f defined on the interval [a,b], the only discontinuities that f can have are jump discontinuities. Other types of continuities require some type of infinite oscillation (e.g. the function y = sin(1/x)), but this involves the function increasing and decreasing, which is not allowed for monotone functions. Thus we consider jump discontinuities only.

Consider the difference d = f(b) - f(a) of the values of the function at the endpoints of the interval [a,b]. Clearly it is positive and finite, due to the properties of f and the fact that it is defined on both endpoints. Note also that the jumps can only be positive, since the function is increasing; the function can only jump up, not down. For any positive number ε, therefore, there can only be a finite number of jumps of length ε, since the sum of the jumps cannot exceed d.



For example, in the above diagram, the function f, which increases from 1 to 3 over the interval [a,b], cannot have more than two jump discontinuities with jump 1, since the sum would then exceed the value of d, in this case, 2.

Therefore, given a monotonically increasing function f, for each positive number ε we can construct a set of points {x1,x2,...,xn}, containing every point that is a jump discontinuity of f with a jump greater than or equal to ε. By the previous remarks, this set is finite for any positive ε (although it is allowed to be empty, e.g., for continuous monotonically increasing functions). Finally, we define Dn(f) for a positive integer n to be the set corresponding to the value ε = 1/n. The union of all of the Dn for positive integer n then includes every jump discontinuity of f, since for any jump discontinuity with jump ε, ε is greater than 1/n for some n. If the jump were 0, the discontinuity would not be a discontinuity at all! Thus every jump discontinuity is in some Dn, and thus in their union, which we shall call D, as consistent with previous notation.

Therefore, the set of discontinuities of a monotonically increasing function f (and similarly for all monotone functions) is a countable union of finite sets, which is countable.

This result is extensible to a monotone function on the real numbers. The set of real numbers R can be expressed as a countable union of closed intervals [n,n + 1], where the union is over every integer n. One can simply collect the discontinuities from each interval (on which the function must be monotone, since it is monotone everywhere) into a larger set. Since a countable union of countable sets is countable, the set of discontinuities over all of R is countable also. Lastly, this result also extends to any function f defined on the real numbers such that there is a countable collection of sets A such that the union of all members of A is R and f is monotone on each member of A. In other words, if the real numbers can be appropriately split into pieces on which a function f is monotone, then the set of discontinuities of f is countable.

As general as this result may be, it certainly does not classify the sets of discontinuities of all functions. We have already seen an example of a function discontinuous everywhere. The function of that example is not monotone on any interval, so Froda's theorem is inapplicable.

To complete the classification of sets of discontinuities, we must introduce the notion of a Fσ set. A subset S of the real numbers is an Fσ set if and only if it is a countable union of closed sets. A closed set in the context of the real numbers is one which contains its boundary points. For example, [0,1], the interval containing 0 and 1, is a closed interval, because it contains its boundary points, 0 and 1. The sets (0,1), [0,1), and (0,1], missing one or both endpoints, are not closed. In addition, any union of disjoint closed intervals such as [-1,2]∪[3,4]∪[5,7] is closed.

The realm of Fσ sets is quite general. First, since R itself, the set of real numbers, has no boundary, it by definition must "contain" its boundary, and is thus closed, and therefore Fσ. Since the empty set has no boundary, it is also closed, and {} is Fσ. Any countable set of points is also Fσ, as a set containing one point, {x}, is always closed, and the collection of Fσ sets is closed under countable union. Thus Q is Fσ. Finally, as an example of a set that is not Fσ, consider the set of irrationals, R - Q. Since Q is dense, i.e. there is a rational number between any two distinct real numbers, no part of R - Q has an interior; there are no "blocks" of irrational numbers with no intervening rationals among the reals. Thus to get the irrationals into a collection of closed sets, we have to "package" them individually, using, for example, countable collections of points. However, the irrationals are uncountable, so no countable union of closed sets can yield R - Q. With this definition, we state the following theorem completely classifying sets of discontinuities:

A set S can occur as a set of discontinuities of a function f on the real numbers if and only if S is Fσ.

The proof that every function f has D(f) an Fσ set is too difficult to consider here. However, we can demonstrate the proof in the reverse direction. To finish this series (see the next post), we construct a function whose discontinuities form an arbitrarily chosen Fσ set.

Sources: Counterexamples in Analysis by Bernard R. Gelbaum and John M. H. Olmsted, Froda's Theorem on Wikipedia, http://holdenlee.wordpress.com/2010/04/26/can-a-function-be-continuous-only-on-rationals/, http://samjshah.com/2009/10/03/sin1x/,

Tuesday, February 18, 2014

Exceptions to Continuity 1

An important class of functions in mathematics is the class of continuous functions. A continuous function is a function without any jumps or undefined points (for a more formal definition, see here). For convenience, we shall limit our scope to functions f on the real numbers.

The class of continuous functions on the real numbers is quite general; all linear, polynomial, and exponential functions fall under this category. However, many other functions fall into the class of discontinuous functions, or those which have at least one point at which they are not continuous. Take as an example the Heaviside step function, which is (conditionally) defined by the equation

.

This function, often denoted θ(x) as above, is graphed below.



The function assumes a constant value of 0 as the value of x approaches 0, and then at zero, it assumes the value 1/2 (solid blue dot). θ(x) then equals 1 for all positive values of x. This function is discontinuous at exactly one point, namely at x = 0 because the function jumps from 0 to 1/2 to 1 at this point. We can then consider the set of points of discontinuity of the function, which for a function f we shall denote D(f) (where "D" stands for discontinuity). In this way, D itself is a function; to each function f on the real numbers it associates the set of points of discontinuity of f. For instance, if f(x) = x2, then D(f) = Ø (the empty set), and, by the discussion above, D(θ) = {0}.

However, many functions have more than one point of discontinuity. Some in fact have an infinite number of discontinuities! Take for example the greatest integer or floor function, which to every real number assigns the greatest integer less than or equal to it. For example, floor(2.5) = 2, floor(6.93) = 6, and floor(1) = 1. The graph of this function is shown below:



The set of discontinuities of the floor function is just the set of integers; as soon as the input of the function increases from 0.999 to 1.000, for example, the output jumps from 0 to 1. Thus D(floor) = Z = {...-3,-2,-1,0,1,2,3,...} (Z is often used to stand for the set of integers). Even for this function, however, the discontiuities are isolated, and "most" of the function still behaves normally. However, there are functions for which every real number is a discontinuity. One notable example is the Dirichlet function, denoted IQ(x) and defined on all real numbers as being equal to 1 if x is rational, and 0 if it is not (see here for information on and examples of rational and irrational numbers). The function is denoted this way because it is also called the characteristic function of the rational numbers on the reals. A characteristic function of any set is the function that is equal to 1 on the set and 0 elsewhere. The symbol IQ indicates that the set in question is Q, the rational numbers. It is difficult to imagine the graph of this function, but it consists of an (countably) infinite set of points along the line y = 1 and an (uncountably) infinite set of points along the line y = 0.

To see that IQ(x) is discontinuous at every real number x, consider the following argument. If x is irrational, let the decimal expansion of x be 0.a1a2a3..., where a1, a2, a3, etc. are the digits of the infinite expansion. Clearly, every member of the sequence 0.a1000..., 0.a1a200..., 0.a1a2a30... is a rational number (as the decimal expansion of each terminates) and the sequence generates rational numbers arbitrarily close to the irrational number x. Thus the function takes the value 1 at points arbitrarily close to where it takes the value 0 and IQ(x) is discontinuous at x. For the case in which x is rational, it is clear that there is an irrational number between every two rationals (for definiteness, one such an irrational number between x and y would be (2-1/2)x + (1 - 2-1/2)y), so the rationals must be isolated points, and thus discontinuities of the function. In conclusion, the function IQ(x), though defined at every real number, is discontinuous at every point in its domain, so D(IQ) = R, the set of real numbers.

Though one might argue that the odd definition of this function seems artificial, as it uses rational and irrational numbers in its definition, this particular function does have a closed form, albeit in the form of an infinite limit. The function IQ(x) can also be defined by the expression:



In the expression above, the limit is calculated pointwise, i.e. the value of the limit is calculated for each real number x, giving the value of the function at x. To see that this expression indeed produces the characteristic function of the rational numbers on the real numbers, first consider the inner limit, indexed by the variable j, for constant k (assume k = 1, so k! = 1). The function cos(πx) is equal to 1 or -1 at every integer.



For large j, cos(πx)2j = 1 at all integers. The "2" in the exponent insures that all outputs of the function are positive. If the exponent were just j, the value of the function at x = 1 would simply oscillate between -1 and 1 and never converge, and the function would be undefined at odd integers. For any point that is not an integer, the value of cos(πx) will have an absolute value less than 1 and therefore approach zero in the limit. The inner limit therefore gives a function which has the value 1 at every integer and 0 elsewhere.

Now let k→+∞. We have already seen that the function will have value 1 whenever the expression within the cosine is integral. For any rational number r/q, where r and q are integers and the fraction is reduced to lowest form, clearly q! (q factorial) has q as a factor. Thus q!(r/q) is an integer. Finally, since q! is a factor of every subsequent factorial, k!(r/q) is an integer for every kq. Therefore, the value of the limit at every rational number becomes 1 as k increases without bound. If the function were 1 at an irrational number s, however, we would have k!(s) equal to an integer for some k, because integers are the only values for which cos(πx) = 1. Thus s would be expressible as a quotient of two integers, which is a contradiction, since s is irrational. We have then confirmed that the function expression indeed gives IQ(x).

Another important example is a modified version of Dirichlet's function, called Thomae's function or the popcorn function. It is defined in the following way.



This function agrees with Dirichlet's function on the irrational numbers, but for any rational number gives the reciprocal of its denominator in lowest form. At the nonzero integers, since these numbers can be represented as n/1, the function assumes the value 1. For simplicity, we also assume that f(0) = 1. A graph of this function is shown below (click to enlarge):



The above shows a graph (a collection of points, in this case) of Thomae's function on the interval (0,1), and some examples of points: 1/2 yields the largest possible output of any number between 0 and 1, namely 1/2. Also, along the horizontal line y = 1/q for any positive integer n lie all points (p/q,1/q), where p and q share no factors, or are said to be relatively prime. Thus the number of points along each line y = 1/q also gives the number of positive integers less than or equal to q that are relatively prime to q. For example, the point (2/5,1/5) is illustrated, and there are a total of four points along the horizontal line containing it, since 1, 2, 3, and 4 are all relatively prime to 5. Notice however that (2/4,1/4) is not a valid ordered pair satisfying Thomae's function because 2/4 can be simplified to 1/2. The points get denser as one approaches the x-axis, (for example following the sequence of points (1/n,1/n), and the only horizontal line along which there are an infinite number of points is y = 0, since Thomae's function assumes the value 0 at every irrational number.

Now we must consider where Thomae's function, if anywhere, is continuous. Clearly, it is discontinuous at any rational number for the same reason as before: any rational number yields a nonzero output, but is surrounded by irrational numbers which are mapped to 0. However, using the formal definition of continuity, we can confirm that Thomae's function is actually continuous on the irrational numbers. The function will be continuous there if the differences in the outputs at an irrational number and at "nearby" points tend to 0 as the "nearby" points come closer and closer to the chosen number. Let s be any irrational, and choose any small positive number ε to be the desired upper bound for the difference between the value of the function at s and at a nearby point. Let q be the smallest positive integer such that ε > 1/q. Since s is irrational, clearly it is not equal to any p/q (p,q relatively prime). Let δ be the distance between s and the closest rational number (in lowest form) with a denominator less than or equal to q. Within a distance δ of s, the function assumes values strictly less than 1/q. Thus the largest possible difference is less than 1/q (since f(s) = 0) which is less than ε, and the function is continuous at s. To make this clearer, the above reasoning is made explicit in the diagram below (click to enlarge):

A demonstration of the above reasoning for an arbitrary irrational s = 0.559246... and ε = 0.22
In the above diagram, the smallest positive integer with ε > 1/q is q = 5, since 1/5 = 0.20 < 0.22. Among those rationals with denominators less than or equal to 5 (which are copied on a duplicated x-axis so that they can more easily be seen), 3/5 is the one closest to s, with a difference δ of about 0.04. If, for any x, x is within a distance 0.04 of s, the function value at x is guaranteed to be less than 0.20 and so within 0.22 of the value of the function at s, 0. Since this can be done for any positive ε, the function is continuous at s. Similarly, the function is continuous at every irrational.

Therefore, there exists a function f (Thomae's function) with D(f) = Q (the set of rational numbers). The question naturally arises whether any set can be the set of discontinuities of a function. This question is explored in the next post.

Sources: Counterexamples in Analysis by Bernard R. Gelbaum and John M. H. Olmsted, The Road to Reality by Roger Penrose, Weierstrass Function, Dirichlet Function on Wikipedia, http://www.maa.org/pubs/Calc_articles/ma001.pdf, http://www.whitman.edu/mathematics/SeniorProjectArchive/2007/huh.pdf

Monday, February 10, 2014

Further Properties of Space-filling Curves

This is the final part of a three-part post. For the first, see here.

In the previous post, we examined an iterative sequence of curves, the limit of which after an infinite number of iterations is called the Hilbert curve. We now prove that the Hilbert curve indeed has the property it was constructed to have: it fills the unit square. Consider the first iteration again.



The first iteration includes all four points of the form (m/2,n/2) when m and n are each either one or three. In binary decimal notation, 1/4 = 0.01 and 3/4 = 0.11. To see the relevance of this fact, now consider the second iteration.



The points along the curve marked by black dots are of the form (m/8,n/8) with m and n both odd (and between 0 and 8), and two of these points are explicitly marked with their coordinates for clarity. It is obvious that the second iteration contains all points of this form. In binary notation, the points are of the form (0.ab1,0.cd1), where a, b, c, and d can stand for either 0 or 1. For example, (7/8,5/8) = (0.111,0.101). Since each iteration contains smaller copies of the previous one, it is clear that this pattern continues, and the third iteration will include all points of the form (m/16,n/16), with 0 < m, n < 16 and both m and n odd. In decimal notation, the curve includes all points each of whose coordinates has a 4-digit terminating binary expansion that ends in 1 (just as the second iteration had 3-digit terminating binary expansions ending in 1).

Next, we must note that any binary expansion can be approximated to arbitrary accuracy by others ending in the digit "1". For example, let P be the point in the unit square (0.101010101...,0.10100000...), where the repetition in the first expansion continues infinitely. Now consider the sequence {(0.11,0.11), (0.101,0.101),(0.1011, 0.1011),(0.10101,0.10001),...}. The nth point in this sequence lies on the curve of the nth iteration, and the sequence converges to the point P defined above. Thus the point P lies on the limit of the iterations, i.e., the Hilbert Curve itself. Note that the second coordinate of point P is exactly matched by the point on the 2nd iteration, and the sequence goes on to actually veer away (temporarily) from its final value. However, it still approaches the same limit as the sequence continues.

Since binary is simply another way of writing the real numbers, it is easy to show that there is a binary expansion for every real number from 0 to 1. For more discussion on this topic, see The Infinity Series, specifically here. Therefore, the Hilbert Curve visits every point in (and on) the unit square, and is indeed a space-filling curve. We note next that the Hilbert curve actually "overachieves" its goal; it actually visits several points of the unit square multiple times. For example, the point (1/2,1/2) is the limit of the sequence {(0.11,0.11), (0.101,0.101),(0.1001, 0.1001),(0.10001,0.10001),...} as well as of another sequence {(0.01,0.01), (0.011,0.011),(0.0111, 0.0111),(0.01111,0.01111),...}. Thus the function mapping the unit interval onto the Hilbert Curve is not one-to-one though it is continuous. Contrast this with the first function we constructed from the unit interval onto the unit square, which was one-to-one (after resolving the issue of multiple decimal representations) but not continuous.

It is impossible for a function from the unit interval to the unit square to be one-to-one and continuous. Such functions are called homeomorphisms, and two spaces for which is it possible to construct a homeomorphism mapping one onto the other are topologically equivalent in a certain sense. This means that they share certain intrinsic toplogical properties. For example, if a homeomorphism from a space that is connected (see image below) to another space exists, the latter space must also be connected.

Examples of connected and disconnected spaces.    Connected spaces can only have one component (A),  while  disconnected ones have multiple disjoint components (B).

Also, two homeomorphic spaces (this means that there is a homeomorphism from one onto the other) share other connectedness properties. For example, the unit interval has the property that, when any point of it (except an endpoint) is removed, it becomes disconnected. However, the unit square cannot be disconnected by the removal of any single point. Hence the two spaces differ in a topological property that is conserved by homeomorphisms and are not homeomorphic. Therefore, a continuous space-filling curve that is also one-to-one is impossible.

It is also worth noting that the concept of a Hilbert curve can be extended to any finite dimension; in three dimensions, instead of filling the unit square, the curve fills the unit cube. This would be done by dividing the cube into 23 = 8 cubes of side length 1/2 and divding the unit interval into 8 corresponding subintervals for the first iteration, and so on. Generally, the Hilbert curve, like many other mathematical oddities, shatters our intuition when it comes to what properties mathematical objects can possess, and reminds us of the differences between the physical and mathematical worlds.

Sources: Counterexamples in Analysis by Bernard R. Gelbaum and John M. H. Olmsted, Space-filling Curve on Wikipedia, http://upload.wikimedia.org/wikipedia/commons/9/95/Connected_and_disconnected_spaces.svg

Sunday, February 2, 2014

Constructing a Space-filling Curve

This is the second part of a three-part post. For the first, see here.

The previous post introduced the concept of a curve in the plane, presenting it as a type of mapping from one-dimensional to two-dimensional space, with the added condition that it be continuous. Finally, an interesting mapping that fills the unit square was presented. However, this example is not continuous. To show this, we shall demonstrate that a particular sequence {xn} = {x1,x2,x3,...} of points in t-space (the one-dimensional domain of the mapping) converges to a point x, also in the domain of f. Then, we shall show that the corresponding sequence of points {f(x1),f(x2),f(x3),...} does not converge to the image f(x) of the limit of the sequence. This will prove that the mapping is discontinuous.

Let {xn} be the sequence {0.490000...,0.499000...,0.499900...,...}. Clearly this sequence converges to x = 0.500. The sequence in the unit square {(0.400...,0.900...),(0.490...,0.900...),(0.490...,0.990...)}, whose members correspond to the value of f at each member of {xn} converges to (0.500...,0.999...), but the value of f at x is not this value. Rather it is f(0.500...) = (0.500...,0.000...). Thus f is not a continuous mapping. Note that even if the non-terminating decimal expansions were selected for those members of the unit interval where there are two possibilities, the function would still be discontinuous, and one would this time use a sequence of points approaching t = 1/2 from above rather than below.

Though, as mentioned previously, Peano was the first to demonstrate the existence of a continuous space-filling curve, the process described below actually refers to a space-filling curve devised by Hilbert shortly afterward, as it is more straightforward geometrically.

To actually construct a space-filling curve f that is continuous, we make use of a limiting process, which goes through steps called iterations. The first iteration of the process that results in the curve is as shown below:



This is the image of the first iteration of the mapping in the plane, but the way it is constructed is more easily understood when the square is divided into four smaller squares. The part of the curve lying in each smaller square is the image of one-quarter of the unit interval, as illustrated below.



Each subset of the unit interval marked with a Roman numeral is mapped to the corresponding red segment contained within the square marked by the same numeral. Clearly the parametrization of the red curve defined this way is continuous, and is a mapping of the unit interval into the unit square. Also, at each point, the segment is equidistant from the center and edge of the square, so each of the three straight parts is of length 1/2.

The next step is to apply the limiting process. The second iteration of the curve is essentially several smaller connected copies of the first, as shown below.



The second iteration of the limiting process (the blue curve at bottom) consists of four copies of the first iteration (some have been rotated) and segments connecting them so that the curve is continuous. Instead of mapping 1/4 of the unit interval into the segment contained within each square we now cut the interval into 16 regions and map each to the part of the curve within each of the 16 squares of side length 1/4 in the proper order. The first eight squares are numbered by Roman numerals in the diagram.

The process then continues, with each step consisting of four copies of the previous one, rotated in the same manner. On the nth step of the process, we can visualize the mapping as taking each subset of the unit interval of length 1/4n to the portion of the curve contained within a square of side length 1/2n, of which there are 4n in total.

Note in addition that the curve of the first iteration is composed of three segments of length 1/2, and thus has total length 3/2. Since the second iteration is made up of copies of the first scaled down by a factor of 1/2 (to fit in the squares which have half the sidelength of the original), it is made of 12 segments of length 1/4, plus 3 additional segments of this length to connect the copies. Thus the total length of the curve of the second iteration is 15/4. Generally, it is easy to see that, taking into account the segments that must be attached to the copies of previous iterations to connect them, that the length of the nth iteration is 2n - 1/2n. This sequence of lengths increases without bound, and therefore the end result, the Hilbert curve, is a curve of infinite length contained within a finite area.

In the next post, we prove that the Hilbert curve indeed fills the unit square and explore more of its properties and extensions.

Counterexamples in Analysis by Bernard R. Gelbaum and John M. H. Olmsted, Hilbert Curve on Wikipedia

Saturday, January 25, 2014

Introduction to Space-filling Curves

In mathematics, one often encounters curves, often as graphs of functions. In the two-dimensional case, these graphs often come about when a dependent variable y has some relationship with an independent variable x, e.g. the parabola y = x2.



The graph of the function y = x2 is a pictorial representation of this specific relationship between y and x.

Alternatively, we may encounter some more complicated graphs when we allow both x and y to be dependent variables of another variable t, called a parameter. For example, consider the parametric function defined by the two equations y = t2 and
x = t, where we specify that the independent variable t can take any real number value. To graph this function on an xy-plane like before, we find the ordered pair (x,y) for each value of t and graph these points.

The perceptive reader will have noted that, through a simple substitution, the two equations of the parametric function above can be combined into the simple relation
y = x2, the same parabola as before. Thus the graph of our parametric function is precisely the same as that of our original function, and they represent the same curve in the xy-plane. We say that the parabola is parametrized by y = t2, x = t, -∞ < t < +∞, where the inequality specifies the domain of t.

However, though some parametric functions can be easily expressed simply with x and y alone, others do not create a simple, or even single-valued, dependence. Consider the more complicated parametric function y = 3cos(3t) + t, x = sin(t), and its graph in the xy-plane, below (for convenience, t is restricted to the domain -2π/3 < t < 2π on the graph below):



In such a function, substituting to obtain a relation directly between y and x would be much more complicated, and could not be a function of the form y = f(x) anyway as some values of x correspond to multiple values of y. Such curves can also intersect themselves many times, as the one above demonstrates.

Yet another way to look at a parametric function is as a mapping from 1-dimensional space (the "number line" of t) to 2-dimensional space (the xy-plane). In fact, we shall define the term curve as the range in 2-dimensional Euclidean space of such a mapping. We also specify that this mapping must be continuous, i.e. that the graph of the curve does not have any "jumps".

From now on we shall consider only mappings of the unit interval, therefore setting 0 ≤ t ≤ 1. The intuitive idea of the range, or image, of this type of curve in the xy-plane is that it is very "narrow", and does not have any area. For example, for any rectangle in the plane, one can easily measure area, but the area of just one of the sides is zero, or for that matter, the area of all four sides (for more about areas, see here). Only the region contained by the four sides has positive area.

However, in 1890, the Italian mathematician Giuseppe Peano made a remarkable discovery. There is a curve whose domain is the unit interval and whose image (graph) fills the entire unit square! (in the xy-plane, this is defined as the region such that both 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1 are satisfied) In other words, a single line can take up a square, even one mapped from a finite interval.

It is crucial to note the significance of the fact that the mapping is continuous, i.e. produces a curve that fills the unit square. It is relatively "easy" to create a mapping from the unit interval to the unit square without this restriction. One way is through use of a number's decimal expansion (in base 10 notation).

Any number in the unit interval can be written in the form 0.a1a2a3..., where we use 0.999... to obtain 1. Consider the function f defined on the unit interval, that "splits" the decimal expansion into two parts and makes each of these a coordinate of a point in the unit square, with

f(0.a1a2a3a4a5a6...) = (0.a1a3a5,0.a2a4a6...).

To ensure that this function is well-defined, we must "make up our minds" what decimal expansion to use to represent numbers such as 1/2, which equals both 0.5000... and 0.4999.... To remedy this, simply chose as the input of the function the terminating (where terminating means that for some N, n > N implies an = 0; for the terminating decimal expansion of 1/2, set N ≡ 1) expansion. Thus f(1/2) ≡ f(0.5000...) and not f(0.4999...). The diagram below indicates graphically the domain and range of the mapping, along with its effect on a selected point.



The function f defined on the unit interval in t-space has as its range the entire unit square in the xy-plane. To see that the entire square is filled, let (0.a1a2a3...,0.b1b2b3...) be a point of the unit square. Then it is easily seen that 0.a1b1a2b2a3b3... maps to this point under f. Since every point in the unit square can be expressed this way, the mapping fills it in its entirety, confirming that the unit interval has "just as many" points as the unit square.

But is the mapping above continuous? It turns out that it is not. For a proof of this fact, and an example of a space-filling curve (where continuity is required), see the next post.

Sources: Counterexamples in Analysis by Bernard R. Gelbaum and John M. H. Olmsted, Space-filling Curve on Wikipedia