
On 8/23/07, Michel Paul <mpaul@bhusd.k12.ca.us> wrote:
I appreciate any suggestions, especially along programming lines, that people may have.
Thanks,
- Michel Paul
Make sure you check out The Book of Numbers by Conway and Guy, and Sloane's On-Line Encyclopedia of Integer Sequences for programming ideas. Absolutely right to focus on Rationals as a Python class, to reinforce student understanding (or to help nurture it in the first place). Using __add__ and __mul__ sets the stage for redefining these ops again and again, over different sets of elements (e.g. polynomials, complex numbers). If you write it so that numerators and denominators accept Rationals as input types, then you have the bases for Continuing Fractions, a deep and fun topic, especially when the drudgery has been taken out of it i.e. you have transparent open source algorithms *and* machine execution. A paradise, by yesteryear's standards. An unexplored junkyard by the standards of today. Here's a fun generator for phi, though inefficient: IDLE 1.2.1
def genphi(): result = 1.0 while True: yield result result = (1 + 1/result)
thegen = genphi() [thegen.next() for term in range(10)] [1.0, 2.0, 1.5, 1.6666666666666665, 1.6000000000000001, 1.625, 1.6153846153846154, 1.6190476190476191, 1.6176470588235294, 1.6181818181818182]
Kirby