# Finding a matrix and its transpose from a given matrix

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• Aug 5th 2007, 12:23 AM
beberenne
Finding a matrix and its transpose from a given matrix
Hi all, I'm new here. I'm currently doing a thesis on image compression and embedding. However, I'm stuck at a final part of my calculations.
Lets say you have a square matrix A. Taking the transpose of the matrix A you will get another square matrix A'.
Multiplying A by A' you get another square matrix B.
Example: A X A' = B

Now assuming you only have the matrix B given to you. How do you find the value of matrix A?

Hope you guys can help in this. Thanks alot.:)
• Aug 5th 2007, 01:04 AM
tukeywilliams
Given that $A \times A^{T} = B$, and we are given the square matrix $B$, the problem is to find $A$ and $A^{T}$.

So lets say $A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$.

Then $A^T = \begin{bmatrix} 1 & 3 \\ 2 & 4 \end{bmatrix}$.

Then $\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 1 & 3 \\ 2 & 4 \end{bmatrix} = \begin{bmatrix} 5 & 11 \\ 11 & 25 \end{bmatrix}$ which is a symmetric matrix.

So if $A = \begin{bmatrix} a & b\\ c & d \end{bmatrix} \begin{bmatrix} a & c \\ b & d \end{bmatrix}$ then

$a^2 + b^2 = 5$
$ac+bd = 11$
$c^2+d^2 = 25$
• Aug 5th 2007, 01:42 AM
tukeywilliams
There also are probably some efficient algorithms (similar to LU-decomposition) that allow you to decompose a given matrix to a product of a matrix and its transpose (numerical linear algebra).
• Aug 7th 2007, 12:24 AM
beberenne
i have checked out the LU-decomposition method and i found it didn't help much in obtaining the product of a matrix and its transpose. Writing the long equation in MATLAB will be a bit difficult as i'm dealing with a 512 X 512 image which will be having many unknowns. Any more suggestions will me most welcomed. By the way, many thanks to tukeywilliams. :)
• Aug 7th 2007, 03:21 AM
JakeD
Since if $AA^T = B$ implies $B$ is symmetric, there exists an orthogonal matrix $P$ such that $P^TBP = \Lambda,$ and $\Lambda$ is a diagonal matrix with the eigenvalues of $B$ along the diagonal and the columns of $P$ are the eigenvectors of $B$. $P^TBP = \Lambda$ is called a unitary transformation. Since $P$ is orthogonal, $PP^T = I$ and thus $B = PP^T B PP^T = P\Lambda P^T.$

Further, since $x^TBx = x^TAA^Tx = (A^Tx)^T A^Tx > 0$ when $B$ is nonsingular, $B$ is positive definite and thus has positive eigenvalues. Thus $\Lambda = D D^T$ where $D$ has the square roots of the eigenvalues of $B$ on the diagonal.

Then $B = P\Lambda P^T = PD D^TP^T = A A^T$ where $A = PD$. So the problem is reduced to finding the eigenvalues and eigenvectors of a symmetric matrix $B.$ There are efficient numerical methods for this.
• Aug 7th 2007, 04:27 AM
beberenne
Correct me if I'm wrong.
Assuming that I extracted the eigenvectors and eigenvalues of B using MATLAB. So i now have a matrix of the eigenvectors of B (eig_vec) and a matrix of the eigenvalues of B (eig_val).

[eig_vec eig_val] = eig(B);

Then D has the square roots of the eigenvalues of B on the diagonal. So i take the square root of the eigenvalues of B.

D = sqrtm(B);

The columns of P are the eigenvectors of B, which means P is equal to the eigenvectors of B.

P = eig_vec;

To find A,
A = PD;
• Aug 7th 2007, 05:12 AM
JakeD
Quote:

Originally Posted by beberenne
Correct me if I'm wrong.
Assuming that I extracted the eigenvectors and eigenvalues of B using MATLAB. So i now have a matrix of the eigenvectors of B (eig_vec) and a matrix of the eigenvalues of B (eig_val).

[eig_vec eig_val] = eig(B);

The eigenvectors must be orthonormal, which means the matrix $P$ must satisfy $P^TP = PP^T = I.$ I'm not familiar with MATLAB, so I don't know if this is the case. The normalized eigenvectors corresponding to distinct eigenvalues will be orthonormal. And multiple eigenvectors corresponding to a single eigenvalue can be made orthonormal through Gram-Schmidt orthogonalization. So the eigenvectors can be made orthonormal. But I don't know if MATLAB does that automatically.

