Monday, 28 January 2013

Sadly Remembering

Born of the sun, they travelled a short while toward the sun
And left the vivid air signed with their honour.
*The Truly Great by Stephen Spender

After more than a quarter of a century, there are still no words.... I was in the school library to watch with a class.... and amidst the cheering for a successsful liftoff.....



Tuesday, 22 January 2013

A Problem About Boxes?


It started with a Twitter post by Mario Livio, who is head of public outreach at the Space Telescope Science Institute (the folks who operate the Hubble Telescope) but most of us know him better as a writer of popular math and science. I especially liked his book on the so-called Golden Ratio.


Mario's tweet was, "For buffs:118=14+50+54=18+30+70=15+40+63=21+25+72 and product of each triple is 37,800."

I got to wondering what was the smallest number that would have more than one partition into three parts so that the product of the three was the same. Turns out after some pencil scribbles, that 13 appears to be the smallest: 13= 1+6+6 = 2+2+9 and both have a product of 36.
Fourteen had two pairs. One with a product of 40 and the other with a product of 72 (I leave the actual values to the interested reader to find.)

Twenty-one seemed to be the smallest with three different pairs. Twenty-two and twenty three were interesting because they had the same product: 5+8+9 = 22, 4+9+10 = 23, but both have a product of 360. Twenty-five also produced a pair with a product of 360.

By thirty-nine I found what I believe is the smallest value with a three different partitions with the same product: 6 + 8 + 25 = 5 + 10+ 24 = 4 + 15 + 20; all three with a product 10 1200.
Forty-nine had two different triples.

I finally resorted to a computer search (it seemed quicker even with my poor programming skills than continuing to try to see a pattern in theses. Did I miss something easy?)to see if there was a quadruple before the 118 that Mario had found. By the time I reached the mid 70's I was repeatedly finding triple matches that had products of 5400, but no quadruples, and finally I concluded that 118 was indeed the smallest number that would have four partitions into three parts which had the same product.

So why is two partitions into three parts interesting? Well, for one thing, I now know that there are two different box shapes (rectangular Parallelepipeds) which have a volume of 36 for which the total sum of the edge lengths is 52 (4x13); and that for integer sides and volume, there is no smaller total side length for which that is true. So the L,W,H relation of 2,4,9 and 1,6,6 are special boxes.

The whole thing did get me off on another search. I wondered if there were distinct integer sided boxes for which the edge lengths had the same total and the surface areas are also equal. The short form would be, are there two partitions of a number n into x,y,z and a,b,c such that xy+xz+yz = ab+ac+bc?

Turns out they are pretty common. The smallest is for n = 9 (a total edge length of 36) with sides of 1,4,4 and 2,2,5. Each would have a surface area of 48 sq units.

Now to search and see if there is one of those lucky coincidences where two different boxes have the same edge length, surface area and volume. But that's for another day.


Friday, 18 January 2013

How Pi Was Almost Equal to Three in Indiana



So what about the state that passed a law that set Pi = 3? Well, it was in the paper, and on the internet, but it never happened, although it did get close once. A hoax article was printed and widely circulated (on April 1, 1998) that said that NASA engineers in Huntsville, Alabama were upset about the discovery that the Alabama legislature had just passed a law making Pi=3. When the perpetrators of the hoax realized that the article was being paraphrased (without all the hints that it was a joke, such as the authors name, April Holiday) and circulating as truth, they tried to circulate a notice of the hoax, but found the truth spread much more slowly than the sensational story.

But it was on this day in 1897 that an actual bill was introduced into the state House of Indiana to pass a law which would have, in effect, make pi equal to ... well several numbers it seems. And I should point out that the proposed bill was the idea idea of a fellow who had already proved many of the impossible constructions of geometry, such as squaring the circle. Here is a another description of the bizarre incident by Cecil Adams from his web column, "Straight Dope":
----------------
It happened in Indiana. Although the attempt to legislate pi was ultimately unsuccessful, it did come pretty close. In 1897 Representative T.I. Record of Posen county introduced House Bill #246 in the Indiana House of Representatives. The bill, based on the work of a physician and amateur mathematician named Edward J. Goodwin (Edwin in some accounts), suggests not one but three numbers for pi, among them 3.2, as we shall see. The punishment for unbelievers I have not been able to learn, but I place no credence in the rumor that you had to spend the rest of your natural life in Indiana. [ Although it is often called the Pi Bill, the main result claimed by the bill is a method to square the circle, rather than to establish a certain value for the mathematical constant π (pi). In fact pi is not mentioned in the text of the bill.]

