### Basic Examples

Basic Examples

Take the numerical derivative of an exponential:

[Exp[x],x,1]

In[]:=

2.71828

Out[]=

Take the numerical derivative of a trig power:

Cos[x]

3

In[]:=

-3.

Out[]=

### Scope

Scope

In[]:=

The expression and evaluation point may be complex-valued:

[Sin[x],x,πI]

In[]:=

11.592+1.32527×10

-10

Out[]=

[Cos[Ix],x,1+I]

In[]:=

0.634964+1.29846

Out[]=

### Generalizations & Extensions

Generalizations & Extensions

In[]:=

NDerivative

[{Exp[x],Sin[x]},x,1]

In[]:=

{2.71828,0.540302}

Out[]=

### Options

Options

In[]:=

#### Method

Method

In[]:=

Use the default "EulerSum" when is not analytic in the neighborhood of :

expr

x

0

[Re[Cos[Iy]],y,1]

In[]:=

1.1752

Out[]=

Check:

D[ComplexExpand[Re[Cos[Iy]]],y]/.y->1//N

In[]:=

1.1752

Out[]=

An incorrect answer is obtained with :

[Re[Cos[Iy]],y,1,Method->NIntegrate]

In[]:=

0.587601+8.39313×10

-17

Out[]=

Here is a derivative where the default method works poorly:

Exp[x

2

In[]:=

68.5073

Out[]=

The correct answer is:

DExp[x],{x,3}/.x->1.

2

In[]:=

54.3656

Out[]=

In this case the expression is analytic, so will work well:

Exp[x

2

In[]:=

54.3656+2.82473×10

-14

Out[]=

#### Scale

Scale

In[]:=

Use to capture the region of variation:

Scales

[Sin[100x],x,0]

In[]:=

215.879

Out[]=

The scale of variation is around :

.01

[Sin[100x],x,0,"Scale"->.01]

100.

Out[]=

A value of that is too large can be compensated by increasing the number of terms:

Scales

[Sin[100x],x,0,"Terms"->11]

In[]:=

100.

Out[]=

Use to specify directional derivatives. The left and right derivatives of the nonanalytic function :

Scale

x

[Abs[x],{x,1},0]

In[]:=

1.

Out[]=

[Abs[x],{x,1},0,"Scale"->-1]

-1.

Out[]=

Check:

Plot[Abs[x],{x,-1,1}]

In[]:=

Complex directions may also be specified:

Check:

Check:

#### Terms

Terms

Increasing the number of terms may improve accuracy. Here is a somewhat inaccurate approximation:

Check:

Increasing the number of terms produces a more accurate answer:

Increasing the number of terms further can produce nonsense due to numerical instability:

Combining an increase in the number of terms with a higher working precision often will reduce the error:

#### WorkingPrecision

WorkingPrecision

In[]:=

Using a higher working precision and additional terms produces an accurate answer:

Higher-order derivatives will again experience numerical instability:

An alternative is to increase the radius of the contour of integration:

### Applications

Applications

In[]:=

Check:

### Properties & Relations

Properties & Relations

In[]:=

The Wolfram Language has built-in code to compute derivatives of numerical functions:

The built-in numerical derivative code can be used. However, it is unable to capture the rapid oscillations:

The correct answer:

Check:

### Neat Examples

Neat Examples

In[]:=

Some fractional and complex derivatives can be computed: