Updating some more...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Updating some more...

kirby urner-4
Yeah, Python 3.x is not ready for prime time in several respects,
all talk of Eclipse aside, but that's to be expected as it's still
pretty new.

I've seen some buzz regarding the #python channel on Freenode,
where I gather some bots have been automatically steering
people away from the 3.x series.

edu-sig doesn't have any real time channel for assisting educators
or their students I don't think.  Too over-specialized maybe.
Asynchronous is good enuff, no need to compete with #python
eh?

Belated congrats to Vern Ceder for stepping up to lead poster
session at usa.pycon 2011 in Atlanta per PSF blog.
http://pyfound.blogspot.com/2010/06/leadership-for-pycon-us-2011.html

I think py-dev is aware of the situation with Python 3.x and
those planning to use that product for production roll outs will
continue encouraging its swift evolution.

As I was mentioning, the O'Reilly School of Technology has
already made the switch, as have the authors of Mathematics
for the Digital Age.[1]

Where I'm focused a lot goes back to spatial geometry and
VPython which I think gives just the right amount of "right brain"
gratification to let the "left brain" keep exercising those lexical
skills (programming, like algebra, like bash/posix/gnu, is
highly lexical).

Geometry + Geography is how the simulation games tend to
work, with a geography being potentially fantastic, a fantasy,
like Alice (in Wonderland) or Uru.[2]  Or a game might be closer
to real, as when running macro and micro economics
simulations (e.g. electrical grid management vs. home
appliances management).[3]

You'll find me on mathfuture (Google group) and math-teach
@ Drexel among other places.  A lot of times I don't think
the material is Pythonic enough to merit any notes to this list.
Sometimes I meet up with other posters to this list.

Using the Decimal class to explore limits some more is in
my queue.  For example, the number e, as in "e ** (1j * math.pi) = -1"
may be expressed as lim (1 + 1/n) ** n.

>>> import math
>>> math.e ** (1j * math.pi)
(-1+1.2246467991473532e-16j)

>>> n = 10000.
>>> (1 + 1/n) ** n
2.7181459268249255
>>> math.e
2.7182818284590451
>>>

My first exercise with the Hubble folks was to look at phi to
some 100 places and do a string match against a text file
with phi to some 100K places.

http://www.4dsolutions.net/presentations/holdenweb/decimaldemo.py
http://www.4dsolutions.net/presentations/holdenweb/PhiTo100000Places.txt

I did something similar with a Ramanujan series converging to pi,
however I felt my coding style was too ugly.[4]

This is a kind of real world convergence investigation that
computational math might include (as an exercise in coding skills),
whereas in the calculator era we stayed happy with much larger
epsilons.

Kirby

[1] http://www.skylit.com/mathandpython.html

[2] http://en.wikipedia.org/wiki/American_McGee's_Alice
http://en.wikipedia.org/wiki/Uru:_Ages_Beyond_Myst

[3] http://mathforum.org/kb/message.jspa?messageID=7111960&tstart=0

[4] http://worldgame.blogspot.com/2008/02/reflective-fragment.html
(has a link back to this archive)
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Updating some more...

Vern Ceder
Hey Kirby,

kirby urner wrote:

> Yeah, Python 3.x is not ready for prime time in several respects,
> all talk of Eclipse aside, but that's to be expected as it's still
> pretty new.
>
> I've seen some buzz regarding the #python channel on Freenode,
> where I gather some bots have been automatically steering
> people away from the 3.x series.
>
> edu-sig doesn't have any real time channel for assisting educators
> or their students I don't think.  Too over-specialized maybe.
> Asynchronous is good enuff, no need to compete with #python
> eh?
>
> Belated congrats to Vern Ceder for stepping up to lead poster
> session at usa.pycon 2011 in Atlanta per PSF blog.
> http://pyfound.blogspot.com/2010/06/leadership-for-pycon-us-2011.html

Thanks. And I'm not forgetting that you played some part in getting me
into the poster session business in the first place... ;)

We'll be issuing the poster session CFP around the same time as the
regular talk CFP, and I really hope some edu-sig-ers will consider
proposing a poster. The whole idea behind posters at PyCon, IMO, is to
give a voice to speakers and topics that otherwise wouldn't make it
through the tough competition of regular talks, so don't be shy.

And it was quite frankly a blast! If you weren't at PyCon it's hard to
describe the super-mega-hallway-track-on-steroids atmosphere that
developed. So start working on those posters!

> I think py-dev is aware of the situation with Python 3.x and
> those planning to use that product for production roll outs will
> continue encouraging its swift evolution.

Yeah, I gave a talk to a group of Pythonistas in Indy last week,
http://learnpython.wordpress.com/2010/06/26/indypy-meetup-and-python-3/
focusing on Python 3.x. They were an accomplished bunch, but not very
familiar with 3.x, except for one who was excited about the use of
Unicode, particularly in source code. His observation was that it made
Python much more accessible for speakers of, say, south Asian languages.
And yeah, I did mention your experiments along those lines.

There are some in the Python community who think that having to port
things to 3.x is going to sap the fun out of the language. I don't agree
- Python 3 is (deservedly) the language of the future and the future
WILL get here. ;)

> As I was mentioning, the O'Reilly School of Technology has
> already made the switch, as have the authors of Mathematics
> for the Digital Age.[1]

