[Edu-sig] Updating some more...

Litvin litvin at skylit.com
Thu Jul 1 03:49:07 CEST 2010


At 07:01 PM 6/30/2010, kirby urner wrote:
>I did something similar with a Ramanujan series converging to pi...

Since you mentioned Ramanujan...

He and Hardy worked quite a bit on the partition function: p(n) = the 
number of different ways n can be represented as a sum of positive 
integers.  The sequence p(n) starts like Fibonacci numbers, 1, 1, 2, 
3, 5... but the next one is 7.  Nice try!

At some point around 1916, an amature mathematician Major MacMahon, 
who was "good with numbers" calculated _by hand_ for Hardy and 
Ramanujan p(n) for n = 1 through 200.  p(200) happens to 
be  3,972,999,029,388.  An interesting story.

It is possible, of course, to write a recursive function to calculate 
p(n), but a more fun way is to use the generating function (1 + x + 
x^2 +x^3+...x^n)*(1+x^2+x^4+x^6+...)(1+x^3+x^6+...)*...*(1+x^n) (due 
to Euler, as most everything else...)  When you distribute, the 
coefficients at x, x^2, ... of the resulting polynomial give you 
p(1), p(2), ... So this could be a basis for a meaningful project on 
lists and polynomials.

If you plug a large enough number into the generating function, say, 
x = 10000, you get a number whose groups of five digits (from the 
right) give you p(n) as long as p(n) < 10000.  So for a relatively 
small n instead of multiplying polynomials you can multiply 
"periodic" integers 100010001...0001*100000001...00000001*...
It is easy, of course, to generate these numbers using strings.  Then 
this becomes a meaningful exercise on strings.

I am currently working on a "test package" for the Math and Python 
book and I've just added a question based on a small peace of this, 
so I felt like sharing.  Not sure whether this is for the left brain 
or for the right brain; these periodic strings are kinda cute. :)

Gary Litvin
www.skylit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20100630/90e9d718/attachment.html>


More information about the Edu-sig mailing list