WOLFRAM

D[f,x]

gives the partial derivative .

D[f,{x,n}]

gives the multiple derivative .

D[f,x,y,]

gives the partial derivative .

D[f,{x,n},{y,m},]

gives the multiple partial derivative .

D[f,{{x1,x2,}}]

for a scalar f gives the vector derivative .

D[f,{array}]

gives an array derivative.

Details and Options

  • D is also known as derivative for univariate functions.
  • By using the character , entered as pd or \[PartialD], with subscripts, derivatives can be entered as follows:
  • D[f,x]xf
    D[f,{x,n}]{x,n}f
    D[f,x,y]x,yf
    D[f,{{x,y}}]{{x,y}}f
  • The comma can be made invisible by using the character \[InvisibleComma] or ,.
  • The partial derivative D[f[x],x] is defined as , and higher derivatives D[f[x,y],x,y] are defined recursively as etc.
  • The order of derivatives n and m can be symbolic and they are assumed to be positive integers.
  • The derivative D[f[x],{x,n}] for a symbolic f is represented as Derivative[n][f][x].
  • For some functions f, Derivative[n][f][x] may not be known, but can be approximated by applying N. »
  • New derivative rules can be added by adding values to Derivative[n][f][x]. »
  • For lists, D[{f1,f2,},x] is equivalent to {D[f1,x],D[f2,x],} recursively. »
  • D[f,{array}] effectively threads D over each element of array.
  • D[f,{array,n}] is equivalent to D[f,{array},{array},], where {array} is repeated n times.
  • D[f,{array1},{array2},] is normally equivalent to First[Outer[D,{f},array1,array2,]]. »
  • Common array derivatives include:
  • D[f,{{x1,x2,}}]gradient{D[f,x1],D[f,x2],}
    D[f,{{x1,x2,},2}]Hessian{{D[f,x1,x1],D[f,x1,x2],},{D[f,x2,x1],D[f,x2,x2],},}
    D[{f1,f2,},{{x1,x2,}}]Jacobian{{D[f1,x1],D[f1,x2],},
    {D[f2,x1],D[f2,x2],},}
  • If f is a scalar and x={x1,}, then the multivariate Taylor series at x0={x01,} is given by:
  • ,
  • where fi=D[f,{x,i}]/.{x1x01,} is an array with tensor rank . »
  • If f and x are both arrays, then D[f,{x}] effectively threads first over each element of f, and then over each element of x. The result is an array with dimensions Join[Dimensions[f],Dimensions[x]]. »
  • VectorSymbol, MatrixSymbol or ArraySymbol can be used to indicate that variables or function values are vectors, matrices or arrays.
  • D can formally differentiate operators such as integrals and sums, taking into account scoped variables as well as the structure of the particular operator.
  • Examples of operator derivatives include:
  • is not scoped by the integral
    is scoped by the integral
    is not scoped by the integral transform
    is scoped by by the integral transform
  • All expressions that do not explicitly depend on the variables given are taken to have zero partial derivative.
  • The setting NonConstants{u1,} specifies that ui depends on all variables x, y, etc. and does not have zero partial derivative. »

Examples

open allclose all

Basic Examples  (7)Summary of the most common use cases

Derivative with respect to x:

Out[1]=1

Fourth derivative with respect to x:

Out[1]=1

Derivative of order n with respect to x:

Out[1]=1

Derivative with respect to x and y:

Out[1]=1

Derivative involving a symbolic function f:

Out[1]=1

Evaluate derivatives numerically:

Out[1]=1

Enter using pd, and subscripts using :

Out[1]=1

Scope  (89)Survey of the scope of standard use cases

Basic Uses  (12)

Derivative of an expression with respect to x:

Out[1]=1

Second derivative:

Out[2]=2

Derivative of an expression at a point:

Out[1]=1

Derivative of a function at a general point x:

Out[2]=2

This can also be achieved using fluxion notation:

Out[3]=3

Derivative at the point x==5:

Out[4]=4

This can be found more easily using fluxion notation:

Out[5]=5

The third derivative at the point x==-1:

Out[6]=6
Out[7]=7

Derivative involving symbolic functions:

Out[1]=1

Partial derivatives of an expression with respect to x and y:

Out[1]=1
Out[2]=2

The mixed partial derivative :

Out[3]=3

The mixed partial derivative :

Out[4]=4

Differentiate with respect to a compound expression:

Out[1]=1

Differentiate with respect to different compound expressions:

Out[1]=1
Out[2]=2
Out[3]=3

Derivative of a vector expression:

Out[1]=1

Matrix expression:

Out[2]=2

Derivative of a nested list:

Out[1]=1

Vector derivative of an expression, also known as the gradient:

Out[1]=1

Second vector derivative, also known as the Hessian:

Out[2]=2

Matrix derivative:

Out[1]=1

Create a table of basic derivatives:

Symbolic Functions  (9)

Derivative of a symbolic function:

Out[1]=1

Substitute in a pure function for f to get a particular result:

Out[2]=2

Derivative of a sum:

Out[1]=1

Product:

Out[2]=2

Quotient:

Out[3]=3

The chain rule for composite functions:

Out[4]=4

Product rule for three functions:

Out[1]=1

State the rule using an Inactive derivative:

Out[2]=2

Partial derivative of a symbolic function:

Out[1]=1

Substitute in for f a pure function in two variables:

Out[2]=2

Derivative of a pure function with respect to non-argument parameters:

Out[2]=2

The result is the function that at point x gives the derivative of with respect to a:

Out[3]=3

Local variables are independent from the differentiation variable:

Out[2]=2

Derivative of a symbolic function at a point:

Out[2]=2

The same, using prime notation:

Out[3]=3

Derivative of an inverse function:

Out[1]=1

Product rule for derivatives of order n:

Out[1]=1
Out[2]=2

Chain rule:

Out[3]=3
Out[4]=4

Elementary Functions  (6)

Polynomial and rational functions:

Out[1]=1
Out[2]=2

Algebraic functions:

Out[1]=1
Out[2]=2

Trigonometric and inverse trigonometric functions:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Exponential and logarithmic functions:

Out[1]=1
Out[2]=2
Out[3]=3

Hyperbolic functions:

Out[1]=1
Out[2]=2

Create a function that turns a list of expressions into a nicely formatted table of derivatives:

Create a table of trigonometric derivatives:

Create a table of hyperbolic derivatives:

Special Functions  (8)

The logarithmic derivative of Gamma is the PolyGamma function:

Out[1]=1

Derivatives of Airy functions are given in terms of AiryAiPrime and AiryBiPrime:

Out[1]=1
Out[2]=2

The derivative of Zeta has a closed-form expression at the origin:

Out[1]=1
Out[2]=2
Out[3]=3

Special functions with elementary derivatives:

Out[1]=1
Out[2]=2

Special functions with derivatives expressed in terms of the same functions:

Out[1]=1
Out[2]=2
Out[3]=3

Derivative of JacobiSN:

Out[1]=1

Derivative of JacobiCD:

Out[2]=2

Derivative of LogIntegral:

Out[1]=1

Derivative of ExpIntegralEi:

Out[2]=2

Derivative of order n for SinIntegral:

Out[3]=3

Create a table of special function derivatives:

Piecewise and Generalized Functions  (8)

Derivative of a piecewise function:

Out[1]=1

Derivative of a ConditionalExpression:

Out[1]=1

Convert a symbolic function into a piecewise function over the reals to differentiate it:

Out[1]=1
Out[2]=2

Compute the piecewise derivative over a finite range:

Out[3]=3

Classical derivatives of pointwise-defined engineering functions:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Distributional derivatives of generalized functions:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Derivative of RealAbs:

Out[1]=1

RealSign:

Out[2]=2

Their counterparts on the complex plane are nowhere differentiable:

Out[3]=3
Out[4]=4

Derivative of Floor:

Out[1]=1

Ceiling:

Out[2]=2

Derivatives of functions defined procedurally:

Out[1]=1
Out[2]=2

Implicitly Defined Functions  (3)

D threads over Equal to compute the derivatives of implicit functions:

Out[2]=2

Compute a partial derivative for an implicit function of two variables:

Out[2]=2

Find partials for implicit functions defined by a system of equations:

Out[2]=2

Vector-Valued Functions  (5)

Derivative of a list:

Out[1]=1

Second derivative:

Out[2]=2

The first derivative to a vector-valued function at a general value t:

Out[2]=2

Computing the same using prime notation:

Out[3]=3

The third derivative at t==0:

Out[4]=4

Computing the same using prime notation:

Out[5]=5

The derivative of a matrix:

Out[1]=1
Out[2]=2

The fourth derivative:

Out[3]=3

The derivative of a vector-valued function stored as a SparseArray:

Out[1]=1
Out[2]=2

Convert the result to a normal array:

Out[3]=3

The derivative of matrix represented as a SymmetrizedArray object:

Out[1]=1
Out[2]=2

Convert the result to a normal matrix:

Out[3]=3

Vector Argument Functions  (6)

Gradient of a scalar function:

Out[2]=2
Out[3]=3

Hessian matrix:

Jacobian of a vector-valued function:

Out[1]=1

Second-order derivative tensor:

Out[3]=3

Compute the derivative of the determinant with respect to the original matrix:

Out[1]=1

The gradient of a vector-valued function stored as a SparseArray:

Out[1]=1

The result is another SparseArray, containing only the nonzero entries:

Out[2]=2

Convert the result to a normal matrix:

Out[3]=3

Hessian computed as a SparseArray:

Out[2]=2

The gradient can also be computed as a SparseArray, but in this case it is effectively dense:

Out[3]=3

Jacobian computed as a SparseArray:

Out[2]=2

Symbolic Array Arguments and Functions  (8)

Derivative of a symbolic vector-valued function with respect to a scalar argument:

Out[1]=1

Derivative of a symbolic matrixvalued function with respect to a scalar argument:

Out[1]=1

Derivative of a symbolic arrayvalued function with respect to a scalar argument:

Out[1]=1

Derivatives of scalar-valued functions with respect to symbolic vector arguments:

Out[1]=1

Real symbolic vector argument:

Out[2]=2

Derivatives of scalar-valued functions with respect to symbolic matrix arguments:

Out[1]=1

Real symbolic matrix argument:

Out[2]=2

Derivative of a scalar-valued function with respect to a symbolic array argument:

Out[1]=1

Derivatives of symbolic arrayvalued functions with respect to symbolic array arguments:

Out[1]=1
Out[2]=2
Out[3]=3

Derivative of a composition of symbolic array functions:

Out[1]=1

Integrals and Integral Transforms  (6)

Differentiate unevaluated integrals:

Out[1]=1
Out[2]=2
Out[3]=3

Fourier transforms:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Laplace transforms:

Out[1]=1
Out[2]=2
Out[3]=3

Convolutions:

Out[1]=1
Out[2]=2

Differentiate the Inactive form of an integral to get the fundamental theorem of calculus:

Out[1]=1
Out[2]=2

A more general form of the fundamental theorem:

Out[3]=3

Differentiate an inactive FourierTransform:

Out[1]=1
Out[2]=2

Verify the formal result:

Out[3]=3
Out[4]=4

Sums and Summation Transforms  (4)

Differentiate an unevaluated sum:

Out[1]=1
Out[2]=2

Differentiation with respect to the dummy variable gives zero:

Out[3]=3

Discrete convolution:

Out[1]=1

Differentiate the Inactive form of a sum:

Out[1]=1
Out[2]=2

ZTransform:

Out[3]=3
Out[4]=4

Differentiate an inactive GeneratingFunction:

Out[1]=1
Out[2]=2

Verify the formal result:

Out[3]=3
Out[4]=4

Indexed Differentiation  (9)

Differentiate with respect to an indexed variable, introducing KroneckerDelta factors:

Out[1]=1

Use Inactive to prevent expansion of the sum:

Out[1]=1
Out[2]=2

Summation indices will be renamed if needed, to avoid name ambiguities:

Out[1]=1

Differentiate an inactive table with respect to an indexed variable:

Out[1]=1

Activate the result to get the explicit vector result:

Out[2]=2

Differentiate an inactive table twice with respect to an indexed variable:

Out[1]=1

In this case only the j^(th) entry is nonzero:

Out[2]=2

Use any notation for indexed variables in sums and tables:

Out[1]=1
Out[2]=2

Differentiate with respect to a symbolic table of indexed variables:

Out[1]=1

Activating the result gives the explicit gradient:

Out[2]=2

Differentiate twice with respect to a symbolic table of indexed variables, introducing a dummy index:

Out[1]=1

Replace symbolic variables with explicit values:

Out[2]=2

Use symbolic vector differentiation of another symbolic vector:

Out[1]=1
Out[2]=2

Vector differentiation of a vector with respect to itself gives the identity matrix:

Out[3]=3
Out[4]=4

Functions Defined by Derivatives  (5)

Define the derivative with prime notation:

This rule is used to evaluate the derivative:

Out[2]=2

Define the derivative at a point:

Out[1]=1
Out[2]=2

Define the second derivative:

Out[1]=1
Out[2]=2

Prescribe values and derivatives of f and g:

Find the derivative of the composition at x=3:

Out[4]=4

Define a partial derivative with Derivative:

Out[2]=2

Options  (1)Common values & functionality for each option

NonConstants  (1)

Differentiate with y considered as depending on x:

Out[1]=1

Solve for the derivative of y to effect implicit differentiation:

Out[2]=2

Applications  (47)Sample problems that can be solved with this function

Geometry of the Derivative  (5)

The derivative gives the slope of the tangent line at a point:

For small displacements h from the base point π, the tangent line gives an excellent approximate of f:

The tangent and f are visually indistinguishable from each other over a small, and only a small, plot range:

Out[4]=4

The derivative gives the limit of the slope of the secant line connecting {x,f[x]} to {x+h,f[x+h]}:

Out[2]=2

Visualize the process for the point {1,f[1]}:

Out[4]=4

Find an equation for the tangent line to a function:

General equation for the tangent line at x=a:

Tangent line at x=4:

Out[3]=3
Out[4]=4

Find an equation for the normal line to a function:

General equation for the normal line at x=a:

Normal line at x=1:

Out[3]=3
Out[4]=4

Find equations for the tangent lines to a function that pass through a point:

General equation for the tangent line at x=a:

Find the tangents to f[x] that pass through (0,-4):

Out[3]=3
Out[4]=4

Characterization of Functions  (5)

Find the turning points on a plane curve:

Out[2]=2
Out[3]=3

Find the critical points of a function:

Out[2]=2

By the second derivative test, these are all maxima or minima:

Out[3]=3

Visualize the critical points:

Out[4]=4

Find all values of c that satisfy the Mean Value theorem on an interval:

Out[3]=3

Define the secant line from a to b:

Define the tangent lines associated with the two values of c:

Visualize the two tangent lines parallel to the secant line along with the original function:

Out[6]=6

Use the first derivative to characterize a function:

Find the critical points of a function:

Out[2]=2

Find where the function is increasing:

Out[3]=3

Find where the function is decreasing:

Out[4]=4

Visualize the results:

Out[5]=5

Use the second derivative to characterize a function:

Find the inflection points of a function:

Out[2]=2

Find where the function has positive concavity:

Out[3]=3

Find where the function has negative concavity:

Out[4]=4

Visualize the results:

Out[5]=5

Relation to Integration  (2)

Perform the change of variable t=x^2 in an integral:

Out[1]=1
Out[2]=2

Verify the results of symbolic integration:

Out[1]=1
Out[2]=2

Multivariate and Vector Calculus  (6)

Find the critical points of a function of two variables:

Out[2]=2

Compute the signs of and the determinant of the second partial derivatives:

Out[3]=3
Out[4]=4

By the second derivative test, the first two pointsred and blue in the plotare minima and the thirdgreen in the plotis a saddle point:

Out[5]=5

Find the curvature of a circular helix with radius r and pitch c:

Out[2]=2
Out[4]=4

Obtain the same result using ArcCurvature:

Out[5]=5

Compute a univariate Taylor series by hand:

Out[1]=1

Compute a multivariate Taylor series by hand:

Out[2]=2

Write a function to automate the process:

Recompute the above using the new function:

Out[4]=4
Out[5]=5

The gradient vector can be computed by finding the partial derivatives of a function:

Out[1]=1

Find the gradient vector of the function :

Out[3]=3

Visualize the direction of the gradient vector using a unit vector representation:

Out[5]=5

The curl of a vector field on the plane can be computed by subtracting the derivatives of its components:

Out[1]=1

Find the curl of the vector field :

Out[3]=3

Visualize the 2D curl as the net "rotation" of the vector field at a point, with red and green representing clockwise and counterclockwise curl, respectively, and radius proportional to the magnitude of rotation:

Out[4]=4

The divergence of a vector field can be computed by summing the derivatives of its components:

Out[1]=1

Find the divergence of a 2D vector field:

Out[3]=3

Visualize 2D divergence as the net "flow" of the vector field at a point, with red and green representing outflow and inflow, respectively, and radius proportional to the magnitude of the flow:

Out[4]=4

Differential Equations  (6)

Construct the differential equation satisfied by an implicit function y[x]:

Out[2]=2

Use D to specify ordinary and partial differential equations:

Out[2]=2

These can be solved using DSolve:

Out[3]=3
Out[4]=4

Define a wave equation in two spatial variables:

Define initial values for the function and its first time derivative:

Specify boundary conditions:

Solve the system using DSolve:

Extract a few terms from the Inactive sum:

Out[5]=5

The two-dimensional wave executes periodic motion in the vertical direction:

Out[6]=6

Specify a Laplacian operator using D:

Specify homogeneous Dirichlet boundary conditions:

Find the 4 smallest eigenvalues and eigenfunctions of the operator in a unit disk:

Visualize the eigenfunctions:

Out[5]=5

Specify an integro-differential equation using D:

Obtain the general solution:

Out[2]=2

Specify an initial condition to obtain a particular solution:

Out[3]=3

Plot the solutions for different values of a:

Out[4]=4

Find a second-degree polynomial solution to the differential equation:

Out[2]=2
Out[3]=3

Rates of Change  (5)

The height of a projectile at time t is given by:

Compute the velocity at t:

Out[2]=2

Compute the acceleration at t:

Out[3]=3

Find when the projectile reaches its maximum height:

Out[4]=4

Find the maximum height of the projectile:

Out[5]=5
Out[6]=6

The area of a circle as a function of time is given by:

Compute the rate of change of area:

Out[2]=2

Find the rate of change of area at a radius of 10 m if the radius increases at a rate of 5m/s:

Out[3]=3

The position of a particle is given by:

Compute the velocity, acceleration, jerk, snap (jounce), crackle and pop of the particle:

Out[3]=3

The total resistance in a circuit of two resistors connected in parallel is given by:

Out[1]=1

Calculate RT for the given values of R1 and R2:

Out[2]=2

Find the rate of change of the total resistance:

Out[3]=3

Calculate the rate of change of the total resistance with the given values:

Out[4]=4

Volume of a cube in terms of side length l is given by:

Surface area of a cube is given by:

Compute the rate of change of the volume of a cube with respect to surface area using the chain rule:

Out[3]=3

Solve for l in terms of surface area and substitute that into the result:

