Diff - Maple Help

diff or Diff

differentiation or partial differentiation

Calling Sequence

 diff(f, x1, ..., xj) $\frac{{ⅆ}^{j}}{ⅆ{x}_{j}\mathrm{...}ⅆ{x}_{1}}f$ diff(f, [x1$n]) $\frac{{ⅆ}^{n}}{ⅆ{x}_{1}^{n}}f$ diff(f, x1$n, [x2$n, x3], ..., xj, [xk$m]) $\frac{{ⅆ}^{r}}{ⅆ{x}_{k}^{m}ⅆ{x}_{j}\mathrm{...}ⅆ{x}_{3}ⅆ{x}_{2}^{n}ⅆ{x}_{1}^{n}}f$

Remark: these calling sequences are also valid with the inert Diff command

Parameters

 f - algebraic expression or an equation x1, x2, ..., xj - names representing differentiation variables n - algebraic expression entering constructions like x$n, representing nth order derivative, assumed to be integer order differentiation Description  • The diff command computes the partial derivative of the expression a with respect to x1, x2, ..., xn, respectively. The most frequent use is diff(f(x),x), which computes the derivative of the function f(x) with respect to x.  • You can enter the command diff using either the 1-D or 2-D calling sequence. For example, diff(x, x) is equivalent to $\frac{ⅆ}{ⅆx}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}x$.  • Note that where j in xj is greater than 1, the call to diff is the same as diff called recursively. Thus diff(f(x1,x2), x1, x2); is equivalent to the call diff(diff (f(x1,x2), x1), x2). The sequence operator$ is useful for forming higher-order derivatives. diff(f(x),x$4), for example, is equivalent to diff(f(x),x,x,x,x) and diff(g(x,y),x$2,y$3) is equivalent to diff(g(x,y),x,x,y,y,y)  • The names with respect to which the differentiation is to be done can also be given as a list of names. This format allows for the special case of differentiation with respect to no variables, in the form of an empty list, so the zeroth order derivative is handled through diff(f,[x$0]) = diff(f,[]). In this case, the result is simply the original expression, f. This format is especially useful when used together with the sequence operator and sequences with potentially zero variables.
 • Derivatives of nth order, where n is not specified as a number, can be constructed as in diff(f(x),[x\$n]) and are interpreted as integer order derivatives, that is, computed assuming n is an integer. The routines for computing these symbolic nth order derivatives can handle most functions of the mathematical language and an increasing number of expressions formed by composing them with other functions or algebraic expressions. The results are returned in closed form or as finite sums - see the Examples section.
 • diff has a user interface that will call the user's own differentiation functions.  If the procedure diff/f is defined, then the function call diff(f(x, y, z), y) will invoke diff/f(x,y,z,y) to compute the derivative.  See example below.
 • If the derivative cannot be expressed (if the expression is an undefined function), the diff function call itself is returned.  (The prettyprinter displays the diff function in a two-dimensional $\frac{ⅆ}{ⅆx}$ format.)
 • The diff command assumes that partial derivatives commute.
 • The capitalized function name Diff is the inert diff function, which simply returns unevaluated.  It appears gray so that it is easily distinguished from a returned diff calling sequence.
 • The differential operator D is also defined in Maple; see D. For a comparison of D and diff see operators[D].

Examples

Compute first order derivatives.

 > $\mathrm{diff}\left(x,x\right)$
 ${1}$ (1)
 > $\mathrm{diff}\left(\mathrm{exp}\left(x\right),x\right)$
 ${{ⅇ}}^{{x}}$ (2)
 > $\mathrm{diff}\left(\mathrm{sin}\left(x\right),x\right)$
 ${\mathrm{cos}}{}\left({x}\right)$ (3)
 > $\mathrm{diff}\left(\mathrm{tan}\left(x\right),x\right)$
 ${1}{+}{{\mathrm{tan}}{}\left({x}\right)}^{{2}}$ (4)
 > $\mathrm{diff}\left(\mathrm{sqrt}\left({x}^{2}\right),x\right)$
 $\frac{{x}}{\sqrt{{{x}}^{{2}}}}$ (5)
 > $\mathrm{diff}\left(x\mathrm{sin}\left(\mathrm{cos}\left(x\right)\right),x\right)$
 ${\mathrm{sin}}{}\left({\mathrm{cos}}{}\left({x}\right)\right){-}{x}{}{\mathrm{sin}}{}\left({x}\right){}{\mathrm{cos}}{}\left({\mathrm{cos}}{}\left({x}\right)\right)$ (6)

Find higher order derivatives.

 > $\mathrm{diff}\left(\mathrm{sin}\left(x\right),\mathrm{}\left(x,3\right)\right)$
 ${-}{\mathrm{cos}}{}\left({x}\right)$ (7)
 > $\mathrm{diff}\left(3{x}^{3}+2{x}^{2}+23x+2342,\mathrm{}\left(x,2\right)\right)$
 ${18}{}{x}{+}{4}$ (8)