Quote:

Then D has the square roots of the eigenvalues of B on the diagonal. So i take the square root of the eigenvalues of B.

D = sqrtm(B);
Is this the square root of B or the eigenvalues of B?

Quote:

The columns of P are the eigenvectors of B, which means P is equal to the eigenvectors of B.

P = eig_vec;

To find A,
A = PD;
Yes. And then you must check that you actually get $AA^T = B.$
• Aug 7th 2007, 07:58 AM
beberenne
The eigenvectors are non orthonormal. For the square root, the function squares the whole matrix.
• Aug 7th 2007, 05:29 PM
beberenne
I have experimented with a 4X4 image. The matrix obtain from the image is B.

$
B = \begin{bmatrix} 1 & -3.8858e-016 & 1.0408e-016 & -2.7756e-017 \\ -3.8858e-016 & 1 & -2.3592e-016 & -2.7756e-01 \\ 1.0408e-016 & -2.3592e-016 & 1 & -1.8041e-016 \\ -2.7756e-017 & -2.7756e-016 & -1.8041e-016 & 1\end{bmatrix}
$

After having extracted the eigenvalues and eigenvectors, P of B;

$
eigenvalues = \begin{bmatrix} -1.1102e-016 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{bmatrix}
$

$
eigenvectors = \begin{bmatrix} -0.5 & 0-0.81917 & 0.14281 & 0.24199 \\ -0.5 & 0.026681 & -0.15422 & -0.85177 \\ -0.5 & 0.31193 & -0.68558 & 0.42741 \\ -0.5 & 0.48056 & 0.69699 & 0.18236\end{bmatrix}
$

The transpose of the eigenvectors is

$
eigenvectors transposed = \begin{bmatrix} -0.5 & -0.5 & -0.5 & -0.5 \\ -0.81917 & 0.026681 & 0.31193 & 0.48056 \\ 0.14281 & -0.15422 & -0.68558 & 0.69699 \\ 0.24199 & -0.85177 & 0.42741 & 0.18236\end{bmatrix}
$

The inverse of the eigenvectors is

$
eigenvectors inversed = \begin{bmatrix} -0.5 & -0.5 & -0.5 & -0.5 \\ -0.81917 & 0.026681 & 0.31193 & 0.48056 \\ 0.14281 & -0.15422 & -0.68558 & 0.69699 \\ 0.24199 & -0.85177 & 0.42741 & 0.18236\end{bmatrix}
$

The product of $
PP^T
$
is not equal to $
P^TP
$

The square root of the eigenvalues of B consist of a complex number

$
eigenvalues squared = \begin{bmatrix} 0 +1.0537e-008i & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{bmatrix}
$

Hope JakeD can comment on this. Thanks
• Aug 7th 2007, 08:02 PM
JakeD
Quote:

Originally Posted by beberenne
I have experimented with a 4X4 image. The matrix obtain from the image is B.

$
B = \begin{bmatrix} 1 & -3.8858e-016 & 1.0408e-016 & -2.7756e-017 \\ -3.8858e-016 & 1 & -2.3592e-016 & -2.7756e-01 \\ 1.0408e-016 & -2.3592e-016 & 1 & -1.8041e-016 \\ -2.7756e-017 & -2.7756e-016 & -1.8041e-016 & 1\end{bmatrix}
$

[snipped]

First, the matrix is not symmetric as is. The entry 2,4 (row 2, column 4) is not equal to the entry 4,2. It looks like a typo and entry 2,4 is missing a 6 at the end. Then the matrix is symmetric.

Second, on any typical computer, numbers like -3.8858e-016 are effectively 0 except for rounding error because numbers like this are at the limits of machine accuracy. But all the entries not on the diagonal are like that. Setting all those entries to zero means the matrix is effectively the identity matrix and the problem is the trivial one B = I and A = A^T = I.

Where did this matrix come from?
• Aug 7th 2007, 10:03 PM
beberenne
Sorry about the typo error. The matrix is symmetrical. The matrix is obtained through a test matrix A multiplied by A transposed. The matrix is generated from a test image of 4 X4. It seems that any image i use, i still get a symmetrical matrix with ones in the diagonal.

The matrix B comes from the product of A and A transposed.

$A= \begin{bmatrix} 0.12452 & 0.65243 & 0.56703 & 0.48714 \\ 0.32858 & 0.34674 & 0.25193 & -0.84163 \\ 0.49466 & -0.65422 & 0.56457 & 0.092583 \\ 0.79489 & 0.16158 & -0.5443 & 0.21398\end{bmatrix}
$

$A'= \begin{bmatrix} 0.12452 & 0.32858 & 0.49466 & 0.79489 \\ 0.65243 & 0.34674 & -0.65422 & -0.16158 \\ 0.56703 & 0.25193 & 0.56457 & -0.5443 \\ 0.48714 & -0.84163 & 0.092583 & 0.21398\end{bmatrix}
$
• Aug 9th 2007, 11:12 PM
beberenne
JakeD, if i let the roundings to be zero, then i would not get the correct answer. As you can see, matrix B is the product of A and A transpose as shown above. By letting the roundings to be zero, then i would not get back A.
• Aug 10th 2007, 12:10 AM
JakeD
Quote:

Originally Posted by beberenne
I have experimented with a 4X4 image. The matrix obtain from the image is B.

$
B = \begin{bmatrix} 1 & -3.8858e-016 & 1.0408e-016 & -2.7756e-017 \\ -3.8858e-016 & 1 & -2.3592e-016 & -2.7756e-01 \\ 1.0408e-016 & -2.3592e-016 & 1 & -1.8041e-016 \\ -2.7756e-017 & -2.7756e-016 & -1.8041e-016 & 1\end{bmatrix}
$

Quote:

Originally Posted by beberenne
Sorry about the typo error. The matrix is symmetrical. The matrix is obtained through a test matrix A multiplied by A transposed. The matrix is generated from a test image of 4 X4. It seems that any image i use, i still get a symmetrical matrix with ones in the diagonal.

The matrix B comes from the product of A and A transposed.

$A= \begin{bmatrix} 0.12452 & 0.65243 & 0.56703 & 0.48714 \\ 0.32858 & 0.34674 & 0.25193 & -0.84163 \\ 0.49466 & -0.65422 & 0.56457 & 0.092583 \\ 0.79489 & 0.16158 & -0.5443 & 0.21398\end{bmatrix}
$

$A'= \begin{bmatrix} 0.12452 & 0.32858 & 0.49466 & 0.79489 \\ 0.65243 & 0.34674 & -0.65422 & -0.16158 \\ 0.56703 & 0.25193 & 0.56457 & -0.5443 \\ 0.48714 & -0.84163 & 0.092583 & 0.21398\end{bmatrix}
$

Quote:

Originally Posted by beberenne
JakeD, if i let the roundings to be zero, then i would not get the correct answer. As you can see, matrix B is the product of A and A transpose as shown above. By letting the roundings to be zero, then i would not get back A.

Multiplying AA' yields
Code:

1.0000e+00  -1.4105e-06  -8.6817e-06  3.1304e-06
-1.4105e-06  1.0000e+00  2.6298e-06  -6.2810e-06
-8.6817e-06  2.6298e-06  1.0000e+00  6.8791e-06
3.1304e-06  -6.2810e-06  6.8791e-06  1.0000e+00

which is not the matrix B you gave above. Is this a different matrix, or is it different because the A matrix wasn't printed with enough precision? Anyway, the B matrix still looks strange. Why is it so close to the identity matrix?
• Aug 10th 2007, 12:18 AM
beberenne
JakeD, i also noticed this problem and did some manual calculations on it. I think is the rounding error of the MATLAB. Mentioning earlier about the eigenvectors of B are not orthogonal, actually they are. At first they seem not as there are rounding errors. But when i manually check, they are orthogonal.

Now the problem is to find D. I'm having problems with finding D as my eigenvalues obtained trough MATLAB are all ones in the diagonal except for [1,1] which is a negative small value.

On why the B similar to an identity matrix, this i do not know. :confused:
• Aug 10th 2007, 12:35 AM
JakeD
Quote:

Originally Posted by beberenne
JakeD, i also noticed this problem and did some manual calculations on it. I think is the rounding error of the MATLAB. Mentioning earlier about the eigenvectors of B are not orthogonal, actually they are. At first they seem not as there are rounding errors. But when i manually check, they are orthogonal.

Now the problem is to find D. I'm having problems with finding D as my eigenvalues obtained trough MATLAB are all ones in the diagonal except for [1,1] which is a negative small value.

From what you showed before, that eigenvalue is effectively zero except for rounding error. In the absence of rounding error, the eigenvalues have to be positive because B is positive definite as I argued before.
Quote:

On why the B similar to an identity matrix, this i do not know. :confused:
I think this is the main issue. Resolve this and things should work.
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last