Virtually all spaces used in physics are Hilbert spaces (treated in the weak sense, i.e. equipped with distributions), which means that they have a scalar product and a norm.
The braket
in Dirac notation is a scalar product and we are
free to define it anyway we like, as long as it satisfies the following
properties:

where
if, and only if,
. Scalar product induces the
norm:

Any norm has to satisfy the following properties:

where
if, and only if,
. Those properties are
automatically satisfied by the induced norm.
In general, any of these properties can be weakened, one can study spaces that have a norm, but not a scalar product, or spaces, that have objects resembling a norm (or a scalar product), that only satisfy some of the properties of the norm (or a scalar product). Those are not very important in physics. On the other hand, it is very important to understand how to work with Hilbert spaces (in the weak sense). Dirac notation makes it very easy to understand and remember how to work with such spaces.
Some examples of frequently used spaces and scalar products follows.
Finite dimensional spaces:

scalar product:

Infinite dimensional spaces:

scalar product:

Function spaces:

scalar product:

scalar product:

scalar product:

Energy scalar product:

All of these scalar products automatically satisfy all of the properties of the
scalar product, only the energy scalar product doesn’t automatically satisfy
, which imposes some conditions on the parameters
and
.
Projection is a linear idempotent operator
:

It takes a vector
from
and projects it onto a vector
from
. Further application of the operator
gains nothing:
.
It decomposes the space
into a direct sum
of
the projection subspace
and its complement
. If
is
from
then its complement
is from
. Given the
space
, the operator
is unique.
Orthogonal projection is a projection that is Hermitean:

The complement of an orthogonal projection is orthogonal to any vector from
:

In other words, orthogonal projection projects a vector
from the space
into an orthogonal subspace (projection subspace)
.
If we choose any orthonormal basis
,
,
, ..., of the subspace
, then the orthogonal projection
is:

because:

and

is independent of the basis, i.e
, as long as
span the same
subspace as
, because the operator
is unique.
To find the closest vector
from
to the vector
from
,
we need to minimize the norm
. So we write
for some vector
from
and simplify
the norm:

which is minimal for
, so we found out that the closest vector is
. We used the fact that
, because
is from the orthogonal complement to the subspace
.
In other words, orthogonal projection finds the closest vector from a subspace
onto which it projects.
In order to project using a nonorthogonal basis
(for example a
finite element basis), we write:

where
are the projection coefficients that we’d like to calculate.
This holds, because
belongs to the space
and every vector from it
can be expressed as a linear combination of
. Now we multiply by
from the left and simplify:

so we need to solve the linear system:

with:

This works for any basis, it doesn’t have to be normalized nor orthogonal.
projection. Orthogonal basis:

Different basis orthogonal basis:

Lagrange interpolation projection onto the space
:

projection onto the space
. Orthogonal basis:

Different orthogonal basis:

Nonorthogonal basis:

projection. Nonorthogonal basis:
