## Norms, Sensitivity & Conditioning¶

Supplemental Julia Notebook

Prof. Doug James

## Vector p-norms in Julia¶

In [1]:
?(norm)

search: norm normpath normalize normalize! normalize_string vecnorm issubnormal


Out[1]:
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 vecnorm to compute the Frobenius norm.

In [2]:
a=ones(3)

Out[2]:
3-element Array{Float64,1}:
1.0
1.0
1.0
In [3]:
norm(a)

Out[3]:
1.7320508075688772
In [4]:
norm(a,2)

Out[4]:
1.7320508075688772
In [5]:
norm(a,Inf)

Out[5]:
1.0
In [6]:
norm(a,1)

Out[6]:
3.0

## Visualizing Vector p-norms¶

Let us look at contour plots of $$\| (x,y) \|_p$$ for different values of $p$.

In [7]:
using Plots

In [8]:
f(x,y) = vecnorm([x y], p)   # parameter-dependent p-norm function

Out[8]:
f (generic function with 1 method)
In [9]:
x = y = linspace(-1, 1, 100);

In [10]:
p=1;
contourf(x, y, f, xlabel="x", ylabel="y", title=string("Norm, p=",p))