July 03, 2009

Kentucky State Police Post 2 June Statistics Report

The Kentucky State Police of Post 2 in Madisonville have released their statistical report for the month of June.

Bail law means jail for more juveniles

MOST young people jailed for breaching bail conditions have not committed another crime but have broken curfews or failed to stay with parents, a controversial report by the NSW Bureau of Crime Statistics and Research shows.

FOCS Papers

For this pre-Independence Day post Bill suggested I write about the math knowledge of our founding fathers or how "P=NP" will declare itself independent of ZFC. Luckily FOCS announced the accepted papers so I can talk about that instead. First the lists.


PC Chair Dan Spielman discusses the review process though he doesn't talk about the usefulness of the 2-page addendum or the criteria used to choose the papers, which seems to have tended again towards the technical.

Here are a few of the many interesting looking papers that caught my eye.

  • David Doty. Randomized Self-Assembly for Exact Shapes
    • You just don't see many STOC/FOCS papers on self-assembly or from Iowa State.
  • Ilias Diakonikolas, Parikshit Gopalan, Ragesh Jaiswal, Rocco Servedio and Emanuele Viola. Bounded Independence Fools Halfspaces
    • I like results that just sound neat and can be fully stated in the title.
  • Zeev Dvir, Swastik Kopparty, Shubhangi Saraf and Madhu Sudan. Extensions to the Method of Multiplicities, with applications to Kakeya sets and Mergers
    • And better randomness extractors too.
  • Or Meir. Combinatorial PCPs with efficient verifiers
    • Sounds interesting and the only FOCS paper that cites one of my papers in the abstract.
  • Rahul Jain, Sarvagya Upadhyay and John Watrous. Two-message quantum interactive proofs are in PSPACE
    • QIP is known to sit in between PSPACE and EXP and it's an interesting open question which way it goes. This paper makes some progress in resolving that.
  • Neeraj Kayal and Shubhangi Saraf. Blackbox Polynomial Identity Testing for Depth 3 Circuit
    • Makes progress on deterministic polynomial identity testing, one of the few remaining probabilistic algorithms to derandomize.
  • Ravindran Kannan. A new probability inequality using typical moments and concentration results
    • Looks like something we will all need to add to our toolboxes. The accepted papers list dropped the word "inequality" which made the paper seem unreal.
  • Alexander Sherstov. The Intersection of Two Halfspaces Has High Threshold Degree
    • An exciting result in its own right. The Complexity class analogue goes the other way: Beigel, Reingold and Spielman showed the class PP is closed under intersections.

July 02, 2009

Learn PCPs at DIMACS

Prahladh Harsha asked me to post the following announcement on the blog. I don't usually post announcements but this seems like an excellent opportunity to learn about approximation and PCPs from the masters. You can find many more links and short announcements on my Twitter Feed where you would also learn the FOCS accepted papers list is out. My thoughts on the FOCS papers tomorrow.
  


DIMACS Tutorial on Limits of Approximation Algorithms: PCPs and Unique Games

When: July 20 - 21, 2009 
Where: DIMACS Center, CoRE Building, Rutgers University

I would like to advertise an upcoming tutorial on "Limits of Approximation Algorithms: PCPs and Unique Games", organized under the auspices of the DIMACS Special Focus on Hardness of Approximation. This tutorial is geared towards graduate students, postdocs and others who are theoretically oriented, but not necessarily familiar with the material.  The aim of the tutorial is to give participants a general overview of approximability, introduce them to important results in inapproximability, including some of the recent developments in the world of probabilistically checkable proofs (PCPs) and the unique games conjecture. 

The list of speakers includes: Matthew Andrews (Alcatel-Lucent Bell Laboratories), Sanjeev Arora (Princeton University), Moses Charikar (Princeton University), Prahladh Harsha (University of Texas, Austin), Subhash Khot (New York University) and Lisa Zhang (Alcatel-Lucent Bell Laboratories).

Registration is free and limited travel support is available for non-local participants (with preference to students and postdocs). More info on the workshop web site.

July 01, 2009

Rings

Every time I read something that pertains to any kind of ring, there's always a necessary section at the beginning stipulating that such-and-such a ring has an identity, that the mappings under consideration must preserve that identity, and so forth. Can someone fill me in as to whether there's some area of study in which people use rings without 1 so extensively that it makes up for the extreme annoyance of dealing with such requirements everywhere else? As far as I can tell, rings without 1 occur basically as often as these things called "monoids" or "groupoids" -- more than never, but certainly not often enough to merit such a basic name, or take up space in textbooks and brains. Can someone set me straight here?

2pi-day? Other holiday possibilities!

May 28 should be Pi-day instead of March 14 since pi should be what we now call 2*pi (6.28...) since 2*pi comes up in more formulas than pi. (When I blogged about this here one of the commenter's suggested 2*pi*i.)

So what-should-be-pi-day was last Sunday. To honor this day I asked people what day or concept they would want to make a holiday. Here is what I got.
  1. Multicultural day. OR give every ethnic group a holiday. This may lead to the 4-day work week.
  2. Mid-autumn day to give us a break.
  3. Pi-Day (March 14)
  4. Mole Day (Oct 23)
  5. Talk like a pirate day (Sept 19.) Did pirates really talk that way in the past? now?
  6. Election day. That way more people will vote.
  7. The day Louis Brandeis got appointed to the supreme court. He was the first Jewish member of the court. This could be a way to celebrate the decline of anti-semitism in America.
  8. Peace Day. Could celebrate the end of some war. But there is always the next war. Oh well.
  9. The day women got the vote. (Aug 26, 1920). To quote Hail to the Chiefs, with regard to the election of Warren G. Harding as president in 1920: {\it It was the first election women voted in. They needed more practice}.
  10. The day the civil rights act passing. Actually there were many civil rights bills passed, so you'd have to pick which one to celebrate. Or celebrate all of them and get a 4-day work week.
  11. Groundhog day. (Feb 2). The movie movie Groundhog day higher Google rank than the day does.
  12. Chocolate day.
  13. Moon day. They have Earth Day so why not Moon Day?
  14. Children's day. We have Mothers and Fathers day, so why not Children's day?
  15. St. Patrick's day. Or the day after to get rid of your hangover.
  16. Teacher's day. Would teachers get this day off?
  17. Weird Al's birthday (10/23). Since its the same as Mole Day we can combine them to get Weird Mole Day.
Lets say they made your choice a holiday. And then there was a movement to make it, instead of the actual day, the 2nd Monday of that month it was in. (or something like that). Would you mind? On the one hand, your holiday is getting made into just a day off. On the other hand, you get a 3-day weekend!

Veterans day would have been the 2nd Monday in November except that some veterans protested. Or did they? Maybe it was groups that claim to represent them. I wonder if veterans prefer 3-day weekends or prefer having their holiday be on the day WW I ended. What is more important: Efficiency or meaning?

Some days would be hard to move. July 4, Cinco do Mayo and Pi-day are rather tied to the day they are celebrated. Even so, the government (and others) gives July 3 off if July 4 is on a Saturday.

Math Illuminated – real life math examples

Many readers write to me asking for examples of “real life math”. Here’s a resource that you may find useful: Math Illuminated.

Are you interested in the connection between math and real life or maybe you’re a teacher and looking for some real life math to share with your students? This resource may help.

As their blurb says:

Mathematics Illuminated is a thirteen-part series for adult learners and high school teachers. The series explores major themes in the field of mathematics, from humankind’s earliest study of prime numbers, to the cutting-edge mathematics used to reveal the shape of the universe.

The materials for each topic include videos, Flash interactives, a “textbook” with good explanations of the concepts, a facilitator guide and a bibliography for further reading. There’s also an interactive Math Family Tree which shows how various discoveries in math are related, and when they appeared (via a timeline).

I mentioned Mathematics Illuminated before in Friday Math Movie – Math Illuminated but I was concentrating on the videos at that time.

So next time you are wondering how to convert a math lesson into a real life scenario, Math Illuminated may give you some starter ideas.

June 30, 2009

Who’s Counting – interesting real-life math applications

Who’s Counting – John Allen Paulos examines the news through numbers gives a fascinating insight into the math behind current news events.

Paulos is a professor of mathematics at Temple University in Philadelphia and is well-known for his book Innumeracy: Mathematical Illiteracy and its Consequences (1988) in which he said:

I’m distressed by a society which depends so completely on mathematics and science and yet seems to indifferent to the innumeracy and scientific illiteracy of so many of its citizens.

His monthly Who’s Counting series is an attempt to address such innumeracy and scientific illiteracy.

The most recent articles (for Jan to Jun 2009) include:

He addresses a range of issues in these articles. One that caught my eye: How to Calculate Chances of Doomsday.

Paulos is worth checking out.

Office furniture giveaway

Here is your chance to win a piece of office furniture in this little giveaway contest:
  • First go check www.csnOfficeFurniture.com website and find a piece you'd like to have if you are the lucky winner. It needs to be $135 or less in value.

  • Then, to participate, purchase any of the Math Mammoth or Make It Real Learning products at Kagi store between now and July 9, 2009.

  • In the comments field on the order page, put either the name of the piece of furniture you'd like to win or the URL to its web page. If you leave this comment field blank, I will not know that you wish to participate so it is crucial!
That's it! I will have a random draw for ONE winner within the participants, and put you in contact with csn Office Furniture company. They will pay for the shipping within United States.

Links you might need:

Visualizing Groups of Symmetries

After realizing that I had some (now) bizarre misconceptions about the groups of symmetries of various graphs, I decided to write a small program to let me visualize the effects of a given permutation on a graph embedded in two or three dimensions:
Here we see a regular dodecahedron. (These don't look great as static images, I know, but the program allows you to rotate the figures which makes them a lot easier to discern.) Suppose we were to twist two of the opposite pentagonal faces; then we'd get something that looks a little like this:In case you couldn't tell from the shape, the background has turned light yellow to indicate that this permutation is not in fact an automorphism of the dodecahedron. This is a platform independent Java application, and I'll post a download as soon as my web hosting comes back up. If anyone would like to look over my Java code and tidy it up, and/or make it into a workable applet, that'd be great; I really don't know Java and this took me way longer to write than it should have.

Relevant math question: If we let S6 act on the vertices of the icosahedron, how many different graphs (up to isomorphism) do we get?

Update: now available for download. Extract the archive into a directory, then either double-click on the .jar file or use the provided shell script or batch file depending on platform. The graphs/ directory contains some different graphs you can load; if you peek at one of the files in a text editor it should be pretty clear how to make your own. Enter permutations in cycle notation, e.g. (1 2)(3 4), and beware the following caveats:
  • The vertices are numbered 0,1,...n-1 rather than 1,2,...n
  • You don't have to reduce your permutations, so you can enter e.g. (1 2)(1 3)(3 4 5) or somesuch. Be aware, though, that the program composites permutations backwards, so you'll have to flip things right to left with respect to normal mathematical notation.
I've had some annoying classpath issues on my computer so I'd be glad to hear whether this works on other people's computers or not.

The NSF Annual Report

The NSF has been getting very strict about having PIs (primary investigators) fill out an annual report listing publications and activities related to their grants. The report is due 90 days before the anniversary of the start of the grant, so if you have a grant that started in the fall you are probably getting notices reminding you that your report is now overdue. 

There are few academic tasks more painful than filling out annual grant reports but best to just grit your teeth and do it or the NSF could cut off your money. Would you rather the alternative, not having to do a report because you don't have a grant?

Annual reports are used more for gathering information than for evaluation so you don't need to worry about the style as much as you might for a grant proposal. 

There is one confusing part of the reporting system on NSF Fastlane: There are separate sections for conferences and publications. Most of our conferences don't show up under conferences so best to just list your other conference papers as proceedings in the publications section, probably under "Books or Other One Time Publications".

Fastlane reporting is a one-size fits all system so it is not well designed for the way computer science handles conferences. But we computer scientists always know how to implement the Kludge.

A Generalization of the Mean

First, some background:

Remember that the mean or expected value of a random variable is defined as the integral of that variable with respect to the associated probability measure. This works out great in some cases, e.g. when we're flipping coins, or rolling dice, or in general when we're thinking about random variables with finite variance. Of course, it's defined for a wider class of random variables -- not everything with a mean has a standard deviation -- but there are certainly random variables out there with no mean.

A famous example of a divergent mean is the St. Petersburg game, which goes something like this: I'll let you flip a coin and pay you for how many heads you can get in a row. If you get heads up the first time, but tails after that, I'll give you a dollar. Two heads in a row, $2. For n heads in general, n > 0, the payout will be $2n-1. Rather than giving you 50 cents for failing so spectacularly as to hit tails on your first try, let's say you just get nothing.

The probability of getting exactly n heads in a row is, of course, 1/2n, so the expected value is

(1/2)($1) + (1/4)($2) + (1/8)($4) + (1/16)($8) + ... = $.50 + $.50 + $.50 + ...

Uh oh. If we keep adding on $.50 forever, the right-hand side is going to infinity! Clearly, you should be willing to pay me any amount of money in order to play this game, since your measly $10k pales in comparison to the promised infinite reward. Any takers?

We're not done here, though; first, let's change up the game a little. We'll leave things the same if you flip 1 head, or three consecutively, or five, and so on, but let's say if you flip an even number of heads, you have to pay me. What was that expectation again?

(1/2)($1) - (1/4)($2) + (1/8)($4) - (1/16)($8) + ... = $.50 - $.50 + $.50 - $.50 + ...

Oh, dear. Depending on how we arrange that series, it can diverge up or down. You can see from here, if you didn't sleep through your calculus classes, that we can even produce a conditionally convergent expectation that can be rearranged to anything!

Okay, I've gotten away from myself here, but, long story short, means are weird. (I seem to be in an Italic mood today for some reason...) That said, consider the following, which has been bouncing around in my head for a year or better. I finally asked someone whether it was true and quickly received the following proof:
Let X1, X2, ... XN be i.i.d. random variables, and let YN = [ X1 + X2 + ... + XN ] / N. Put f(N) = Median(YN). If μ = Mean(Xi), i.e. if that mean exists, then as N → ∞ we have f(N) → μ.

Proof (thanks to Robert Israel): The Weak Law of Large Numbers states that, for ɛ>0, Pr{|YN - μ| ɛ} → 1 as N → ∞. For N sufficiently large, then, Pr{|YN - μ| ɛ} > 1/2, or in other words, more than half of the distribution for YN lies within the interval (μ - ɛ, μ + ɛ). In particular, at least half lies within (-∞, μ + ɛ), so there is no way that the median f(N) can exceed μ + ɛ; symmetrically, f(N) > μ - ɛ. Combining both sides, we see that |f(N) - μ| ɛ, which is to say that f(N) → μ as N → ∞.
Note that this limit can converge in circumstances where there is no mean -- for instance, it clearly always gives the axis of symmetry for a symmetric distribution, and there exist symmetric distributions which have no mean, e.g. the Cauchy distributions. So in broad terms this is a generalization of the concept of the mean.

I'm really no expert on statistics or probability, so I don't really know how far the applications go or whether this is an elementary exercise in graduate textbooks in the field. I just thought it was interesting, and I'll probably poke around with it in the days to come.

June 29, 2009

Re-request/when to include a known proof in a paper?

In my post of June 24 I requested some help on a sum (among other things). In particular, we had a summation result that we were using in a paper and we wanted to know if it was new or not. We got three comments relevant to it
  1. Method of differences due to Pascal
  2. discrete calculus analog of the fact that the nth degree Taylor expansion of a polynomial is the polynomials.
  3. The first lemma is a direct consequence of the method of finite differences; it says that the nth forward difference of a polynomial of degree n-1 is identically zero. The inner summation in the second identity is basically computing the coefficients of the Newton Form of the polynomial, although you seem to be using a slightly different basis. Nevertheless, these results are quite standard.
This raises a request and some question.

REQUEST:
Authors of those comments (and others who know stuff)--- please email me more exact references. I found some things on Google but it would be good to know what to read and what is a good source to reference. Preferable online.
QUESTION: In a paper if you are using a result that is known how much detail should you put in?
  1. Clearly put in that it is known and provide a references. I would not want to frustrate my readers with This is easily derived from the method of differences. without providing a reference. In this day and age an online reference if you can mange it.
  2. If the result is not quite written down anywhere but your readers could easily derive it using known techniques, then you do not need to supply a proof. But this is not as clear a statement as it sounds- it depends on how you define readers, easily, known, and technique.
  3. If the result is known but you have a cute proof of it which seems new (hard to tell) then what do you do?
  4. If the proof is short then I am more inclined to include it. If its an e-journal than length matters less. (This topic has been raised in a different form before---if Conferences proceedings are CD's then why have a page limit?)
  5. If there are no online references then I am more inclined to include a proof.
  6. My only real point here is that its a QUESTION- what is the cutoff for what is worth including? There is no one answer.

June 27, 2009

Automata and the A-D-E classification.

Introduction


The A-D-E classification is a strange ubiquitous pattern that appears in many branches of mathematics. Typically it appears when you try to classify certain types of mathematical construction. If the A-D-E classification applies then you end up with two infinite sequences of cryptically named objects (A1,A2,A3,...) and (D1,D2,D3,...) as well as three leftover objects called E6, E7 and E8. Unfortunately, most of these objects and their classifications are tricky to define using only elementary mathematics. However, there is one type of object that is classified in this way that can be given a relatively straightforward computational description involving a little linear algebra and assuming you know a tiny bit about automata.

But first: why care about the A-D-E classification? Well I tried to say a little bit about how symmetries relate to nature a while back. Certain types of possible symmetry of particle physics can be classified the A-D-E way. The symmetry group corresponding to E8 is the now famous exceptional group E8. I won't be able to get to an explanation of how groups are involved. But at least I'll be able to give a hint about the bigger picture that E8 is part of.

Non-deterministic Finite State Automata


Here's a diagram representing a very simple non-deterministic finite state automaton (NDA):

It can be in one of two states. When in state A it can transition to state B and in state B it can only transition back to state B, but it can do so in two different ways.

Vector Automata


Now I'll introduce a more general kind of automaton: a vector automaton (VA). (I made that term up, it's not meant to correspond with anyone else's terminology.) Every vector automaton is built from an NDA. But each state corresponds to a finite dimensional vector space and each transition corresponds to a linear function mapping from the vector space of the source state to the vector space of the destination state. We could turn the above example into a VA by assigning a 1D vector space VA to A, a 2D vector space to VB and defining linear functions:

f : (x) -> (x,0)
g : (x,y) -> (-y,x)
h : (x,y) -> (y,-x)

A VA is just like an NDA in that it transitions from state to state according to the given transitions. But additionally it keeps track of a vector in the vector space corresponding to the current state. Each time it makes a transition the linear function corresponding to that function is applied to the vector. So in the example above, the NDA might start in state A with a scalar value x (ie. a 1D vector). When it makes its first transition its vector becomes the 2D vector (x,0) and after that each transition rotates the vector through 90 degrees clockwise or anticlockwise.

There's a lot of freedom in defining a VA given its underlying NDA. For each node you can pick any vector space you like of any finite dimension, and for each transition you can pick any linear function you like mapping between the source and target vector spaces.

Let's make this a little more formal. An NDA is a finite set of states combined with a finite set of transitions. Each transition has a source and destination, each of which is a state. That's it. You're allowed any finite number of transitions between states and a transition can have the same state as source and destination.

A VA is an NDA combined with a finite dimensional vector space attached to each state and a linear function for each transition such that the function maps from the vector space of the of the source to the vector space of the target.

Now consider this really simple NDA:

When we build a VA from this NDA, for convenience I'll call the vector spaces corresponding to A and B, A and B. And I'll call the linear function from A to B, f. How many VAs can be made from this VA? Clearly an infinite number. But a lot of them are very similar.

Suppose we assume A and B are 2-dimensional and write their elements as pairs (x,y). Suppose f(1,0)=u and f(0,1)=v and that u is not a multiple of v and both are non-zero. Then we can use u and v as a basis for B. If we write f as f' in this new basis we get f'(1,0)=(1,0) and f'(0,1)=(0,1). So by relabelling the basis of B we have actually revealed that an infinite number of choices for f reduce to the same thing apart from a change of basis in B.

Up to change of basis in A and B we find there are only three possibilities:
(1) u and v are distinct, non-zero, and not multiples of each other.
(2) u is non-zero but v is zero
(3) both u and v are zero

We started with an infinite number of possibilities for our particular choice of dimensions and ended up with just 3. We'll say that two VAs are equivalent if we can get one from the other by changing basis like this.

On the other hand, consider this NDA:

Let's choose A, B and C to be 1-dimensional vector spaces and define f, g and h as:

f(x) = x
g(x) = x
h(x) = λx

where λ is any real number. Then h(g(f(x)))=λx. We can choose any λ we like so we have an infinity of possibilities. No amount of basis change is going to change this fact. This is different from the case above because now we're comparing x and h(g(f(x))) which lie in the same vector space. So when our NDAs have loops in them, the space of possible VAs, for most choices of dimension, is infinite.

The sum of two VAs


If we have two VAs corresponding to the same NDA we can combine them together to make a single machine. The state is given by a state in the shared underlying NDA, but we now have a pair of vectors. Each time there is a transition we apply the pair of transforms to transform the two vector simultaneously. But we can encode a pair of vectors as a single vector simply by concatenating together the vector components in some basis. So this machine is just another VA. The dimension of the vector space for each state is simply the sum of the dimensions of the vector spaces in the original VAs. So, given two VAs we can sum them to get a third.

Given a VA for an NDA it may or may not be equivalent to the sum of two simpler VAs. If it isn't, it's said to be irreducible. If it is, then we can ask the same question about the simpler VAs. In this way, every VA is the sum of irreducible VAs.

Main Theorem


Now comes the main result I want to give:

If the graph underlying the NDA is one of the following list then (and only then) there is a finite number of inequivalent irreducible VAs for the NDA. All other VAs for that NDA are simply finite sums of machines from this finite set. Here's the list:

That's it! Weird huh? (Note that diagram Xn has n nodes.)

Strangely, those same diagrams (and a few more) appear (in a quite different way) when classifying the possible symmetries of fundamental particles. The symmetries are given the same names as these diagrams. And in just the same way we get those 'sporadic' symmetries leading up to E8. Those same diagrams also arise in Catastrophe Theory.

I'd like to sketch the proof, at least in one direction, but I seem to have run out of time. Another day perhaps. But note that none of these diagrams have loops for the reasons I gave above, and I've already shown that A2 gives only a finite number of choices for a certain choice of dimension.

Meanwhile, I should give the proper mathematician names for the things above. The diagrams listed above are examples of Dynkin diagrams. A non-deterministic automaton as described above is known as a quiver. A vector automaton is normally known as a representation of a quiver. And the theorem above is half of Gabriel's theorem.

June 26, 2009

Women in Philosophy of Logic and Philosophical Logic

Catarina Dutilh Novaes sent the following important message to PHILOS-L last weekend, reposted here with her permission:
Dear all,

Recently (and admittedly very late!), I started thinking more seriously about the lack of gender balance in the areas in which I do most of my research, namely history and philosophy of logic and philosophical logic. What got me thinking was probably the (positive) noise being made at Feminist Philosophers. One of the issues raised by the Feminist Philosophers is the low proportion of women in most philosophy conferences (in particular as invited/keynote speakers); I realized that in the workshop I am organizing, there are only three women as speakers, including myself! So I think this is a matter that deserves further attention.

Richard Zach had a blog entry a while ago on the staggeringly low number of women publishing in the journals of the area (his data concerned the Journal of Philosophical Logic). From this sort of data it is all too easy to conclude that there simply aren't enough women around working in (philosophy of) logic and philosophical logic so as to redress the imbalance seen in conference lineups. But here again the usual analysis applies: the lack of female speakers at such conferences reinforces the idea that the area is just not 'for women', which in turn does not encourage young female students to pursue interests they might have in the area. Absence of female keynote speakers may also be a discouraging factor for other female researchers to submit papers to such conferences. Sally Haslanger has a wonderful piece on how vicious these mechanisms can be, which can be found here: Changing the Ideology and Culture of Philosophy: Not by Reason (Alone)

So the purpose of this message now is to question the widespread impression that there are not (or very few) prominent female logicians and philosophers of logic, people with the standing to be keynote speakers at major conferences. I was thinking it might be useful to compile a list of such people, sort of a handy device that could help those organizing conferences in the area to ensure a better gender balance among the speakers. Please send me names off list, and I will post the results to the whole list once we have a significant number of names. Just to give you an idea of what I have in mind, here are some women that would obviously be on such a list: Juliet Floyd, Penelope Maddy, Gila Sher, Delia Graff Fara. I’m sure there are many more such talented women working in the philosophy of logic and philosophical logic, so I look forward to many reactions!

Thanks!

Catarina
cdutilhnovaes at yahoo dot com
Please respond to Catarina at the email address above!

Math Teachers At Play #10

Welcome to the tenth edition of Math Teachers At Play blog carnival! Here with the heat of the summer, "less is more". We concentrate on teaching issues, but also get to "play" a bit with binary numbers, geometry, integers, and an optical illusion.

TEACHING

What's a math teacher going to do with Wolfram | Alpha ?



In case you haven't heard... Wolfram|Alpha is a new, computational search engine. And if you're a math teacher, you should be aware of it.

Collection of Web Freebies discusses Wolfram|Alpha as your Personal Free Online Math Assistant.

I wrote an introduction to Wolfram|Alpha as well. I feel it can both be a benefit and a drawback to math education - a benefit because it can free us from routine calculations, and a drawback because students still need to learn to do those, but how can you easily enforce that?

W|A presents a dilemma to math teachers... because it can solve SO MUCH. It can solve just about any routine type calculation in algebra 1 or algebra 2 or calculus courses. So what can a teacher do? Jason, The Number Warrior wonders how we can be Teaching to the Limits of Wolfram Alpha. In essence, should teachers strive to find problems that cannot be solved with Wolfram|Alpha?


What's a math teacher going to do with homework?


I have checked these answers 3 times and I think you got #10 wrong.
Photo courtesy of Vicki's pics
Another, an age-old, dilemma for math teachers. What is the best way to assign, grade, and check homework? Sam Shah conducted an unofficial survey on the matter and presents the Homework Survey Results.

I glanced over the survey results, and found one response that really "struck" me as a "sweet" solution to the homework problem. It is from a 5th grade teacher, and I apologize for taking so much space for it here but I just feel it was really good (and if the person feels I shouldn't quote this, please let me know). Emphasis mine:

"I work hard at the beginning to set up a culture of responsibility for themselves. They are responsible for making sure they understand, for asking questions, for asking for more practice or another example.

When we come into class, we check the answers together. I will solve a problem or two on the board that I have learned over the years is confusing. Other than that, I expect them to ask for clarification if a problem is wrong.

They "grade" their own. If it's wrong, they are expected to take a minute right then to figure out why it was wrong. Usually it's a silly mistake. If not, they bookmark it to ask questions during our next work time.

I don't give any grades. I don't assess it. The final test/quiz is their grade. The homework is just them figuring out how to do the skills. They know they won't be graded on it. They know they won't be penalized for getting it wrong. They know that the whole point of the homework is to figure this math stuff out. If they get it wrong, they know they haven't mastered it and need to get help.

On the opposite side, if a student doesn't do their homework, I don't get too upset. We have a talk about how they hurt themselves, because now they don't have an accurate measure of if they can do it on their own. I can't help them because they didn't get the opportunity to make their mistakes before the test. However, I have a few who don't need to do homework. They still earn A's on the final test. They learned it by being in class and paying attention.

With those who obviously do need the homework practice, but aren't doing it, I problem solve that on a case-by-case basis.

It changes the whole culture of learning and mastery in the classroom. But it is VERY important to set up that culture at the beginning."
Now, I'm not claiming that middle and high school teachers could easily transfer these ideas to their classes... but perhaps they can, at least somewhat. Please discuss homework at Sam Shah's post.

A teacher's problems do not end with homework. Can you believe that TEACHING as a profession is so difficult in today's world that sites exist solely to help new teachers to SURVIVE their first year? That's exactly the word that is used. Teaching Degree.org has compiled a list of 100 Helpful Websites for New Teachers, and the list includes new teacher "survival" sites, teacher video sites, freebies, inspirational sites, and several other categories as well.

Some Math As Well

At Exploring Binary blog we find an EXCELLENT way to explain binary numbers that he found when he taught his mother binary numbers . It's true, once you struggle at explaining a concept to someone who's not a math whiz, you really get to the brass tacks of the matter.

Denise from Let's play math! has some geometry challenges for us, some of which are from ancient Egypt. I solved the puzzle under the title "Can You Explain This?", using fractions (and not avoiding them as it tells you to do). I also pondered number (2) but couldn't find an immediate (easy) way to find an answer. I don't think she ever posted answers to those.

spiral illusionJohn Cook from The Endeavour blog shows us an optical illusion that is so fooling that I couldn't believe my eyes at first. Quite amazing. He also makes an analogy from the optical illusion to a "mathematical" illusion within his own work.

Dr. Jeff is asking us to fold a humongous piece of xerox paper and see how many folds reach to the top of mount Everest or the sun, among other things. You probably won't believe the answers!

If you're into 5th-7th grade math, please check also my videos about integer subtraction.




This is where to send your submission for the next carnival on July 10th at Math Mama Writes. Happy summer, everyone!

Tales of Two Theories

I finished reading two very different books about two theories in physics, The Age of Entanglement: When Quantum Physics Was Reborn by Louisa Gilder and “Gina Says,” Adventures in the Blogsphere String War "selected and edited" by Gil Kalai. While vastly different in style they both feature scientists happy to talk about and defend their own points of view in controversy theories but rarely willing to reconsider those views.

Louisa Gilder's book takes a detailed look at the early years of quantum theory using an interesting technique: Creating imagined conversations between the leading scientists of the time based on their writings. These conversations make the development of the theory an exciting story when greats like Einstein, Bohr and Heisenberg struggle over the right ways to handle the seemingly paradoxical nature of quantum effects. As Bohr gets quoted in the book during a Copenhagen trolley ride with Einstein and Sommerfeld, "I suppose that during a stage in science where everything is in ferment, it cannot be expected that everybody has the same view about everything". 

Gilder's book gives a detailed year by year development through the 1935 Einstein-Poldolsky-Rosen paper but then moves much quicker through David Bohm's theories from his exile in Brazil (due to McCarthyism), the Bell inequalities and related experiments, and the development of quantum cryptography and computing. The computer science aspects are particularily short with only a brief mention of "the reclusive Peter Shor and the witty Luv Grover". She doesn't ignore the political backdrops of the times but thankfully she doesn't overly emphasize it either.

You won't learn more than the broad strokes of quantum physics with this book but you get to relive the development of a discipline as brilliant minds argue the right way to model a new phenomenon. 

Gil Kalai's book is a quick read from the viewpoint of "Gina" a non-expert who comments on the blogs of mostly string theory skeptics. It certainly was a fun read but I finished not sure of the purpose of the book. Seemed to focus more on the role of bloggers and commentors than the philosophical questions of developing a complicated theory that seemingly can't be tested. Where's Occam's Razor when you need it? Kalai had some interesting digressions to areas like Godel's incompleteness theorem and Bayesian learning but those just added to the disjointness of the book. Kalai's book does have the big advantage of being a free download.

So I'd recommend Gilder's book if you want a detailed almost novel-like development of a field and Kalai's book if you want a quick fun free read on how some skeptics defend their skepticism. 

Both books remind us that theoretical research must go beyond just doing the math, in finding the simplest models that best capture the concepts we study. Lessons that hold as much in computer science as they do in physics.

June 25, 2009

Wolfram|Alpha is here


Wolfram|Alpha is a new, computational search engine. If you do a query where the answer has quantitative data, Wolfram|Alpha probably gives it.

For example, try enter your last name. Wolfram|Alpha gives you information about the popularity of that name. For example, "miller" ranks 6th within the US and there are about 1,128,000 people with that surname.

Enter a first name, and it will even give you a graph showing the name's popularity over the years. I just found out that Cindy's popularity peaked in about 1960. No wonder it is a common first name among the mothers who ask me questions about their children's math education.

Enter a town - for example Houston, and see what information comes up.

But, the reason I'm writing this post is because Wolfram|Alpha (or Walpha as some called it) especially excels in mathematical queries.

This has implications to mathematics education, especially in high school and college. This tool is completely free, easy to use, and accessible for everyone with an Internet connection (even with a smart phone). Just imagine if you are a math teacher and you assign homework for your 9th graders, "Find the equation of the line that goes through points (2,5) and (-8, -9)." W|A does it in a split second.

It also solves equations. For example, Solve ln(x)+ ln(x-2)+ ln(15). It even gives you the solution steps - just click on "show steps".

Please see a full list of examples of what Wolfram|Alpha can do in mathematics.

While W|A easily computes a lot for the elementary algebra or calculus student, it doesn't stop there. Look at the examples for elementary mathematics given on the site. It also acts as a fraction and percent calculator. Granted, normal calculators do those as well.

So, what is a teacher to do? Will a lot of the content in high school and college math courses suddenly become obsolete?

Now, Wolfram|Alpha is not what started bringing technological tools into classroom. That trend has been here for a while (think graphic calculators, computers). However, it is an extension of the trend that makes the computational tools more easily accessible and available to nearly all students.

I see Walpha both as a benefit and as a drawback.

- BENEFIT: Teaching can focus more on the concepts and less on tedious calculations, since practically all students will have a tool they can use for computations and graphing (all you need is a computer with an Internet connection or a smart phone). Students could be given more problems of the type that require thinking and problem solving, and less of the mechanical calculation problems.

- DRAWBACK: It is a fact that one cannot adequately learn mathematics without also learning many of these "mechanical tasks", such as how to find the slope of a line when given two points, or how to graph a parabola from its equation. If these skills were totally skipped, students wouldn't be prepared for the next mathematics course where such knowledge is needed. So, teachers cannot skip those topics and need to enforce student learning in such a way that cheating with Wolfram|Alpha cannot happen (putting such problems in the test).

Actually, I'm not so sure if W|A will change the actual teaching so much, because many students have already been having graphic calculators, which do similar things as W|A. I wonder if the biggest change it brings along is a decline in the sales of graphic calculators...

Read also what others have blogged about W|A :

Impact of Wolfram Alpha on Math Ed

Wolfram Alpha is up and running

Wolfram|Alpha and the shrinking future of the graphing calculator

Walpha Wiki discussion

Complexity Report from DNA 15

Guest post by Aaron Sterling

I attended DNA 15, the 15th International Meeting on DNA Computing and Molecular Programming, held June 8-11, 2009, at the University of Arkansas. The co-chairs of the organizing committee were Rusell Deaton and Jin-Woo Kim, who I thought did a great job. The research presented, and the backgrounds of the attendees, were diverse from experimental nanochemistry to theoretical computer science. I'll highlight a few elements of the program that had TCS and complexity flavor.

Jim Aspnes and Kenichi Morita gave TCS plenary talks. Aspnes introduced the audience to the computational theory of “population protocols” (see here for a survey) a theory of computation over a large network of agents who each possess very limited computational power. This theory can model ad hoc wireless networks, and (potentially) smart molecules interacting in solution. Morita surveyed results on reversible cellular automata and presented animations that showed the inner workings of several such devices. A reversible computation device is one in which each noninitial configuration has exactly one preceding configuration. Many models of natural computing are reversible models.

NP-completeness of the Direct Energy Barrier Problem Without Pseudoknots, due to Manuch et al., was presented by Anne Condon. The Energy Barrier Problem is decision problem about molecular folding. Given a structure in some initial configuration, does there exist a pathway through subsequent configurations to a final configuration, such that the step from each configuration to the next requires at most energy k, for some fixed k. The paper reduces a simplified version of the Energy Barrier Problem to 3-Partition, a known NP-complete problem.

Several papers discussed the theory and practice of building DNA-based circuits. I would like to focus on Signal Propagation and Propagation Delays in Molecular Circuits by Seelig and Soloveichik, as it puts forth the thesis that circuit depth is not the correct measure of time complexity for chemical circuits (in contrast to electronic circuits, or classical circuit complexity). They present a theoretical model to capture something that has been observed in the lab: when there are just a few molecules of a certain species in solution, the reactions that depend on them will be slow, because the species will interact with low probability, since contact with it is so rare. As a result, stepping through a circuit is not a linear process. Approach to completion of a circuit becomes increasingly slow the deeper the circuit is, because the later layers require the output of all the earlier layers. One possible fix for this is to catalyze the reactions in question, so the reactions occur quickly even if there is only a small amount of species present. The drawback to this is leakage: if a chemical species is not fully consumed at an earlier stage, its presence can build exponentially at later stages, leading to the circuit providing incorrect answers. All in all, an intriguing model that raises a lot of questions.

DNA 16 will take place in Hong Kong, and DNA 17 will be organized by Erik Winfree at CalTech. I'm looking forward to them both!

June 24, 2009

Two requets: A sum and a reference

I have two requests from my readers. Both are essentially help tracking things down.

First: We (Bill Gasarch, Clyde Kruskal, Justin Kruskal) have in a paper of ours a summation that we proved. Is it new? Here is the summation: (It uses a sum that I previously inquired about here and got useful information, including that it was originally proved by Euler.)

Let p(x) ∈ Z[x] be a polynomial of degree n with constant term 0.

p(s) - ∑k=1n(s+k-1 choose k)∑i=0k-1(k-1 choose i)(-1)i (p(s+i+1) - p(s+i)) = 0
Our proof is here.

(Side Request: How do you do a choose-sign in html?)

Second: I am, as always, tracking down lower bounds on the VDW numbers. I need the article An application of the Lovasz Local Lemma, a new lower bound for the Van der Warden numbers by Zoltan Szabo, Random Structures and Algorithms, 1990. Electronic preferred, but will take what you got. SO, if someone has it please email me article or pointer or whatnot. (Pointer might not work if your library has access to this journal, since ours does not have it in electronic or hardcopy.)

i got it tatted on my skin

yes, yes, the definition for convergence of a sequence is now on my back. and now, i rep it on my skin for life.



I made one alteration to the definition (for personal reasons - so it means more to me), can you find it?




UPDATE:







PM@100: Logic from 1910 to 1927

Call for Papers
PM@100: Logic from 1910 to 1927

21 – 24 May, 2010
Bertrand Russell Research Centre
McMaster University
Hamilton, Ontario
Canada

The Bertrand Russell Research Centre in 2010 will host a conference to celebrate the 100th anniversary of the publication of the first volume of Russell and Whitehead’s Principia Mathematica.

The publication in 1910 of the first of the three volumes of Russell and Whitehead’s Principia Mathematica was a landmark in the development of logic, the foundations of mathematics, and the application of logic in philosophy. The rapid development of these fields in the two decades after 1910 owes perhaps more to Principia Mathematica than to any other work. Subsequently, however, its lessons learnt in different ways by different people, it becomes more difficult to determine exactly what the world owes to this gigantic piece of work. Daunting both for its size and its technical difficulty, the book is now known more by reputation than by detailed study. Russell himself maintained, no doubt with some exaggeration, that he knew of only six people besides the authors who had read the entire three volumes. He remained dissatisfied with the foundations of the work and attempted a major revision (this time without Whitehead’s help) in a second edition published in 1925–27, which further complicated its historical legacy.

A century after its first appearance, a great deal has changed. Many of Russell’s working papers on the problems it addressed have been published, and this has led to significant re-interpretations of the work itself. Enough time has now passed to make it possible to evaluate what contributions it made, or failed to make, to philosophy, logic, and the foundations of mathematics.

Presenters Include: Patricia Blanchette, Charles Chihara, Warren Goldfarb, Ivor Grattan-Guinness, Leila Haaparanta, Allen Hazen, David Kaplan, Gregory Landini, Peter Simons, Alasdair Urquhart, and Richard Zach.

Submissions to the conference are sought in all areas relating to Principia Mathematica or to the development of logic and to the philosophy and foundations of mathematics in the years between the two editions.

Contributors are asked to submit two copies of an essay suitable for 30–45 minute presentation with an abstract no later than 1 January 2010 to:

Professor Nicholas Griffin, Director
The Bertrand Russell Research Centre
1280 Main Street West
Hamilton, Ontario
CANADA L8S 4M2

EMAIL: ngriffin@mcmaster.ca
FAX: 905-577-6930

Graduate students are also encouraged to submit. Announcements of acceptances for the program will be made by the end of February 2010.

Conference Co-Organizers:

Nicholas Griffin
The Bertrand Russell Research Centre
McMaster University
ngriffin@mcmaster.ca

Bernard Linsky
Department of Philosophy
University of Alberta
bernard.linsky@ualberta. ca

June 23, 2009

Annoucing YATB (Yet Another Theory Blog)

Jon Katz has a blog Random Bits

We've put it on our blogroll.

What will it be about? To quote Jon himself:

The blog will cover random topics, but especially crypto. It was started because there are currently no (active) crypto blogs and I hope this will become, to paraphrase Lance, a meeting place for the crypto community where we would have some discussions, sometimes quite heated, over the issues of concern to our community
Some advice for Jon and any new blogger:
  1. In your technical posts try to have the first paragraph so that if someone doesn't want to read the rest of it they still get something out of.
  2. Spellcheck!
  3. Will you post every day but almost never make comments on the blog (Bill and Lance model)? Will you post once a week but make lots of comments on your own blog (Scott Aaronson model)? Will you post class notes? (Luca does that. Scott sometimes.) Will you be controversial or stear clear of controversy? (I'll let you guess who does what, it varies at times.) Do you have guest posts? What is your policy on anonymous commenters? There are no right and wrong answers; however, you should have answers.
  4. If you have an idea for a blog try to write it up as soon as possible while you still are enthused about it. If it doesn't work then put it aside--- it may combine well with another idea later.
  5. Keep a backlog of blogs that are timless.
  6. Don't get upset at lack of comments, stupid comments, comments that misinterpret your post, or off-topic comments. You will get all of these.
  7. If you try to make each blog perfect you will have a hard time getting anything out.
  8. Technical posts are harder to write then others and may get tiring (though Lipton's doing just fine with them). Pace yourself on those.

June 22, 2009

SIGACT

I'm honored to have been elected as the new chair of SIGACT, the ACM Special Interest Group on Algorithms and Computation Theory. The rest of the executive committee (as of July 1) will be Cynthia Dwork, Anna Lysyanskaya, Michael Mitzenmacher, Mike Saks and Richard Ladner as previous chair. I look forward to working with all of them. 

A fond goodbye and thanks to those leaving the committee: Richard Cole, Joan Feigenbaum, Éva Tardos and Hal Gabow. We will have a difficult act to follow.

SIGACT has a small number of formal responsibilities: Running the STOC conference, co-sponsoring and cooperating with several other conferences, handling prizes and awards, publishing SIGACT News and acting as the theory liaison to the ACM mostly in dealing with publications. But SIGACT plays a more important role, as the organization that addresses and protects the interests and needs of the theoretical computer science community, the whole community, not just those who come to our conferences regularly. 

So please let us know what issues you think are important to the theoretical computer science and how SIGACT can help address these needs. Feel free to contact me or any other member of the executive committee. SIGACT exists to serve you.

June 20, 2009

Erdös Lap Number

Erdös apparently liked to have children sit on his lap. See this 1969 conference photo http://staff.spd.dcu.ie/johnbcos/oxford.htm (There is also a young dashing George Andrews on the left.) So it was funny to see this page on the lap number. Unfortunately, my Erdös number is still 4. I probably could decrease it to 3 by randomly putting my thesis [...]

June 19, 2009

The Story of the Blog

Google is celebrating the 10th anniversary of Blogger by asking its users to write the stories of their blogs. I'll bite as this blog has become such a a large part of my life and I like to think a part for the theoretical computer science community and beyond.

In 2002 I read a Newsweek article on then new phenomenon on blogging. I decided to give it a try. I wanted to blog on a specific topic and so I started blogging on the topic I know best. On August 22, 2002 I started "My Computational Complexity Web Log", the first major blog devoted to theoretical computer science. The blog gained in readership after a sardonic mention in Jason Kottke's popular blog. All of a sudden I had thousands of readers interested in computational complexity. In that first year I wrote mostly technical posts. I did a set of posts entitled Foundations of Complexity giving an introduction to the field and a series Complexity Class of the Week where I would review results and questions about a specific complexity class. Later on I wrote a monthly series of my Favorite Theorems in the field.

But the technical posts take considerable effort to write and proofread so I started writing more opinion and academic-oriented posts. The blog became a meeting place for the theoretical computer science community where we would have some discussions, sometimes quite heated, over the issues of concern to our community. Most of the young people I would meet at conferences knew me more for the blog than for my research. For a while a Google search on my name led to the blog before it led to me.

Changes happen. I shortened the name of the blog and experimented with podcasting. In March of 2007 after a post on turtles, I realized I was just going through the motions and decided to retire from blogging. Bill Gasarch took over the blog and kept it going. But I had too much I wanted to say and rejoined the blog in January 2008. Since then Bill and I have co-written this blog trying to get out a post every working day.

Now we have many excellent blogs in theoretical computer science ranging from very technical to very amusing. We strive to be the blog of record, the weblog people turn to to learn about the issues and happenings in the community. Weblogs have become the places that brings our ever growing academic community together in a way our conferences no longer can. I'm glad this blog is able to play its part in that effort.

June 18, 2009

Measuring worksheets

I finally got around to creating another worksheet generator that had been "lacking" for a while from my "collection" - measuring units worksheets. Those where you ask kids to convert 6 cups to ounces, or 5 kg 40 g to grams.

Measuring units worksheets

These are free and printable. I've made lots of ready-made links for some common type worksheets, but of course with the generator you can customize it how you want. Both metric and customary units are included; however I did not include all possible metric units, because the focus here is for grades 3, 4, and 5.

Nondeterministic Parallelism

A reader asks
Can we define a class NNC such that NC ⊆ RNC ⊆ NNC. Is NNC known by some other name? It is clear that NNC ⊆ NP, but the reverse is not obvious.
NC is Nick's Class (named after Nick Pippenger) and can be characterized by either a PRAM model with polynomial processors and poly-logarithmic time or by polylogarithmic-depth polynomial-sized circuits1.

So what about nondeterministic NC or NNC? NNC is just the same as NP.

First let's consider randomized NC, RNC. Here each processors each had a limited number of random bits but they can share their random bits through memory, a technique used for example to find maximal matchings.

NNC, particularly if you want to have RNC ⊆ NNC, needs to have a similar definition. Suppose all the processors could act nondeterministically. Here is an NNC algorithm for 3SAT with n variables and m clauses.
  1. Processor i (1 ≤ i ≤ n) guesses the ith bit of a potential satisfying assignment and writes it in memory location i.
  2. Processor j (1 ≤ j ≤ m) checks whether this assignment makes clause j true.
  3. If all processors in the second round accept than accept (which takes another log m rounds).

Since 3SAT is NP-complete under reductions computable easily in parallel, we have NNC = NP. The reverse direction is a simple simulation.

A simple observation but a very important point: Every nondeterministic computation has an easy nondeterministic parallelization. 

Alternately you can define RNC or NNC with an additional random or nondeterministic input (in either the circuit or parallel model) and get the same classes. 

RL and NL on the other hand handle randomness and nondeterministic differently. Here you have one processor using polynomial time and logarithmic space. While the processor can use a polynomial number of random/nondeterministic bits, the processor cannot remember them all. So RL and NL are considerably weaker, in particular both are contained in P.

Noam Nisan wrote paper On Read-once vs. Multiple Access to Randomness in Logspace that explores these definitions of randomness in more depth.


  1. I'm ignoring uniformity issues in this post.

Benchmark

I got myself a hp tx2 tablet running on amd Turion with 4GB ram. A dear friend helped me upgraded to vista 64 bit in order to fully utilize the ram. I tested it against the desktop running xp 32 bit on pentium core 2 duo. I was told that this desktop actually has 8GB [...]

June 17, 2009

Do laypeople know what Prisoner's Dilemma is? Now they might

(Our blog has ALWAYS been green.)

This is a continuation of the topic in this blog entry.

In the June 17, 2009 issue of The New Republic, in an article called Plan of Attack, the term Prisoner's Dilemma was used and not explained. Does the public know what the term means? Are they supposed to learn what it means from context? I am asking these questions non-rhetorically. Here is the context and exact quote.

Context: Bob Woodward is going to do a book about the Obama White house. If you work in the White house, do you cooperate with him or not?

He (Bob Woodward) flashes a glimpse of what he knows, shaded in a largely negative light, with the hint of more to come, setting up a series of prisoner's dilemmas in which each prospective source faces a choice: Do you cooperate and elaborate in return for (you hope) learning more and earning a better portrayal-- for your boss and yourself? Or do you call his bluff by walking away in the hope that your reticence will make the final product less authoritative and therefore less damaging? If no one talks, there is no book. But if someone talks--- then everyone-- always talks.
  1. Do people who are not involved with game theory on some level know what The Prisoner's Dilemma is? Some do, but I wonder how many.
  2. Does it matter? Are writers freer to use terms the audience might not know since the writers know the readers can look it up easily. This is even more true if you are reading online and the writer provides links. However, in that case you may get distracted and not finish the article.
  3. Will writers do this more often and will this educate the public?
  4. I have also seen this on TV. If a show mentions some fact I didn't know, I might look it up. Sometimes its fictional, but sometimes its true. And sometimes you may get a skewed view of the issue: I once saw the 25th amendment used three times in one month of TV (West Wing, 24, and a repeat of 24) and always in a dramatic fashion. I looked it up and now know it; however, in real life, it has never been used in a dramatic fashion.
  5. The article right after the Woodward one was about what to do with the detainees at Gitmo. The name of the article: Prisoner's Dilemma

June 16, 2009

Cond. Cvg Sequences in R^d AND real applications!

We present some PURE math that was APPLIED in a real way. I am more surprised by these things than I should be.

Recall that a summation ∑i=0 ai Conditionally Cvgs if it cvg but ∑i=0 |ai| does not cvg.

Recall the following theorem.

Cond Cvg Thm: Let ∑i=0 ai be a cond. cvg sum. Let A ∈ R. Then there exists a way to rearrange the summation such that it cvg to A.
What happens if instead of reals you have points in Rd? For this we need Steinitz's Lemma which we state below. For a nice proof and discussions of variants of it see Imre Barany's paper On the power of linear dependencies (Also available here in case it goes away from his website.)

Steinitz's Lemma Let d be a natural number, B be the unit ball in Rd, and V be a finite subset of B such that ∑v∈ V v = 0. Then there is an ordering v1, v2, ..., vn of the elements of V such that

v1 ∈ dB

v1+v2 ∈ dB

v1+v2+v3 ∈ dB

etc.

v1+...+vn ∈ dB

End of Statement of Steinitz's Lemma

This can be used to show the following:
d-dim version of Cond Cvg Theorem If a1, a2, a3,... ∈ Rd and ∑i=0 ai conditionally cvgs then the set of points that this sum can be rearranged to converge to is an affine subspace of Rd.

This looks like a question and answer in pure math. But wait! there are applications of this sort of thing! And I don't mean applications to other parts of pure math! I don't even mean applications to complexity theory! There are applications to algorithms! Here are four references from Imre Barany's article. Only one was online (alas). If you find links to the other articles then send me link AND article and I will modify this post.

  1. A vector sum theorem and its application to improving flow shop guarantees. By I. Barany. Math. Oper. Res. Volume 6, 1981, 445-452. downloadhere or if it goes away or does not work then here
  2. Bibliography: Series of vectors and Riemann sums. By I. Halperin and T. Ando. Sapporo, Japan, 1989
  3. On approximate solutions of a scheduling problem. by S.V. Sevastyanov. Metody Diskr. Analiza Volume 32, 1978, 66-75. (In Russian).
  4. On some geometric methods in scheduling theory: a surey, Discrete Applied Math, Volume 55, 1994, 59-82.

June 15, 2009

Conference Proceedings should have final version in Journal! (Guest Post)

(Guest Post by Samir Khuller.)

I have noticed that even though in the 80's and 90's a large number of FOCS, STOC, and SODA papers eventually appeared in journals (David Johnson even kindly edited a book that gave pointers to the journal versions of FOCS and STOC papers), the percentage appears to have declined significantly (I have not done a systematic analysis, but when I look for papers I often find that no journal version appeared.)

Most conference papers (even the top conferences) are not reviewed extremely carefully for correctness. The PC has a limited amount of time, and a large volume of papers to review.

What is the reason for this decline?

Are we so desperate to publish papers that we do not want to do a thorough job writing up the proofs after "staking our claim"?

Its very frustrating when when you are reading a paper and details are omitted or missing. Worse still, sometimes claims are made with no proof, or even proofs that are incorrect. Are we not concerned about correctness of results any more? The reviewing process may not be perfect, but at least its one way to have the work scrutinized carefully.

Now that proceedings are on CD's do we still need a strict 10 page limit on the conference version? Is this limit there to simply encourage people to submit to journals? If so, I am not sure its working.

What can we as a community do to ensure that results get properly reviewed and published in full in journals after they are published at a conference?

June 12, 2009

Math on Kindle DX

My Kindle DX arrived yesterday. I loved my first Kindle which I used for reading books and the New York Times. But the Kindle couldn't handle mathematical papers. The DX has native PDF support. So how well does it do for our community's papers?

I tested the DX on PDF documents, postscript won't work. I chose papers from STOC, CACM, Springer and Elsevier journals, ECCC, my own PDFlatex generated papers and the open access Theory of Computing and the ACM Transactions on Computation Theory journals. 

The math looks great. The resolution (1200x824) looks fine, the formulas and diagrams show up as good as on regular paper. No color but that's not an issue for most of our papers.

The papers take a couple of seconds to load and usually (but not always) quick to change pages. I had the worst experience on a scanned paper (Valiant's permanent paper) which took a very long time to load and change pages and looks as lousy on the Kindle as it does printed.

There are two ways to view a paper: portrait and landscape. Let me discuss each separately.

Portrait: A page of the PDF is filled into the screen area. The screen is about 3/4 the height and 2/3 the width of the US standard 8.5x11 paper so some papers are slightly squished, particularly multicolumn STOC and CACM papers have this problem. The ToC and ToCT papers looked the best. The text, formulas and diagrams are also shrunk but still quit readable as long as I am using my reading glasses (yes I've gotten old).

Landscape: You get to landscape mode simply by turning the screen (or manually with the Aa button). The landscape mode keeps the original aspect ratio but you only see part of the page. The width of screen in landscape mode is about the same as the width of regular paper so the type size is about right. You can move through the rest of the page with the Next Page/Prev Page buttons but otherwise no scrolling. The 5-way button seems to have no effect on PDF documents.

Extras: You can do a basic text search within a PDF document but not between documents or in scanned documents. Unlike normal Kindle documents you can't change the type size, add notes, highlight text, convert text to speech or move to a word to get its definition. You can bookmark a page but otherwise the only way to navigate is via the next page/prev page buttons. No way to click on links within a PDF file.

You can move documents quickly through the USB cable. The Kindle has tons of memory and can hold lots of PDF files. You can move whole directories but the Kindle flattens them out listing every file (by file name) separately on the main home page. You can also email papers at $0.15/MB and most of our papers are well under a megabyte.

Many of the issues above could be fixed by software updates but no guarantees Amazon will do so. Also it shouldn't be hard to produce DX-friendly PDF documents, with the right aspect ratio and large font size. If the DX gets popular than publishers might start producing Kindle-friendly versions of their papers. The old Chicken v. Egg problem.

June 11, 2009

Progress on my sleeve


Progress!
Progress!
My Mandelbrot sleeve is progressing. It's been a year and a few months. I go in for some work for an hour or more every 2-3 weeks on average. The artist is 23 years old.




also... anyone know R? I'm doing bioinformatics these days and figure it's about time to learn R. I'd love it if you're available for answering the occasional inane question over IM. thanks!!

The Great Oracle Debate of 1993

In the STOC talk Russell Impagliazzo gave on his paper An Axiomatic Approach to Algebrization, Russell alluded to a controversy with his earlier still unpublished paper with Sanjeev Arora and Umesh Vazirani. Bill asked me if I knew about the controversy and I said I'd answer in a blog post.

The Arora-Impagliazzo-Vazirani paper was submitted to the 1993 Complexity conference (then called Structure in Complexity Theory) which was part of the first FCRC conference in San Diego. The AIV paper tried to explain why the then recent interactive proof results (IP=PSPACE, MIP=NEXP, PCP theorem) don't relativize. I somehow got hold of a copy of the paper and thought AIV completely missed the mark, focusing on local checkability instead of the algebraic transformation of formulas. Also the AIV paper seemed down on relativization, a common theme, and I thought a response necessary. So I quickly wrote up my own response paper The Role of Relativization in Complexity Theory

The PC didn't accept the AIV paper but they set up a debate between Russell and myself at the conference. Russell and I spent several wonderful hours before the debate overlooking the ocean and talking about our models.1 We did find some common ground during the day which unfortunately led to a debate without much fireworks.

After the debate, Juris Hartmanis asked me to submit my paper to the Complexity Column he ran for the Bulletin of the EATCS and so it appeared there. AIV is still going through revisions and Russell said during the STOC talk (that's last week's STOC) that they still planned to publish it. 

To continue the debate: Russell gave his STOC talk explaining that limiting the types of relativization would lead to "worlds" closer to our own. But you get a trade-off: While a few more techniques relativize in this model, it becomes much harder to create oracles, most of the oracles we have in the traditional model don't go through for the restricted model. Since the 1993 debate there have been many oracles in the traditional model published. Local checkability, algebraic methods and every other technique has failed to crack any of those oracles after they've been published. So why restrict our worlds when we still get so much more mileage in the traditional model?


  1. The beach resort where we had the first FCRC was so much nicer than the inland location of the last two San Diego FCRCs

June 10, 2009

Can we make this problem FUN?

Consider the following cute problem:
Alice, Bob, and Carol each have a number between 0 and 1,000,000,000,000 on their forehead. Everyone can see the numbers that are NOT on their own forehead. Call the three numbers x,y,z. They wish to determine if x+y+z is divisible by 1,000,000,000,000. There is an easy solution: Alice can just say Bob, your number is .... This would take 13 digits of communication. Can they do better?
Chandra, Furst, and Lipton showed that if instead of 1,000,000,000,000 was replaced by 2n, and if n is large, then do this in roughly \sqrt n bits. They were more interested in the k-party lower bound of ω(1) since this leads to lower bounds on branching programs. (NOTE: They studied a variant of the the problem above, but everything they did applies hear also.) See their paper or my writeup for JUST the upper bound or my writeup of the upper and lower boundand its application to branching programs for more information.

The problem stated above with people having numbers on their foreheads sounds like it could be a fun problem for the layperson. BUT: The problem with this problem for the layperson is two fold: (1) The original problem involves 3-free sets. While our community might say Wow, an application of stuff coming out of van der Waerden's theorem (or at least I would say that), the layperson would not think of it or care. (2) Frankly, I don't know if 13 digits numbers are big enough for the asymptotics to kick in and give a better answer than 13.

SO- here is my challenge: Is there a solution to this problem (or perhaps one with larger numbers) where the solution is non-trivial--- that is, you do not communicate all of the numbers, but is also FUN! FUN means you can tell it to your non-mathematical-nephew, or perhaps your 10-years-old-great-niece-who-likes-math. Quite okay if its far worse than \sqrt(n).

June 09, 2009

Integer subtraction

I recently finished another video of mine, this time on the topic of subtraction of integers. You can watch it here:


Subtracting Integers


In it, I explain three different models that we can use to justify the rules for subtracting integers to the students. The three models are:

1) number line jumps;
2) concept of difference;
3) counters.

Please read about these models in more detail in my updated article How to teach operations with integers.

Fifty Years of Mathmagic Land

I finally succumbed to Twitter. I plan to use my twitter account to supplement the blog with bite-sized items. I may sometimes expand those tweets into longer blog postings like today.

My 11-year old daughter talked about using straight lines and angles to improve her mini-golf game. That reminded me of the billiard ball scene in a Donald Duck math movie I saw many times over during my grade school years. Off to YouTube where we watched Donald in Mathmagic Land which coincidentally turns fifty years old this month.

Holds up pretty well after fifty years though the modern music, art, architecture and technology aren't so modern any more. Catch the Turing machine (reel-to-reel computer) near the end.

It was this movie and a Time-Life book on mathematics (which had a really cool chapter on probability) that got me excited by the fun of math which, of course, helped shape my future academic career.

The movie has a scene where Donald tries to open some locked doors that the narrator says represents knowledge yet to be discovered. Cool to think that I have now witnessed many of those door opened, some with my own hands.

June 08, 2009

Massachusetts teachers' math exam

Photo by Made In China

I was almost ready to comment on this exam, where only about 27% of aspiring aspiring elementary school teachers passed the new math section of the state's licensing exam this year...

Boston.com says about this test, "Education leaders said the high failure rate reflects what they feared, that too many elementary classroom and special education teachers do not have a strong background in math and are in many ways responsible for poor student achievement in the subject, even in middle and high schools."

...and then I noticed I had been looking at the wrong link for the practice test. The real link is this:
Massachusetts Tests for Educator Licensure, Mathematics Subtest, from MTEL Practice Tests website.

I feel that test is pretty good! In fact, I'd recommend that you do some problems from it, if you're teaching any grade from 1-12. If you're teaching middle or high school, you could use some of those problems with your students, and if you're teaching elementary, it's just to check if YOU have the adequate math skills.

The open-response item is particularly interesting, and good, I think. It shows a student response on a particular geometry problem, and asks:

"Use your knowledge of mathematics to create a response in which you analyze the elementary school student's work and provide an alternative solution to the problem. In your response, you should:
  • correct any errors or misconceptions evident in the elementary school student's work and explain why the response is not mathematically sound (be sure to provide a correct solution, show your work, and explain your reasoning); and

  • solve the problem using an alternative method that could enhance the elementary school student's conceptual understanding of ratios and decimal multiplication in the context of the problem."
Take a look at the math test.


What kind of math would I test elementary teachers on

If I made a test for future elementary school teachers, I'd ask lots of questions about elementary and middle school math INCLUDING "WHY" questions. If they know that, then they can explain the math to their students as well.

I might ask questions related to common errors and misconceptions kids have. "Sally calculated that 0.5 + 0.12 = 0.17. What concept is Sally not understanding (and it's not decimal addition)? What kind of intervention do you think would help?"

I would ask questions that test their understanding of why long division or long multiplication works.

I'd test their knowledge of middle school level math and some high school level math. I'd test for problem solving abilities.

Elementary teachers should know middle school math well (percents, proportions, equations, geometric constructions, statistical graphs, etc.) so that they know what the elementary math they teach is leading to. For example, they should know square roots and Pythagorean theorem. That way, when they teach multiplication, they can throw in a "teaser" for the best kids in the class, asking, "What number multiplied by itself is 64?" Or, "I say a number, you say what number multiplied by itself gives that number."

So, I might actually ask, "What further mathematical concepts after 3rd grade depend on a good knowledge of multiplication tables?" Or, "Students study prime factorization in 6th grade. Give two examples where the understanding of this concept is needful in further mathematics studies within grades 6-12."

See also what MathMama writes about Tests .... (TIMSS & the MA teacher licensing test)

Are there any longstanding conjectures that ended up being false?

Mathematics and TCS are full of conjectures. Some are proven true, some are still not known. Most that have been resolved have been true:
  1. Fermat's last theorem should have been called a conjecture. It was proven. I don't think any serious mathematician ever thought it was false.
  2. Baudet's' Conjecture is now VDW's Theorem.
  3. The Modell Conjecture is now Faltings Theorem.
  4. I could list more, so could you.
Are there any conjectures that ended up being false? Yes, though none listed below is really a clean story.
  1. Hilbert's 10th problem asked for an algorithm that would, given a poly in many variables over Z, determine if it has a Diophantine solution. We now know this cannot be done. While this may have surprised Hilbert, he was aware of this sort of thing happening. See the preface to his problems, or better see his entire address here.
  2. Same with the Ind of CH from ZFC. Hilbert thought it was true. More to the point, Hilbert certainly thought it had an answer. Now we know that it does not. Or at least that its ind of ZFC.
  3. NL=coNL surprised alot of people.
  4. In 1986 most people thought that P\ne BPP (hard to believe!). One notable exception was Mike Sipser. Now most people think that P=BPP. Of course, not resolved yet.
I have not been able to find a dramatic example of a long standing conjecture that a large community believed ending up being false. Do you know of any?

I doubt that any of the Clay problems will end up being false. I doubt that any serious mathematician thinks that any will end up being false. That might be self-correcting: if someone did we would label him (perhaps unfairly) non-serious.

June 07, 2009

Hashing Molecules

Twenty or so years ago I worked for a pharmaceutical company that had a large database of compounds. That got me thinking about the problem of how to perform lookups based on molecular structures. If you can find a bunch of numbers that encapsulate the molecular structure then you can use them as database keys. But you need to ensure that the same molecule entered in two different ways gets mapped to the same numbers, and you'd like different molecules, such as stereoisomers, or even enantiomers to get mapped to different values.

That got me thinking and around then I came up with an idea for hashing molecules inspired by some of the mathematics I'd been doing not long before. I never got around to coding it up but twenty years later it dawned on me that I could easily do it using a similar technique to what I used for untangling tangles and translating trace diagrams. Anyway, as I've already given examples of how to translate diagrams to monadic expressions I'm going to skimp on the details in this post and just talk about things specific to molecular structures. For this post to make sense you have to understand those earlier posts.

So first comes the usual Haskell preamble:


> {-# LANGUAGE MultiParamTypeClasses,FlexibleInstances,FunctionalDependencies,GeneralizedNewtypeDeriving #-}

> module Main where

> import Data.HashTable
> import Data.List as L
> import Data.Int
> import Data.Array
> import GHC.Arr
> import qualified Data.Map as M
> import Control.Monad
> infixl 5 .+
> infixl 6 .*


I'm going to be using the vector space monad with a 4-dimensional vector space. This type labels the dimensions:


> data I = A | B | C | D deriving (Eq,Ord,Show,Ix,Enum)


n-valent atoms will be represented by functions that consume n-tuples. We'll start with a simple hash:


> c' (a,b,c,d) = hashString ("C" ++ show (a,b,c,d))


My prime motivation for using Haskell for this problem is that the code was super-easy to write and investigate. But it's inefficient. I'll talk about how to remedy this properly at the end. But for now I'm going to memoise many functions as arrays using a Memoisable type class with a memo method. So I'll be using c instead of c':

> c = memo $ \x -> symmetrise a4 c' x .* return ()

Note the use of the symmetrise function. The idea is that the 4 bonds coming out from (singly-bonded) carbon can be thought of as lying at the corners of a tetrahedron.

They have tetrahedral symmetry. So I'd like my hash to also have this symmetry so that, for example, c (i,j,k,l) == c (j,i,l,k). We can enforce this by summing over all 24 permutations of the arguments compatible with this symmetry, also known as A4. So a4 lists all of these permutations:


> a4 (i,j,k,l) = [
> (i,j,k,l),
> (j,i,l,k),
> (k,l,i,j),
> (l,k,j,i),

> (i,k,l,j),
> (i,l,j,k),

> (k,j,l,i),
> (l,j,i,k),

> (j,l,k,i),
> (l,i,k,j),

> (j,k,i,l),
> (k,i,j,l)
> ]


And symmetrise performs the summation:


> symmetrise group f x = sum (map f (group x))


We can define other molecules too. Hydrogen is easy:


> h = memo $ \a -> hashString ("H" ++ show a) .* return ()


Oxygen has S2 symmetry:


> s2 (i,j) = [ (i,j), (j,i) ]
> o' (a,b) = hashString ("O" ++ show (a,b))
> o = memo $ \x -> symmetrise s2 o' x .* return ()


You can think of a carbon atom and a hydrogen atom, say, as a pair of arrays cijkl and hi, and bonding them together as summation over a shared index. So methane would be the sum over i,j,k,l = A..D of cijklhihjhkhl. To this end, define a bond as:


> bond :: V Int32 I
> bond = return A .+ return B .+ return C .+ return D


We can make H2 like so:


> h2 = simp $ do
> i <- bond
> h ! i
> h ! i


i <- bond makes i a bond which we then attach to two hydrogen atoms. Evaluating h2 will give us the hash for hydrogen gas.

Rather than dive straight into CH4 we can construct some useful building blocks. Hydrogen with a bond already attached:


> h_ :: V Int32 I
> h_ = do
> m <- bond
> h ! m
> return m


I'm using a trailing underscore _ to indicate a free bond.

ch2_ accepts one bond and returns another. Once memoised it is, in effect, just a 4x4 matrix and can be used to rapidly build chains.


> ch2_ = memo $ \i -> simp $ do
> k <- bond
> l <- bond
> m <- bond
> h ! l
> h ! m
> c ! (i,k,l,m)
> return k


So here's code to make an alkyl chain with a free bind at the end.


> alkyl_ 0 = h_

> alkyl_ n = simp $ do
> i <- alkyl_ (n-1)
> ch2_ ! i


We can now make alkanes by attaching a hydrogen atom at the end and make methane as a special case:


> alkane n = simp $ alkyl_ n >>= (h ! )
> methane = alkane 1


Now a hydroxyl group:


> oh = memo $ \i -> simp $ do
> j <- bond
> h ! j
> o ! (i,j)


And you can have a drink on me:


> ethanol = simp $ do
> i <- alkyl_ 2
> oh ! i


Carbon double bonds turn out to be straightforward. We can simply use a pair of bonds:


> doubleBond :: V Int32 (I,I)
> doubleBond = simp $ do
> i <- bond
> j <- bond
> return (i,j)


Carbon-carbon double bonds tend not to twist and this is reflected in the hash. We'd have to apply symmetrise if we wanted twistable bonds.

We can make a pre-canned doubly bonded carbon atom pair:



> c_c = memo $ \(i,j,k,l) -> simp $ do
> (m,n) <- doubleBond
> c ! (i,j,m,n)
> c ! (m,n,k,l)


So we can build ethene like this


> ethene = simp $ do
> i <- h_
> j <- h_
> k <- h_
> l <- h_
> c_c ! (i,j,k,l)


Here's a methyl group with a free bond


> ch3_ = simp $ do
> l <- h_
> ch2_ ! l


So we can build a bunch more compounds


> propene = simp $ do
> j <- ch3_
> i <- h_
> k <- h_
> l <- h_
> c_c ! (i,j,k,l)

> cisbut2ene = simp $ do
> i <- ch3_
> j <- h_
> k <- ch3_
> l <- h_
> c_c ! (i,j,k,l)

> transbut2ene = simp $ do
> i <- h_
> j <- ch3_
> k <- ch3_
> l <- h_
> c_c ! (i,j,k,l)

> cisbut2ene' = simp $ do
> i <- h_
> j <- ch3_
> k <- h_
> l <- ch3_
> c_c ! (i,j,k,l)

> _2methylpropene = simp $ do
> i <- ch3_
> j <- ch3_
> k <- h_
> l <- h_
> c_c ! (i,j,k,l)

> _2methylpropene' = simp $ do
> i <- h_
> j <- h_
> k <- ch3_
> l <- ch3_
> c_c ! (i,j,k,l)


An interesting problem is building a benzene ring. Here's a first attempt with six free bonds:


> ring1 (p,q,r,s,t,u) = simp $ do
> i <- bond
> j <- bond
> k <- bond
> c_c ! (j,q,i,p)
> c_c ! (i,u,k,t)
> c_c ! (k,s,j,r)


The problem with that is that benzene rings are special. The electrons are 'delocalised' so that the ring has rotational symmetry. We need to sum over the two consistent ways to assign single and double bonds around the ring. For the more general case of interlocking benzene rings we must still sum over all consistent assignments.




> ring = memo $ \(p,q,r,s,t,u) -> simp $ ring1 (p,q,r,s,t,u) .+ ring1 (q,r,s,t,u,p)


And some more compunds:


> phenyl = memo $ \p -> simp $ do
> q <- h_
> r <- h_
> s <- h_
> t <- h_
> u <- h_
> ring ! (p,q,r,s,t,u)

> benzene :: V Int32 ()
> benzene = simp $ do
> i <- bond
> phenyl ! i
> h ! i

> phenol :: V Int32 ()
> phenol = simp $ do
> i <- bond
> phenyl ! i
> oh ! i

> toluene :: V Int32 ()
> toluene = simp $ do
> i <- ch3_
> phenyl ! i

> toluene' :: V Int32 ()
> toluene' = simp $ do
> p <- h_
> q <- h_
> r <- h_
> s <- ch3_
> t <- h_
> u <- h_
> ring ! (p,q,r,s,t,u)

> toluene'' :: V Int32 ()
> toluene'' = simp $ do
> p <- h_
> q <- h_
> r <- ch3_
> s <- h_
> t <- h_
> u <- h_
> ring ! (p,q,r,s,t,u)

> _1_2_dimethylbenzene = simp $ do
> p <- ch3_
> q <- ch3_
> r <- h_
> s <- h_
> t <- h_
> u <- h_
> ring ! (p,q,r,s,t,u)

> _1_3_dimethylbenzene = simp $ do
> p <- ch3_
> q <- h_
> r <- ch3_
> s <- h_
> t <- h_
> u <- h_
> ring ! (p,q,r,s,t,u)

> _1_4_dimethylbenzene = simp $ do
> p <- ch3_
> q <- h_
> r <- h_
> s <- ch3_
> t <- h_
> u <- h_
> ring ! (p,q,r,s,t,u)

> _1_5_dimethylbenzene = simp $ do
> p <- ch3_
> q <- h_
> r <- h_
> s <- h_
> t <- ch3_
> u <- h_
> ring ! (p,q,r,s,t,u)


As we might hope, the three different ways to define toluene give the same result. We also discover that 1,3- and 1,5-dimethylbenzene are the same compound (or at least probably are, this isn't a perfect hash).


> main = do
> print $ "toluene = " ++ show toluene
> print $ "toluene' = " ++ show toluene'
> print $ "toluene'' = " ++ show toluene''
> print $ "_1_2_dimethylbenzene = " ++ show _1_2_dimethylbenzene
> print $ "_1_3_dimethylbenzene = " ++ show _1_3_dimethylbenzene
> print $ "_1_4_dimethylbenzene = " ++ show _1_4_dimethylbenzene
> print $ "_1_5_dimethylbenzene = " ++ show _1_5_dimethylbenzene


Now I need to say something about performance. The above code is naive and performs many unnecessary summations. For example, hashing a long chain should only take time linear in its length. But using the above code indiscriminately could give you exponential time. A good implementation might take a divide and conquer approach: slice the molecule in half through a bunch of bonds, compute partial hashes for each half and then sew the halves together in time exponential in the number of bonds you sliced through. For the types of molecules I've seen in real pharmaceutical databases (say) this is actually pretty cheap if you're smart about the slicing. The hashes in the above code could probably be computed many thousands of times faster. As it is, you'll probably need to compile the above with optimisation.

I'm willing to bet that with small changes, and with suitable choice of matrices over the reals, we can get invariants of molecules that predict physical properties. These calulations are reminiscent of algorithms for various types of counting algorithm so at the very least they probably compute things that are meaningful from a statistical mechanics perspective.

Incidentally, this approach to stitching together atoms was inspired by an old paper by R. C. Penner on fatgraphs - nothing to do with chemistry. A few days ago he put a paper online about an application to modelling proteins.

Update: Since writing this I've found a name for what I'm doing. I'm converting a chemical structure diagram into a tensor network. There seems to be lots of literature on how to evaluate these efficiently. In effect, everything I've been doing in this blog in terms of converting diagrams to code is an example of evaluating a tensor network.




Now comes the memoisation class:


> class Memoisable ix where
> memo :: (ix -> a) -> Array ix a

> instance Memoisable I where
> memo f = array (A,D) [(i,f i) | i <- [A .. D]]

> instance Memoisable (I,I) where
> memo f = array ((A,A),(D,D)) [(i,f i) |
> p <- [A .. D],
> q <- [A .. D],
> let i = (p,q) ]

> instance Memoisable (I,I,I,I) where
> memo f = array ((A,A,A,A),(D,D,D,D)) [(i,f i) |
> p <- [A .. D],
> q <- [A .. D],
> r <- [A .. D],
> s <- [A .. D],
> let i = (p,q,r,s) ]

> instance Memoisable (I,I,I,I,I,I) where
> memo f = array ((A,A,A,A,A,A),(D,D,D,D,D,D)) [(i,f i) |
> p <- [A .. D],
> q <- [A .. D],
> r <- [A .. D],
> s <- [A .. D],
> t <- [A .. D],
> u <- [A .. D],
> let i = (p,q,r,s,t,u) ]


Missing instances from Data.Array:


> instance (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6) => Ix (a1,a2,a3,a4,a5,a6) where
> range ((l1,l2,l3,l4,l5,l6),(u1,u2,u3,u4,u5,u6)) =
> [(i1,i2,i3,i4,i5,i6) | i1 <- range (l1,u1),
> i2 <- range (l2,u2),
> i3 <- range (l3,u3),
> i4 <- range (l4,u4),
> i5 <- range (l5,u5),
> i6 <- range (l6,u6)]

> unsafeIndex ((l1,l2,l3,l4,l5,l6),(u1,u2,u3,u4,u5,u6)) (i1,i2,i3,i4,i5,i6) =
> unsafeIndex (l6,u6) i6 + unsafeRangeSize (l6,u6) * (
> unsafeIndex (l5,u5) i5 + unsafeRangeSize (l5,u5) * (
> unsafeIndex (l4,u4) i4 + unsafeRangeSize (l4,u4) * (
> unsafeIndex (l3,u3) i3 + unsafeRangeSize (l3,u3) * (
> unsafeIndex (l2,u2) i2 + unsafeRangeSize (l2,u2) * (
> unsafeIndex (l1,u1) i1)))))

> inRange ((l1,l2,l3,l4,l5,l6),(u1,u2,u3,u4,u5,u6)) (i1,i2,i3,i4,i5,i6) =
> inRange (l1,u1) i1 && inRange (l2,u2) i2 &&
> inRange (l3,u3) i3 && inRange (l4,u4) i4 &&
> inRange (l5,u5) i5 && inRange (l6,u6) i6


And the same vector space monad I've used many times before. Strictly speaking, it's more like a semiring module monad as Int32 isn't a field.


> swap (x,y) = (y,x)

> class Num k => VectorSpace k v | v -> k where
> zero :: v
> (.+) :: v -> v -> v
> (.*) :: k -> v -> v
> (.-) :: v -> v -> v
> v1 .- v2 = v1 .+ ((-1).*v2)

> data V k a = V { unV :: [(k,a)] } deriving (Show)

> reduce x = filter ((/=0) . fst) $ fmap swap $ M.toList $ M.fromListWith (+) $ fmap swap $ x
> simp (V x) = V (reduce x)

> instance (Ord a,Num k) => Eq (V k a) where
> V x==V y = reduce x==reduce y

> instance (Ord a,Num k,Ord k) => Ord (V k a) where
> compare (V x) (V y) = compare (reduce x) (reduce y)

> instance Num k => Functor (V k) where
> fmap f (V as) = V $ map (\(k,a) -> (k,f a)) as

> instance Num k => Monad (V k) where
> return a = V [(1,a)]
> x >>= f = join (fmap f x)
> where join x = V $ concat $ fmap (uncurry scale) $ unV $ fmap unV x
> scale k1 as = map (\(k2,a) -> (k1*k2,a)) as

> instance Num r => MonadPlus (V r) where
> mzero = V []
> mplus (V x) (V y) = V (x++y)

> instance (Num k,Ord a) => VectorSpace k (V k a) where
> zero = V []
> V x .+ V y = V (x ++ y)
> (.*) k = (>>= (\a -> V [(k,a)]))

> e = return :: Num k => a -> V k a
> coefficient b (V bs) = maybe 0 id (L.lookup b (map swap (reduce bs)))

June 06, 2009

The late Richard Lewis

I’ve never met him, but he did research in the area of partitions and was a friend of several people I know. One of them - Shaun Cooper - by pure chance found a reference to Richard in the 1996 autobiography of Howard Marks named “Mr Nice”. On the cover it said of Marks “He [...]

Rajeev Motwani

Tragic news from Jennifer Widom via Paul Beame.
I am deeply saddened to inform the database community that Prof. Rajeev Motwani passed away Thursday night in a swimming pool accident at his home. He will be remembered by the large number of professional colleagues, faculty colleagues, and students whose education and lives have been enriched tremendously by his.
A tremendous loss for the theory community as well. Rajeev Motwani had an incredible publication record particularly in algorithms, wrote major textbooks, served our community well and was a true bridge between theory and practice. He received the Gödel prize in 2001 for the PCP paper. We lost one of the great ones.

Update: Suresh, one of Rajeev's former students, writes a very nice personal remembrance

June 05, 2009

Not about STOC/Funny Stuff people have send me

The other bloggers have done such a great job covering STOC that I won't add anything, except to say that I agree most of whats been said: Moser's talk and result were GREAT, the Innovations in Computer Science Conference has to be better defined, and Lance has both lost weight AND gotten a haircut

People often send me funny short math things and say this would be great for your blog!. Here is a collection of things people send me over the last year. XKCD comics:
  1. RANDOM NUMBER
  2. OPEN SOURCE
  3. HAMILTONIAN
  4. LABYRINTH PUZZLE
  5. ONLINE COMMUNITIES
  6. SECURITY
  7. DUTY CALLS

A song about Mandelbrot Sets, although one of the comments on it claims that the song is actually about Julia sets. The person who send it was amused that there is a curse word in it. But he's young and easily amused--- he's 32.

A recursive music video.

June 04, 2009

A Kolmogorov Complexity Proof of the Lovász Local Lemma

Robin Moser gave one of the best STOC talks ever in his award-winning paper A Constructive Proof of the Lovász Local Lemma. Not only an amazing result but also an incredibly inventive simple proof that he came up with while preparing the talk.

Here is a sketch of Moser's proof written as a Kolmogorov complexity argument. This is not the full Lovász Local Lemma but captures the main principle.

Theorem: Suppose we have a k-CNF formula φ with n variables and m clauses and each clause shares a variable with at most r other clauses. There is a constant d such that if r 2k-d then φ is satisfiable. Moreover we can find that assignment in time polynomial in m and n.

Here's the algorithm:

Solve(φ)
Pick a random assignment of φ
While there is an unsatisfiable clause C
         Fix(C)

Fix(C)
Replace the variables of C with new random values
While there is clause D that shares a variable with C that is not satisfied
        Fix(D)

Assume Fix(C) always terminates. Every clause that was satisfied before we called Fix(C) will still remain sastisfied and C will also now be satisfied. So Solve makes at most m calls to Fix.

We need to show all the Fix(C) terminate. Suppose the algorithm makes at least s Fix calls including all the recursive ones. We will show s is bounded and thus the algorithm terminates.

Fix a Kolmogorov random string x of length n+sk (random relative to φ, k, s, r, m and n) and assume the algorithm uses the first n bits as the initial assignment and k bits each to replace the variables in each Fix call.

If we know which clause is being fixed, we know the clause is violated so we know all the bits of this clause and thus we learn k bits of x. We then replace those bits with another part of x.

So we can describe x by the list of clauses we fix plus the remaining n bits of the final assignment. We can describe the C such that Fix(C) is called by Solve by m log m bits and the remaining fixed clauses by log r + O(1) bits because either it is one of r clauses that intersects the previous clause or we indicate the end of a recursive call (keeping track of the recursion stack).

So we must have m log m + s(log r+O(1))+n ≥ n+sk or s(k-log r-O(1)) ≤ m log m.

To show s is bounded, we need k-log r-O(1) to be positive or r2k-d for some constant d.

Note this in fact shows s = O(m log m) so the algorithm runs in polynomial time. We choose the x randomnly which with high probability will be Kolmogorovly random. QED

In the talk, Moser gives the bound r2k-3 and in follow-up work with Gábor Tardos shows r2k/e (e = 2.71…) which is the best that comes out of the original Lovász Local Lemma.

A Failure of Social Networks?

One of Northwestern's professors made quite a splash a month ago with his group's predictions on the spread of the Swine Flu (now called H1N1). Dirk Brockmann claimed a worst-case scenario of 1700 flu cases by the end of May. Another group in Indiana made similar predictions. The research got picked up on a front page New York Times article. Brockmann's group used data from Where's George, a site that tracks movement of dollar bills, to understand interactions that would lead to the spreading of disease.

So how did these groups do? Not even in the right ballpark, off by two orders of magnitude. As a follow-up article in Tuesday's Science Times the CDC estimated there were well over 100,000 cases by the end of last month. What went wrong? In short Brockmann claims faulty initial data. Nevertheless I always worry that bad predictions from scientists make it harder to have the public trust us when we really need them to.

Might this be an instance where prediction markets greatly out-performed the experts? In short, no. There were relevant markets but two big problems: 
  • No one thought to create a market for the number of flu cases over a couple of thousand. 
  • Prediction markets require a verifiable outcome so they were based on CDC confirmed cases. But after the flu turned out not to be that dangerous, the CDC stopped confirming most cases and there were less than 7500 confirmed cases by the end of May.

June 03, 2009

Guess the plots!

What do these depict?


Here are two others. Different data source, different point in time, but what are they?


They are all linked in pairs - one coloured and one black linked together. They are not sports related. And they are taken from real world data. The colours are relevant and constitute a hint in their own right.

Thoughts from STOC

I haven't been to STOC/FOCS since FCRC in San Diego two years ago. Since then I dropped thirty pounds and got a haircut last week. Amazing how many people thought something looked different about me and asked about the haircut.

I missed the Valiant celebration but it brought a large number of senior theorists who don't often attend STOC/FOCS. I enjoyed seeing and talking with them. Still, despite a relatively easy to reach location (say compared with last year's Victoria), STOC only attracted about 260 attendees, nearly half students. We just don't get draw many non-local attendees who don't have papers in the conference. Though David Johnson told me he's attended every STOC since the early 70's.

I don't attend many talks at STOC, I prefer to hang in the hallways chatting with people, about research, politics, gossip and baseball. The talks I did attend usually had about five or so good minutes of motivation and results followed by technical details for experts in that particular area. That's probably the right way to give those talks but I was rarely one of those experts.

And then I see a talk as amazing as Moser's and I realize: This is why I love theory.

May 30, 2009

Word problem Singapore way

Laura had 24 clips more than Holly. After she gave 5 clips to Holly, Laura had twice as many clips as Holly. How many clips did Laura have left?

This is from Singapore Challenging Word Problems book 3 (which they are now discontinuing, I heard).

I found two ways to solve this using the bar diagrams.

Solution 1. Notice that this is showing how I solved it initially, and at one point I had to adjust the length of the bar.

bar diagram solution 1



Solution 2.

bar diagram solution 2

In either case, once you get that x = 9 (the amount of clips Holly had in the beginning), it's easy to solve that Laura had 28 clips left after giving 5 to Holly.



Algebraically:

Initially Laura has L, Holly has L - 24. (Obviously you could also choose to use H and let Laura have H + 24.)

Then Laura gives 5 to Holly, so now Laura has L - 5 and Holly has L - 24 + 5 which is L - 19.

At this point Laura has double as many clips as Holly: L - 5 = 2(L - 19) and we can solve.

L - 5 = 2L - 38
L = 33.

Laura had 33 - 5 = 28 after she gave 5 to Holly.

There are probably other ways to solve this as well.

May 29, 2009

Math Teachers at Play #8

Go visit Math Teachers at Play carnival at Let's Play Math. Lots of neat stuff this time!

I definitely want to try this with my daughter for multiplying by 7s. I also really liked
Four things I used to think about calculus, and what I’ve replaced them with
- a teacher whose teaching has evolved towards conceptual understanding.

Mathematically Structured but not Necessarily Functional Programming

These are the slides and the extended abstract from my MSFP 2008 talk. Apparently, I forgot to publish them online. There is a discussion on the Agda mailing list to which the talk is somewhat relevant, so I am publishing now.

Abstract: Realizability is an interpretation of intuitionistic logic which subsumes the Curry-Howard interpretation of propositions as types, because it allows the realizers to use computational effects such as non-termination, store and exceptions. Therefore, we can use realizability as a framework for program development and extraction which allows any style of programming, not just the purely functional one that is supported by the Curry-Howard correspondence. In joint work with Christopher A. Stone we developed RZ, a tool which uses realizability to translate specifications written in constructive logic into interface code annotated with logical assertions. RZ does not extract code from proofs, but allows any implementation method, from handwritten code to code extracted from proofs by other tools. In our experience, RZ is useful for specification of non-trivial theories. While the use of computational effects does improve efficiency it also makes it difficult to reason about programs and prove their correctness. We demonstrate this fact by considering non-purely functional realizers for a Brouwerian continuity principle.

Download: msfp2008-slides.pdf, msfp2008-abstract.pdf

May 25, 2009

Research on conceptual understanding

Just an interesting piece... a recent study has found that teaching conceptual understanding in math makes children learn better, as opposed to teaching procedures.

You Do The Math: Explaining Basic Concepts Behind Math Problems Improves Children's Learning

The children were taught about solving equations such as

4 + 5 + 3 = ___ + 3

either procedurally, or conceptually. Procedural instruction went kind of like this:

"Add the three numbers on this side, 4 + 5 + 3. That's 12. Then subtract the number here from that, 12 - 3 = 9. That's the number that goes to the blank."

In the conceptual group they were taught about equivalence, the equation having two sides that have to be equal.

Of course... the conceptual teaching is the way to go!

Here's a link to the research paper (in press):
Matthews, P. & Rittle-Johnson, B. (in press). In pursuit of knowledge: Comparing self-explanation, concepts, and procedures as pedagogical tools. Journal of Experimental Child Psychology.

Long division and dyslexia

Photo by laura.bell

I have a dyslexic 9 year old and I wish to find out if your program can benefit him. I have tried Math-U-See and it became too boring or frustrating for him. I have tried various other programs in hope of not overwhelming him. He has completed the delta Math U See level but I feel needs more work on long division. He simply gets very frustrated with it, as the length of time and knowing where to place number due to dyslexia. Is your curriculum a spiral curriculum? Any suggestions would help.
One of my books from the Blue Series goes through long division in several small steps: Math Mammoth Division 2

I would suggest that for a dyslexic child, have him do ALL the problems on a squared paper (grid paper). That will help him place the numbers right. Not all the problems in my division book are done with the grid... but for your son, it may be necessary to always use such paper.



Secondly, when you teach on board or on paper, at each step COLOR the whole column of ones, or tens, or hundreds (whichever you are working at). I have not done such exactly like what I explain now in my book, I'm just telling you to try that: color the column you're looking at, at each step.

This will help him focus on the specific place value, such as hundreds, and help him place the digit in the quotient in the hundreds column, write the product, and calculate the difference in that column.

Apart from those tips, it might also help if you check whether he understands the REMAINDER concept outside long division. For example,

16 / 5 = ??

42 / 10 = ??

He must be able to do those well in order to some day understand why long division works. HOWEVER, it's possible for children to learn the motions of long division without understanding why it works. So, definitely do not discontinue long division just because he doesn't grasp why it works. That understanding may come later on.

My curriculum does not use a "short" spiral like Saxon/Abeka/Horizons. It is more mastery based. However, different concepts are reviewed and studied usually on 2 or 3 neighboring grade levels, and I also use problems about new concepts that also use previous concepts so they cannot be forgotten. For example, once they learn about writing addition and subtraction from the same picture, then that is used to learn fact families, which is also used later on with x.

Hope this helps.

May 24, 2009

Recommendations for pre-algebra

Folks often ask me how far I'm planning to write my Math Mammoth complete curriculum (the Light Blue books). Right now I'm finishing up 5th grade. After that, I will be writing 6th grade. But, I'm not really planning to go on after that.

I feel a child who will have finished Math Mammoth 6th grade (once it is available) is probably ready for pre-algebra for 7th grade. Perhaps not all children won't be, but a good portion of those who use Math Mammoth should be.

Pre-algebra is sort of "in-between" course. It is bridging the world of numerical computations of elementary math, and the world of algebra where we manipulate variables. Pre-algebra courses typically cover these topics:



Photo by ecumaniac
* integers
* fractions, decimals
* factors, exponents
* solving linear equations
* solving linear inequalities
* ratio and proportion
* percent
* graphing linear functions
* Pythagorean theorem and other geometry topics
* some statistics and probability.

Most students take prealgebra in 8th grade, just prior to taking algebra 1. However, it is possible to study these topics in 7th grade as well, if the student has a good foundation from grades 1-6. And that is what I'm aiming for in writing Math Mammoth - a good enough foundation of concepts so the student can go on to pre-algebra after 6th grade.

I have prepared an article that talks more about the various pre-algebra book choices.

May 23, 2009

Trace Diagrams with Monads

Knot diagrams aren't the only kind of diagram that can be translated nicely into Haskell monad notation. Other types of diagram include Penrose Spin Networks, many kinds of Feynman Diagram, Penrose Tensor Notation, birdtracks and a type of closely related diagram I hadn't met before: Trace Diagrams.

I encourage readers to check out the Wikipedia page and associated papers on trace diagrams as they give a better tutorial than I could write. My aim here is to show how those diagrams can be translated directly into working code just like with knots.

As usual, this is literate Haskell so I need these lines:


> {-# LANGUAGE MultiParamTypeClasses,FunctionalDependencies,FlexibleInstances #-}

> module Main where

> import qualified Data.Map as M
> import Control.Monad
> infixl 5 .+
> infixl 6 .*


I'll reuse my vector space monad code from before and work in a 3D space with the axes labelled X, Y and Z.

> data Space = X | Y | Z deriving (Eq,Show,Ord)


We draw vectors as little boxes with connections emerging from them:


Now recall from my knot posts that we represent a diagram with m legs at the top and n legs at the bottom as an expression that takes an m-tuple as input and returns an n-tuple "in the monad" as output.

Vectors can be represented as elements of V Float Space, for example:

> u,v,w :: V Float Space
> u = return X .- return Y
> v = return X .+ 2.* return Y
> w = return Y .- return Z

I could have emphasised that there are zero inputs at the top by using type signature () -> V Float Space instead.

Given two vectors we can form their dot product. The dot product itself is represented by a little u-shaped curve:

So the dot product of v and w is drawn as:

(The i and j are just so you can see what corresponds to what in the code below. They're not really part of the diagram.)

We can implement the dot product as

> cup :: (Space,Space) -> V Float ()
> cup (i,j) = case (i,j) of
> (X,X) -> return ()
> (Y,Y) -> return ()
> (Z,Z) -> return ()
> otherwise -> 0 .* return ()

and compute an example using

> vdotw = do
> i <- v
> j <- w
> cup (i,j)

We hook up legs of the diagram using corresponding inputs and outputs in the code.

Now consider this diagram:

If we attach another vector to the free leg then we get the dot product. So this object is a thing that maps vectors to scalars. Ie. it's a dual vector. So dual vectors are represented by diagrams with a free leg at the top. We can redraw this diagram:
In other words, turning a vector v upside down turns it into a dual vector that takes w to the dot product of v and w. Here's some code for making the dual of v.

> dual :: V Float Space -> Space -> V Float ()
> dual v i = do
> j <- v
> cup (i,j)

We can also consider cross products. These take two vectors as input and output one. So we're looking at a diagram with two legs at the top and one at the bottom. We'll use a bold dot to represent one of these:

Here's the implementation:

> cross :: (Space,Space) -> V Float Space
> cross (X,Y) = return Z
> cross (Y,Z) = return X
> cross (Z,X) = return Y

> cross (Y,X) = (-1) .* return Z
> cross (Z,Y) = (-1) .* return X
> cross (X,Z) = (-1) .* return Y

> cross _ = mzero

We can form a triple product u.(v×w) like this:

We can then abstract out the triple product bit that looks like this:

Implementing it as:

> trident :: (Space,Space,Space) -> V Float ()
> trident (i,j,k) = do
> l <- cross (i,j)
> cup (l,k)

Remember that if u, v and w give the rows of a 3x3 matrix, then u.(v×w) is the determinant of that matrix.

We can also define a dot product for dual vectors that we can draw like this:

The code looks like this:

> cap :: () -> V Float (Space,Space)
> cap () = return (X,X) .+ return (Y,Y) .+ return (Z,Z)

We can now combine the two dot products in a diagram like this:

We can write that as:

> cupcap i = do
> (j,k) <- cap ()
> cup (i,j)
> return k

We'd hope that we could pull this diagram taut and get the identity linear map. If you try applying cupcap to X, Y and Z you'll see it has exactly the same effect as return, which does indeed represent the identity.

(If you allow me to digress, I'll point out that there's something really deep going on with this almost trivial looking identity. It represents the identity map in the sense that it copies the input i to the output k. Imagine we were dealing with the trivial monad, ie. the one that just wraps values. Then no matter how cup and cap were implemented it would be impossible for k to be a copy of i. If you follow the flow of information through that code then i disappears into cup and k is read from cap without it seeing i. If we read from top to bottom we can think of cap as emitting a pair of objects and of cup as absorbing two. There is no way that any information about i can be communicated to k. But in the vector space monad, k can depend on i. As I've mentioned a few times over the years, the universe is described by quantum mechanics which can be described using the vector space monad. Amazingly the above piece of code, or at least something like it, can be physically realised in terms of particles. It describes a process that is fundamentally quantum, and not classical. In fact, Coecke shows that this is a precursor to quantum teleportation in section 3c of this paper. You could also think in terms of information about i being sent back in time through the cap. That's the idea behind this paper on Effective Quantum Time Travel.)

Now we can make a fork by bending down the tines of the cross product:


> fork () = do
> (i,j) <- cap ()
> (k,l) <- cap ()
> m <- cross (j,k)
> return (i,l,m)


We can write matrices as boxes with a leg for input and a leg for output. Here's an example matrix:


> a :: Space -> V Float Space
> a X = 2 .* return X
> a Y = return Z
> a Z = (-1) .* return Y

It rotates by 90 degrees around the X axis and scales the X axis by a factor of two.

With the help of our two dot products we can turn a matrix upside-down:

The corresponding code is:

> b :: Space -> V Float Space
> b l = do
> (i,j) <- cap ()
> k <- a j
> cup (k,l)
> return i

Turning a matrix upside down gives its transpose. You'll find that matrix B rotates in the opposite direction to A but still scales by a factor of two.

Surprisingly, 3! times the determinant of a 3x3 matrix A can be represented by this diagram:

So we can write a determinant routine as follows:

> det a = do
> (i,j,k) <- fork ()
> i' <- a i
> j' <- a j
> k' <- a k
> (1/6.0) .* trident (i',j',k')

(Again I've labelled the diagram so you can easily see what corresponds where in the code.)

I could keep going, but at this point I'll just defer to Elisha Peterson's paper. I hope that I've given you enough clues to be able to translate his diagrams into Haskell code, in effect giving semantics for his syntax. As an exercise, try writing code to compute the adjugate of a 3x3 matrix.

And a reminder: none of the above is intended as production-worthy code for working with 3-vectors. It is intended purely as a way to give a practical realisation of trace diagrams allow people to experimentally investigate their properties and make testable conjectures.

And now comes the library code needed to make the above code work:


> swap (x,y) = (y,x)

> class Num k => VectorSpace k v | v -> k where
> zero :: v
> (.+) :: v -> v -> v
> (.*) :: k -> v -> v
> (.-) :: v -> v -> v
> v1 .- v2 = v1 .+ ((-1).*v2)

> data V k a = V { unV :: [(k,a)] }
> instance (Num k,Ord a,Show a) => Show (V k a) where
> show (V x) = show (reduce x)

> reduce x = filter ((/=0) . fst) $ fmap swap $ M.toList $ M.fromListWith (+) $ fmap swap $ x

> instance (Ord a,Num k) => Eq (V k a) where
> V x==V y = reduce x==reduce y

> instance (Ord a,Num k,Ord k) => Ord (V k a) where
> compare (V x) (V y) = compare (reduce x) (reduce y)

> instance Num k => Functor (V k) where
> fmap f (V as) = V $ map (\(k,a) -> (k,f a)) as

> instance Num k => Monad (V k) where
> return a = V [(1,a)]
> x >>= f = join (fmap f x)
> where join x = V $ concat $ fmap (uncurry scale) $ unV $ fmap unV x
> scale k1 as = map (\(k2,a) -> (k1*k2,a)) as

> instance Num r => MonadPlus (V r) where
> mzero = V []
> mplus (V x) (V y) = V (x++y)

> instance (Num k,Ord a) => VectorSpace k (V k a) where
> zero = V []
> V x .+ V y = V (x ++ y)
> (.*) k = (>>= (\a -> V [(k,a)]))

> e = return :: Num k => a -> V k a
> coefficient b (V bs) = maybe 0 id (lookup b (map swap (reduce bs)))

May 19, 2009

Survey on Causation

My good friend Antony Eagle has a survey on causation that he'd like people to have a look at. The link is here:

http://www.surveymonkey.com/s.aspx?sm=flm10kfdTBAcPUGy1hay9A_3d_3d

x-posted at Thoughts, Arguments and Rants

May 16, 2009

Newest Blog Carnival is online

Check out the latest edition of Math Teachers at Play blog carnival. It's up at Homeschool Bytes. As a carnival pick, I enjoyed Plat Diviseur (Fractions on a plate) post. It's about a dining plate... Go see!

May 13, 2009

Mapping zipcodes in R

I started fiddling around with R again, and ended up playing with a zipcode database.

So, first I downloaded the zipcode database at Mapping Hacks, and unpacked the zipfile in my working directory.

Then, I loaded the data into R

> zips <- read.table("zipcode.csv",sep=",",quote="\"",header=TRUE)
> names(zips)
[1] "zip"       "city"      "state"     "latitude"  "longitude"
[6] "timezone"  "dst"      
 

So, now I have an R frame containing a lot of US cities, their geographical coordinates, and their zip codes. So we can start playing with the plot command! After rooting around a bit, I ended up settling on the smallest footprint plot dot I could make R produce, by setting the option pch=20 in the plot options. Hence, I ended up with a command basically like this:

> plot(zips$longitude,zips$latitude,type="p",col=((zips$zip/10000)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=0.1)
 

where the +1 after the modulus is to make even 0-values plot, and the cex parameter sets the point size to something small and pretty.
First digit of the USPS zip code

We can continue this, tweaking the divisor to extract all the other digits of the zip code, and we end up getting:

> plot(zips$longitude,zips$latitude,type="p",col=((zips$zip/1000)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=0.1)
 

and the result
Second digit of the USPS zip code

> plot(zips$longitude,zips$latitude,type="p",col=((zips$zip/100)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=0.1)
 

and the result
Third digit of the USPS zip code

> plot(zips$longitude,zips$latitude,type="p",col=((zips$zip/10)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=0.1)
 

and the result
Fourth digit of the USPS zip code

and finally

> plot(zips$longitude,zips$latitude,type="p",col=((zips$zip/1)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=0.1)
 

and the result
Fifth digit of the USPS zip code

And then, of course, we can zoom in on data too. So we can do things like extracting Californian zip codes

> cazips <- zips[zips$state == "CA",]
> plot(cazips$longitude,cazips$latitude,type="p",col=((cazips$zip/1000)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=0.5)
 

to get
Second digit of the Californian USPS zip code
or, we could extract New York zip codes:

> nyzips <- zips[zips$state == "NY",]
> plot(nyzips$longitude,nyzips$latitude,type="p",col=((nyzips$zip/100)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=0.5)
 

Third digit of the New York USPS zip code
or even extract, say, the zip codes starting with 10 or 11, covering New York City and surroundings and take a closer look

> ny10zips <- nyzips[nyzips$zip<12000,]
> ny10zips <- ny10zips[ny10zips$zip>9999,]
> plot(ny10zips$longitude,ny10zips$latitude,type="p",col=((ny10zips$zip/100)%%10)+1,pch=20,axes=FALSE,xlab="",ylab="",cex=1.0)
 

Third digit of the USPS zip codes 10xxx and 11xxx

Chocolate and mental performance

Photo by Cacaobug

You might have seen this piece of news about a new study:

Scientists reveal how eating chocolate can help improve your maths
Eating chocolate could improve the brain's ability to do maths, a new study suggests.

I think I have experienced this effect. Whenever I eat several pieces of dark chocolate, it definitely seems (while I do various computer work) that my brain works faster and I'm more alert. I also think that this effect is not because of sugar, because the dark chocolate does not have high amounts and because I definitely don't feel the same if I just ate, say, a sweet apple or a cookie.

I like both chocolate and the "alert" feeling after eating it. I don't like it when I start feeling the "brain drain" (your brain can definitely get tired after several hours of researching/writing emails & blogposts/devising math problems etc.). I don't know if this effect is from flavanols in chocolate like it mentions in the study, or theobromine, or both, or also something else.

The brand I often get here is El Rey. I don't have a clue about its flavanol content; it says it's made with "rare, flavorful, coveted" Venezuelan cacao beans only. But be that as it may, the taste sure IS good!