# Use of Digital Technology in Integrated Mathematics Education
## 3 Methods
 \tag{50}\]  
\[D= \begin{bmatrix}30&\cdots&12\\ \vdots&\ddots&\vdots\\ 24&\cdots&-17\end{bmatrix} ,N\times n \tag{51}\]  
The first step in determining the principal components of the \(D\) matrix is to calculate the covariance matrix of the \(U\) matrix. It can be easily seen that, due to the extraction of the average value from each column of the \(D\) matrix, the \(n\times n\) covariance matrix \(C\) can be expressed as  
\[C=COV[U]=U^{T}\times U/n \tag{52}\]  
The rank of the matrix \(U\) (\(N\times n\)) is max N, so there are max N nonzero eigenvalues for \(COV[U]\); then, it can be calculated the eigenvectors of the transposed matrix. Thus, if \(\phi\) is an eigenvector of the transposed matrix, then \(\psi=U^{T}*\phi\) is an eigenvector of the initial matrix \(C=COV[U]\). The eigenvalues are the same as for the transposed matrix. Following the normalisation of the eigenvectors, their set forms a basis in the \(R^{N}\) space:  
\[\forall\psi_{i},\psi_{j},\qquad\psi_{i}*\psi_{j}=\left\{ \begin{array}{ll}0, \text{ if }i\
eq j\\ 1,\text{ if }i=j\end{array} \right. \tag{53}\]  
We will now express all the lines of the \(U\) matrix (the former faces from which the average face was subtracted) in the base formed by the eigenvectors. Each eigenvector corresponds to an eigenvalue that represents the variation of the \(U\) matrix data along the corresponding eigenvector. Therefore, instead of using all N eigenvectors, we will only use M representatives that correspond to the largest M eigenvalues. Typically, for the facial recognition problem, the value of M is quite small (between 20 and 50). Thus, we will express the lines of the matrix \(U\) in the M-dimensional basis formed by the \(M\) vectors chosen:  
\[\psi_{PCA}=\{\psi_{1},\psi_{2},\cdots,\psi_{M}\} \tag{54}\]  
Figure 19: Steps of image transformation. Each line will have \(M\) coefficients that are obtained by projecting that line (scalar product) onto each of the chosen vectors. Thus, an image \(p_{x}=(i_{1};i_{2};\ldots i_{n})\) is expressed in the new space of the chosen vectors (the space of the principal components) as follows:  
\[p_{\psi}=(p_{x}-\mu_{x})\psi_{PCA} \tag{55}\]  
We thus managed to reduce the image representation from an n-dimensional space (n = 128 \(\times\) 128) to an M-dimensional space. The original image can also be roughly reconstructed from the M vectors by applying the inverse transformation:  
\[p_{x}=p_{\psi}\Psi_{PCA}^{T}+\mu_{x} \tag{56}\]  
It can be shown that by choosing the \(M\) eigenvectors corresponding to the largest M eigenvalues, the squared error of the reconstruction of the matrix \(D\) is minimised (any other vectors lead to a larger error). The choice of \(M\), however, depends on the dataset \(D\); for this, an M value can be chosen that allows a reconstruction superior to a given peak signal-to-noise ratio (PSNR), or the following method can be adopted. Given that the sum of the eigenvalues is equal to the sum of the variations in the N directions given by the eigenvectors, one can calculate the percentage of \"variation\" preserved by choosing K principal vectors as follows:  
\[r_{k}=100*\frac{\sum_{i=1}^{k}\lambda_{i}}{\sum_{i=1}^{N}\lambda_{i}} \tag{57}\]  
\(K\) is chosen so that the percentage is at least equal to a given threshold (e.g., 95%). Given a test image \(p_{y}\), the average image will be subtracted from it and then it will be expressed (projected) into the M-dimensional basis of the chosen eigenvectors, resulting in a set of coefficients \(W=\{w_{1},w_{2}\ldots w_{M}\}\). The closest image to the test image will be determined by evaluating a distance (e.g., Euclidean [37] or Mahalanobis [38]) between the W vector and the \(W^{\prime}\) vectors calculated for the other images of the database.