# [Edu-sig] Re: More on intro to Python (today's 3 hr training)

Kirby Urner urnerk at qwest.net
Tue Mar 29 20:54:58 CEST 2005

```> So, the "smart" algorithm should be  (untested here.... left as an
> exercise :-)
>
> sum = ( f(a) + f(b) ) / 2.
> x = a + h
> B = b-h/2  # takes care of round-off error at end point.
>
> .while x <= B:
> .    sum += f(x)
> .    x += h
> .
> . sum *= h
> . return sum
> ========
>
> André

Your comments and Henrik's are cogent and valuable and provide definite
improvements.  Plus the discussion is conceptual i.e. we're dealing with
nuts and bolts problems that the calculus deals with.

So my general question is, as usual:  wouldn't this be an interesting and
intelligent way to teach math?  You get concepts, and you get programming
skills, and you start to think about analyzing and fine tuning algorithms.
Plus you grow to appreciate the power of the calculus, which gives us close
formed expressions so often -- a way to avoid fast for-loops entirely.

Kirby

```

More information about the Edu-sig mailing list