March 10, 2010

Hilbert Space Methods for Differential Equations

In addition to individual articles, the Electronic Journal of Differential Equations also publishes monographs in the area of differential equations. The first one was a book that I think I remember seeing on library bookshelves: Showalter’s Hilbert Space Methods for Differential Equations.

The Source of Obama's Trouble

The Obama administration and Democrats in general are in trouble because they are not urgently and effectively addressing the issue that most Americans want them to: the frightening economic insecurity that has put a chokehold on millions of American families.

March 09, 2010

Research and Markets: A Quick Guide to Fitness Fundamental...

Research and Markets has announced the addition of Woodhead Publishing Ltd's new report " A Quick Guide to Fitness Fundamental Engineering Mathematics " to their offering.

Why the eigenvalues of a PSD matrix are continuous w.r.t. its entries

A fellow student asked me that question today, and I came up with the following answer: Clearly the top eigenvalue is continuous, as it’s just the norm. Then by writing f_k(A) = \sum_{i=1}^k \lambda_i(A) , the sum of the top k eigenvalues of A, as the SDP


\begin{aligned}
\max & \text{ Trace}(AB) \\
\text{subject to} & \\
 & \|B\| \leq 1 \\
 & \text{Trace}(B) = k \\
 & B \succeq 0
\end{aligned}

we see that f_k(A) is convex (since a function of the form f(A) = \sup_{B \in \mathcal{B}} \langle A, B \rangle , i.e. the supremum of linear functions, is convex). Since a convex function on an open set is continuous, we see that f_k is continuous on the positive semidefinite cone, so \lambda_k(A) = f_k(A) - f_{k-1}(A) is continuous on the same set also.

Another interesting question: are the eigenvalues of a general square matrix continuous w.r.t. to its entries? I believe that’s the case, because we’re talking about roots of polynomials, after all, but I don’t know a simple argument off the top of my head.Possibly relevant posts:

Subitizing - a video review


What is "subitizing"? It's probably a new word for most. It basically means being able to recognize instantly how many objects you see, without counting.

We all do that with the dots on the face of a dice. People who play dominoes with the larger set also learn to do that with the dots on the dominoes (they can go up to 18).

But why would such be important? It is for children, because it promotes number sense, and also ties in with the concepts of addition, subtraction, and even place value.

Look at the dominoes in the picture, and especially the one in the front with turquoise dots on the left side and three orange dots on the right.

Photo courtesy of catheroo


Looking at the turquoise dots, can you tell how many there are without counting?

Most of us realize that it is just one less than three rows of three, or nine. So therefore it has eight dots. That is "subitizing".



By learning to subitize a child is learning:
• number sense
• to associate a number with a whole collection
• to visualize quantities and the associated number
• relationships between numbers
• to visualize subsets of a number
• to use subsets of numbers to quickly make addition and
subtraction equations
• the foundation for quick and creative mental arithmetic
• place value concepts


I recently had the opportunity to watch a video made specifically to address this math concept, called Subitize Me! It is about 28 minutes long and meant for children from PreK to 2nd or 3rd grade.

This is the trailer of the video:




In it, two children go through an adventure of sorts inside ancient ruins where they have to first be able to tell the number of gold coins before they can escape. The children get there through a series of seven "lessons", for example with dice, with a snowman, or spacecraft. In each lesson they learn more and more about subitizing, until finally they are able to see the large number of coins in groups of ten tens (hundred) and groups of tens.

My children liked the movie and wanted to watch it twice (thus far). It is actually recommeded to watch it repeatedly over time so children can cement the concepts shown in the video.

This is a commercial movie on a DVD. The DVD also has some additional exercises for children to watch and think through. You can also purchase (separately) a booklet for the teacher that has activities you can do and has a brief summary of the movie.

The video is well made and ties in with the math concepts very well. I would recommend it to elementary school teachers, libraries, co-ops, math clubs and any such places where many children have the opportunity to watch it.

I'm definitely not against home users (parents) purchasing it, either. This concept is beneficial for all children and teachers! However, I consider it a bit pricey, as compared to other math-related movies and DVDs that are available commercially, because it does not really cover that big a part of the typical math curriculum. So you need to consider your budget. Maybe you could resell it afterwards, which would reduce the cost.

I also hope they would make it available for watching online for a small fee, kind of like how you can "rent" (download) movies from Amazon for a few dollars. That would make it more accessible to larger numbers of parents.

Please see more information about the movie at Movie Makers.



Disclaimer: I received from Movie Makers company a link to be able to watch this movie for free, plus the PDF version of the teacher activity booklet. I did not receive any other compensation. The opinions are mine.

HW policies: PROS and CONS

The last blog entry had lots of good comments about different HW policies. I enumerate them and say PROS and CONS
  1. Hard Deadline. PRO- uniform, no favoritism, can post HW Solutions or go over HW in class as soon as it is handed in. CON- there could be legitimate reasons for lateness that are short of a doctors note. CON- you want the student to DO the HW even if it will be late. CON- you need to be TOUGH to say NO.
  2. Moral Deadline (what I do, see last post). Same as Hard Deadline, but its a bit easier to say NO.
  3. Penalty for lateness. PRO- the students will still do the HW. CON- delay in posting solution. CON- slackers are still slackers. ODDITY- the penalty is supposed to discourage lateness. But it may encourage it (gee, 10% off if I hand it in one day late. OKAY, its a deal)
  4. Look at late HW only if they affect the final grade. PRO- less to look at likely, CON- Don't really want to keep track of these things. CON- student may not be discouraged from handing things in late.
  5. Only count (say) 10 of the 12 HWs, and have HARD DEADLINES. PRO- same as HARD DEADLINE. CON- students will blow off 2 HW's, possibly the last two which may be important for the final. CAVEAT- raises the much bigger question of whether to treat students like adults or like ...students.
  6. Students get x number of late days (this one was new to me). PRO- well defined rule, flexible but no favoritism. CON- delay in posting solutions. CON- keeping track of it.
  7. If you miss a HW then the others will count more (up to some limit). PRO- uniform. CON- students may still miss some HW they should do.
  8. HW are OPTIONAL. PRO- they sink or swim on their own. CON- they sink or swim on their own.
Diff topic- how much to COUNT HW? I often count it low (like 10-20 percent) so that I don't' have to worry too much about cheating. Actually I think its GOOD if students help each other but BAD if students copy each other, but it can be hard to tell.

Which of these work best? Depends alot on the school and the course and even the profs willingness to say NO.

March 08, 2010

Someone’s Math Teacher Weeps

I was reading some political blogs this morning, when I came across this quote:

Look, there’s an endless list of topics I don’t understand at all. I went through an entire semester of pre-Calculus in high school and was never able to understand what a function is. I still don’t. It’s a complicated subject and I was a lazy student.

I don’t know what to say to that.

A HW policy- MORAL due date.

This semester I am using the following HW policy.
HW is due on Tuesday. However, your dog died! Hence you get an extension to Thursday. That is, for all people in the class I assume you have a quasi-legit reason to ask for an extension to Thursday. Hence you can hand it in Thursday for full credit. However, if you want an extension past that you will not get it since I already gave you an extension to Thursday. (There may be some severe exceptions which will have to be documented.)
  1. This will save alot of time in terms of students asking permission to hand it in late since I will say I already have you an extension and you are asking for another one?
  2. Some students will get into the habit of handing it in Thursday. This is okay so long as they do not ask for an extension past that.
  3. Clyde tells me that this is really a cheat- the HW really is due Thursday. I may have a higher moral ground when telling them they can't hand it in later than Thursday, but they will still feel that they deserve an extension if their dog dies on Wednesday. My response: they do not.
  4. I do make sure that they have enough knowledge to do the HW by Tuesday.
  5. I am teaching one Junior-Senior class and one honors-class so these are already pretty good students. They (I hope) know what I mean when I say that they cannot ask for an extension past Thursday. Also they will likely not need them. I have not tried this in a Freshman class. I would like to but they are usually co-taught and large so it would be harder to manage.

People Who Oscillate

From today's mini-AIR:

The Oscillating Humans Project, announced here, is searching for a living specimen - an exemplar - of an oscillating human.

DEFINITION: For purposes of the project, an Oscillating Human is someone who consistently, repeatedly, over many years, expresses opinions directly opposite to opinions he or she expressed earlier, always ignoring and/or denying the existence of copious, easily found clear documentation of the earlier opinions.

PURPOSE: The exemplary person, once identified, will serve as an example for teachers to use in logic classes. To minimize the chance of lawsuits, the exemplar must be a "public person", with (as stated above) for whom there is copious, easily found, clear documentation of years and years of oscillation.

If you know of an outstanding specimen, please send:

1. The name and a 20-word biographical sketch of the person.
2. Several URLs pointing to clear, unarguable documentation.

Send to: OSCILLATING HUMANS PROJECT: marca AT improbable.com

NOTE: This is an education project. It is NOT an exercise in naming people you don't like. No screeds, please.

Oscillating Humans Literature Review

Published research about this form of human oscillation may be scarce. One of the few apparently relevant items — judging it by its title, if not by its contents, is this British study:

"Oscillation of Human Performance as a Personality Measure," Michael A. Tainsh, Perceptual and Motor Skills, vol. 35, no. 2, October 1972, pp. 677-8.

Truly pertinent citations will be welcomed.

A logistic (in the nonmathematical sense) aside

I’m within \epsilon of having a new roommate, so naturally I’m planning what I’ll do with the extra $625/month I’ll be saving. Guffaw. The first two months are spoken for already— it’s past time for new glasses, and I haven’t paid off my Caltech dining account in several months—, then I’ll start saving up to get a car, since it looks like I’m going to be here another 3 years or so. After that, I dream of actually adding to my savings account for the first time in over a year.Possibly relevant posts:

Lines of primes

Prime numbers have fascinated mathematicians for centuries. A prime number has exactly 2 factors – one and itself. The only even prime is 2, the rest are all odd.

The primes less than 100 are as follows:

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

There doesn’t appear to be a pattern in the distribution of primes.

How about the "gap" (spacing) between the primes? Is there a pattern in that?

1 2 2 4 2 4 2 4 6 2 6 4 2 4 6 6 2 6 4 2 6 4 6 8