The text of the bill consists of a series of mathematical claims followed by a recitation of Goodwin's previous accomplishments:
"... his solutions of the trisection of the angle, doubling the cube and quadrature of the circle having been already accepted as contributions to science by the American Mathematical Monthly ... And be it remembered that these noted problems had been long since given up by scientific bodies as unsolvable mysteries and above man's ability to comprehend."
Goodwin's "solutions" were indeed published in the AMM, though with a disclaimer of 'published by request of the author'.

If you feel up to the task, the bill can be found here.

Just as people today have a hard time accepting the idea that the speed of light is the speed limit of the universe, Goodwin and Record apparently couldn't handle the fact that pi was not a rational number. "Since the rule in present use [presumably pi equals 3.14159...] fails to work ..., it should be discarded as wholly wanting and misleading in the practical applications," the bill declared. Instead, mathematically inclined Hoosiers could take their pick among the following formulae:
(1) The ratio of the diameter of a circle to its circumference is 5/4 to 4. In other words, pi equals 16/5 or 3.2
(2) The area of a circle equals the area of a square whose side is 1/4 the circumference of the circle. Working this out algebraically, we see that pi must be equal to 4.
(3) The ratio of the length of a 90 degree arc to the length of a segment connecting the arc's two endpoints is 8 to 7. This gives us pi equal to the square root of 2 x 16/7, or about 3.23.

There may have been other values for pi as well; the bill was so confusingly written that it's impossible to tell exactly what Goodwin was getting at. Mathematician David Singmaster says he found six different values in the bill, plus three more in Goodwin's other writings and comments, for a total of nine.

Lord knows how all this was supposedly to clarify pi or anything else, but as we shall see, they do things a little differently in Indiana. Bill #246 was initially sent to the Committee on Swamp Lands. The committee deliberated gravely on the question, decided it was not the appropriate body to consider such a measure and turned it over to the Committee on Education. The latter committee gave the bill a "pass" recommendation and sent it on to the full House, which approved it unanimously, 67 to 0.

In the state Senate, the bill was referred to the Committee on Temperance. (One begins to suspect it was silly season in the Indiana legislature at the time.) It passed first reading, but that's as far as it got. According to The Penguin Dictionary of Curious and Interesting Numbers, the bill "was held up before a second reading due to the intervention of C.A. Waldo, a professor of mathematics [at Purdue] who happened to be passing through." Waldo, describing the experience later, wrote, "A member [of the legislature] then showed the writer [i.e., Waldo] a copy of the bill just passed and asked him if he would like an introduction to the learned doctor, its author. He declined the courtesy with thanks, remarking that he was acquainted with as many crazy people as he cared to know."

The bill was postponed indefinitely and died a quiet death. According to a local newspaper, however, "Although the bill was not acted on favorably no one who spoke against it intimated that there was anything wrong with the theories it advances. All of the Senators who spoke on the bill admitted that they were ignorant of the merits of the proposition. It was simply regarded as not being a subject for legislation."

Tennessee is also frequently mentioned as a state that "passed a pi=3 bill" but that seems to come from a small reference by Robert Heinlein in Stranger in a Strange Land. "In the Tennessee legislature a bill was again introduced to make the ratio pi exactly equal to three"."

* Much of the text was taken from http://www.straightdope.com. and Wikipedia



Wednesday, 16 January 2013

First Steps into Primes and Number Theory


Sometimes it takes several tries before ideas find purchase in my hard skull. This blog started with a post by Ben Vitale that relates the number eight to the digital root of twin primes. I posted it as a number curiosity on the eighth day of the year.