Out[4]=4

Implicit Functions  (3)

Find an equation for the tangent line to an implicit function at (1,):

Out[7]=7

Compute the slope at x=1:

Out[8]=8

Tangent line at x=1:

Out[9]=9

Visualize the tangent:

Out[10]=10

Find the points where the slope of an implicit function equals :

Out[1]=1
Out[2]=2
Out[3]=3

The relationship between functions is given by:

Out[1]=1

Find the derivative of z[t]:

Out[2]=2

Calculate z'[t] with the given values:

Out[3]=3

Optimization  (3)

Find the maximum area of a rectangular fence of 2000 ft., bordered on one side by a barn:

Compute the area in terms of width:

Out[3]=3
Out[4]=4

Find the maximum:

Out[5]=5
Out[6]=6

By the second derivative test, this value is a true maximum:

Out[7]=7

Alternately, compute the area in terms of length:

Out[8]=8
Out[9]=9
Out[10]=10

Visualize how the area changes as the length changes:

Out[11]=11

Find the shortest distance from a curve to the point (1,5):

Out[1]=1

Compute the distance in terms of y:

Out[3]=3
Out[4]=4

Find the minimum point:

Out[5]=5

By the second derivative test, this is a minimum:

Out[6]=6

Visualize how the distance changes with position:

Out[11]=11

Find the dimensions of a lidless, cylindrical can with the least material that can hold up to 2 L of water:

Compute the height in terms of the radius, using the volume constraint:

Out[3]=3

Compute the surface area in terms of the radius:

Out[4]=4

The radius corresponding to the minimum surface area:

Out[5]=5

By the second derivative test, this is a minimum:

Out[6]=6

Compute the radius, height and surface area of the minimum configuration:

Out[7]=7

Visualize how the dimensions vary with radius:

Out[11]=11

L'Hôpital's Rule  (3)

Find the limit of the ratio of two functions as x0:

Directly solving the limit leads to an indeterminate form of type :

Out[3]=3

L'Hôpital's rule can be used because in an interval around , both and are defined, and :

Out[4]=4

Indeed, and are continuous, and , so can be computed trivially:

Out[5]=5

Verify the result using Limit:

Out[6]=6

Visualize the two functions and their ratio:

Out[7]=7

Find the limit of the ratio of two functions as x:

Directly solving the limit leads to an indeterminate form of type :

Out[3]=3

L'Hôpital's rule can be used because for all , both and are defined, and :

Out[4]=4

However, using the first derivatives also leads to an indeterminate form:

Out[5]=5

The second derivatives are constant and obviously satisfy the conditions of L'Hôpital's rule:

Out[6]=6

Hence can be computed trivially:

Out[7]=7

Verify the result using Limit:

Out[8]=8

Find the limit of the product of two functions as x0:

Directly solving the limit leads to an indeterminate form of type 0×:

Out[3]=3
Out[4]=4

Note that is not defined:

Out[5]=5

However, exists and is positive for all , and it also exists and is negative for all :

Out[6]=6

As is clearly defined for all real , L'Hôpital's rule can be applied in the form:

Out[7]=7

The quotient in the right-hand limit gives a continuous expression whose limit is simple to compute:

Out[8]=8
Out[9]=9
Out[10]=10

Symbolic Array Calculus  (6)

Approximate the variance for a perturbed vector:

Order zero approximation:

Compare with the exact value:

Out[4]=4

Order one approximation:

Out[6]=6

Compare with the exact value:

Out[8]=8

Order two approximation:

Out[9]=9

Since the second derivative does not depend on , the order two approximation equals the exact value:

Out[11]=11

Approximate the determinant of a perturbed matrix:

Order zero approximation:

Compare with the exact value:

Out[3]=3

Order one approximation:

Out[4]=4

Compare with the exact value:

Out[6]=6

Order two approximation:

Out[7]=7

Compare with the exact value:

Out[9]=9

Derive a least-squares solution for data given as a list of pairs :

Out[1]=1

Find the vector of vertical deviations for the data:

Out[2]=2

Define the sum of squares of the vertical deviations for the data:

Out[3]=3

Set up the least-squares equations:

Out[4]=4
Out[5]=5

Generate some data:

Solve the least-squares problem for this data:

Out[7]=7
Out[8]=8

Find GammaDistribution parameters that best fit the given data using the maximum likelihood method:

Out[2]=2

Maximize the log-likelihood function :

Out[4]=4

Compute the gradient of :

Out[5]=5

Find a zero of the gradient, with replaced by :

Out[6]=6
Out[7]=7

Visualize the result:

Out[8]=8

Compare with the result computed using EstimatedDistribution:

Out[9]=9

Find an optimality condition for a portfolio optimization problem with the expected return and standard deviation :

The goal is to maximize when the vector of asset weights satisfies Total[x]=1. The constraint can be used to represent where the unconstrained vector variable consists of the first coordinates of :

The maximum occurs at a critical point of :

Out[3]=3

Express the condition in terms of :

Out[4]=4

Compute the gradient of the log-likelihood function of the linear regression model represented by the equation , where are normally distributed random variables with mean zero and variance :

The log-likelihood function is given by:

Out[2]=2

Compute :

Out[3]=3

Express the result in terms of :

Out[4]=4

Compute :

Out[5]=5

Other Applications  (3)

Compute the coefficients of a power series:

Out[1]=1
Out[2]=2

Derive a closed form for by differentiating with respect to at :

Out[1]=1
Out[2]=2

Now integrate first and then differentiate with respect to at :

Out[3]=3
Out[4]=4
Out[5]=5

The final result:

Out[6]=6

Verify the result:

Out[7]=7

Derive a closed form for by differentiating w.r.t. at :

Out[1]=1
Out[2]=2

Compute and then differentiate:

Out[3]=3
Out[4]=4
Out[5]=5

The result:

Out[6]=6

Verify the result:

Out[7]=7

Properties & Relations  (23)Properties of the function, and connections to other functions

The derivative of a function is defined as a limit:

Out[2]=2

The Limit of DifferenceQuotient is the derivative D:

Out[1]=1
Out[2]=2

D is the inverse of Integrate:

Out[1]=1
Out[2]=2
Out[3]=3

The fundamental theorem of calculus:

Out[1]=1

Differentiation inside of Integrate:

Out[1]=1

D returns formal results in terms of Derivative:

Out[1]=1
Out[3]=3

D differentiates expressions with respect to a given variable:

Out[1]=1

Derivative is an operator and returns pure-function results:

Out[2]=2

The derivative of a function at a point may not be available in closed form:

Out[1]=1

An approximation to the derivative can be obtained using N:

Out[2]=2

D[f,{array1},] is essentially equivalent to First[Outer[D,{f},array1,]]:

Out[1]=1

If f and a are arrays, Dimensions[D[f,{a}]==Join[Dimensions[f],Dimensions[a]]:

Out[1]=1
Out[2]=2

D[f,{{x1,x2,,xn}}] is effectively equivalent to Grad[f,{x1,x2,,xn}]:

Out[1]=1
Out[2]=2

Div[{f1,f2,,fn},{x1,x2,,xn}] is the trace of the vector derivative of f:

Out[1]=1

More generally, Div[f,x] is the contraction of the last two dimensions of the vector derivative of f:

Out[2]=2
Out[3]=3
Out[4]=4

Curl[f,x] is times the HodgeDual of the vector derivative of f, where r is the rank of f:

Out[2]=2
Out[3]=3

For scalar f, Laplacian[f,{x1,x2,,xn}] is the trace of the second vector derivative of f:

Out[1]=1

More generally, Laplacian[f,x] is the contraction of the last two dimensions of the second vector derivative of f:

Out[2]=2
Out[3]=3
Out[4]=4

Compute the derivative of Total[a] with respect to a using symbolic arrays:

Out[1]=1
Out[2]=2

Compare with the results obtained using indexed differentiation:

Out[3]=3
Out[4]=4
Out[5]=5
Out[6]=6

ArcCurvature can be defined in terms of D:

Out[3]=3

Systems of differential equations involving D can be solved with DSolve:

Out[1]=1

Use D to specify a heat equation with homogeneous Dirichlet boundary conditions:

The eigensystem for this differential system can be found with DEigensystem:

Eigenvalues:

Out[3]=3

Eigenfunctions:

Out[4]=4

D can be defined using DifferenceDelta:

Out[1]=1
Out[2]=2

D can be defined using DiscreteShift:

Out[1]=1
Out[2]=2

The right one-sided derivative is computed with a right-hand limit:

Out[1]=1

The left one-sided derivative is computed with a left-hand limit:

Out[2]=2

Note that this function is not differentiable at x==0:

Out[3]=3

D assumes that other variables are independent of the differentiation variable:

Out[2]=2

Dt assumes that other variables may depend on the differentiation variable:

Out[3]=3

By manually specifying all other variables as constant, Dt can yield the same result as D:

Out[4]=4

Compute the derivative of an implicit function using D and Solve:

Out[2]=2

Use ImplicitD to compute the derivative of an implicit function:

Out[3]=3

Possible Issues  (5)Common pitfalls and unexpected behavior

Results may not immediately be given in the simplest possible form:

Out[1]=1
Out[2]=2

Functions given in different forms can yield the same derivatives:

Out[1]=1
Out[2]=2

D returns generic results that may not account for discontinuities, cusps or other special points:

Out[2]=2

Neither f nor g is differentiable at 0:

Out[3]=3

f is discontinuous, and g has a cusp:

Out[4]=4

If a function can be expanded into a Piecewise expression, D will provide more accurate results:

Out[5]=5

Cached values for D may miss changes in underlying definitions:

Out[1]=1
Out[2]=2

The issue can be resolved by clearing the system cache:

Out[4]=4

The variable of differentiation is treated literally:

Out[1]=1

The following mathematically equivalent input gives 0 because there is no Sin[x] in the first argument:

Out[2]=2

Interactive Examples  (2)Examples with interactive outputs

Find the tangent line to a function:

Out[3]=3

Visualize the secant converging to the tangent as for different base points :

Out[4]=4

Neat Examples  (2)Surprising or curious use cases

Compute the tangent and normal vectors of a 3D parametric function:

Out[4]=4

Create a table of n^(th) derivatives:

Wolfram Research (1988), D, Wolfram Language function, https://reference.wolfram.com/language/ref/D.html (updated 2024).
Wolfram Research (1988), D, Wolfram Language function, https://reference.wolfram.com/language/ref/D.html (updated 2024).

Text

Wolfram Research (1988), D, Wolfram Language function, https://reference.wolfram.com/language/ref/D.html (updated 2024).

Wolfram Research (1988), D, Wolfram Language function, https://reference.wolfram.com/language/ref/D.html (updated 2024).

CMS

Wolfram Language. 1988. "D." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/D.html.

Wolfram Language. 1988. "D." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/D.html.

APA

Wolfram Language. (1988). D. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/D.html

Wolfram Language. (1988). D. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/D.html

BibTeX

@misc{reference.wolfram_2025_d, author="Wolfram Research", title="{D}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/D.html}", note=[Accessed: 20-June-2025 ]}

@misc{reference.wolfram_2025_d, author="Wolfram Research", title="{D}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/D.html}", note=[Accessed: 20-June-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_d, organization={Wolfram Research}, title={D}, year={2024}, url={https://reference.wolfram.com/language/ref/D.html}, note=[Accessed: 20-June-2025 ]}

@online{reference.wolfram_2025_d, organization={Wolfram Research}, title={D}, year={2024}, url={https://reference.wolfram.com/language/ref/D.html}, note=[Accessed: 20-June-2025 ]}