There doesn’t appear to be a pattern in the gaps, either.

Spiraling

Stanislaw Ulam was a Polish-American mathematician who was involved in the Manhattan Project during World War II.

One day he was bored in a meeting and began to write numbers in a spiral. He started like this, moving in a clockwise direction.

1 → 2 ↓
4 ← 3

The next round continued the "spiraling" pattern, as follows.

7 8 9 10
6 1 2 11
5 4 3 12

He kept going (it must have been a long meeting), then highlighted the prime numbers and found something interesting.

73 74 75 76 77 78 79 80 81 82
72 43 44 45 46 47 48 49 50 83
71 42 21 22 23 24 25 26 51 84
70 41 20 7 8 9 10 27 52 85
69 40 19 6 1 2 11 28 53 86
68 39 18 5 4 3 12 29 54 87
67 38 17 16 15 14 13 30 55 88
66 37 36 35 34 33 32 31 56 89
65 64 63 62 61 60 59 58 57 90
100 99 98 97 96 95 94 93 92 91

Many of the primes appear to line up when arranged in such a sprial.

Let’s go much bigger and see what happens. We observe there are many places where the primes form line segments, mostly at 45°, but sometimes horizontal and vertical.

prime distribution - spiraling

You can see an even bigger display, courtesy of Prime Curios.

What I found interesting in the large picture is where primes are not – there are distinct blocks and patterns of white space where no primes occur.

This spiral appeared on the cover of Scientific American in March 1964 and continues to generate research interest to this day.

Check out more such prime number information in the book Prime Curios! The Dictionary of Prime Number Trivia  by Chris Caldwell and G. L. Honaker, Jr.

Why do we care about primes?

Apart from many other things, prime numbers are vital in the development of encryption algorithms, used in generating secure Internet transactions.

Related posts:

  1. Largest known prime: 2^43,112,609 – 1
  2. Friday Math Movie – Math Illuminated
  3. Message to G8 Environment Ministers

Algebraic Number Theory at Leiden

Qiaochu Yuan recommended Stevenhagen’s mathematical writings in general, so I did some additional searching. I found this page of lecture notes for algebraic number theory courses at Leiden University.

Stevenhagen’s notes on class field theory look particularly interesting. They start with particular examples, and explain what the theory means in those particular examples.

March 07, 2010

Products, Limits and Parametric Polymorphism