5 * 7 = 35, 3 + 5 = 8
11 * 13 = 143, 1 + 4 + 3 = 8
17 * 19 = 323, 3 + 2 + 3 = 8
29 * 31 = 899, 8 + 9 + 9 = 26, 2 + 6 = 8
41 * 43 = 1763 1 + 7 + 6 + 3 = 17, 1 + 7 = 8
59 * 61 = 3599, 3 + 5 + 9 + 9 = 26, 2 + 6 = 8
71 * 73 = 5183, 5 + 1 + 8 + 3 = 17, 1 + 7 = 8
101 * 103 = 10403, 1 + 0 + 4 + 0 + 3 = 8
(Ben deserves credit for stimulating my curiosity on numerous occasions, so check out his blog site here)

A couple of days later one of my Kiwi readers, Don S McDonald, proved that the proof was so trivial it could be tweeted.... by tweeting it.
"twin primes product (6n -1)*(6n +1) =36*n sq -1 =8 mod 9 digital root."

Did I suddenly think, "Oh Yeah, this would make a great blog for introducing young students to primes and number theory?". Nope, just sent Don a quick response and back into my mental haze.

Then David Brooks wrote to add that one might explore the digital root of cousin and sexy primes, pointing out a couple of good websites to finally shake me out of the doldrums.
(And at last he finally gets to the point of the blog)
SOoooo.....
or
The reason I think this would be a great point to start young mathematical minds into proofs and number theory is because all the ideas in the rest of the post need only these mathematical foundations:
A) A very basic understanding of modular arithmetic topics, which is often mentioned in middle school as "clock arithmetic" and continues to be an important mathematical concept as the student progresses to more advanced math.
B) The binomial Distribution


There is a very wide range of mathematical talent in the folks who follow this blog, and many of the mathematical professors and professionals will find this post very trivial. But I am writing this with young people like my grand-nephew Alex in mind. Alex is a clever middle school student with an affinity for math and science but I fear his education is leaving him with the idea that math is about memorizing the techniques in order to answer questions quickly. I would hope he finds that math can be more exciting when you focus on the next question rather than the last answer. So for introductory math students like Alex, and the folks who teach them, a sequence of ideas to introduce number theory.

Ideas Related to twin primes
A big idea that Bob glossed over in his twitter-proof is that all primes greater than three must be one more or one less than a multiple of six. Students might be more interested in being given a question something like, "Three, five and seven are all three prime. Is there another triplet of primes of the form p, p+2, and p+4?"
For the student with even a modest understanding of modular arithmetic, the answer proof is simple. One of the three must have a factor of three.


It would seem that with a little prodding, they might be able to dig out confirmation for the 6n +/-1 model for all primes greater than 3.

At this point I might point out that two primes which differ by four are called prime cousins. Examples are (3,7), (7,11), (13,17) and (19,23). I would recast the
last question about twin primes; is it possible to have a triple of prime cousins, p, p+4, and p+6.

Students should quickly find that there is, (3,7,11). We point out that there was one set of prime triplets also, and ask, "Are there any more triples of cousins?"
Using the same modular approach from the triple of primes, they should see that there are no others.

"So, do you think anything interesting might happen if we found the digital root of the product of cousin primes?"
After a little calculation (teachers might call this practice) they will find that 3x7 = 21 has digit root of 3, but 7x11=77; 13x17=221; and 19x23= 437 all have a digital root of 5. Can this be true for all the rest.
Now we get a chance to emulate Don's binomial approach. Using (6n+1) for the smaller, the larger would be 6n+5. When we multiply we get 36n2 + 36n + 5; and the result is complete.

Then I would proceed to sexy primes. I would point out to the class that the "sexy" in this case is related to the Latin for six. I would point it out, but I doubt it would stem the flow of jokes.
Sexy primes are pairs of primes which differ by six. Five and eleven, seven and thirteen, eleven and seventeen are all sexy prime pairs.

If we return to the idea of the digital root of the product, could we find similar relation to the twin primes relation from Ben Vitale? A little experimentation leads us to 5x11 = 55, 5+5=10, and 1+0=1. Likewise we note that 7x13=91 also with a digital root of 1. Students are prone to jump to conclusions (teachers are too) and many may call out that answer.
If they do, just ask them if they can show that is true for all the values algebraically. Others who may have gone on to 11x17=187 will realize that the prediction is false. Now we can encourage them to press on and look for a pattern they think is true. Eventually one will be able to show that the digital root is always 1, 4, or 7 or of the form (3n+1).

By leading them to look at the alternate form of the statement, that all products are congruent to 1 mod 3, the problem can be reduced to two simple cases.

