A program to calculate the gradient, Using function hess to obtain the gradient – HP 50g Graphing Calculator User Manual

Page 472

Advertising
background image

Page 15-2

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

max

φ(x,y,z) = ∇φ •∇φ/|∇φ| = |∇φ|

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
the CALC menu, e.g.,

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

1

, x

2

, …,x

n

), and a vector of the functions [‘x

1

‘x

2

’…’x

n

’]. Function HESS returns the Hessian matrix of the function

φ, defined

Advertising