And I gather that at least one class at UCLA is using my book, which is
  solely Python 3.x (further book info in my sig).

Cheers,
Vern

> Where I'm focused a lot goes back to spatial geometry and
> VPython which I think gives just the right amount of "right brain"
> gratification to let the "left brain" keep exercising those lexical
> skills (programming, like algebra, like bash/posix/gnu, is
> highly lexical).
>
> Geometry + Geography is how the simulation games tend to
> work, with a geography being potentially fantastic, a fantasy,
> like Alice (in Wonderland) or Uru.[2]  Or a game might be closer
> to real, as when running macro and micro economics
> simulations (e.g. electrical grid management vs. home
> appliances management).[3]
>
> You'll find me on mathfuture (Google group) and math-teach
> @ Drexel among other places.  A lot of times I don't think
> the material is Pythonic enough to merit any notes to this list.
> Sometimes I meet up with other posters to this list.
>
> Using the Decimal class to explore limits some more is in
> my queue.  For example, the number e, as in "e ** (1j * math.pi) = -1"
> may be expressed as lim (1 + 1/n) ** n.
>
>>>> import math
>>>> math.e ** (1j * math.pi)
> (-1+1.2246467991473532e-16j)
>
>>>> n = 10000.
>>>> (1 + 1/n) ** n
> 2.7181459268249255
>>>> math.e
> 2.7182818284590451
>
> My first exercise with the Hubble folks was to look at phi to
> some 100 places and do a string match against a text file
> with phi to some 100K places.
>
> http://www.4dsolutions.net/presentations/holdenweb/decimaldemo.py
> http://www.4dsolutions.net/presentations/holdenweb/PhiTo100000Places.txt
>
> I did something similar with a Ramanujan series converging to pi,
> however I felt my coding style was too ugly.[4]
>
> This is a kind of real world convergence investigation that
> computational math might include (as an exercise in coding skills),
> whereas in the calculator era we stayed happy with much larger
> epsilons.
>
> Kirby
>
> [1] http://www.skylit.com/mathandpython.html
>
> [2] http://en.wikipedia.org/wiki/American_McGee's_Alice
> http://en.wikipedia.org/wiki/Uru:_Ages_Beyond_Myst
>
> [3] http://mathforum.org/kb/message.jspa?messageID=7111960&tstart=0
>
> [4] http://worldgame.blogspot.com/2008/02/reflective-fragment.html
> (has a link back to this archive)
> _______________________________________________
> Edu-sig mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/edu-sig

--
This time for sure!
    -Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
[hidden email]; 260-436-0746; FAX: 260-436-5137

The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Updating some more...

Litvin-2
In reply to this post by kirby urner-4
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

_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Updating some more...

kirby urner-4
Totally mind-boggling Gary.

Tracing through On-Line Dictionary of Integer Sequences I figured out
how to do it recursively, which might not be as much fun.  For one
thing, it takes forever to run.  I despair of ever reaching p(200) this way.
Major MacMahon rocks 'n rules (Hardy and Ramanujan too).

This song about Ramanujan's life is both funny and kinda sad:
http://www.archive.org/details/Ramanujan
(play control in upper right)

Kirby


>>> gen = a000041()
>>> [next(gen) for i in range(60)]
[1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231,
297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718,
4565, 5604, 6842, 8349, 10143, 12310, 14883, 17977, 21637, 26015,
31185, 37338, 44583, 53174, 63261, 75175, 89134, 105558, 124754,
147273, 173525, 204226, 239943, 281589, 329931, 386155, 451276,
526823, 614154, 715220, 831820]

Here's the code:


def a000041():
    gen = a137683()
    while True:
        yield sum(next(gen))

def pascal():
    row = [1]
    while True:
        yield row
        row = [i+j for i,j in zip(row + [0], [0] + row)]

def invpascal():
    gen = pascal()
    while True:
        row = next(gen)
        if len(row)%2:
            yield [row[i]*pow(-1,i) for i in range(len(row))]
        else:
            yield [row[i]*pow(-1,i+1) for i in range(len(row))]

def a137683():
    gen1 = invpascal()
    gen2 = a026794()
    n = 1
    ipmatrix = [] # inverse pascal triangular matrix
    while True:
        ipmatrix.append(next(gen1))
        result = []
        row = next(gen2)
        for i in range(n):
            col = [0 for j in range(n)]
            for k in range(i,n):
                col[k] = ipmatrix[k][i]
            result.append(sum([i * j for i,j in zip(row, col)]))
        yield result
        n += 1

def a026794():
    n = 1
    while True:
        row = []
        for k in range(1, n+1):
            row.append(T(n,k))
        yield row
        n += 1

def T(n, k):
    """
    T(n, k)=if(k<1|k>n, 0, if(n==k, 1, sum(i=k, n-k, T(n-k, i))))
    """
    if k < 1 or k > n:
        return 0

    if n == k:
        return 1

    else:
        return sum([T(n-k, i) for i in range(k, n-k+1)])

# bonus, not used
def a010054():
    n = 0
    incr = 0
    tri = incr
    while True:
        if n == tri:
            yield 1
            incr += 1
            tri = tri + incr
        else:
            yield 0
        n += 1







On Wed, Jun 30, 2010 at 6:49 PM, Litvin <[hidden email]> wrote:

> 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
>
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig