[Edu-sig] Where mathematics comes from

Kirby Urner urnerk@qwest.net
Sun, 26 Jan 2003 13:28:04 -0800


At 02:59 PM 1/26/2003 -0500, John Miller wrote:
>I recently came across a book by Lakoff & Nunez called "Where mathematics 
>comes from : how the embodied mind brings mathematics into being". After 
>reading the introduction, I jumped to the four appendices where the equation
>
>e^(pi)i = -1
>
>is explained. I never thought I'd be able to understand that equation, but 
>reading their explanation made it tantalizingly approachable. It may well 
>be that much of why people were turned off to math in school can be 
>explained by metaphoric deficiencies in the teaching of it. And they show 
>how to rectify the situation with their (metaphor-based) take on how that 
>particular equation might be better explained. Anyway, it'll probably take 
>a few re-readings before I really get it, but at least now, there's a chance...
>
>John Miller
>Technology Services
>School of Education
>University of Michigan

What kind of explanation do they give I wonder?

The approach I've usually seen, and which I think sort of mirrors Euler's 
process,
involves expanding e^x as a polynomial and then showing how the polynomial
expansions of sine and cosine sort of merge to give the same thing, or at
least of we pass ix as our value (complex number), the signs change such that
e^ix = cos(x) + i sin(x).  Here's an example of this approach:
http://www.nrich.maths.org.uk/mathsf/journalf/aams/q57.html

But then you need to go back and figure out why these are valid polynomial
expansions for e, cos and sin.

We could avoid the proofs for a bit and just play around with the first
expansion, comparing outputs on both sides of the equals sign.  I.e. in
Python we have math.exp(x) for raising e to the xth power.

The expansion is (1/0! 1/1! 1/2! 1/3! 1/4!...) where these are the
coefficients of a polynomial, with x^0, x^1, x^2, x^3... respectively.

One thing we can do in Python is produce successive factorials using a
generator, because once we have 4!, why go back and start the multiplications
all over just to get 5!.  Just multiply 4! (which we already have) by
5 fer gosh sakes.

Now I'm using the PyCrust shell:

  >>> from __future__ import generators, division
  >>> from operator import add
  >>> from math import exp, pi

  >>> def fact():
        """
        Sequence of factorials: 0! 1! 2! 3!...
        """
        n=0; result=1
        while 1:
          if n == 0: yield 1
          n += 1
          result *= n
          yield result

   >>> [f.next() for i in range(10)]  # sequence of factorials
   [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

Now we can build the polynomial expansion:

  >>> def polye(n,x):
         """
         Polynomial expansion of e^x to n terms, using fact() generator
         """
         f = fact()
         return reduce(add,[x**i/f.next() for i in range(n)])

and compare exp(x) with polye(n,x), where n is the number of terms
we want in our expansion:


   >>> exp(3)          # e^x ; x = 3
   20.085536923187668
   >>> polye(25,3)
   20.0855369231876


   >>> polye(50,10)     # e^x ; x = 10
   22026.465794806711
   >>> exp(10)
   22026.465794806718

I notice I needed to push the number of terms pretty high (like to
50) to get a lot of agreement as x increases.  Lots to play with here.
Perhaps we need an exponentially increasing number of those polynomial
terms, to stay on target, as x increases linearly.

Now comes the big test (vis-a-vis the topic at hand).  Let's make x = i*pi
where i = sqrt(-1). Right away, we see that math.exp() fails, because it
won't take a complex argument.  But polye() passes the test with flying
colors.

   >>> x = complex(0, pi)

   >>> exp(x)
   Traceback (most recent call last):
     File "<input>", line 1, in ?
   TypeError: can't convert complex to float; use e.g. abs(z)

   >>> polye(50,x)
   (-1.0000000000000002+3.4586691443277667e-016j)

Note that, at 50 terms in our expansion, the imaginary component is
vanishingly small, and the real part is about as close to -1 as you
can get in floating point arithmetic.

Kirby