13.7.1 Gradient
The derive
command finds partial derivatives of a multivariable expression.
diff and grad
can be used synonymously for derive here.
-
derive takes two arguments:
-
expr, an expression involving n real variables.
- [x1,…,xn], a vector of the variable names.
- derive(expr,[x1,…,xn])
returns the gradient of expr; namely, the vector of partial
derivatives of
expr with respect to x1, …, xn.
For instance, in dimension n=3, with variables [x,y,z]:
Example
Find the gradient of F(x,y,z)=2x2y−xz3.
derive(2*x^2*y-x*z^3,[x,y,z]) |
or:
diff(2*x^2*y-x*z^3,[x,y,z]) |
or:
grad(2*x^2*y-x*z^3,[x,y,z]) |
|
| ⎡
⎣ | 2· 2 x y−z3,2 x2,−3 x z2 | ⎤
⎦ |
| | | | | | | | | | |
|
|
| ⎡
⎣ | 4 x y−z3,2 x2,−3 x z2 | ⎤
⎦ |
| | | | | | | | | | |
|
To find the critical points of F(x,y,z)=2x2y−xz3:
solve(derive(2*x^2*y-x*z^3,[x,y,z]),[x,y,z]) |