# IMSL_NORM

The IMSL_NORM function computes various norms of a vector or the difference of two vectors.

Note: This routine requires an IDL Analyst license. For more information, contact your Exelis VIS sales or technical support representative.

By default, IMSL_NORM computes the Euclidean norm as follows:

If the keyword One is set, then the 1-norm:

is returned. If the keyword INF is set, the infinity norm max|xi| is returned. In the case of the infinity norm, the index of the element with maximum modulus also is

returned.

If the parameter y is specified, the computations of the norms described above are performed on (x – y).

## Examples

For additional information on using IMSL_NORM, see Additional Examples.

### Example 1

In this example, the Euclidean norm of an input vector is computed.

x = [ 1.0, 3.0, -2.0, 4.0 ]

n = IMSL_NORM(x)

PM, n, Title = 'Euclidean norm of x:'

Euclidean norm of x:

5.47723

## Syntax

Result = IMSL_NORM(x [, y] [, INDEX_MAX=variable] [, INF=value] [, ONE=value] )

## Return Value

The requested norm of the input vector. If the norm cannot be computed, NaN is returned.

## Arguments

### x

Vector for which the norm is to be computed.

### y

If present, IMSL_NORM computes the norm of (x – y).

## Keywords

### INDEX_MAX

Named variable into which the index of the element of x with the maximum modulus is stored. If INDEX_MAX is used, then the keyword INF also must be used. If the parameter y is specified, then the index of (x – y) with the maximum modulus is stored.

### INF

If present and nonzero, computes the infinity norm max|xi|.

### ONE

If present and nonzero, computes the 1-norm

## Additional Examples

### Example 2

This example computes max | xi– yi| and prints the norm and index.

x = [1.0, 3.0, -2.0, 4.0]

y = [4.0, 2.0, -1.0, -5.0]

n = IMSL_NORM(x, y, /Inf, Index_Max = imax)

PM, n, Title = 'Infinity norm of (x-y):'

PM, imax, Title = 'Element of (x-y) with maximum modulus:'

Infinity norm of (x-y):

9.00000

Element of (x-y) with maximum modulus:

3

## Version History

6.4 | Introduced

## See Also