Compute partial derivatives.

 > $\mathrm{diff}\left(\mathrm{sin}\left(x\right),y\right)$
 ${0}$ (9)
 > $\mathrm{diff}\left({x}^{2}+x{y}^{2},x\right)$
 ${{y}}^{{2}}{+}{2}{}{x}$ (10)
 > $\mathrm{diff}\left(2x+{y}^{2},y\right)$
 ${2}{}{y}$ (11)
 > $\mathrm{diff}\left({x}^{2}+x{y}^{2},x,y\right)$
 ${2}{}{y}$ (12)
 > $h≔5{x}^{2}+2{x}^{2}y+3x{y}^{2}+12yx+\frac{3{y}^{3}}{x}$
 ${h}{≔}{5}{}{{x}}^{{2}}{+}{2}{}{{x}}^{{2}}{}{y}{+}{3}{}{x}{}{{y}}^{{2}}{+}{12}{}{y}{}{x}{+}\frac{{3}{}{{y}}^{{3}}}{{x}}$ (13)
 > $\mathrm{diff}\left(h,x,y\right)$
 ${4}{}{x}{+}{6}{}{y}{+}{12}{-}\frac{{9}{}{{y}}^{{2}}}{{{x}}^{{2}}}$ (14)
 > $\mathrm{diff}\left(h,y,x\right)$
 ${4}{}{x}{+}{6}{}{y}{+}{12}{-}\frac{{9}{}{{y}}^{{2}}}{{{x}}^{{2}}}$ (15)
 > $\mathrm{diff}\left(h,\mathrm{}\left(y,3\right)\right)$
 $\frac{{18}}{{x}}$ (16)

The Diff command is inert, it returns unevaluated.

Note: To enter the 2-D calling sequence of the Diff command, type Diff at the input, press Esc, and then select Diff(inline).

 > $\mathrm{Diff}\left(\mathrm{tan}\left(x\right),x\right)$
 $\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{tan}{}\left({x}\right)$ (17)
 > $\mathrm{Diff}\left(\mathrm{tan}\left(x\right),x\right)=\mathrm{diff}\left(\mathrm{tan}\left(x\right),x\right)$
 $\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{tan}{}\left({x}\right){=}{1}{+}{{\mathrm{tan}}{}\left({x}\right)}^{{2}}$ (18)
 > $\mathrm{diff}\left(f\left(x\right),x\right)$
 $\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}\right)$ (19)
 > $\mathrm{diff}\left(f\left(x,y\right),x,y\right)$
 $\frac{{{\partial }}^{{2}}}{{\partial }{x}{\partial }{y}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right)$ (20)
 > $\mathrm{diff}\left(f\left(x,y\right),x,y\right)-\mathrm{diff}\left(f\left(x,y\right),y,x\right)$
 ${0}$ (21)

An empty list specifies no derivatives:

 > $\mathrm{diff}\left(g\left(x,y,z\right),\left[\right]\right)$
 ${g}{}\left({x}{,}{y}{,}{z}\right)$ (22)

Teach Maple how to differentiate $f\left(g\left(x\right)\right)$ = $\frac{\frac{ⅆ}{ⅆx}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}g\left(x\right)}{{f\left(x\right)}^{2}}$

 > diff/f := proc(g,x) diff(g,x)/f(x)^2 end proc:
 > $\mathrm{diff}\left(f\left(\mathrm{sin}\left(x\right)\right),x\right)$
 $\frac{{\mathrm{cos}}{}\left({x}\right)}{{{f}{}\left({x}\right)}^{{2}}}$ (23)

Symbolic order differentiation is also handled. For example, for arbitrary integer values of n,

 > $\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)$ (24)

Inert objects can be evaluated with the value command.

 > $\mathrm{value}\left(\right)$
 ${\mathrm{sin}}{}\left({x}{+}\frac{{n}{}{\mathrm{\pi }}}{{2}}\right)$ (25)

Note that in the context of a call to diff (or Diff), n entering $\frac{{ⅆ}^{n}}{ⅆ{x}^{n}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}f\left(x\right)$ is understood to be an integer; that is: diff computes integer order derivatives. To compute fractional derivatives see fracdiff.

A more involved example

 > $\mathrm{Diff}\left(\mathrm{exp}\left({x}^{2}\right),\mathrm{}\left(x,n\right)\right)$
 $\frac{{{ⅆ}}^{{n}}}{{ⅆ}{{x}}^{{n}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{ⅇ}}^{{{x}}^{{2}}}$ (26)
 > $\mathrm{value}\left(\right)$
 ${{x}}^{{-}{n}}{}{{2}}^{{n}}{}{\mathrm{MeijerG}}{}\left(\left[\left[{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)$ (27)

The Leibniz rule for the nth derivative of a product

 > $\mathrm{Diff}\left(f\left(x\right)g\left(x\right),\mathrm{}\left(x,n\right)\right)$
 $\frac{{{ⅆ}}^{{n}}}{{ⅆ}{{x}}^{{n}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}\left({f}{}\left({x}\right){}{g}{}\left({x}\right)\right)$ (28)
 > $\mathrm{value}\left(\right)$
 ${\sum }_{{\mathrm{_k1}}{=}{0}}^{{n}}{}\left(\genfrac{}{}{0}{}{{n}}{{\mathrm{_k1}}}\right){}\left(\frac{{{ⅆ}}^{{\mathrm{_k1}}}}{{ⅆ}{{x}}^{{\mathrm{_k1}}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}\right)\right){}\left(\frac{{{ⅆ}}^{{n}{-}{\mathrm{_k1}}}}{{ⅆ}{{x}}^{{n}{-}{\mathrm{_k1}}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{g}{}\left({x}\right)\right)$ (29)