diff/x$n - Maple Programming Help # Online Help ###### All Products Maple MapleSim Home : Support : Online Help : Mathematics : Calculus : Differential Calculus : diff/symbolicorder diff/x$n

compute a (partial) symbolic integer order derivative (or integral) of an expression

Calling Sequence

 diff( f(x), x$n ) $\frac{{ⅆ}^{n}}{ⅆ{x}^{n}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}f\left(x\right)$ diff( f(x), x$(-n) )

Parameters

 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

Description

 • 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 $\frac{{ⅆ}^{n}}{ⅆ{x}^{n}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}cos\left(x\right)$.
 • 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 Computational Approach

 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.

Examples

Compute the nth derivative of cos(x).

 > $\mathrm{cn}≔\mathrm{diff}\left(\mathrm{cos}\left(x\right),\mathrm{}\left(x,n\right)\right)$
 ${\mathrm{cn}}{≔}{\mathrm{cos}}{}\left({x}{+}\frac{{n}{}{\mathrm{\pi }}}{{2}}\right)$ (1)

Compare with the result obtained by direct differentiation.

 > $\mathrm{c3}≔\mathrm{diff}\left(\mathrm{cos}\left(x\right),\mathrm{}\left(x,3\right)\right)$
 ${\mathrm{c3}}{≔}{\mathrm{sin}}{}\left({x}\right)$ (2)
 > $\mathrm{eval}\left(\mathrm{c3}-\mathrm{cn},n=3\right)$
 ${0}$ (3)

Compute the nth integral of ${ⅇ}^{2x}$.

 > $\mathrm{diff}\left(\mathrm{exp}\left(2x\right),\mathrm{}\left(x,-n\right)\right)$
 ${{ⅇ}}^{{2}{}{x}}{}{{2}}^{{-}{n}}$ (4)

A basic formula: symbolic derivative of a monomial:

 > $\mathrm{diff}\left({x}^{m},\mathrm{}\left(x,n\right)\right)$
 ${\mathrm{pochhammer}}{}\left({m}{-}{n}{+}{1}{,}{n}\right){}{{x}}^{{m}{-}{n}}$ (5)

A more difficult function:

 > $\mathrm{tn}≔\mathrm{diff}\left(\mathrm{arctan}\left(x\right),\mathrm{}\left(x,n\right)\right)$
 ${\mathrm{tn}}{≔}\frac{{{2}}^{{n}}{}{\mathrm{MeijerG}}{}\left(\left[\left[{0}{,}{0}{,}\frac{{1}}{{2}}\right]{,}\left[\right]\right]{,}\left[\left[{0}\right]{,}\left[{-}\frac{{1}}{{2}}{+}\frac{{n}}{{2}}{,}\frac{{n}}{{2}}\right]\right]{,}{{x}}^{{2}}\right){}{{x}}^{{1}{-}{n}}}{{2}}$ (6)
 > $\mathrm{normal}\left(\mathrm{expand}\left(\mathrm{evalc}\left(\mathrm{simplify}\left(\mathrm{eval}\left(\mathrm{diff}\left(\mathrm{arctan}\left(x\right),\mathrm{}\left(x,5\right)\right)-\mathrm{tn},n=5\right)\right)\right)\right)\right)$
 ${0}$ (7)

Compute the formula for the nth derivative of sin(x).

 > $\mathrm{Diff}\left(\mathrm{sin}\left(x\right),\mathrm{}\left(x,n\right)\right)$
 $\frac{{{ⅆ}}^{{n}}}{{ⅆ}{{x}}^{{n}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{sin}{}\left({x}\right)$ (8)
 > $\mathrm{value}\left(\right)$
 ${\mathrm{sin}}{}\left({x}{+}\frac{{n}{}{\mathrm{\pi }}}{{2}}\right)$ (9)

Now compute the nth integral of the result.

 > $\mathrm{diff}\left(,\mathrm{}\left(x,-n\right)\right)$
 ${\mathrm{sin}}{}\left({x}\right)$ (10)

References

 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