diff/x$n
compute a (partial) symbolic integer order derivative (or integral) of an expression
Calling Sequence
Parameters
Description
The Computational Approach
Examples
References
diff( f(x), x$n )
ⅆnⅆxnf⁡x
diff( f(x), x$(-n) )
f(x)
-
algebraic expression depending on x to be differentiated (or integrated)
x
name; differentiation (or integration) variable
n
symbol understood to be an integer representing the differentiation (or integration) order
The diff( f(x), x$n ) calling sequence computes a formula for the nth (integer order) derivative of the expression f(x). To compute derivatives of fractional order see fracdiff.
The diff( f(x), x$(-n) ) calling sequence computes a formula for the nth integral of the expression f(x).
The symbolic derivative is computed using a database of core differentiation formulas, sum representations for functions, full partial fraction expansions, and tools from the gfun package.
You can enter the command for symbolic differentiation using either the 1-D or 2-D calling sequence. For example, diff(cos(x), x$n) is equivalent to ⅆnⅆxncos⁡x.
The environment variable _EnvFallingNotation allows you to select how "x to the n falling" is represented: x^falling(n) := x(x-1)(x-2)...(x-n+1) can be represented by the pochhammer symbol, GAMMA notation, or factorial notation. Each has some advantages. The default value is pochhammer.
Note: The command diff implicitly assumes that n is an integer. Substitution of fractional values into the resulting formula will not compute fractional derivatives - for that purpose use fracdiff. Depending on the case, symbolic order differentiation can be a computationally expensive operation; uncomputed sums in the output are represented using Sum, not sum.
The expression is recursively examined for simple expressions. A direct formula for monomials of the form C*(x-a)^p is used when such patterns are matched in the input. Rational functions are converted to full partial fraction form.
When complicated terms are found in the input, a sequence of increasingly powerful heuristics is tried: guessing a differential equation satisfied by the term, converting it to hypergeometric form, or converting it to Sum form by means of the built-in functional database.
Compute the nth derivative of cos(x).
cn≔diff⁡cos⁡x,`$`⁡x,n
cn≔cos⁡x+n⁢π2
Compare with the result obtained by direct differentiation.
c3≔diff⁡cos⁡x,`$`⁡x,3
c3≔sin⁡x
eval⁡c3−cn,n=3
0
Compute the nth integral of ⅇ2⁢x.
diff⁡exp⁡2⁢x,`$`⁡x,−n
ⅇ2⁢x⁢2−n
A basic formula: symbolic derivative of a monomial:
diff⁡xm,`$`⁡x,n
pochhammer⁡m−n+1,n⁢xm−n
A more difficult function:
tn≔diff⁡arctan⁡x,`$`⁡x,n
tn≔2n⁢MeijerG⁡0,0,12,,0,−12+n2,n2,x2⁢x1−n2
normal⁡expand⁡evalc⁡simplify⁡eval⁡diff⁡arctan⁡x,`$`⁡x,5−tn,n=5
Compute the formula for the nth derivative of sin(x).
Diff⁡sin⁡x,`$`⁡x,n
ⅆnⅆxnsin⁡x
value⁡
sin⁡x+n⁢π2
Now compute the nth integral of the result.
diff⁡,`$`⁡x,−n
sin⁡x
Benghorbal, Mhenni, and Corless, Robert M. "The nth derivative." SIGSAM Bull (Communications in Computer Algebra). Vol. 36 No. 1, (2002): 10-14. http://doi.acm.org/10.1145/565145.565149
See Also
convert/fullparfrac
convert/parfrac
D
diff
eval
evalf
fdiff
fracdiff
int
Sum or sum
value
Download Help Document