Function Repository Resource:

# ProjectionMatrix

Compute the projection matrix for a given vector space

Contributed by: Rauan Kaldybayev
 ResourceFunction["ProjectionMatrix"][A] returns the projection matrix onto the column space (range) of an m×n matrix A, with m≥n. ResourceFunction["ProjectionMatrix"][A,W] returns the projection matrix onto the column space (range) of A with a specified metric W.

## Details

The metric W should be a positive-definite matrix.
ResourceFunction["ProjectionMatrix"][A,W] returns the projection matrix for the case when the inner product of two vectors x and y equals xT.W.y for some positive-definite matrix W.

## Examples

### Basic Examples (3)

Compute the projection matrix onto the column space of a matrix:

 In[1]:=
 Out[1]=

Project a vector onto this vector space:

 In[2]:=
 Out[2]=

Visualize:

 In[3]:=
 Out[3]=

### Scope (3)

Compute the projection matrix for the case when the dot product between a pair of vectors x and y is given by xT.W.y:

 In[4]:=
 Out[4]=

Compute the projection matrix onto the column space of a singular square matrix:

 In[5]:=
 Out[5]=

Compute the projection matrix onto the column space of a symbolic real-valued matrix:

 In[6]:=
 Out[6]=

### Properties and Relations (2)

ProjectionMatrix[Transpose@{v}].u is equivalent to Projection[u,v]:

 In[7]:=
 Out[7]=

ProjectionMatrix[Transpose@{v},W].u is equivalent to :

 In[8]:=
 Out[8]=

### Possible Issues (1)

ProjectionMatrix can fail with badly conditioned numerical matrices. Consider Läuchli’s example. The output of the function may differ depending on whether the input is given in exact numbers or in MachinePrecision numbers:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

## Publisher

Wolfram Summer Camp

## Version History

• 1.0.0 – 19 January 2022