From johnabloodworth3 at gmail.com Thu Nov 14 00:58:57 2013 From: johnabloodworth3 at gmail.com (Jay Bloodworth) Date: Wed, 13 Nov 2013 18:58:57 -0500 Subject: [Edu-sig] Syllabus Message-ID: <52841241.7010505@gmail.com> Does anyone have a link to a syllabus that might be appropriate for a 9 week (give or take) introductory programming course? Thanks, Jay From kirby.urner at gmail.com Sat Nov 23 04:04:30 2013 From: kirby.urner at gmail.com (kirby urner) Date: Fri, 22 Nov 2013 19:04:30 -0800 Subject: [Edu-sig] Fibonacci Numbers and Phi (again) Message-ID: Here's something mathematical from the Poly list [1], adapting something by David Koski. The code shows how one might use a program to express a cool relationship, without offering a proof. The unit-test shows use raising PHI from the -6 to the 29th power and finding an equivalent expression built solely from three consecutive Fibonacci numbers and the sqrt(5). Something like: LOOP: PHI ** E = (FIB[N] + FIB[N-2] + FIB[N-1]*RT5) / 2 E += 1 N += 1 Start with: E = -6 FIB[N-2] = 13 FIB[N-1] = -8 FIB[N] = 5 in . . . 13, -8, 5, -3, 2, -1,1, 0, 1, 2, 3, 5, 8,13 . . . === """ Encapsulating a discovery -- not a proof. By David Koski (Python by K. Urner) Failure at around 37th power is due to floating point limitations. """ import unittest def fibonacci(a=0, b=1): while True: yield a a, b = b, a + b series1 = fibonacci(5, -3) # 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 series2 = fibonacci(-8, 5) # -8, 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 series3 = fibonacci(13,-8) # 13, -8, 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 RT5 = pow(5, .5) # "square root" of five PHI = (1 + RT5)/2 # golden proportion def cool_formula(): """ Two fib numbers, two apart, plus the one in the middle * sqrt(5) all over 2, gives PHI to a power. Advancing all three sequences gives successive powers. """ while True: yield (next(series1) + next(series3) + next(series2) * RT5)/2.0 class TestPhi(unittest.TestCase): def test_loop(self): gem = cool_formula() for e in range(-6, 30): # adjust range (fails about 37th power) answer = next( gem ) self.assertAlmostEqual( PHI ** e, answer) if __name__ == "__main__": unittest.main() [1] Polyhedron mailing list Contributions to mailto:polyhedron at lists.mathconsult.ch Admin: http://lists.mathconsult.ch/mailman/listinfo/polyhedron Archive: http://lists.mathconsult.ch/mailman/private/polyhedron/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Sat Nov 23 05:57:34 2013 From: kirby.urner at gmail.com (kirby urner) Date: Fri, 22 Nov 2013 20:57:34 -0800 Subject: [Edu-sig] Fibonacci Numbers and Phi (again) In-Reply-To: References: Message-ID: """ Another version, using a generator of Fibonacci "triples"... Encapsulating a discovery -- not a proof. By David Koski (Python by K. Urner) Failure at around 37th power is due to floating point limitations. """ import unittest def fib_triple(a=0, b=1): """ >>> from anyproject import fib_triple >>> gem = fib_triple() >>> next(gem) (0, 1, 1) >>> next(gem) (1, 1, 2) >>> next(gem) (1, 2, 3) >>> next(gem) (2, 3, 5) >>> next(gem) (3, 5, 8) >>> gem = fib_triple(13,-8) >>> next(gem) (13, -8, 5) >>> next(gem) (-8, 5, -3) >>> next(gem) (5, -3, 2) >>> next(gem) (-3, 2, -1) >>> next(gem) (2, -1, 1) >>> next(gem) (-1, 1, 0) """ c = a + b while True: yield a, b, a + b a, b, c = b, a + b, b + c series = fib_triple(13,-8) # 13, -8, 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 RT5 = pow(5, .5) # "square root" of five PHI = (1 + RT5)/2 # golden proportion def cool_formula(): """ Two fib numbers, two apart, plus the one in the middle * sqrt(5) all over 2, gives PHI to a power. Advancing all three sequences gives successive powers. """ while True: f0, f1, f2 = next(series) yield (f0 + f2 + f1 * RT5)/2.0 class TestPhi(unittest.TestCase): def test_loop(self): gem = cool_formula() for e in range(-6, 30): # adjust range (fails about 37th power) answer = next( gem ) self.assertAlmostEqual( PHI ** e, answer) if __name__ == "__main__": unittest.main() -------------- next part -------------- An HTML attachment was scrubbed... URL: From litvin at skylit.com Sat Nov 23 06:49:45 2013 From: litvin at skylit.com (Litvin) Date: Sat, 23 Nov 2013 00:49:45 -0500 Subject: [Edu-sig] Fibonacci Numbers and Phi (again) In-Reply-To: References: Message-ID: <7.0.1.0.2.20131123004922.05cca650@skylit.com> Kirby, I am sorry to spoil all the fun, but this is a not a gem but a mathematical trick, and I think the way to deal with mathematical tricks is to explain them, not to verify with code. There are two Fibonacci sequences that are also geometric sequences 1, x, x^2, ..., x^n,...: when x = phi or x = -1/phi, because phi and -1/phi are the roots of the quadratic equation x^2 = x+1. Any Fibonacci sequence is a linear combination of these two: F[n] = a*phi^n + b*(-1/phi)^n. a and b can be determined from the first two terms of the sequence: a + b = F[0] a*phi - b/phi = F[1] If you choose F[0] and F[1] (not necessarily integers) in a tricky way, so that b = 0, then F[n] = a*phi^n. In addition, if a = phi^e, then F[n] = phi^(e+n). Working in reverse, you can find F[0] and F[1] that satisfy these conditions and get the trick going. Here F[0] = (13 + 5 - 8*sqrt(5))/2 = 9 - 4*sqrt(5) F[1] = (-8 - 3 + 5*sqrt(5))/2 = (-11+5sqrt(5))/2 Easy to verify that F0*phi = F1, so, indeed, b = 0 and F[n] is a geometric sequence. Also, phi^6 = 9 + 4*sqrt(5), so F[0]*phi^6 = 1 and a = F[0] = phi^(-6). You get F[n] = phi^(n-6). Gary Litvin www.skylit.com At 10:04 PM 11/22/2013, you wrote: >Here's something mathematical from the Poly list [1], adapting >something by David Koski. > >The code shows how one might use a program to express a >cool relationship, without offering a proof. > >The unit-test shows use raising PHI from the -6 to the 29th >power and finding an equivalent expression built solely from >three consecutive Fibonacci numbers and the sqrt(5). > >Something like: > >LOOP: > PHI ** E = (FIB[N] + FIB[N-2] + FIB[N-1]*RT5) / 2 > E += 1 > N += 1 > >Start with: > >E = -6 > >FIB[N-2] = 13 >FIB[N-1] = -8 >FIB[N] = 5 > >in . . . 13, -8, 5, -3, 2, -1,1, 0, 1, 2, 3, 5, 8,13 . . . > >=== > > >""" >Encapsulating a discovery -- not a proof. >By David Koski (Python by K. Urner) > >Failure at around 37th power is due to floating point limitations. >""" > >import unittest > >def fibonacci(a=0, b=1): > while True: > yield a > a, b = b, a + b > > >series1 = fibonacci(5, -3) # 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 >series2 = fibonacci(-8, 5) # -8, 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 >series3 = fibonacci(13,-8) # 13, -8, 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 > >RT5 = pow(5, .5) # "square root" of five >PHI = (1 + RT5)/2 # golden proportion > >def cool_formula(): > """ > Two fib numbers, two apart, plus the one in the middle * sqrt(5) > all over 2, gives PHI to a power. Advancing all three sequences > gives successive powers. > """ > while True: > yield (next(series1) + next(series3) + next(series2) * RT5)/2.0 > >class TestPhi(unittest.TestCase): > > def test_loop(self): > gem = cool_formula() > for e in range(-6, 30): # adjust range (fails about 37th power) > answer = next( gem ) > self.assertAlmostEqual( PHI ** e, answer) > >if __name__ == "__main__": > unittest.main() > >[1] Polyhedron mailing list >Contributions to >mailto:polyhedron at lists.mathconsult.ch >Admin: >http://lists.mathconsult.ch/mailman/listinfo/polyhedron >Archive: >http://lists.mathconsult.ch/mailman/private/polyhedron/ > >_______________________________________________ >Edu-sig mailing list >Edu-sig at python.org >https://mail.python.org/mailman/listinfo/edu-sig At 10:04 PM 11/22/2013, kirby urner wrote: >Here's something mathematical from the Poly list [1], adapting >something by David Koski. > >The code shows how one might use a program to express a >cool relationship, without offering a proof. > >The unit-test shows use raising PHI from the -6 to the 29th >power and finding an equivalent expression built solely from >three consecutive Fibonacci numbers and the sqrt(5). > >Something like: > >LOOP: > PHI ** E = (FIB[N] + FIB[N-2] + FIB[N-1]*RT5) / 2 > E += 1 > N += 1 > >Start with: > >E = -6 > >FIB[N-2] = 13 >FIB[N-1] = -8 >FIB[N] = 5 > >in . . . 13, -8, 5, -3, 2, -1,1, 0, 1, 2, 3, 5, 8,13 . . . > >=== > > >""" >Encapsulating a discovery -- not a proof. >By David Koski (Python by K. Urner) > >Failure at around 37th power is due to floating point limitations. >""" > >import unittest > >def fibonacci(a=0, b=1): > while True: > yield a > a, b = b, a + b > > >series1 = fibonacci(5, -3) # 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 >series2 = fibonacci(-8, 5) # -8, 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 >series3 = fibonacci(13,-8) # 13, -8, 5, -3, 2, -1, 1, 0 , 1, 2, 3, 5, 8 > >RT5 = pow(5, .5) # "square root" of five >PHI = (1 + RT5)/2 # golden proportion > >def cool_formula(): > """ > Two fib numbers, two apart, plus the one in the middle * sqrt(5) > all over 2, gives PHI to a power. Advancing all three sequences > gives successive powers. > """ > while True: > yield (next(series1) + next(series3) + next(series2) * RT5)/2.0 > >class TestPhi(unittest.TestCase): > > def test_loop(self): > gem = cool_formula() > for e in range(-6, 30): # adjust range (fails about 37th power) > answer = next( gem ) > self.assertAlmostEqual( PHI ** e, answer) > >if __name__ == "__main__": > unittest.main() > >[1] Polyhedron mailing list >Contributions to >mailto:polyhedron at lists.mathconsult.ch >Admin: >http://lists.mathconsult.ch/mailman/listinfo/polyhedron >Archive: >http://lists.mathconsult.ch/mailman/private/polyhedron/ > >_______________________________________________ >Edu-sig mailing list >Edu-sig at python.org >https://mail.python.org/mailman/listinfo/edu-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Sat Nov 23 17:08:17 2013 From: kirby.urner at gmail.com (kirby urner) Date: Sat, 23 Nov 2013 08:08:17 -0800 Subject: [Edu-sig] Fibonacci Numbers and Phi (again) In-Reply-To: <7.0.1.0.2.20131123004922.05cca650@skylit.com> References: <7.0.1.0.2.20131123004922.05cca650@skylit.com> Message-ID: > On Fri, Nov 22, 2013 at 9:49 PM, Litvin wrote: > Kirby, > > I am sorry to spoil all the fun, but this is a not a gem but a > mathematical trick, and I think the way to deal with > mathematical tricks is to explain them, not to verify with code. Having an algebraic verification is more like the proof I did not provide. Thanks for the reasoning Gary. I do think there's a two phase understanding for theorems where phase one is too oft neglected, which is understanding what the theorem is claiming or asserting, before attempting an analysis of "why?". Euler's Theorem by way of example, the one with the totient, a generalization of Fermat's: it's too easy to just stare at the assertion and not think of examples, not know what it says. This is where I think a Python program may come in handy, not as a proof of a theorem but as a illustration or demonstration of its consequences. See the theorem in action somehow. Seeing something in Python that's runnable may close some critical circuits in the brain of the theorem's reader. "Now I better know what it means" may be the aha experience. Most people who have read up on Fibonaccis know they can be extended in the negative direction. Then the idea of starting with any two numbers, not necessarily integers may be introduced. The limit of F[N+1]/F[N] and its relationship to PHI (equal as N -> infinity) may then be discussed. I've taken exactly this same approach with one of Ramanujan's for 1/pi (just flip it for pi). A little Python generator will do the trick. In this case the gem being verified has not to my knowledge been fully explained or reasoned about (the proof has yet to be supplied): http://worldgame.blogspot.com/2012/01/testing-math-ml.html (this blogpost uses MathJax, a good resource for the JavaScript-enabled) I'm still without an explanation for this pi digits generator from one of Michel Paul's students, but I share it around in hopes of finding one -- and then I hope its one I can follow. https://groups.google.com/forum/#!msg/mathfuture/LA0pMPC6-HE/MBGWxn4ENsUJ Thanks again for clearing up any mysteries that may have attached to the PHI ** N formula (I originally called it a formula, not a gem... some gems are only semi-precious). Kirby -------------- next part -------------- An HTML attachment was scrubbed... URL: From litvin at skylit.com Sat Nov 23 19:54:11 2013 From: litvin at skylit.com (Litvin) Date: Sat, 23 Nov 2013 13:54:11 -0500 Subject: [Edu-sig] Fibonacci Numbers and Phi (again) In-Reply-To: References: <7.0.1.0.2.20131123004922.05cca650@skylit.com> Message-ID: <7.0.1.0.2.20131123134822.05c54de0@skylit.com> Kirby, You are right, a little program does help to clarify the statement and the formulas involved. But then, keep it really simple (no classes, no generators), so that understanding of the code doesn't get in the way. For example: from math import sqrt rt5 = sqrt(5) phi = (1 + rt5)/2 def neat_formula(f0, f1, f2): return (f0 + f2 + rt5*f1)/2 power_of_phi = phi**(-6) f0, f1, f2 = 13, -8, 5 for k in range(20): print("{0:8.5f} {1:8.5f}".format(power_of_phi, neat_formula(f0, f1, f2))) f0, f1, f2 = f1, f2, f1+f2 power_of_phi *= phi There are many other occasions to bring in more advanced tools. Gary Litvin www.skylit.com At 11:08 AM 11/23/2013, kirby urner wrote: > > On Fri, Nov 22, 2013 at 9:49 PM, Litvin > <litvin at skylit.com> wrote: > > > Kirby, > > > > I am sorry to spoil all the fun, but this is a not a gem but a > > mathematical trick, and I think the way to deal with > > mathematical tricks is to explain them, not to verify with code. > > >Having an algebraic verification is more like the proof I did not >provide. Thanks for the reasoning Gary. > >I do think there's a two phase understanding for theorems where >phase one is too oft neglected, which is understanding what the >theorem is claiming or asserting, before attempting an analysis of "why?". > >Euler's Theorem by way of example, the one with the totient, a >generalization of Fermat's: it's too easy to just stare at the >assertion and not think of examples, not know what it says. > >This is where I think a Python program may come in handy, not as a >proof of a theorem but as a illustration or demonstration of its >consequences. See the theorem in action somehow. > >Seeing something in Python that's runnable may close some critical >circuits in the brain of the theorem's reader. "Now I better know >what it means" may be the aha experience. > >Most people who have read up on Fibonaccis know they can be extended >in the negative direction. Then the idea of starting with any two >numbers, not necessarily integers may be introduced. > >The limit of F[N+1]/F[N] and its relationship to PHI (equal as N -> >infinity) may then be discussed. > >I've taken exactly this same approach with one of Ramanujan's for >1/pi (just flip it for pi). A little Python generator will do the >trick. In this case the gem being verified has not to my knowledge >been fully explained or reasoned about (the proof has yet to be supplied): > >http://worldgame.blogspot.com/2012/01/testing-math-ml.html > >(this blogpost uses MathJax, a good resource for the JavaScript-enabled) > >I'm still without an explanation for this pi digits generator from >one of Michel Paul's students, but I share it around in hopes of >finding one -- and then I hope its one I can follow. > >https://groups.google.com/forum/#!msg/mathfuture/LA0pMPC6-HE/MBGWxn4ENsUJ > >Thanks again for clearing up any mysteries that may have attached to >the PHI ** N formula (I originally called it a formula, not a gem... >some gems are only semi-precious). > >Kirby > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Sat Nov 23 20:11:39 2013 From: kirby.urner at gmail.com (kirby urner) Date: Sat, 23 Nov 2013 11:11:39 -0800 Subject: [Edu-sig] Fibonacci Numbers and Phi (again) In-Reply-To: <7.0.1.0.2.20131123134822.05c54de0@skylit.com> References: <7.0.1.0.2.20131123004922.05cca650@skylit.com> <7.0.1.0.2.20131123134822.05c54de0@skylit.com> Message-ID: Yes, I would consider that an improvement, though I might go back to a generator with: from math import sqrt rt5 = sqrt(5) phi = (1 + rt5)/2 def neat_formula(f0, f1, f2): while True: yield (f0 + f2 + rt5*f1)/2 f0, f1, f2 = f1, f2, f1+f2 power_of_phi = phi**(-6) results = neat_formula(13, -8, 5) # seed me for k in range(20): print("{0:8.5f} {1:8.5f}".format(power_of_phi, next(results))) power_of_phi *= phi Going back and forth between yours and mine is introducing a small delta, so if the game were to introduce generators as a genre, I could see doing a bunch of small deltas like this. Kirby On Sat, Nov 23, 2013 at 10:54 AM, Litvin wrote: > Kirby, > > You are right, a little program does help to clarify the statement and the > formulas involved. But then, keep it really simple (no classes, no > generators), so that understanding of the code doesn't get in the way. For > example: > > from math import sqrt > > rt5 = sqrt(5) > phi = (1 + rt5)/2 > > def neat_formula(f0, f1, f2): > return (f0 + f2 + rt5*f1)/2 > > power_of_phi = phi**(-6) > f0, f1, f2 = 13, -8, 5 > for k in range(20): > print("{0:8.5f} {1:8.5f}".format(power_of_phi, neat_formula(f0, f1, > f2))) > f0, f1, f2 = f1, f2, f1+f2 > power_of_phi *= phi > > There are many other occasions to bring in more advanced tools. > > Gary Litvin > www.skylit.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: