> Kirby Urner wrote:
> > Again, I think you're probably right, that this particular example is
> > perverse. Edu-sig is a scratch pad for bad ideas too. :-D
>
> Sorry, Kirby, I see we all seemed to jump on top of you here.
>
> --Scott David Daniels
> [EMAIL PROTECTED]
S'ok.
>From my point
> -Original Message-
> From: David Handy [mailto:[EMAIL PROTECTED]
>
> I'll try and answer that one.
I won't repeat your post, since it is long - but will say that I understand
its sentiments and largely agree with them.
Those of us clever enough to have gotten on the bandwagon from 1.
If I can toss in one (okay, two) more thought/s (and then I'll go back
to llurking again), I particularly remember a java exercise in which
the instructor gave us a handful of (intentionally!) black-box
functions along with the arguments that they take and the outputs that
they gave. We were to str
On Wed, Mar 30, 2005 at 07:15:58AM -0500, Arthur wrote:
> What I can't and don't understand - as a 'radial" - was why those who
> purport to most appreciate Python as it is would sign in mass unto an
> endeavor which could foreseeable alter what it is and how it is used in
> dramatic ways, and do s
> From: Arthur [mailto:[EMAIL PROTECTED]
> > From: Lloyd Hugh Allen [mailto:[EMAIL PROTECTED]
> > To: Arthur
> > Subject: Re: RE: [Edu-sig] RE: Integration correction
> >
> > I thought that there already were little black box libraries all over
> > the plac
> -Original Message-
> From: Lloyd Hugh Allen [mailto:[EMAIL PROTECTED]
> To: Arthur
> Subject: Re: RE: [Edu-sig] RE: Integration correction
>
> I thought that there already were little black box libraries all over
> the place. Just that most of them were in C etc
Oops. meant to reply to all. Sorry.
On Wed, 30 Mar 2005 07:24:16 -0500, Lloyd Hugh Allen
<[EMAIL PROTECTED]> wrote:
> I thought that there already were little black box libraries all over
> the place. Just that most of them were in C etc.
>
>
> On Wed, 30 Mar 2005 07:15:58 -0500, Arthur <[EMAIL
> From: Kirby Urner [mailto:[EMAIL PROTECTED]
> Now, if g(x) really *did* go on for 30-40 lines, OK, then maybe a
> decorator
> adds to readability.
>
> Something to think about.
From
http://www.corante.com/many/archives/2005/03/09/one_world_two_maps_thoughts_
on_the_wikipedia_debate.php
""
Kirby Urner wrote:
Again, I think you're probably right, that this particular example is
perverse. Edu-sig is a scratch pad for bad ideas too. :-D
Sorry, Kirby, I see we all seemed to jump on top of you here.
--Scott David Daniels
[EMAIL PROTECTED]
___
Kirby Urner wrote:
From: Kirby Urner <[EMAIL PROTECTED]>
[snip ... Kirby, Art and many others including myself discuss
the possible misuse of decorators in the context of calculating
> derivatives and integrals numerically end snip]
Now, if g(x) really *did* go on for 30-40 lines, OK, then
> And with a decorator:
>
> def simpson(f):
>def defint(a,b,n=1000):
> [...]
>return defint
>
> @simpson
> def g(x): return x*x
>
> >>> g(0, 3)
> 9.0036
No matter how cool decorators are, I don't think this is a good
example of how to use them. The function g(x) is a
[EMAIL PROTECTED] wrote:
From: Kirby Urner <[EMAIL PROTECTED]>
@simpson
def g(x): return x*x
g(0, 3)
9.0036
My resistance to decorators is not unrelated to the fact that I don't
> seem capable of getting my mind around them.
>
> I do find it quite disconcerting that the arguments "g"
> From: Kirby Urner <[EMAIL PROTECTED]>
> > @simpson
> > def g(x): return x*x
> >
> > >>> g(0, 3)
> > 9.0036
>
> My resistance to decorators is not unrelated to the fact that I don't seem
> capable of getting my mind around them.
>
Hi Art --
Actually, I'm with you. The above use i
From: Kirby Urner <[EMAIL PROTECTED]>
> @simpson
> def g(x): return x*x
>
> >>> g(0, 3)
> 9.0036
My resistance to decorators is not unrelated to the fact that I don't seem
capable of getting my mind around them.
I do find it quite disconcerting that the arguments "g" is expecti
> Here's my implementation of Simpson's, except it divides the interval into
> 2n segments.
>
> >>> def simpson(f,a,b,n):
>h = float(b-a)/(2*n)
>sum1 = sum(f(a + 2*k *h) for k in range(1,n))
>sum2 = sum(f(a + (2*k-1)*h) for k in range(1,n+1))
>return (h/3)*(f(a)
> But you never use the trapezoidal rule in real life!
> Simpson gives much smaller error for the same amount
> of computation. In fact, it is exact for Kirby's example!
>
> Henrik
Here's my implementation of Simpson's, except it divides the interval into
2n segments.
>>> def simpson(f,a,b,n):
> Kirby got the trapezoidal integration rule wrong.
> This is the corrected version.
>
> def integrate(f,a,b,n=1000):
> sum = 0
> h = (b-a)/float(n)
> for i in range(1,n):
>sum += f(a+i*h)
> return h*(0.5*f(a)+sum+0.5*f(b))
>
Here's the same thing using a generator e
> Kirby got the trapezoidal integration rule wrong.
Right, I was just doing a simple average, not any trapezoid. My rectangles
took the mean between f(x-h) and f(x+h), nothing more. Not the best
approximation, I agree, but simple to think about, and some text books show
it.
> This is the correc
Kirby got the trapezoidal integration rule wrong.
This is the corrected version.
def integrate(f,a,b,n=1000):
sum = 0
h = (b-a)/float(n)
for i in range(1,n):
sum += f(a+i*h)
return h*(0.5*f(a)+sum+0.5*f(b))
The interval must be divided into n equal parts, so
an arbitrar
19 matches
Mail list logo