Applications Google
Menu principal

Post a Comment On: Only Python

"Computing derivatives using Python"

6 Comments -

1 – 6 of 6
Anonymous Anonymous said...

Nice example. Care to add the name of the numerical method used?

6:56 AM

Blogger André Roberge said...

I do not know if this method has a name. It is something I picked up more than 15 years ago. I tried to look it up in a few books but didn't find it anywhere.

9:24 AM

Anonymous Anonymous said...

Approximations of this form are called "finite differences", of which there are many variations. The particular difference formula your employing is often called a "second-order centered difference", while the one your contrasting against is a "first-order forward difference." The "second-order" and "first-order" refer to the accuracy. Second-order means that the error in the approximation decreases with decreasing h proportional h*h, while first-order decreases only proportional to h.

9:42 AM

Anonymous Anonymous said...

Directly from the time machine:

http://mail.python.org/pipermail/edu-sig/2003-March/002757.html

3:02 PM

Blogger Matthew Strax-Haber said...

Check this out (possibly a bit clearer for debugging):

def D(f,h=1e-5):
'''Return derivative of function f'''
def df(x):
return (f(x+h)-f(x))/h
df.__name__ = f.__name__ + '_dx'
return df

8:56 PM

Blogger Unknown said...

You should be careful when using this formula since the limit of this formula might exist while the limit that defines the derivative might not. They are not the same thing although the "second-order centred difference" formula provides better numerical approximation.

5:08 PM

Spammers: none shall pass.
You can use some HTML tags, such as <b>, <i>, <a>

Comments on this blog are restricted to team members.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot