# A Program To Calculate The Gradient; Using Function Hess To Obtain The Gradient - HP 50g User Manual

Graphing calculator.

At any particular point, the maximum rate of change of the function occurs in
the direction of the gradient, i.e., along a unit vector u =
/|
|.
The value of that directional derivative is equal to the magnitude of the gradient
at any point D
(x,y,z) =
/|
| = |
|
max
The equation (x,y,z) = 0 represents a surface in space. It turns out that the
gradient of the function at any point on this surface is normal to the surface.
Thus, the equation of a plane tangent to the curve at that point can be found by
using a technique presented in Chapter 9.
The simplest way to obtain the gradient is by using function DERIV, available in

## A program to calculate the gradient

The following program, which you can store into variable GRADIENT, uses
function DERIV to calculate the gradient of a scalar function of X,Y,Z.
Calculations for other base variables will not work. If you work frequently in the
(X,Y,Z) system, however, this function will facilitate calculations:
<< X Y Z 3
ARRY DERIV >>
Type the program while in RPN mode. After switching to ALG mode, you can
call the function GRADIENT as in the following example:

### Using function HESS to obtain the gradient

The function HESS can be used to obtain the gradient of a function as shown
next. As indicated in Chapter 14, function HESS takes as input a function of n
independent variables (x
, x
, ...,x
), and a vector of the functions ['x
'
1
2
n
1
'x
'...'x
']. Function HESS returns the Hessian matrix of the function , defined
2
n
Page 15-2