Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
ND's implementation is slow
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andrew Moylan  
View profile  
 More options Oct 16 2007, 3:40 am
Newsgroups: comp.soft-sys.math.mathematica
From: "Andrew Moylan" <andrew.j.moy...@gmail.com>
Date: Tue, 16 Oct 2007 07:40:43 +0000 (UTC)
Local: Tues, Oct 16 2007 3:40 am
Subject: ND's implementation is slow
NumericalCalculus`ND uses Richardson extrapolation to estimate the
derivative, so e.g. ND[Sin[x], x, 5] has the following equivalent one-line
implementation in Mathematica:

InterpolatingPolynomial[{#, (Sin[5. + #] -
        Sin[5.]) / #} &  /@ (2.^-Range[0, 6]), 0]

>> 0.2836621854529269

Compare with:

Needs["NumericalCalculus`"]
ND[Sin[x], x, 5]

>> 0.2836621854529268

Interestingly, the one-line implementation in Mathematica is quite a bit
faster than ND! :

Do[
  InterpolatingPolynomial[{#, (Sin[5. + #] -
         Sin[5.]) / #} &  /@ (2.^-Range[0, 6]), 0]
  ,
  {10000}
  ] // Timing

>> {1.392, Null}

Do[ND[Sin[x], x, 5], {10000}] // Timing

>> {7.561, Null}

Part of this is due to extra overheads for ND like processing user input and
options. Even taking this into account, however, the
InterpolatingPolynomial-based implementation above is still about twice as
fast. I've modfied my NDerivative package to use this method instead of
NumericalCalculus`ND and I've also added a drop-in replacement for ND,
called FastND.

Do[FastND[Sin[x], x, 5], {10000}] // Timing

>> {4.046, Null}

If you want to use NDerivative or FastND, you can get them from
http://andrew.j.moylan.googlepages.com/mathematica.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google