Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Numerical Differentiation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4298] Re: Numerical Differentiation
  • From: rubin at msu.edu (Paul A. Rubin)
  • Date: Sat, 29 Jun 1996 03:56:47 -0400
  • Organization: Michigan State University
  • Sender: owner-wri-mathgroup at wolfram.com

In article <4q5k43$bsb at dragonfly.wolfram.com>,
   mrj at cs.su.oz.au (Mark James) wrote:
->Does anyone know of a function that calculates the derivative of
->a function (that can't be differentiated symbolically) at a given
->point by numerical means?  I can't find it as a built-in or in the
->standard packages.  Thanks.
->
A simple solution would be:

In[1]:=  ndiff[ f_, x_, eps_:.0001 ] := 
	  (f[ x + eps ] - f[ x - eps ])/(2 eps) /;
	  Positive[ eps ]
In[2]:=	 ndiff[ Exp, 2 ]
	 ndiff[ Exp, 2, .01 ]  (* less accurate *)
Out[2]=	 7.38906
	 7.38918

The first argument is a function, the second the point at which to 
differentiate, the (optional) third is the step size to use.  I'm doing a 
centered estimate here.  You might find more accurate formulas in a book on 
numerical analysis.  (Unfortunately, mine are buried at home someplace.)

My rather vague recollection from my numerical analysis course (a couple of 
decades ago) is that numerical differentiation is not the most stable of 
processes, due in part to the wonders of rounding error.  In any event, I'm 
not sure how to determine the accuracy of your answer.

Hope this helps.

Paul

**************************************************************************
* Paul A. Rubin                                  Phone: (517) 432-3509   *
* Department of Management                       Fax:   (517) 432-1111   *
* Eli Broad Graduate School of Management        Net:   RUBIN at MSU.EDU    *
* Michigan State University                                              *
* East Lansing, MI  48824-1122  (USA)                                    *
**************************************************************************
Mathematicians are like Frenchmen:  whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different.                                    J. W. v. GOETHE

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Help: Column/Row Vector
  • Next by Date: Re: Abs and variables
  • Previous by thread: Numerical Differentiation
  • Next by thread: Re: Numerical Differentiation