Hopefully we can lead them to figure out that numbers of the form 6n+1 are congruent to 1 mod 3, and 6n-1 forms would be congruent to 2. Now we need them to discover that both the sexy primes must be of the same form, either 6n+1, or 6n-1.
If both numbers are 6n+1, the product must be a number that is equal to 1 mod 3. If both are of the form 6n-1, the product must be a number that is equal to 2x2= 4 mod 3, which is also 1.

After no success finding triplets of primes, or prime cousins, students may expect that the same result may occur with sexy primes, but they should discover several triples that are less than 100; (7, 13, 19) and (17, 23, 29) both show up quickly. In fact, there are sexy prime quadruplets such as (11, 17, 23, 29) that they might discover as they search for triples. There is an interesting pattern in the sexy quadruples that might tease students interest, all the first primes in the quadruples end in one.
There is even one sexy quintuplet, (5, 11, 17, 23, 29), but since every fifth number in such a sequence is divisible by five, there can be no more.

It may even be worth pointing out to younger students that there is a general name for numbers which differ by a common amount. They are called arithmetic sequences.

And as a reward, you might try this puzzle by David Wells from his "The Penguin Book of Curious and Interesting Puzzles" which can be solved with some clever use of the idea of modular congruence. I'll post the answer down the page a ways. Enjoy..


_____________________________________________________________________________________
An old invoice showed that seventy-two turkeys had been purchased for "x67.9x". The first and last digits were illegible. How much did each turkey cost?

/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/


*********************************************
SPOILER