> {-# LANGUAGE RankNTypes #-}


When I wrote about memoizing polymorphic types I mentioned that you can think of forall a. F(a) as the product over all types a of F(a), where F is some type level function. For example F might be a type constructor like []. That's not completely accurate, as I hope to now explain. Along the way we should get some insight into the meaning of the limit of a functor in a category.

Suppose we have two types, A and B. We can form their product (A, B). We have the two projections fst and snd and if we have an element x in (A, B) we know that there is no necessary relationship between fst x and snd x. We can freely choose x so that each of fst x and snd x can take on any values we like in A and B.

But now consider an element of forall a. F(a). For each concrete type X we have a projection πX::forall a. F(a) -> F(X). So it looks like a product of all types. However, we can't freely choose elements of forall a. F(a) so as to get any element of F(X) we like for each choice of X. To demonstrate this, consider an element x of the type forall a. [a]. For any choice of X we get a projection. For example, picking X to be Int or String gives:


> p1 :: (forall a. [a]) -> [Int]
> p2 :: (forall a. [a]) -> [String]
> p1 x = x
> p2 x = x


We can draw a simple category diagram representing this:




However, forall a. [a] comes with a free theorem. For this particular type we have a free theorem that says that for any f :: X -> Y, fmap f (p1 x) == p2 x. For example consider the well known function show :: Int -> String. The free theorem tells us that this diagram commutes:




So if p1 x == [3] then p2 x == ["3"]. We have lost free choice. But we have lost a lot more freedom than this. We have a commuting triangle like this for absolutely any function f :: X -> Y. It should be clear that there is no way we can pick elements of our list to satisfy all of these constraints. So x must be the empty list.

Cones
This scenario of having one projection for each type has a name. It's an example of a cone. Let's borrow the definition from Wikipedia:

Let F:J→C be a functor. Let N be an object of C. A cone from N to F is a family of morphisms with one morphism for each X,

πX:N→F(X)

so that for every morphism f:X→Y, the following diagram commutes:



For any Haskell functor F, the free theorem tells us that we have exactly these diagrams with forall a. F(a) playing the role of N. So forall a. F(a), with its projections to F(X), forms a cone.

Limits
If F is an instance of the Haskell Functor type class, ie. an endofunctor on Hask, then the type forall a. F(a) gives us a cone. But not just any old cone. I don't know how to prove this but I'm pretty sure it's true that the free theorems for a functor are the only non-trivial relations between F(X) and F(Y) that we're forced to obey. If that's true, then, in a sense, forall a. F(a) is the "biggest" type satisfying the free theorems. We can make this more precise by saying that for any cone N with associated projections πX, we can can map it uniquely to forall a. F(a) so that the following diagram commutes:



This special kind of cone has a name. It's called a limit. In other words, ∀a. F(a) = lim F. In fact, this is exactly how Limit is defined in category-extras.

In a sense you can think of a limit of a functor in any category as being like a product for which a version of the free theorems for a functor holds.

Colimits
A dual story can be told for existential types and colimits. But to do this we need free theorems for existential types. I'll leave that until I've figured out a nice way to derive these free theorems...

Final words
I should have written this article before I wrote one on coends. Think of it as a prequel.

The fact that we don't have complete freedom of choice when defining polymorphic elements in Haskell is what we mean by 'parametric' polymorphism. Instead of specifying one individual value for each type we define the elements in a uniform way. In a language like C++ we can use template specialisation to freely construct a rule for getting a value from a type using 'ad hoc' polymorphism. That freedom comes at a price - it becomes harder to reason about polymorphism.

It's amazing that many definitions in category theory emerge naturally (pun fully intended) from the free theorems. I keep hoping that one day I'll find a paper on exactly what is going on here that I understand. The original free theorems paper is very uncategorical in its language.




March 06, 2010

Stevenhagen on Number Rings

These notes by Stevenhagen provide an elementary introduction to rings of algebraic numbers.

Collatz conjecture: 3n+1

The conjecture states that starting with any positive integer, n, map this it n/2 if n is even, or map n to 3n+1 otherwise. Iterating will eventually lead to 1. This was a subject of today’s clever xkcd comic. It’s quite remarkable that if you google it, xkcd is the second hit after wikipedia. Pretty [...]

March 05, 2010

The Geometry Center

The Geometry Center at the University of Minnesota was a pioneer in putting mathematics on the web. The Center specialized in visualization of advanced geometric topics.

The Center itself was closed in 1998, but their website is still available. The site is quite old (the pages that note that Netscape 2.0 is required are particularly poignant reminders), and many parts of it no longer work, but much of the content is still there.

Solve this nasty recursion

I’ve “reduced” a problem to solving this recursion:


\displaystyle
\begin{cases}
\Omega_{k,m} = \sum_{\omega = 0}^k {2k \choose 2\omega} \Omega_{k-\omega, m-1} & k \geq 1 \text{ and } m \geq 1 \\
\Omega_{0,m} = 1 & m \geq 1 \\
\Omega_{k,0} = 0 & k \geq 1
\end{cases}

This looks nasty, and certainly beyond my experience. Any ideas on how to proceed? I guess I could try Z-transforms, but … just yuck.Possibly relevant posts:

March 04, 2010

Math GIFs

Here is a page with individual GIFs/PNGs for each math symbol. This is useful for the occasional inclusion of math formulas on a web page, for example. It also has directions on how to build more complex formulas using just HTML. The page is part of the Metamath project.

Special Issue of TOC in honor of Rajeev Motwani

(Guest post by Samir Khuller, Sudipto Guha, Laci Babai)

Special Issue of the journal Theory of Computing
in honor of Rajeev Motwani (1962 - 2009)

Submit contributions by July 30, 2010.

Submissions in all areas of theoretical computer science will be considered, with preference for topics related to Rajeev's work. All papers undergo strict peer review and must meet the standards of Theory of Computing.

See details at http://www.cs.umd.edu/~samir/ToCMotwani.htm.

The Rising Sea (weblog)

Daniel Murfat has a nice series of notes on various mathematical topics, mostly algebraic geometry.

March 03, 2010

Can The Hill Cipher ever be used?

Alice and Bob want to sent a message so that even if Eve intercepts it, she cannot tell what it is. We will allow Alice and Bob a short private meeting to exchange information (or perhaps they will use RSA or Diffie-Helman for that). But the key can't be that long and has to be reusable (so one-time pad does not qualify). I describe below a well known cipher called the Hill Cipher. I think that there are circumstances where it could do well; however, I am curious what you think.
Let n be a parameter we pick later. Alice generates a random n x n matrix of elements from {0,...,25} and checks that the Det mod 26 is nonzero. (CORRECTION ADDED LATER: the Det has to have an inverse mod 26, so has to be rel prime to 26.) Alice gives this to Bob. Alice and Bob both compute its inverse. Alice and Bob can exchange messages by encoding every block of n by this matrix. So the first n letters of the text get multiplied by the matrix to get a diff n letters. Then the next n letters after that, etc.
  1. n has to be small enough so that Alice and Bob don't mind exchanging n2 elements of {0,...,25}
  2. n has to be large enough so that going through all possible n x n matrices is not practical for Eve.
  3. n has to be large enough so that tables of how often particular n-sized blocks occur are useless.
  4. Can combine with other techniques. Perhaps Alice and Bob first encode using the Vigenere Cipher and then apply the Matrix. They would then have to also share the Key for the Vigenere Cipher.
  5. QUESTION: If ALL Eve gets is the text then is this a good cipher? Clearly if Eve also somehow gets her hands on a message and what it was coded to she will easily crack the code. But if not then does this work well? This code is not used because Eve might get her hands on such, but I wonder if these are circumstances where it would be reasonable.
  6. Is there a value of n that is both big enough and small enough (a Goldilocks n).
  7. What else is known about this?

History of Loops

I came across this history of loops, a generalization of groups, where I picked up this interesting tidbit: loops are named after the Chicago Loop, the central business district of Chicago. (The elevated trains tracks form a loop that enclose it.)

March 02, 2010

Knuth Prize for 2009: David Johnson

Dave Johnson Won the KNUTH PRIZE for 2009: click here

I can't add much to the article linked to except to say that it is well deserved.

The Wikipedia entry on the Knuth Prize does not list him yet (March 2, 2010, 4:15PM East Coast Time in America). I wonder how fast it will get updated?

March 01, 2010

Epistemological Tenses

The Economist has an article on the question of the hardest language to learn. They suggest that a language called Tuyuca is the answer. What makes Tuyuca unusual is that verbs carry an ending that indicates whether the statement is thought to be true or known to be true with certainty. Imagine a language with one tense for conjectures, and another for theorems.

Dual of an inequality and equality constrained SDP

Update: The dual SDP for \gamma_2(A) can be more simply written as

 \max 2 \langle \lambda, A \rangle subject to
 \text{diag}(s) \geq 0 ,
 s^t 1 \leq 1
 \text{diag}(s) - \begin{pmatrix} 0 & \lambda \\ \lambda^t & 0 \end{pmatrix} \succeq 0.

So it’s surprising that the \lambda which solves this seems to be in the \gamma_2^\star 1/2-ball. It’s easy to see that this ball is included in the feasible points, but no reason to think that it is the entire set of feasible points.

I spend mucho time deriving and checking this duality, then implementing it in CVX, so I record it here so hopefully I don’t have to redo this (I realize I could’ve looked this up, but the point is to derive it so I have a better chance of remembering it myself):

The dual of the SDP  \min \langle C, X \rangle s.t. X \succeq 0 ,  \mathcal{A}(X) \preceq 0 .  \mathcal{B}(X) = M is the SDP \max \langle \lambda, M \rangle s.t. \mathcal{A}^\star(s) - \mathcal{B}^\star(\lambda) + C - Z = 0 .  s \succeq 0 ,  Z \succeq 0.

In particular, this implies the dual of the SDP I mentioned before gives \gamma_2(A) is the SDP

 \max \left\langle \lambda, \begin{pmatrix} 0 & A &  \\ A^t & 0 &  \\  &  & 0 \end{pmatrix} \right\rangle
s.t. \begin{pmatrix} \text{diag}(s) & \\ & -s^t 1 \end{pmatrix} - \begin{pmatrix} 0 & \lambda_2 & \\ \lambda_3 & 0 & \lambda_5 \\ & \lambda_6 &  \end{pmatrix} + \begin{pmatrix} 0 & 0 & \\ 0 & 0 & \\ & & 1 \end{pmatrix} - Z = 0 ,  s \succeq 0 ,  Z \succeq 0

where I decomposed \lambda as follows

 \lambda = \begin{pmatrix} \lambda_1 & \lambda_2 & \\ \lambda_3 & \lambda_4 & \lambda_5 \\ & \lambda_6 & 0 \end{pmatrix}.

If A \in \R^{n \times m}, then \lambda \in \R^{(n+m+1) \times (n+m+1)} and its components break down as follows: \lambda_1 \in \R^{n \times n} , \lambda_2 \in \R^{n\times m}, \lambda_3 \in \R^{m \times n}, \lambda_4 \in \R^{m \times m} , \lambda_5 \in \R^{(n+m) \times 1}, and \lambda_6 \in \R^{1 \times (n+m)}.

As you can see, this is an unwieldy SDP to write out, but it has its benefits as a method for calculating \gamma_2(A). Specifically, I believe that 2\lambda_2 is a matrix in the unit \gamma_2^\star ball which achieves \gamma_2(A):

 \displaystyle \gamma_2(A) = \max_{\gamma_2^\star(B) \leq 1} \langle A, B \rangle = \langle A, 2\lambda_2 \rangle.

Numerical experiments indicate this is so, but I’d like to establish it. Here’s some CVX code to test this out (mostly this is just here– as is this entire post and all posts relating to my research– for archival purposes):

% solve the dual SDP for a random matrix
A = randn(20,20);
[n,m] = size(A);
cvx_begin
    variable s(n+m);
    variable lambda(n+m+1, n+m+1);
    variable Z(n+m+1, n+m+1) symmetric;
    maximize( trace( lambda * [zeros(n) A zeros(n,1); A.' zeros(m,m+1); zeros(1,n+m+1)] ));
    subject to
        s >= 0;
        Z == semidefinite(n+m+1);
        [diag(s) zeros(n+m,1); zeros(1,n+m) -ones(n+m,1).'*s] - ...
            [zeros(n) lambda(1:n, n+1:n+m+1); ...
             lambda(n+1:n+m, 1:n) zeros(m) lambda(n+1:n+m, n+m+1); ...
             lambda(n+m+1, 1:n+m) 0] + diag([zeros(1,n+m) 1]) - Z == 0; 
cvx_end
B = lambda(1:n, n+1:n+m);
% the solution to the dual SDP, the primal SDP, and  (lambda_2, A) (inner product) should
% all be the same
[cvx_optval gamma2norm(A) trace(2*B.'*A)] 
gamma2dualnorm(2*B) % check 2lambda_2 is in the gamma2dual norm ball

Possibly relevant posts:

New Math Mammoth books

There are now three new books available in the Blue Series. They are all for grades 5-6. The material for these books came from the Light Blue 5th and 6th grade curricula. Please click on the links to learn more and see samples.

  1. Math Mammoth The Four Operations
    (with a Touch of Algebra)

    The main topics studied in this book are simple equations, expressions that involve a variable, the order of operations, long multiplication, long division, and graphing simple linear functions.

    The idea is not to practice each of the four operations separately, but rather to see how they are used together in solving problems and in simple equations. We are trying to develop student's algebraic thinking. Many of the ideas in this chapter are preparing them for algebra in advance.

  2. Math Mammoth Ratios & Proportions & Problem Solving

    This worktext concentrates, first of all, on two important concepts: ratios and proportions, and then on problem solving.

    First, we study thoroughly the concept of ratio, including how it connects with fractions and the aspect ratio in rectangles.

    Solving proportions is divided into three separate lessons. In the first one, we solve proportions by thinking through equivalent ratios. In the second one, the usual method of cross-multiplying is introduced. Then follows a lesson that explains just why cross-multiplying is allowed. Then there is more practice with solving proportions and word problems. We also study scaling geometric figures and floor plans.

    The last lessons concentrate on various kinds of word problems that can be solved with the help of bar or block diagrams (the same kind as in Singapore Math). These involve problems with fractional parts, and then problems involving ratios. The diagrams become a powerful tool to solve such problems without the use of algebra.

  3. Math Mammoth Place Value 5

    Math Mammoth Place Value 5 is a short worktext that covers value up to the trillions—that is, numbers up to 15 digits—rounding them, and using a calculator.

    The first lesson covers place value up to billions. Then, we study exponents, and right after that, place value up to trillions, writing the numbers in the expanded form using exponents. After working with addition a little, there are two lessons about calculator usage.

CCC 2010 papers posted (I know- Old News)

As Lance tweeted, the papers for CCC 2010 are posted here.
  1. The Guest Speakers look AWESOME!: Khot, Raz, Regev. Also Banquet speaker Hartmanis AWESOME!
  2. Based on titles alone (not so reliable) it looks like there are no quantum papers. Someone tell me- is that really true? Even if there are some, I am sure there are not many. Has the field run its course? Doubtful. In fact, it may be the other way around--- the field has grown and their are other places for that work to appear.
  3. ADVICE: Try to download some of the papers that (1) interest you AND (2) you have the prereq knowledge OR always wanted to get that knowledge. Either read them or use them to find refs to read.
  4. Is there a centralized place to download them? There should be!!!!!! Other conferences manage this (SODA for one).
  5. I will be at STOC and CCC. Hope to see you there!

Language Arts resources

You might wonder what is that kind of title all about? Well, while this is definitely a math blog, and I do not claim to be an expert on language arts, I just keep having people ask me about language arts resources, if I have any, or if I can recommend any. So, I want to answer this question here once and for all, and then I can just reference this blogpost whenever someone else asks the same.



I have been doing an "eclectic" mix of various language arts resources with my kids.

1. Learning to read.

Photo courtesy by Yves

I definitely am an advocate of teaching children to read as early as they are able. This is not so much for the purpose of them being able to do school work, but to increase their "horizons" of everything via books. Of course, this age at which a child might learn to read varies. I personally learned to read on my own at age 4. I asked my mom about the different letters and then started reading from a newspaper. But keep in mind, Finnish language is written nearly exactly as it is pronounced, so learning to read Finnish is very easy.

My oldest learned to read at age 2. The second child learned to read at age 3. I didn't force them; I just gently prodded if they'd be ready to learn the letters, and then proceed to reading. With both, I used "Teach Your Child to Read in 100 Easy Lessons" and I liked this book really well. Towards the end, I didn't like how some of the stories turned out, but at that point I was able to start using some really easy books from the library.

Another great resource we used a lot was the website Starfall.com. It is just fantastic for early readers. It has little animated movies for the letters, then little stories and interactive activities and problems, etc. Kids could spend hours on it at a time, if allowed.

I have always encouraged them to read lots of books of all kinds. And now they are both "book worms".


2. Spelling.

I started out by letting my Dear Daughter 1 (the older, or DD1) to just do some copywork from children's books. Then we went on to do the Explode the Code workbooks by a recommendation of a friend. They teach you phonics and spelling, and seemed to work just fine for her.

She's a natural speller and seems to remember words very well. She has not had any big troubles with spelling. I have also done dictation with her a few times here and there (choosing sentences from storybooks), but it has been quite easy for her so I haven't kept up with it continually.

Recently I purchased by DD1's own request a book titled Daily Paragraph Editing for grade 5 and she has thoroughly enjoyed it. It involves finding and correcting spelling and punctuation errors in short stories.

With the younger (DD2), I have used some of the beginning Explode the Code books, but they were going too fast for her. So I changed her into Evan Moor's spelling book for 1st grade. We have both liked that a lot, and I have ordered the 2nd grade one for her as well. She definitely needs much more help to remember how to spell words than her sister.

Recently she has also fallen in love with Spellingcity website. She wants to especially practice various animal words.


3. Vocabulary

Reading lots of books gives children a lot of vocabulary, so that is one means I've relied on (naturally). But besides that, I wanted to try out some vocabulary resources. I have used downloadable versions of 240 Vocabulary Words 4th Grade Kids Need to Know and 240 Vocabulary Words 5th Grade Kids Need to Know from Currclick. Nowadays we are using Wordly Wise books also. Both of these I've found to be quality resources.


4. Grammar

I have mainly used regular, used textbooks that I've picked from The Home School Book Depot. Grammar is, again, something that comes quite easily to my DD1.

I remember playing this silly game to teach her about past, present, and future tense: I would have a drink of water or something in front of me, and I'd say, "FUTURE TENSE: I will drink this water." Then I'd start drinking, and say, "PRESENT TENSE: I'm drinking or I drink now." Once I was finished, I'd say, "PAST TENSE: I drank the water." I remember she had so much fun with that silly thing, and it thorougly taught her the idea of what past, present, and future tenses are all about.

I have also used this cheap workbook: Brighter Child® English and Grammar, Grade 3. It was basic, as expected, but alright.

Some computer games she has played, such as CLUEFINDERS 3RD GRADE ADVENTURES or Smart Steps software have also practiced her grammar concepts and skills.


5. Writing

After learning to write the print letters, I used copywork with my DD1 (from various books). I don't even remember exactly how, but she has not had any problems not wanting to write. In fact, she still enjoys writing little made-up animal stories. The other kind of "story" writing I've used in those early years was to write about what she did yesterday or about some interesting event in her own life (such as a trip somewhere).

I have also always been very happy to see her use writing in her play. She might write a shopping list, or a list of names for her stuffed animals, or a Veterinarian sign for the door, or instructions for a little treasure hunt, etc. etc. Now her little sister is picking up that habit... and I think that's very good. I don't usually correct anything in these writings that are part of the play... because I feel it can encourage them to be confident about their writing skills and see writing as something useful and valuable.

The younger one is following in her sister's footsteps, and has written a collection of short animal stories. She's glued printed pictures of the animals to those pages (the printed pictures definitely inspired her to write them!). The stories are short, but fine for her age, definitely. They are full of spelling errors, of course, and the letters don't always stay on the lines. But I still feel those stories are little treasures - they're like a stepping stone into creative writing.

However, I definitely feel I don't have the capabilities of teaching writing in the manner that real English teachers do, as the grade levels advance. Therefore, I have a plan of getting my children take English courses from an online school (at this moment I'm thinking of Keystone, because they have middle school also). This is still future... and maybe I'll change my mind later on, but at this point it's something I wish to use.

Meanwhile, something else has popped up just recently. In the past, I have made math worksheets for Spidersmart tutoring centers, and they happen to specialize in reading/writing instruction, and they have an online program for that. So... I will be trying their program out for DD1. It involves reading real books, and then answering comprehension & vocabulary questions about the book, and writing some sort of essay or assignment about it. A REAL teacher will check the answers and give feedback! (That's the part I like most, because I feel somewhat inadequate to do that.) The student then has to correct the answers. I'm excited about the program, and I hope this will be beneficial.


So... that's it for now. Quite a mixture of resources, and I'm sure there will be more to add to the list later.

Financial math – how Citibank overcharges

Interest rates are starting to edge up as economic conditions improve.

But even in the traditionally high-interest rate countries (like Australia and New Zealand), banks lend at around 7 to 8% currently, while in much of the world, interest rates are at, or very near, 0%.

So it’s extraordinary (to me) how banks are allowed to charge such whopping amounts on credit card debt.

Here’s an excerpt from Citibank Singapore’s credit card fine print (“RC” stands for “Ready Credit”).

I’ve highlighted some of the charges you’d be up for if you are (heaven forbid) just 1 day late with your payment.

Additional Information Box for Credit Card & RC

Over Limit Fee
(Not applicable to Citibank Personal Business Gold Visa Card)
If the current balance exceeds your limit, an over limit fee of $40 shall be charged
CITIBANK CREDIT CARD
Repayment Grace Period 25 days from the date of statement of accounts
Interest Charges

The effective interest rate applicable will be:

a) the prevailing product interest rate of 2% per month (24% per annum); or

b) a promotional rate of 1.5% per month (18% per annum) which may be extended based on the good conduct of your account. Notwithstanding the above, Citibank reserves the right to cancel/vary this promotional rate at any time (including if your account becomes delinquent); or

c) an interest rate of 2.25% per month (27% per annum) in the event your account is twice or more past due within the last six months. Citibank reserves the right to apply this interest rate. Your interest rate will revert to the prevailing product interest rate, as soon as your account is no longer twice or more past due within the last six months.
Minimum interest charge – S$3

Cash Advance Charges S$15 or 5% of amount drawn, whichever is higher
Late Fees

a) a fixed charge of S$50; and

b) a late payment interest charge computed in a manner similar to interest charges at a rate of 0.1875%, 0.25% or 0.28125% per month based on an effective interest rate of 18%, 24% or 27% per annum respectively, as applicable on your account. The late payment interest charge will be shown in the monthly statement of account as part of the interest charge.

Minimum Payment 1% of the current balance, plus the interest charges (including interest/service charges for any recurring/instalment payments), plus late payment charge or S$50 whichever is greater, plus any overdue amount in excess of the combined credit limit (if applicable)

The kicker is they are allowed to vary the conditions as they go along.

And did you know if you have loans with other institutions, and you default with them, you can be charged a higher interest rate on this card?

The high interest rates are justified by the banks on the grounds they are lending to people who pose some risk. This is certainly the case in the US where it is still easy to get a credit card. In the Singapore case, there are income limits (normally S$30,000 per year fro locals and $60000 per year for foreigners) before you can apply for a card.

There are thousands of people in the US who are now owing more than they borrowed (using their credit cards) and the interest (and fees) are growing so fast, it’s sending them bankrupt, especially as the Global Financial Crisis results in job losses.

Oh, and what was the main cause of the financial crisis? Lending money to people who couldn’t afford it, and didn’t understand the risks, of course.

It used to be simple. Banks could only lend to people who had the means to pay it off and could secure the loan via some mortgage (this means if you stopped paying, the banks could sell your house.) It reduced excessive and risky lending. And I doubt we’ll see that situation again anytime soon.

To be fair, it’s not just Citibank. All credit card providers do this because they can, giving us a US economy with around 1 trillion in credit card debt.

See Frontline’s The Card Game, from PBS.

Be careful what you sign.

Related posts:

  1. Online banking usability
  2. Another misleading credit card advertisement
  3. Financial literacy for students

February 28, 2010

Homomorphisms and Horn Clauses

The idea of a homomorphism extends neatly to general signatures. A function between two objects with the same signature is a homomorphism if it preserves all function and relation symbols. So φ is a homomorphism if for each n-ary function symbol f

φ( f(x1, …, xn) ) = f( φ(x1, …, φ(xn) )

and each n-ary relation symbol R

R(x1, …, xn) implies R(φ(x1, …, φ(xn))

This coincides with the usual definition of homomorphism for groups and rings. For partially-ordered sets, homomorphisms correspond to order-preserving maps.

Dividing decimals by decimals

When dividing decimals by decimals, such as 45.89 ÷ 0.006, we are told to move the decimal point in both the dividend and the divisor so many steps that the divisor becomes a whole number. Then, you use long division. But why?

Schoolbooks often don't tell us the "why", just the "how".

This video explores this concept.


Divide decimals - why do we move the decimal point?



It has to do with the fact that when we move the decimal point, we are multiplying both numbers by 10, 100, 1000, or some other power of ten. When the dividend and the divisor are multiplied by the same number, the quotient does not change. This principle makes sense:

0.344 ÷ 0.004 can be thought of, "How many times does four thousandths fit into 344 thousandths?"

The same number of times as what four fits into 344!

So, 0.344 ÷ 0.004 can be changed into the division problem 344 ÷ 4 without changing the answer. Both 0.344 and 0.004 got multiplied by 1000.

When we simplify fractions or write equivalent fractions, we use the same principle. Remember, fractions are like division problems.

3/7 is 3 ÷ 7.

And, 3/7 = 6/14. We can multiply the numerator and the denominator (or the dividend and the divisor) by some same number, without changing the value of the fraction (the quotient).

Or, 90/100 = 9/10. Or 0.9/0.2 = 9/2.

What’s in a name …

while a rose by any other name may smell as sweet, a mathematician might just be discriminated by his/her name. The perceived ability of a mathematician (as well as most academics) is by publications. There are two norms in listing authorship of joint work. One adopted by mathematics and economics is to list the authors [...]

February 27, 2010

CVXOPT + Pythonika = convex optimization from Mathematica

One of the reasons why I use Matlab more than Mathematica is Matlab supports convenient convex optimization via the open source CVX package, while Mathematica doesn’t seem to have any support even via (open source) third party packages for convex optimization.

Now it seems I’ve found a relatively easy way to rectify this, by interfacing Mathematica with the CVXOPT Python package using Pythonika. At least under Ubuntu, this was a hasslefree process: apt-get python-cvxopt, then download and compile Pythonika. The only modifications that I needed to make to the Pythonika makefile were to add a ‘-lrt’ linker flag and point to the correct python version and the correct Mathematica Linker library. Then I was able to use CVXOPT to solve a linear program from Mathematica!

CVXOPT doesn’t seem to provide the same type of natural mathematical language interface as CVX does, and I’m not sure how flexible/convenient the interface between Python and Mathematica provided by Pyhtonika is, but this is an interesting development.Possibly relevant posts:

A way not to get sign decompositions

One idea for getting sign decompositions of a matrix, inspired by Grothendieck’s inequality (the dual formulation) is to get a factorization A = UV^t which realizes  \gamma_2(A) and then round the entries of U,V to signs somehow, take D to be an appropriate scaling matrix, and use UDV^t as your approximate sign decomposition of A.

You can use this as the primitive step in a greedy algorithm, and get pretty good results (if! you use least squares to calculate D)– I implemented this method, simply replacing the entries of U,V with their signs–, but it’s not a particularly smart way of getting sign decompositions. For one thing, you could probably equally as well use random sign matrices U,V, because if you use least squares projection, you’re guaranteed that \|A - UDV^t\|_F < \|A\|_F with reasonable probability at each step (take this with a grain of salt: I think this is easy to show, but I've not checked that it's true), which is all that you can hope to say even if you use the U,V from the \gamma_2 decomposition. That is to say, there's nothing inherently special or useful about the \gamma_2 decomposition.

To drive home the point, first notice that 1 = \|I\|_{1 \rightarrow \infty} \leq \gamma_2(I) , so \gamma_2(I) = 1. Therefore we can find a wide range of factorizations achieving \gamma_2(I): take U = V to be any orthonormal matrix. So there's definitely not anything special about the factors, or the signs you'd round them to, in the general case.

Second, and more importantly, it seems difficult to prove anything about the rate of convergence of these types of greedy algorithms. And (this is just a gripe, because even a factorization corresponding to \|A\|_{\infty \rightarrow 1}^\star can be far from sparse), although the factorizations I've seen returned with my particular greedy scheme have reasonably many terms, there's no kind of guarantee of sparseness.

Possibly relevant posts:

February 26, 2010

Is Math too hard?

Are humans good at Math?

In the movie Oh God Book II God (played by George Burns) says that Math was a mistake, I made it too hard!. While I am reluctant to contradict God, George Burns, or God as portrayed by George Burns, scientists have found evidence that people are pretty good at math. At least people have known about numbers for a far longer time than previously thought. See this article. What does this mean for us? The next time one of your students says I can't do this! I'm just not that good at math! you can tell them that this is just not true.

An Aside: Before posting this I wanted to verify that that quote really was in that movie. I would have thought it would be a quote that math people, or people who think math is hard, or math people who know math is hard, would remember. When I googled it all I could find was a comment on this blog entry of Scott's by Bill Gasarch. Not what I would call a confirmation. It may be that my quote is not quite exact. If anyone knows for sure (e.g., has the DVD and checks it) let me know.

February 25, 2010

Exponent worksheets

There's a new addition at HomeschoolMath.net, free exponent worksheets.

You can create an unlimited supply of free printable exponents worksheets there. The worksheets concentrate on calculations with exponents, such as solving 33 or (1/2)4 or (-5)0 or 8-2. You can choose to include negative or zero exponent. You can choose fractions, decimals, or negative numbers as bases. You can also make worksheets that have one other operation besides exponentiation (several operations with powers).

Doing it OLD SCHOOL!

If you browse the Univ of MD Schedule Web pages for the last few years I would:
  1. Ask you why you were doing that. Seems like an odd use of your time.
  2. Point out to you that Automata Theory which usually gets around 8 people got 23 (it competes with crypto as noted a few blog entries ago).
Why the uptick? Did we use email? blogs? a websites? twitter? FACEBOOK? eBay? None of the above. We had tried some of those in the past to NO effect. We did it Old School! I went around to the classes that feed into Automata Theory and TALKED about them for 5 minutes each around registration time. And the talks were off-the-cuff. No PowerPoint, no fireworks, no technicolor show with an intermission. Also we told advisers to be on the lookout for people who might want to take it and tell them while advising.
  1. I had a prior post on why email is less effective then is used to be (I can't find the post- if you know where it is let me know.) To summarize from memory- people get too much email and some goes to SPAM filters or can be claimed to have.
  2. (A colleague of mine suggested this.) If I just EMAIL about a class, I have not spend much effort and the students sense that. If I go out of my way to talk about the class then the students think that I care.
  3. There are some other explanations for some of the uptick: Comp Sci enrollment is up (might account for 4 students) and by a fluke we have 2 grad students taking the course (which accounts for 2 students). But going from 12 in Spring 2009 to 24 in Spring 2010 is alot. (It was taught be people who are thought us as good teachers both times.)
The point is, if you want something to get attention locally do it old-school! Or at least do it old-school in conjunction with high-tech.

Meet Sade (if you haven’t already)

Sade is one of those artists I heard about constantly growing up, (you know how black people get about their Saw-day) so it’s kind of odd that I just started listening to her for real last week– growing up, of course I was familiar with “The Sweetest Taboo” and “Smooth Operator”, but I couldn’t say I knew she sung them. The title track from her latest album, “Soldier of Love”, is what caused me to start paying close attention. It must be that I needed to spread my musical wings before I could appreciate her style of music.

Anyhoo, here’re some of my favorite songs by her (if nothing else, check out “By Your Side”):

You is welcome, kinfolk!Possibly relevant posts:

An observation on the norming functionals of the norm ball

Here’s a nice observation due to a colleague of mine: if B = UDV^t is the sign factorization of B corresponding to \|B\|_{\infty \rightarrow 1}^\star, and we take D \geq 0, and  A is an extreme point on the \infty \rightarrow 1 unit ball satisfying \|B\|_{\infty \rightarrow 1}^\star = \langle A, B \rangle, then

 \displaystyle \|B\|_{\infty \rightarrow 1}^\star =\sum d_i \langle A, u_iv_i^t \rangle \leq \sum d_i \max_{\|v\|_\infty, \|u\|_\infty \leq 1 }  v^t A u = \sum d_i = \|B\|_{\infty \rightarrow 1}^\star

so each \langle A, u_iv_i^t \rangle is either 1 or 0.

Thus, for each rank one sign matrix in the decomposition of B, \langle A, u_iv_i^t \rangle = 1 . Inteeeeresting…Possibly relevant posts:

February 24, 2010

What is in MY automata theory course/What should be

In the last post I pondered what was more important: Automata Theory or Crypto. This raises the question of what should be in a course in automata theory. Rather than discuss that I will tell you what is in mine and see what you think. (ADDED LATER: YOUR COMMENTS HAVE MADE ME RETHING THINGS. I WILL ADD MINMIZING DFA'S TO THE COURSE THIS SEMESTER. I AM JUST FINISHING UP REG STUFF SO I CAN DO IT NOW.)

The standard topics are:
  1. Regular Languages: DFA's, NFA's, Reg Expressions.
  2. PDA's, CFL's.
  3. Turing Machines, computable and c.e. sets.
  4. NPC
The following make this course a bit different than others, though not much. All the thing listed below that I claim I WON"T do are definite- I WON"T do them. All the things that I claim I WILL do are less definite I can't do all of them. I'll see how it goes and which ones I will do.
  1. Decidability of Weak Second Order with S and ≤. The language has quantifiers that range over finite sets, quantifiers that range over natural numbers, and symbols for Successor and ≤. The proof uses Reg Languages. We do it in the Reg Language section and then revisit it when we do decidability. At that point I will also tell them (but not prove) about some theories that are undecidable. We also do decidability of Presburger arithmetic (quantify over naturals, have + and ≤) which follows from decidability of WS1S easily. Will also talk about decidability of S1S and omega-automta, but not prove anything. This did not take up too much time because I presented alot of it as more examples of regular languages. This material is not in any textbook that I know of, however see pages 8-28 of this PhD thesis.
  2. I am NOT going to do the algorithm for MINIMIZING a DFA.
  3. I am NOT going to do Context-Sensitive Languages.
  4. I am NOT going to have them prove things that are obvious, like that S-->aSb, S-->emptystring generates {anbn}. Generally I am against having students prove things that are obvious.
  5. I am NOT going to have them ever program a Turing Machine. I will tell them they can do everything and rarely refer to them ever again. I DO need the definition so that I can prove Cook's theorem.
  6. I am NOT going to to Primitive Recursive functions.
  7. In the NPC section I WILL DO the protocol for, in our language, NGI (non-Graph-Isom) is in AM.
  8. In the NPC section I WILL DO the protocol for, in our language, given bit-commit, 3-COL is in ZK. (I may to other ZK protocols as well.)
  9. In the NPC section will do that Vertex Cover with FIXED k is in O(n2) (I know that better is known.) Why? Because this is a very good example of an obvious thing (can't do better than roughly O(nk)) being WRONG. Shows the NEED to prove things.
  10. Might do NSPACE(n) closed under Complementation. Might not- this may be conventionally difficult for this audience. And we really wont' be talking about space anyway.
  11. Let SUBSEQ(L) be the set of a subsequence of L. I will, throughout the year, do the following: Show that if L is regular than SUBSEQ(L) is regular, Show that if L is context free than SUBSEQ(L) is context free, Show that if L is c.e. than SUBSEQ(L) is c.e. All of this leads to material I discussed in this old post. I WILL NOT prove that if L is ANY language then SUBSEQ(L) is regular, but I may talk about it.

February 23, 2010

wolfram alpha

I thought I would have written something about wolfram alpha when it was released but a search of the archives brought nought. I was reading an MAA magazine and found a new trick. You can actually find word subsets. Yes, I’m aware that of the very clear internet anagram server which is an anagram of [...]

Another kind of sports reporting

Inspired by John Allen Paulos, who just now tweeted

Obvious, but NBC hasn’t said: Canada, Norway, Germany way ahead of US in Olympic medals per capita. Many ways to rank: Cf. Arrow’s theorem.

I decided to redo the medals list. Here, the number of medals per capita among the top countries.

Country Gold/capita Silver/capita Bronze/capita Total/capita
Norway 1.23E-06 6.17E-07 1.03E-06 2.88E-06
Austria 3.58E-07 3.58E-07 3.58E-07 1.07E-06
Slovenia 0 4.87E-07 4.87E-07 9.74E-07
Switzerland 6.43E-07 0 2.57E-07 9.00E-07
Latvia 0 8.90E-07 0 8.90E-07
Sweden 3.21E-07 2.14E-07 2.14E-07 7.49E-07
Estonia 0 7.46E-07 0 7.46E-07
Slovakia 1.84E-07 1.84E-07 1.84E-07 5.53E-07
Croatia 0 2.25E-07 2.25E-07 4.51E-07
Netherlands 1.81E-07 6.03E-08 6.03E-08 3.01E-07
Canada 1.47E-07 1.18E-07 2.94E-08 2.94E-07
Czech republic 9.51E-08 0 1.90E-07 2.85E-07
Germany 8.56E-08 1.10E-07 6.12E-08 2.57E-07
Belarus 0 1.05E-07 1.05E-07 2.11E-07
Finland 0 1.87E-07 0 1.87E-07
Korea 8.04E-08 8.04E-08 2.01E-08 1.81E-07
France 3.06E-08 3.06E-08 6.11E-08 1.22E-07
Poland 0 7.87E-08 2.62E-08 1.05E-07
Australia 4.51E-08 4.51E-08 0 9.02E-08
USA 2.27E-08 2.59E-08 3.24E-08 8.10E-08
Russian Federation 1.41E-08 2.11E-08 4.23E-08 7.75E-08
Italy 0 1.66E-08 4.98E-08 6.64E-08
Kazakhstan 0 6.34E-08 0 6.34E-08
Japan 0 7.85E-09 1.57E-08 2.35E-08
Great Britain 1.61E-08 0 0 1.61E-08
China 2.25E-09 7.49E-10 7.49E-10 3.74E-09

(Data taken on February 23, from the current state of olympic medals achieved at that date, and from the Wikipedia page listing populations of the nations of the earth, taken the same date)

Any good book suggestions?

It looks like I might soon have some spending money. I haven’t gone on a fiction buying spree in a while. Any suggestions? I’m going to pre-order The Desert Spear, because Warded Man was too awesome for me to miss out on the sequel, but other than that, it’s up in the wind. I’ve been out of the sci-fi/fantasy book loop.

Looking for suggestions… I’d prefer one offs and completed series over incomplete series.Possibly relevant posts:

A tentative (no theoretical analysis) sign factorization

I’ve found a tentative algorithm for sign factorization. I’ve only tested it on random matrices (generated using rand and randn) in Matlab– as opposed to theoretically verifying that it holds, or even testing on real datasets– so it may turn out that it just works with high probability for random matrices generated in those particular ways … but hey, that’d be a result.

The error bound looks to be something like \| A - \hat{A} \|_{\text{F}} \leq c(A)^p\|A\|_{\text{F}} where \hat{A} is the sign matrix factorization and c(A) depends on the size of A (it may also depend on \|A\|_{1 \rightarrow \infty}), and the integer p represents the number of times you do a greedy type recursion.

Fingers crossed! as I’m off to attempt an analysis.

Update: Oops, it seems you can’t get that c(A)^p factor arbitrarily small.Possibly relevant posts:

February 22, 2010

What is more importantt: Automata Theory or Crypto?

The way the requirements are set up at Univ of MD at College Park, without getting into details, has set up a competition between Crypto and Automata Theory That is, a student might take one or the other, but taking both does not serve her well for the requirements. Hence the students get to decide which one is more important, Crypto or Automata Theory. We did not plan it this way, it just happened. Automata Theory is Reg Languages, CFG/PDA, Computability theory, NPC. (A later post will expand on this since I am teaching it this semester.)

  1. The students overwhelmingly take crypto. One year 150 students took Crypto (one section of 50 in the fall, two sections of 50 each in the spring) and 8 students took automata theory. Both courses are always taught by people who are regarded as good teachers, so that is not the issues.
  2. I tend to think that Automata Theory is more important, but I may be biased. I also think that Automata Theory can be understood pretty well, whereas to understand crypto you really need to understand some Number Theory and even some security. Hence it is a strange stand-alone course.
  3. Some students think that the crypto course will get them a job. A course in security may get them a job, but just crypto I kind of doubt.
  4. Since more students choose Crypto we offer it more often. Since we offer it more often more students take it. (I exaggerate the circularity.) Also, its cross listed with Math so some math majors take it. This may account for some of the difference but not even close to all of it.
  5. So, how does your school do this? In particular, do you let the students tell you what course is more important, or do you tell them? Is it bad if they tell us? YES if we end up with courses on twitter, NO if the students are more aware of what is important then we old academics are.

World Math Day 2010


World Math Day 2010 is coming up on March 3rd. You might remember it from last year. It is a free event and lots of fun for the kids.

Registrations close March 2nd. Once you register, you can go practice at the website.

In it, students complete against other students from around the globe in REAL time, with simple mental math questions (such as 7 + 8 or 24 ÷ 4 or 9 × 9). It involves more than 2 million students from over 200 countries.
  • Brand NEW format.
  • Be part of setting a world record!
  • Designed for all ages and ability levels. Simple to register and participate. All you need is Internet access.
  • Great prizes
  • And it’s absolutely free!!
Remember to hurry because the registration closes March 2nd, 2010.

www.worldmathday.com

February 20, 2010

Math Teachers at Play again

The most current edition is posted at MathRecreation. It's very interesting, with lots of variety, head on over!

February 18, 2010

A problem about Graph Partitions (guest post)

(Guest post from Richard Taylor who requests information on a problem.)

The following graph partition problem arises in connection with studies I am doing on a particular dynamical systems problem. I wonder if there are any complexity results on it. Given a 3-regular graph, can the vertex set be partitioned into 2 sets in such a way that the induced subgraphs formed each have vertices of degree at least 2? Could this be NP complete? There are a few results on vertex partitions I have found in the literature - but none quite like this.

First Request from Bill G: In the past I have posted on problems and have had comments tell me that its well known or falls out easily from some theory, but then not give me a reference or proof sketch. Please, if you are going to say its known, give a reference or proof sketch.

chiropractic

I know, this is a very rare post from me, now.  Don't count on it being a trend, though I'd like it to.


I've finally started seeing a chiropractor.  She's also a fibro specialist, which helps, and very near home, which means I can get there by myself.

Found out that my neck is a ( where it should be a ) -- it curves the wrong way entirely.  No wonder it causes me so much pain.  Also my lower back, as I suspected, curves too far, but at least it curves in the correct direction.  And my pelvis/sacrum is wonky, twisted, and I have some arthritis in my lower spine. 

The most debilitating of my pain these days is in my lower back...  my other body pain (which is everywhere, in many types, and is extreme) and general fatigue keeps me from being able to do too much in general, but my lower back is keeping me from being able to stand up for more than 5-10 minutes at all.  If I can get that under control, then at least I'll be able to do a few minutes of housework again.  I haven't been able to do even that lately.

Effects from the first adjustments:  it felt minor at the time, but left me with a slight headache all day (in spite of extra oxycodone both before and after the session, and icing both areas tonight), and lots of neck soreness now.  A little soreness in the lower back area, but the lion's share in the neck.  Now I'm wishing I was going back tomorrow rather than Friday, because I want her to fix this!  Oh well...  I do expect adjustments to trigger flares, but they'll be worthwhile in the long run.

February 17, 2010

Kurt Mehlhorn to receive EATCS award

Kurt Mehlhorn will receive EATCS award! Read about it here.

He has had a LONG and PRODUCTIVE career with many EXCELLENT papers. While he is mostly known for data structures and algorithms and Comp Geom, he did do some complexity theory early on. Here is a list of his papers up to 2007. Note that the first few are in complexity theory.

People in TCS can change fields easier than math since there is less background to learn. At least that was true at one time. I think it is harder to switch fields in Comp Sci now then it was then since now we know more.

February 16, 2010

e to the pi vs pi to the e

(ANSWER to Trivia Questions from Last Post: The last president who became president NOT by being VP and having the prez die, but then did not run again, was Rutherford B. Hayes. Hayes and Obama are the only presidents who have law degrees from Harvard. For more on both of these questions see this excerpt from my Prez Trivia Quiz.)

When I was 12 my school got a very primitive computer. The teacher asked me what I wanted it to do for me. I said
I want to know whats bigger eπ or πe.
I typed both of them in, but I forgot the order I typed them in so I didn't find out. I didn't try again because I realized that even if I found out the answer it would not tell me a reason for the answer.

I had forgotten all about it until last week when I got a review of the book When Least is Best (book by Paul Nahim, review by Yannis Haralambous) in my capacity of SIGACT NEWS book review editor. Here is a quote from the review:
Imagine you are stranded on a desert island (without logarithm tables or computers) and--- probably due to an emotional shock---your only concern is to find out which one among numbers πe and eπ is bigger. The solution is: take h(x)=ln(x)/x, take the derivative twice to prove that x=e is a maximum, and that gives eπ is bigger.
I am sure this is well known; however, since I didn't know it until last week I hope this will enlighten some of my readers.

Something about arrays

What is it called when I have a lot of integers
and I want to find out
how many of those integers are within two given values.
for example
given these 10,000 integers
how many are within
j and k

whats that called?

February 15, 2010

Prediction on Presidents Day

Its PRESIDENT"S DAY so I have two predictions: One about the election of 2012 and one about P vs NP.

ON P VS NP: I have one prediction about P vs NP. It is not about when it will be solved (though I think this will be a long time). Look at the separation NC1 ≠ AC0. This was NOT achieved by taking a problem complete for NC1 (the word problem for S5) and showing it is not in AC0. Instead a different problem in NC1, PARITY, was shown to not be in AC0 (CHECK- is it known that PARITY is NOT complete for NC1? I think so - PARITY can be done in width 2 , poly sized BP and NC is equivlaent to width 5 poly sized, is probably the main part of the proof.)

I predict that P ≠ NP will be proven by showing some problem that is in NP but NOT NPC is not in P. The NPC problems seem to be hard to prove things about. Hence a problem in NP but not NPC may be better. Factoring is a candidate for this. Graph Isom may also be a candidate--- its like PARITY in that its very delicate. But it may very well be in P.

ON THE ELECTION OF 2012. For the Prez election of 2008 I predicted, before the primaries, that the candidates would be Barak Obama and John McCain, and that Barak Obama would win. I never blogged about it so my readers may be skeptical that I made such a prediction. Hence I will, today, predict the nominess for 2012: Barack Obama and Mitt Romney.

Barack Obama is obvious- TRIVIA- The last president to decline to run for a second term was LBJ. Note that he originally got to be Prez because he was VP when JFK died. The one before that was Harry Truman. Note that he originally got to be Prez because he was VP when FDR died. Who was the last president who obtained office NOT be being VP when the Prez died, who did not run for a second term? MORE TRIVIA:Call this prez X. Give a non-trivial trivia question for which the answer is Barack Obama and X. (I will answer these at the beginning of my next post.)

Mitt Romney- The republicans tend to give the nomination to someone familiar to them. Like the guy who came in second last time. Palin is also familiar to them, and she may run in the primaries, but I do not think she will get the nomination.

I also predict that Obama will win.

February 11, 2010

FOCS 2010 CALL FOR PAPERS is out!

(Univ of MD at College Park had Monday, Tuesday, Wed, Thursday all off. I've spend most of that time shoveling snow, so I am tired. Hence I am glad to have a SHORT post today- easier on the hands and arms.)

ADDED LATER-- I won't post Friday - instead I will add to this post. Note that there is NO PAGE LIMIT for FOCS submission! Is this a new policy? Have other conferences done this? It makes sense with e-proceedings to have no page limit for FINAL versions, but for Submissions. Might be hard on the committee and the sub-referees. PRO- people can include complete proofs and may be expected to. This will lead to better quality submission and less chance of error. CON- if you are restricted to 10 pages you are forced to make your point and shut up. PRO- Your submission and your final version and your journal version can be similar so less hassle changing formats. What do you think?

FOCS 2010 call for papers is out. Where is the link? You just read it! I did? Third Base!

Most important byte of info: April 7 is submission deadline. If a student said that he was sick and had a doctors note, you would likely give him an extension for a deadline. For FOCS, if a potential submitter tells the program chair that he is sick, I doubt he'll get an extension.

IF you had your paper rejected from STOC then should you submit to FOCS? It would be nice (though hard to really do) if the reports from STOC said Even though the paper was turned down, it was one of those papers which could have gone either way, so it could get into FOCS or XXX. or Your paper is not worthy of STOC or FOCS or XXX.

I am writing THIS before I actually post (duh). Right now if you type FOCS 2010 into Google, Our FOCS conference is the SECOND entry. Here is hoping that this post will boost it to the top.

February 10, 2010

Algebra problem: airplane's speed in still air

Photo by Caribb

Someone sent me this algebra problem:
An airplane flew for 6 hours with a tail wind of 60km/hr. The return flight against the same wind took 8 hours. Find the speed of the boat in still water.


Initially, this sounds like a trick problem, because you can't know the speed of the boat when all the information given is about an airplane!

But, let's assume they meant to ask the speed of the AIRPLANE in still air.

This problem has to do with constant speed. Constant speed ALWAYS involves TIME & DISTANCE.

And here we have two situations with two different speeds: First the airplane flies over there, with the wind helping. Then it flies back, and the wind is contrary of course.

It helps to organize our information in a table, once again. We'll need time, distance, and speed. And remember, speed = distance/time, or distance = speed * time. This time, time is known for both situations. Distance is not, but it is the same distance that way and back (call it d). Traveling there, the speed will be the sum of the airplane's speed (v) plus the wind speed (60). Traveling back, the wind is contrary so its speed is subtracted from the airplane's speed.


| Time | Distance | Speed
------------------------------------------
There | 6 | d | v + 60
-----------------------------------------
Back | 8 | d | v − 60

I'll copy the same table here, but instead of using d for distance, I'll calculate it using distance = speed × time.


| Time | Distance | Speed
------------------------------------------
There | 6 | 6(v+60) | v + 60
-----------------------------------------
Back | 8 | 8(v-60) | v − 60

Now, one just needs to find a way to make an equation... it will be a bit different in different word problems, but this time we get it from the fact that the distance over there is the same as the distance back:

6(v + 60) = 8(v − 60)

6v + 360 = 8v − 480

840 = 2v

v = 420

The speed of the airplane in still air is 420 km/h.

Check: For checking, we will calculate the distance it traveled. Traveling 6 hours with the speed (420 + 60) km/h or 480 km/h means the distance was 2,880 km. Traveling back took 8 hours, so the speed must have been 2,880 / 8 = 360 km/h, which is (420 − 60) km/h. So, the story "matches".

STOC and More

The Snows of Maryland are keeping Bill away from this blog again. Here in Chicago we deal with snow (and even earthquakes) in stride--my kids still have yet to have a snow day this year.

So I'm back for a day to bring you some news.

The STOC accepted papers list is up, Shiva Kintali is collecting PDF pointers and Noam Nisan pulls out the AGT papers. Lots of goodies this year. You can change base without losing space (love that rhyming title), save space with algebrization and adding quantum to interactive proofs keeps it in PSPACE. 

You just don't see a lot of BLANK is computable results in STOC these days so nice to see a paper with BLANK=HOM=Is a given homomorphism of a regular language expressed by a tree automata itself regular? Sound technical but it actually has connections to XML.

So come to the conference. As Bill mentioned earlier, there are travel awards available for needy students even if you don't have a paper. Apply for visas if needed as soon as possible (click here if you need a letter). The Complexity and EC conferences will both be held also in Cambridge immediately following STOC.

The other big news, according to the Center for Computational Intractability, theory's own Subhash Khot wins the 2010 NSF Waterman award. The NSF gives away only one of these awards each year to a young researcher across all of science.

We are entering CS award season so keep an eye out for the Knuth Prize (the Knuth Prize Lecture will be at STOC), the EATCS award and Gödel Prize (presented at ICALP), Turing and other ACM awards. The SIGACT Distinguished Service award nominations are still open until March 1st which will also be presented at STOC.

February 09, 2010

What is an Elementary Proof?

What is an Elementary Proof? Different things in different contexts.
  1. An Elementary Proof is one that does not use Complex Analysis. Basic Calculus is fine. This was the criteria when people asked for an Elementary Proof of The Prime Number Theorem. Such a proof was found by Erdos and Selberg. (See this paper for the history) Later Oliver Sudac (TCS, The Prime Number Theorem is PRA Provable, Vol 257, NOT Online) showed there is a proof in Primitive Recursive Arithmetic which is weaker than Peano Arithmetic. An interesting article on this which IS online is by Jeremy Avigad on all of this is at Number Theory and Elementary Arithmetic. From what I hear, the original proof is still the easiest way to prove it. (NOTE- Oliver Sudac, if you are reading this put your paper on line. If you do not then over time it will be called ``Avigad's theorem''.)
  2. An Elementary proof is one that can be taught to a class of bright college students in about two hours. If you hear someone say Shelah's primitive recursive bounds on the VDW bounds is elementary this is what they mean. (See here. for the paper.) )
  3. An Elementary proof is one that does not use advanced techniques. The original proof of Szemeredi's Theorem is rather difficult; however, it does not use advanced techniques. You could probably teach it to a class of bright college students in about two months. Even so, I would hesitate to call it elementary. It might be easier to learn the background mathematics for one of the non-elementary proofs rather than follow the elementary one.
  4. An Elementary proof is one that some bright high school students can come up with during a High School Math Competition.
    1. The following is elementary: Show that any for any 3-coloring of the natural numbers there exists x,y that are the same color such that x-y is a square.
    2. The following is probably not elementary: Show that any for any 4-coloring of the natural numbers there exists x,y that are the same color such that x-y is a square. I wanted to put it on the Maryland Math Competition to find out if it was elementary, but alas they didn't let me. I do not know of a proof that a bright college student could do on his own. The theorem is true by poly VDW thm; however, I would very much want to see an easier proof.
    3. The following is elementary: Show that if n is a power of 2 then if there are 2n-1 integers then some n of them sum to 0 mod n.
    4. The following is probably not elementary: Show that if n is any integer then if there are 2n-1 integers then some n of them sum to 0 mod n. The proof in here is elementary in that you could explain it to a bright college student in 30 minutes; however, I don't think they could come up with it themselves.
    5. In Elementary Particle Theory it is the particles that are elementary, not the theory.
It is hard to pin down Elementary rigorously. I just want to be able to understand a proof and the intuition behind it. But we can't define elementary in terms of what I want.

What theorem would you most want to see an elementary proof of? For me it would be Gowers bounds on the VDW numbers.

February 07, 2010

The Categorification of the Naturals

A heavyweight looking title, but this post is really about nothing more than doing arithmetic.

Peano Arithmetic
I've seen many articles on type level arithmetic. They all seem to share the idea that the Haskell type system can be made to perform computations by treating types as symbols that can be manipulated according to rules. But every article I have seen seems to miss the important idea that the naturals don't have to simply be empty symbols - that they are perfectly good types with elements and that the basic operations of arithmetic have nice a interpretation as functions between types. Implementing these missing pieces will also give an example of categorification.

As usual, some Haskell administration first because this post is runnable Haskell code:


> {-# LANGUAGE ScopedTypeVariables, UndecidableInstances #-}
> {-# OPTIONS -fglasgow-exts #-}


Here are what are commonly called (some of) the Peano axioms defining addition and multiplication:

1. 0+b = b
2. Sa+b = S(a+b)
3. 0.b = 0
4. Sa.b = b+a.b

The idea is that S represents the "successor" function maping n to n+1. Using just these definitions, and induction, we can define addition and multiplication for all natural numbers. For example, 3 is represented by SSS0 and 2 by SS0 and we can compute 3+2 using

2+3
= SS0+SSS0 by definition
= S(S0+SSS0) by 2
= S(S(0+SSS0)) by 2
= SSSSS0 by 1
= 5 by definition


But where do addition and multiplication come from? One point of view is that the natural numbers are what we get when we take finite sets but consider sets of the same size to be equal. We can do the same with finite types. The type Bool and Maybe () both have two elements (ignoring bottoms) and are isomorpic. We can just consider these to be the same type, called 2. Given two types A and B we can form Either A B. The number of elements in this new type is the sum of the number of elements in A and B. If we blur the distinction between isomorphic types we can think Either as being the addition operator. Similarly, (,) can be thought of as multiplication. The Peano axioms now describe the properties of addition and multiplication defined in this way.

When we consider different types to be equal we lose some information. In particular, we lose that fact that given two types of the same size, we can construct an explicit isomorphism between them. But there's no need to do this. We can go back to the Peano axioms and reinterpret them as a recipe for constructing the isomorphism. If we do this, then any theorem we prove (constructively) using the Peano axioms can be interpreted as explicitly constructing an isomorphism between types. We normally just forget about the isomorphism. This 'forgetting' is so common that it has a name: decategorification. Putting the structure back is called categorification.

Type Level Naturals
We will represent the natural number n as a type with precisely n elements. We'll start with the type representing zero. Obviously it must have no elements. It's traditionally called Void.


> data Void
> instance Show Void where
> show _ = undefined


That undefined will cause no problems as we can never pass an argument into show.

If Void is playing the role of 0 we need something to play the role of S. That's Maybe. Given a type A, Maybe A is the type with one more element. So we can mimic the definitions of the natural numbers:


> type One = Maybe Void
> type Two = Maybe One
> type Three = Maybe Two
> type Four = Maybe Three
> type Five = Maybe Four
> type Six = Maybe Five


and so on. I'll call these the natural number types. We can also label the elements of these types. Here are some elements:


> zero = Nothing
> one = Just zero
> two = Just one
> three = Just two
> four = Just three
> five = Just four


Addition
Now we can define addition. We want to be able to take a pair of natural number types A and B and construct an explicit isomorphism between Either A B and a natural number type which I'll label Plus A B. I'll call the isomorphisms one way plus and the other way plus'. Here's a suitable type class:


> class Plussable a b where
> type Plus a b
> plus :: Either a b -> Plus a b
> plus' :: Plus a b -> Either a b


From axiom 1 we want 0+b=b. This immediately gives:


> instance Plussable Void b where
> type Plus Void b = b

> plus (Right b) = b
> plus' b = Right b


We can view axiom 2, Sa+b = S(a+b), as:



The implementation of plus implements the mapping of the shaded square directly. If we ignore the shaded square and consider only the unshaded ones, then we are left with another simpler addition. We can implement the isomorphism for that by using plus recursively. Here's the code:


> instance Plussable a b => Plussable (Maybe a) b where
> type Plus (Maybe a) b = Maybe (Plus a b)
> plus (Left Nothing) = Nothing
> plus (Left (Just a)) = Just ((plus :: Either a b -> Plus a b) (Left a))
> plus (Right b) = Just ((plus :: Either a b -> Plus a b) (Right b))

> plus' Nothing = Left Nothing
> plus' (Just x) =
> let i' = plus' :: Plus a b -> Either a b
> in case i' x of
> Left a -> Left (Just a)
> Right b -> Right b


Multiplication
Now we can implement multiplication similarly. First the type class:


> class Timesable a b where
> type Times a b
> times :: (a, b) -> Times a b
> times' :: Times a b -> (a, b)


Multiplication by zero gives zero. This is straightforward to implement for the simply reason that we don't actually have to implement isomorphisms for the empty type:


> instance Timesable Void b where
> type Times Void b = Void
> times _ = undefined
> times' _ = undefined


(That's not quite true, Haskell, for some reason, forces us to write a line of code that can never be used. I think this ought to be fixed.)


> instance (Timesable a b, Plussable b (Times a b)) => Timesable (Maybe a) b where
> type Times (Maybe a) b = Plus b (Times a b)

> times (Nothing, b) =
> let i = plus :: Either b (Times a b) -> Plus b (Times a b)
> in i (Left b)

> times (Just a, b) =
> let i = plus :: Either b (Times a b) -> Plus b (Times a b)
> in i (Right (times ((a, b))))

> times' b =
> let i' = plus' :: Plus b (Times a b) -> Either b (Times a b)
> in case i' b of
> Left b -> (Nothing, b)
> Right ab -> let (a, b) = times' ab in (Just a, b)


That's it. We've decategorified type level arithmetic. Given an equality like 2*3=6 we automatically get an isomorphism like

times :: (Two, Three) -> Six


Isomorphisms from Equations
But what about more general equation like 2*2+5 = 3*3? Can we automatically construct the isomorphism?

One approach is simply to reduce each side of the equation to its canonical form, in this case 9, and then use this to construct a pair of isomorphisms, one from the left hand side to the 9 element natural number type, and one from 9 element natural number type to the right hand side. We'll use a type class to indicate that a type can be reduced to canonical form. The map doing the reduction will be called canonical:


> class Canonicable a where
> type Canonical a

> canonical :: a -> Canonical a
> canonical' :: Canonical a -> a


Void is already in canonical form so there's nothing to do in this case:


> instance Canonicable Void where
> type Canonical Void = Void

> canonical = id
> canonical' = id


If something is of type Maybe A, and A is reducible to canonical form, then we can simply reduce Maybe A in two steps:


> instance Canonicable a => Canonicable (Maybe a) where
> type Canonical (Maybe a) = Maybe (Canonical a)

> canonical Nothing = Nothing
> canonical (Just n) = Just (canonical n)
> canonical' Nothing = Nothing
> canonical' (Just n) = Just (canonical' n)


Now I give the rule for reducing Either A B to canonical form. We just have to reduce A and B to canonical form and then apply plus:


> instance (Canonicable m, Canonicable n, Plussable (Canonical m) (Canonical n)) => Canonicable (Either m n) where
> type Canonical (Either m n) = Plus (Canonical m) (Canonical n)
> canonical (Left m) =
> let i = plus :: Either (Canonical m) (Canonical n) -> Plus (Canonical m) (Canonical n)
> in i (Left (canonical m))
> canonical (Right n) =
> let i = plus :: Either (Canonical m) (Canonical n) -> Plus (Canonical m) (Canonical n)
> in i (Right (canonical n))
> canonical' x =
> let i' = plus' :: Plus (Canonical m) (Canonical n) -> Either (Canonical m) (Canonical n)
> in case i' x of
> Left m -> Left (canonical' m)
> Right n -> Right (canonical' n)


Now we need to do the same for multiplication. I'm beginning to feel sorry for the stress we're putting the compiler through:


> instance (Canonicable m, Canonicable n, Timesable (Canonical m) (Canonical n)) => Canonicable (m, n) where
> type Canonical (m, n) = Times (Canonical m) (Canonical n)
> canonical (m, n) =
> let i = times :: (Canonical m, Canonical n) -> Times (Canonical m) (Canonical n)
> in i (canonical m, canonical n)
> canonical' x =
> let i' = times' :: Times (Canonical m) (Canonical n) -> (Canonical m, Canonical n)
> (m, n) = times' x
> in (canonical' m, canonical' n)


Now using the canonical forms we can build the isomorphism for any equation:


> iso :: (Canonical m ~ Canonical n, Canonicable m, Canonicable n) => m -> n
> iso m = canonical' (canonical m)


So let's return to 2*2+5=3*3. The isomorphism should be:


> test = iso :: Either (Two, Two) Five -> (Three, Three)


If we've done our job correctly, the compiler won't complain that it can't build the isomorphism.

If you really want you can try running this code for a few values:


> go1 = Left (zero, one)
> go2 = Left (one, zero)
> go3 = Right four


Try writing code to implement the inverse, checking that it does give the inverse for these three cases.

Conclusions
So there you have it, categorified arithmetic. Of course categorifying the naturals isn't so hard. But what does it mean to categorify the number π? You'll have to read some John Baez to find out more.

There sort of is an application of the operations defined above. The type Three say is the type of indices into a three element type. More generally, these natural number types give indices into fixed length containers and the addition and multiplication operations give type safe ways to map between containers that have the same size. This could be used to pack n-dimensional fixed size arrays into 1-dimensional arrays and vice-versa with compile-time checking of array indices. In practice, however, the compiler would need to be smart enough to realise it could use integers internally rather than the more complex structures it's probably using. But it's curious to see similar operations appear in some OpenCL array manipulation code I've been playing with.

The code above isn't all that pretty. As I've said before: Haskell is two languages. There's the value level language and the type level one. The former is much prettier than the latter, especially if you can use type inference to eliminate the latter.

By the way, you can view iso as a command to trigger the Haskell compiler to prove there is an isomorphism between two types of a certain class. This is very similar to what a tactic in Coq does. In fact, the code I've written above is very similar to what a proof in Coq might look like. The main difference is that Coq gives you a helping hand and can fill in details whereas Haskell forces us to do all of the work ourselves.

An Irrelevant Aside
When I was still at high school a friend returned to visit after a few months at university. He'd been playing with Prolog and showed me how to define Peano arithmetic in that language. Since then, I've sort of been obsessed with squeezing Peano arithmetic out of every computational system that can do it. Hence my C++ code here. I looked him up on the web and it turns out he also wrote the original BSD automounter. Small world.


February 06, 2010

Celebrating e-day

Tomorrow 2/7 is e-day.

e or Euler's number is a number that is approximately 2.718281828, so that is why someone chose 2/7 as an e-day. But e is an irrational number, so its decimal expansion is never-ending and never-repeating.

Why is this number e so important that people have even named a day after it?

If you've studied calculus, you already know at least part of the story. But even if you haven't, I'll try to unravel at least the most basic feature of e.

Consider the exponential function ex. It is graphed below.


It has one remarkable property: when you draw a tangent to it at any particular point, the SLOPE of that tangent is always the value of the function ex at that point. See below two examples:

A tangent at 0.69 with slope 2


A tangent at -0.69 with slope 0.5

This feature is usually expressed this way: ex is its own derivative, or the derivative of ex is ex. There exists NO other function with that property!

Here's also an interesting explanation about one fundamental property of e as it relates to growth: An intuitive guide to exponential functions. This guide is meant for BEGINNERS. It's not based on calculus. Instead, it starts by looking at a basic system that doubles after an amount of time, and refines this basic system to arrive at the idea of e.

But that's just for starters. The number e has popped up in all kinds of interesting places for mathematicians over the years. For example





One famous equation ties in e, Pi, 1, 0, and the imaginary unit i — five important numbers in mathematics:

eiπ + 1 = 0

See even more representations of e (infinite series, continued fractions, infinite products, and special limits). It truly is quite a number! I don't claim to understand why it is involved in all these things - like I said, it seems to "pop up" in all kinds of places. But maybe you can see a glimpse of why it is so special.



Curiously, in some places, e-day means something different from a day dedicated to the number e. But to celebrate the e-day in honor of the number e, whatever your language, I suggest making or baking a food that either starts with "e" or has "e" as a prominent part of its name... such as chEEsE or browniEs. It's your choice!