# norm

``````..  norm(A, [p])

Compute the ``p``-norm of a vector or the operator norm of a matrix ``A``, defaulting to the ``p=2``-norm.

For vectors, ``p`` can assume any numeric value (even though not all values produce a mathematically valid vector norm). In particular, ``norm(A, Inf)`` returns the largest value in ``abs(A)``, whereas ``norm(A, -Inf)`` returns the smallest.

For matrices, the matrix norm induced by the vector ``p``-norm is used, where valid values of ``p`` are ``1``, ``2``, or ``Inf``. (Note that for sparse matrices, ``p=2`` is currently not implemented.) Use :func:`vecnorm` to compute the Frobenius norm.``````

## Examples

The `norm` function in Julia calculates the `p`-norm of a vector or the operator norm of a matrix `A`. By default, it computes the `p=2`-norm.

``norm(A, [p])``

For vectors, the parameter `p` can take any numeric value, although not all values produce a mathematically valid vector norm. The `norm(A, Inf)` returns the largest value in `abs(A)`, while `norm(A, -Inf)` returns the smallest.

For matrices, the `p`-norm used is the matrix norm induced by the vector `p`-norm. Valid values for `p` are `1`, `2`, or `Inf`. Note that for sparse matrices, `p=2` is currently not implemented. To compute the Frobenius norm, use the `vecnorm` function.

Here are some examples of using the `norm` function:

1. Compute the Euclidean norm of a vector:

``````julia> v = [3, 4];
julia> norm(v)
5.0``````
2. Compute the `p=1` norm of a vector:

``````julia> w = [-1, 2, -3];
julia> norm(w, 1)
6.0``````
3. Compute the `p=Inf` norm of a matrix:

``````julia> A = [1 2; -3 4];
julia> norm(A, Inf)
7.0``````
4. Compute the Frobenius norm of a matrix using `vecnorm`:
``````julia> B = [1 2; 3 4; 5 6];
julia> vecnorm(B)
9.539392014169456``````

Please note that these examples assume that the necessary variables are defined before using the `norm` function.