Per my 'Pentagon math' thread, I think the golden ratio (phi) is an
important one to explore in K-12.[1] It's one of those key nodes in our
curriculum network.
Given a regular pentagon, the ratio of a diagonal to an edge is phi. In
other words, that famous pentacle pattern is phi-edged, vis-à-v
I'm sorry, but I couldn't help taking Kirby's findphi() function as a
personal challenge.
At the cost of roughly doubling the complexity of the code (19 lines instead
of ten lines in the function body), I was able to improve the performance by
a factor of more than 6500, while basically still usin
> (Yes, I know the original version wasn't claimed to be optimized, but it
> was crying to be optimized...)
>
Yes. This is a valuable addition to the thread. Thanks for taking the
time.
Reminds me of when Tim Peters used to swing by in the early days of edu-sig
and optimize the hell out of my
At 14:33 21/09/2005, you wrote:
>At the cost of roughly doubling the complexity of the code (19 lines instead
>of ten lines in the function body), I was able to improve the performance by
>a factor of more than 6500, while basically still using the same
>"brute-force" approach of guessing a number,
On Wed, Sep 21, 2005 at 06:44:01PM +0100, Peter Bowyer wrote:
> At 14:33 21/09/2005, you wrote:
> >At the cost of roughly doubling the complexity of the code (19 lines instead
> >of ten lines in the function body), I was able to improve the performance by
> >a factor of more than 6500, while basica
On Wed, Sep 21, 2005 at 09:31:41AM -0700, Kirby Urner wrote:
> Mine original draft makes sense to set the stage, cuz the reasoning is so
> dang primitive. Yours adds a layer of sophistication more reflective of how
> real world programmers learn to squeeze the most out of their cycles.
Your origi
David Handy wrote:
> On Wed, Sep 21, 2005 at 09:31:41AM -0700, Kirby Urner wrote:
>
>>Mine original draft makes sense to set the stage, cuz the reasoning is so
>>dang primitive. Yours adds a layer of sophistication more reflective of how
>>real world programmers learn to squeeze the most out of
> On Wed, Sep 21, 2005 at 09:31:41AM -0700, Kirby Urner wrote:
>
>Of course all of this requires temporarily ignoring the fact that algebraic
>methods give us a way to compute phi as simply (1 + math.sqrt(5))/2.0.
I've been considering this a bit. The closed form here begs the
question, what i
On 22 Sep 2005 at 12:00, (Kirby Urner) wrote:
> > Some lessons that might be learned from this approach:
> >
> > (1) when working with floats, you want to compare differences, not check for
> > equalities, e.g. looking for when b/a == 1/b would be a bad idea.
> >
> > (2) you get greater accuracy
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Daniel Ajoy
> Sent: Thursday, September 22, 2005 10:07 AM
> To: edu-sig@python.org
> Subject: Re: [Edu-sig] Brute force solutions
>
> My approach to teaching about phi i
> I've been considering this a bit. The closed form here begs the
> question, what is math.sqrt(5)? Sure, we have a built-in function that
> computes this, but someone had to write the algorithm that computes
> sqrt. That calculation makes use of numerical techniques similar to what
> we are discus
> I've a couple times implemented the old manual algorithm for finding
> square roots. I might be able to dig those up for discussion. The longer
> it runs, the more digits you get.
>
> Kirby
But instead, this steaming unoptimized octopus of a code specimen spits back
the repeating digits for a
>The fun part here is we can use numerator/denominator syntax with
open-ended
>precision integers, to like express sqrt of 19 as some humongous fraction
>(as many digits as memory will allow). This lets us far surpass the
>floating point barrier.
For example, the sqrt of 19 is rougly:
7459690842
>n = ((pow(orig,0.5) + addterm)/denom)**2
H, this may be the Achilles heal of my project, to not use any sqrt
finder in the process of finding a sqrt using continued fractions. Back to
the drawing board?
Kirby
mai
[EMAIL PROTECTED] wrote:
>>The fun part here is we can use numerator/denominator syntax with
>
> open-ended
>
>>precision integers, to like express sqrt of 19 as some humongous fraction
>>(as many digits as memory will allow). This lets us far surpass the
>>floating point barrier.
OK, here we g
15 matches
Mail list logo