Since 72 is divisible by both 9 and 8, we know that the number must have a digital root of zero, and the last three digits will be divisible by 8 (equal to 0 mod 8)
So 79x must be divisible by 8, and the last digit must be a 2.
Now we can use the fact that the digital root must equal 9 (or 0). 6+7+9+2 has a digital root of 6, so we need three more to make nine, and 3 must be the first digit. Now all we need to do is take the total price, 367.92 and divide by 72. It appears that each bird costs 5.11 (Pounds, dollars, Euros, or other monetary units of your choice
****************************************************************

Tuesday, 15 January 2013

He's a Poet and A Preacher,....




Today is the anniversary of the Birth of Henry Aldrich, who can only be described as a man of many talents. He was born January 15 in 1648. Most remembered for a logic textbook that was in use for centuries, he was also a mathematician, poet, musician, and humorist, all this in addition to his "day" job as a cleric.

Reading about his diversity I was reminded of the old Kris Kristofferson song, "He's A Pilgrim".
He's a poet, he's a picker, he's a prophet, he's a pusher
He's a pilgrim and a preacher and a problem when he's stoned
He's a walking contradiction, partly truth and partly fiction
Taking every wrong direction on his lonely way back home

The song is here for those who may want to listen. It has been a favorite of mine for years.

Aldrich was educated at Westminster School under the famous, or perhaps infamous, Dr Richard Busby. Busby was renowned as much for his mastery of the cane and strap as for his educational practices. Alexander Pope poked fun at him in his 1743 edition of The Dunciad and decrys his emphasis on rote memorization which he said put a "jingling padlock" on the brain. Whatever his faults, his students included Christopher Wren, Robert Hooke, John Dryden, John Locke, and the above mentioned Henry Aldrch. (at one time it is said that sixteen of his former students were bishops)

In 1662 he switched to Christ Church, Oxford, and received his MA in 1669 and took Holy Orders and became a tutor there.

He seems to have been recognized early as an accomplished musician and composer. "The ability of Aldrich as a composer was recognised already, and at the
Encaenia of 1672 he was called upon to set to music certain verses written by
Bishop Fell-In laudem Musices Carmen Sapphicum. " (*Suttle) He was recognized well beyond the walls of Christ Church, for he received a request from Dr.
Huntingdon, the Provost of Trinity College, Dublin, to compose music to present at an "Act ceremony which Trinity College, Dublin proposed to hold in imitation of Oxford. "
To the average person, his most remembered contribution to music may be "Hark, the bonny Christ Church bells.", which is still available on seasonal records such as this one at Amazon.


By 1674 he had published Elementa geometricae. There are very few evidences of his ability as a mathematician in print, but he seems to have been held in high esteem by the mathematical movers and shakers of the period.
Suttle writes, "It was during these early years at Christ Church that Aldrich seems to have acquired a considerable reputation as a mathematician. As early as 1675 a
letter written by Sir Philip Percival to Sir Robert Southwell describes Aldrich
as . a great mathematician of our house."
He adds that he was involved in the foundation of the Philosophical Society in 1683, (which became the London' Royal Society.') and is listed as having been present at the first meetings, and his name is linked with that of Dr. John Wallis,
By 1702 David Gregory would speak highly of him in the preface to his Astronomiae physicae et geometricae elementa, (1702). Gregory describes frequent conversations with Aldrich, who freely imparted his views as to the purpose and profit of mathematics and how it should be taught.

Aldrich is best known as the author of a little book on logic (Artis Logicæ Compendium). There is little original material in the book. Its format closely follows Petrus Hispanus Summulae Logicales but it was used at Oxford for generations.  A revised edition was in use until the middle of the 19th century.

In 1689 he became Dean of Christchurch to succeed the Roman Catholic John Massey, who had fled to the Continent.

"As the head of Christ Church Aldrich gained a reputation which justly
eclipsed that of all his contemporaries. His own scholarship was so comprehensive
and varied that his writings included editions of Greek and Latin texts,
ecclesiastical pamphlets, and books on Logic, Mathematics, Architecture,
Heraldry and Music. He was consulted upon such varied subjects as ancient
memorials and remains, ancient musical notation, architectural schemes, and
books of all kinds" (*Suttle)
Aldrich was also an accomplished architectural designer.  He drew up the plans for All Saints Church on the High Street of Oxford ,now the Lincoln College library, and the Peckwater Quadrangle at Christ's Church.




His associates maintain that he was also both a scholar and a wit.  One sample of his humor is provided in the epigram below about  five reasons for drinking:

Si bene quid memini, causae sunt quinque bibendi;
Hospitis adventus, praesens sitis atque futura,
Aut vini bonitas, aut quaelibet altera causa.

The translation runs:

If on my theme I rightly think,
There are five reasons why men drink:—
Good wine; a friend; because I'm dry;
Or lest I should be by and by;
Or — any other reason why.
*Wik

Saturday, 5 January 2013

Before There Were Four-Fours, There Were Four-Threes

*Eyegate Gallery


EVERYONE has encountered the four-fours problem, using four fours and whatever mathematical operations that were allowed to make a number, or a set of numbers. You may even have read that it originated in the famous book of recreations by W. W. Rouse Ball; Wikipedia still has, "The first printed occurrence of this activity is in 'Mathematical Recreations and Essays' by W. W. Rouse Ball published in 1892. In this book it is described as a 'traditional recreation'. "

I know you've heard it before, but here we go again, "Wikipedia is wrong about that."

The first record I have found of a puzzle like these was in an 1818 edition of The schoolmaster's assistant: being a compendium of arithmetic both practical and theoretical : in five parts, and early American Arithmetic by Thomas Dilworth.
This image is from page 189 and part of a collection of "Short and Diverting Questions". As is typical of many of the early such problems, there were no specifications for the operations that might be employed. I have found the same exact problem in the 1800 edition. 
In the same collection of problems, Dilworth poses a problem requesting the use of four threes...(which should give you a big clue if you are stuck on the previous problem of using four figures to make 12.
Ok, even I can do that one, and the dd+d/d format becomes a regular problem through the years with different digits; the most common being in the form of "use four nines to make 100."

Professor Singmaster says the both the Dilworth problems appear in a 1743 edition of this book.
By 1788 similar problems show up in another classic American Arithmetic by Nicolas Pike,"Said Harry to Edmund, I can place four 1's so that, when added, they shall make precisely 12. Can you do so too?"

The first printed version I can find of a question like this that asks about using three or four of the same number to find a set of integers appears in 1881 in a U.K. magazine called, Knowledge: an Illustrated Magazine of Science. It was founded and edited by Richard A Proctor, the English astronomer who is remembered for his maps of Mars (and has a crater there named for him). It may be that the Cupidus Scientiae who submitted the question is, in fact, the editor.


The next edition (Jan 6, 1882) did indeed carry the solutions, as well as correspondence from an H. Snell who provides that 19 = 4! - 4 - 4/4 (he uses the Jarret symbol for factorial which looks like a right angle symbol with the number on the horizontal line)
The editor felt that factorials were inappropriate for the problem as posed. The following week (Jan 13,1882) there were several solutions for 19 from contributors, including (4+4-.4)/.4.

When W. W. Rouse Ball got into the act, it was in the third edition of his MRE 1896 and it was a long step away from the four-fours as we have come to know it. He repeated a problem previously used by Sam Loyd in 1893 which became popular in the United Kingdom; "Make 82 with the seven digits 9, 8, 7, 6, 5, 4, 0." Loyd offered a prize of 100 pounds for the solution. The solution, involving the use of repeating fractions, was given as 80.5 + .97 + .46 = 82 with all the decimal values repeating. This was indicated in the period by using a single dot above the values which repeated.

It was not until the fifth edition of 1911 of MRE that Ball gives the more common version, and describes it as, "An arithmetical amusement, said to have been first propounded in 1881,...) which seems to refer to the posting in Knowledge. By the sixth edition (1914) he has extended the problem to four nines and four threes. This one is significant because it seems to be the first that discusses what values can be achieved by what set of operations.

After a while it even caught on with higher level mathematicians. In 1991 Clifford A. Pickover asked for good approximations to Phi using four fours.
In 1999 it became popular to ask for integers created using the digits 1, 9, 9, 9.
And it seems I saw a few of those floating around the internet at the beginning of 2012.
But remember, it all started with Jack and Harry, and four-threes.

Wednesday, 2 January 2013

Solution to the Holiday Puzzle



On Christmas Eve I posted a problem about "counting Squares" suggested by Joshua Zucker in response to my blog on the history of problems involving sums of squares.

Since I'm about to give the answer to that here, you might want to go read that post first in order not to have the puzzle spoiled.


The idea is to count the number of squares that could be made in a (n+1) by (n+1) array of dots as shown above. For reasons that reflect more on how my mind works than good mathematics, I have chosen to call the 3x3 array of lattice points a 2x2 square grid. Others may wish to add one to my n's etc.

First, a solution I'm pretty sure of. I'm pretty sure because it comes Neil Sloane's OEIS web page, and these guys are pretty good fact checkers. They give 1, 6, 20, 50, 105, 196, 336, 540, as the solutions for n= 1,2,...etc.

Now that the answer is out of the bag, I wanted to show how I arrived at a solution with a simple counting scheme, and then a recursive approach and a detail that I completely overlooked until Joshua sent me a note.

First, to steal from Sinatra, I do it my way.

After playing with the puzzle awhile, I noticed that for a nxn grid, there were exactly n squares that had all vertices on the outer edges.

There is always one that looks "aligned" to the grid, as below:

but the insight came when I realized that there would be n-1 more that were "tilted". In the 3x3 square there are two that look like this:

So in the 4x4 square grid, there was 1 aligned and 3 tilted squares that were inscribed. But of course for all the smaller grids inside, there were multiples of all the smaller grids.

So to count, for example, the number of squares in a 4x4 square grid of points, we know that there are 4 on the first shell, but on there are 22 ways to pick the upper left corner of a 3x3 grid inside this, and each of those grids have 3 squares that can be formed on the outside of each of these grids. Likewise there are 32 ways to pick a 2x2 grid inside the 4x4, and each of them contains 2 unique squares. and of course there are the final 42 ways to pick a 1x1 grid that each has only one square. Finding a total of 1(4) + 4(3) + 9(2) + 16(1) = 4+12+18+16 = 50.

In general this will produce the total for any level. Start at the nth level and 1(n)+22(n-1)+32(n-2)... down to n2(1).
That's easy enough to write in summation notation,  so I leave it to the reader and move on to something a little more interesting.

A recursive way to count the square is to use a three column recursive process.  Folks who love spreadsheets could quickly extend this to huge values.   It uses the interesting fact, which completely escaped me, that the number of tilted squares at any level, is the same as the total number of squares at the previous level.

Grid Size .................. Aligned squares................... Tilted squares  ............... Total squares
1x1 ............................ 1 2  ............................................... 0 .......................................1
2x2 ............................22+12..............................................1........................................6
3x3 ..................... 32+22+12..............................................6........................................20
4x4....................42+ 32+22+12  .......................................20.......................................50
nxn                  Sigma n2 ..................... total from (n-1)x(n-1)       ... sum of #'s on this row


This can lead quickly, I think, to realizing that the total after n levels is just the sum of all the square based pyramids up to the one with n2 in the base,  In a table that looks like:
Grid size       Squares
1       .............   1
2  ................... 22 + 12 + previous total =4+1+1=6
3  ....................32+22+12 + Previous total = 9+4+1+6=20

 On thinking about the number of tilted squares at each new level, the number of NEW tilted squares at the n+1 grid will be (n2 - (n-1)2) + 2[(n-1)2 - (n-2)2] + 3[(n-2)2 - (n-3)2]...  and these differences turn into the Gnomens that the Greeks knew were intimately tied to the squares.  For them this expression would probably look like (2n-1) + 2(2n-3) + 3(2n-5) + .... +(n-1)(1) .

For younger students who have not experienced this, the gnomen may be thought of as just the odd numbers arranged in an L, and the sequence of odds will always produce a square number.  Below I have 1+3+5 making a 3x3 square of 9 units.


For the 5x5 square grid, the number of NEW tilted squares that occurs will be 7+2(5)+3(3)+4(1)=20
Can we make these Gnomens give us the square based pyramids we seek?  It seems we can, for if we spread them out we have 7 + 5 + 5 + 3 + 3 + 3 + 1 + 1+ 1 + 1... and regrouping them as (7+5+3+1) + (5 + 3 + 1) + (3 + 1) + 1  =16 + 9 +4 + 1 = 30 we have a square based pyramid for a 4x4 base.
 The number of NEW tilted squares exactly matches the old number of non-tilted squares, and thus the total of all the squares at the previous level.


Joshua wrote me with a more combinatorial solution to counting the tilted squares and I repost his words below for fear I would not do justice with a summary.


---------------------------------------------------------------------
Here's an almost-rigorous proof of one amazingly compact formula for the total number of tilted squares.  At least ,if I understand my own logic correctly, this counts all the squares whose sides are not parallel to the axes, in a grid of area n^2 (and thus of n+1 by n+1 dots).

Any tilted square has its vertices on four different rows.  But once we choose three of them, in order from bottom to top let's say, the shape of the square is fixed.  So:

We choose the 3 rows.  There are (n+1) choose 3 ways to do this.
Let's call them a, b, c in order. At this point we know that the
square is based on the vector (b-a, c-b).

Then we have to choose a location for the top point; the rest is then
determined by those vectors.  There are n+1 choices for that top point
in its row.  But some of those don't work, because the vectors will
make things stick out one way or another.

But the total horizontal extent of the square is (c-a).  So we are
going to have (n+1) - (c-a) places where the top point will work.

This seems like it's going to lead to a big ugly summation, maybe even a double sum or possibly triple.  But there is symmetry!

There are (n-1)*1 ways where c - a = 2, because we choose the top row
in n-1 ways, and then the middle row in 1 way, since there's only 1
more row in the distance of 2.
There are (n-2)*2 ways where c - a = 3, because we choose the top row
in n-2 ways, and then the middle row has 2 possibilities in between.
And so on, up to 1*(n-1) ways where c-a = n.

In other words, the number of ways for 2 and n are the same, for 3 and
n-1, and so on, since this is a symmetric list.  So the average is
(n+2)/2.

And (n+1) - (n+2)/2 = n/2.  (A shame that this much algebra had to be involved to get that elegant n/2.)  So, there are (n+1 choose 3) ways to pick three rows, and on average each of those leads to n/2 tilted squares.

So there are (n+1 choose 3) * n/2 tilted squares in the grid. Add your n(n+1)(2n+1)/6 if you want the grand total.

QED.

Now onward to (n choose 2) * (n+1 choose 2) / 3... which is (without very much work) clearly algebraically equivalent, and a combinatorial proof seems within reason for that formula as well.  I have a few other equivalent formulas to think about too ...

Incidentally, all of these were discovered by some brute-force summations and then various algebraic or finite-differences tricks to find the simpler forms, and then the combinatorial approaches were found as explanations of the surprisingly simple formulas.

Thanks Joshua, both for the original problem, and a stimulating solution.