% Copyright The Numerical Algorithms Group Limited 1991. % Certain derivative-work portions Copyright (C) 1988 by Leslie Lamport. % All rights reserved % Title: Differentiation % Author: Clifton J. Williamson % Date created: 1 November 1989 % Date last updated: 1 November 1989 \begin{page}{ExDiffBasic}{Computing Derivatives} \beginscroll To compute a derivative, you must specify an expression and a variable of differentiation. For example, to compute the derivative of {\em sin(x) * exp(x**2)} with respect to the variable {\em x}, issue the following command: \spadpaste{differentiate(sin(x) * exp(x**2),x)} \endscroll \autobuttons\end{page} \begin{page}{ExDiffSeveralVariables}{Derivatives of Functions of Several Variables} \beginscroll Partial derivatives are computed in the same way as derivatives of functions of one variable: you specify the function and a variable of differentiation. For example: \spadpaste{differentiate(sin(x) * tan(y)/(x**2 + y**2),x)} \spadpaste{differentiate(sin(x) * tan(y)/(x**2 + y**2),y)} \endscroll \autobuttons\end{page} \begin{page}{ExDiffHigherOrder}{Derivatives of Higher Order} \beginscroll To compute a derivative of higher order (e.g. a second or third derivative), pass the order as the third argument of the function 'differentiate'. For example, to compute the fourth derivative of {\em exp(x**2)}, issue the following command: \spadpaste{differentiate(exp(x**2),x,4)} \endscroll \autobuttons\end{page} \begin{page}{ExDiffMultipleI}{Multiple Derivatives I} \beginscroll When given a function of several variables, you may take derivatives repeatedly and with respect to different variables. The following command differentiates the function {\em sin(x)/(x**2 + y**2)} first with respect to {\em x} and then with respect to {\em y}: \spadpaste{differentiate(sin(x)/(x**2 + y**2),[x,y])} As you can see, we first specify the function and then a list of the variables of differentiation. Variables may appear on the list more than once. For example, the following command differentiates the same function with respect to {\em x} and then twice with respect to {\em y}. \spadpaste{differentiate(sin(x)/(x**2 + y**2),[x,y,y])} \endscroll \autobuttons\end{page} \begin{page}{ExDiffMultipleII}{Multiple Derivatives II} \beginscroll You may also compute multiple derivatives by specifying a list of variables together with a list of multiplicities. For example, to differentiate {\em cos(z)/(x**2 + y**3)} first with respect to {\em x}, then twice with respect to {\em y}, then three times with respect to {\em z}, issue the following command: \spadpaste{differentiate(cos(z)/(x**2 + y**3),[x,y,z],[1,2,3])} \endscroll \autobuttons\end{page} \begin{page}{ExDiffFormalIntegral}{Derivatives of Functions Involving Formal Integrals} \beginscroll When a function does not have a closed-form antiderivative, \Language{} returns a formal integral. A typical example is \spadpaste{f := integrate(sqrt(1 + t**3),t) \bound{f}} This formal integral may be differentiated, either by itself or in any combination with other functions: \spadpaste{differentiate(f,t) \free{f}} \spadpaste{differentiate(f * t**2,t) \free{f}} \endscroll \autobuttons\end{page}