# Matrix function problem

Discussion in 'Homework Help' started by FBorges22, Jun 14, 2010.

1. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
Greetings..

I am trying to solve this question but I don't remember how to solve this type of question... Given a matrix A below... How I can calculate the cos($A\pi/4$)?

$
A =
$\begin{array}{ccc} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 2 & 1 & -2 \end{array}$
$

Thanks,
FBorges22

2. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
782
Replace each element aij in the matrix with the value

$cos(\frac{a_{ij}\pi}{4})$

So if aij=0

$cos(\frac{0\pi}{4})=cos(0)=1$

and so on ...

Last edited: Jun 14, 2010
3. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
That is not the right solution... some of my colleagues stated that is necessary to find the eigeinvalues of the matrix and perform some operations that I cannot remember very well... What alternative methods are available? do you know anyone?

thanks

4. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,281
326
The well known series expansion of Cos(x) is:

1 - x^2/2! + x^4/4! - x^6/6!...

Substitute A*pi/4 for x in the series and take the limit. If you only need a numerical approximation, just take several terms of the series.

Using Mathematica, I get an exact solution, shown in the attachment.

File size:
1.6 KB
Views:
20
5. ### Georacer Moderator

Nov 25, 2009
5,142
1,266
What do the eighenvalues have to do with this problem? If that's the right question, then I guess the right answer is the one t n k gave.

6. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
Previously, I tried to make a point to point substitution... But that is the not the right way.

$
cos(\pi*A/4)=
$\begin{array}{cc} cos(0) & cos(\pi/4) & cos(0) \\ cos(0) & cos(0) & cos(\pi/4) \\ cos(\pi/2) & cos(\pi/4) & cos(-\pi/2) \\ \end{array}$=

$\begin{array}{cc} 1 & sqrt{2}/2 & 1 \\ 1 & 1 & sqrt{2}/2 \\ 0 & sqrt{2}/2 & 0 \\ \end{array}$
$

To do the things right I must always work with the equivalent related to the Taylor series??? Could you send the Mathematica script to me, please?

Last edited: Jun 15, 2010
7. ### Georacer Moderator

Nov 25, 2009
5,142
1,266
No, the table you just calculated is the right one. I quite sure! Matlab stands on my side too!

8. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
I remember that I showed this to the my professor and he disagrees with me but I don't know why... Could you send the Matlab script to me??

9. ### Georacer Moderator

Nov 25, 2009
5,142
1,266
It's nothing fancy. I just define the table:

A=[0 1 0; 0 0 1; 2 1 -2];

and then do the operation:

cos(A*pi()/4)

10. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
Interesting... the table is all right... I do not know why my professor said something concerned about the eigenvalues in this problem... This is strange...

11. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,281
326
Have a look at this:

http://mathworld.wolfram.com/MatrixExponential.html

The result you get when you calculate the exponential of the individual elements of a matrix may not be the same as when you use the series to evaluate with the whole matrix as the argument.

The same difference exists for other functions of a matrix, such as the cosine.

In addition to the series method, you also can use the eigenvalue decomposition to calculate the matrix exponential.

12. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
Humm... interesting...

Do you think that my solution is correct? The Matlab agrees with me but I am very concerned about the commentary from my professor.

13. ### Georacer Moderator

Nov 25, 2009
5,142
1,266
We all know (at least I do) that a professor isn't by a loooong shot a god or a guru. But let's not allow disbelief land between you and your professor. Is this question so important? Do you get one shot and that's all? What's so bad about talking about this with him? Professors are people too!

14. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,281
326
It all depends on whether the matrix function Cos() is wanted, or just the cosine of the individual elements.

I would suspect the professor wants the matrix function because he mentioned using eigenvalues, which are not needed if all that is wanted is the cosine applied to the individual elements (multiplied by pi/4, of course).

15. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
Yes! It is the matrix function that he asking... How should I determinate?

16. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,281
326
The matrix must be diagonalizable, which, lucky for you, it is.

Diagonalize the matrix as shown in:

http://www.sosmath.com/matrix/diagonal/diagonal.html

When you get down to part 4, you will end up with an eigenvalue decomposition for your matrix (I have used E for the matrix of eigenvalues to avoid confusion with your matrix designator of A):

$A=P*E*P^{-1}$

I would recommend that you multiply this out to see if you get back your original matrix; this will guarantee that you have done it right so far.

Now, replace the diagonal elements of E, Enn, with cos(Enn*pi/4), giving a new matrix E'.

Multiply out the expression:

$P*E^'*P^{-1}$

Giving:

$Cos(A*\frac{\pi}{4})=P*E^'*P^{-1}$

Last edited: Jun 17, 2010
17. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
This technique that you showed, in your post, is very similar to the calculation of Jordan Canonical Form... that was also a subject that I saw recently... I always find this a little hard and I am having trouble understanding well... Could you show a little more clear example please?

Thanks,

18. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,281
326
I think it would be better if you would try to follow the steps I outlined with your actual matrix A, and then if it doesn't work out, I can help you determine where you went wrong.

Calculate the eigenvalues and eigenvectors of A.

Create P, a matrix whose columns are the eigenvectors of A, with each eigenvector in the same column as the associated eigenvalue in the matrix E. Create E, a 3x3 matrix whose diagonal elements are the eigenvalues of A, the other elements being zero.

Carry out the multiplications I showed with the numerical matrices.

Last edited: Jun 17, 2010
19. ### FBorges22 Thread Starter Active Member

Sep 11, 2008
104
0
Ok... Here we go: Given the matrix A

$
A = $\begin{array}{ccc} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 2 & 1 & -2 \end{array}$
$

Finding the eigenvalues...

$
A = $\begin{array}{ccc} 0-\lambda & 1 & 0 \\ 0 & 0-\lambda & 1 \\ 2 & 1 & -2-\lambda \end{array}$ = \lambda^{3}+2\lambda^2+\lambda-2 = (\lambda+1)(\lambda+2)(\lambda-1)
$

And that we conclude that the eigenvalues are: $\lambda_{1}=-1$,$\lambda_{2}=-2$,$\lambda_{3}=1$ Now, if we pick the $\lambda_{3}$ and solve the $(A-\lambda_{3}I)v=0$ equation we have:

$
$\begin{array}{ccc} -1 & 1 & 2 \\ 0 & -2 & 1 \\ 2 & 1 & -3 \end{array}$ $\begin{array}{ccc} x \\ y \\ z \end{array}$ = $\begin{array}{ccc} 0 \\ 0 \\ 0 \end{array}$
$

Building the linear system we have:

$
\{
-x+y+2z=0 \\
-2y+z=0 \\
2x+y-3z=0 \\
$

Solving the system we have:

$
y=x/5$
and$z = 2x/5
$

Then, the egeinvector associated with $\lambda_{3}$ is $v_{3}= $\begin{array}{ccc} 1 & 1/5 & 2/5 \\ \end{array}$^{T}
$

The same operation for the $\lambda_{1}$ we get the eigenvector:

$v_{1}= $\begin{array}{ccc} 1 & -1/5 & -2/5 \\ \end{array}$^{T}
$

Well I am doing correct so far? I am still solving the question... Soon I will post the continuation

20. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,281
326
You haven't done this right. The correct result should be:

$
$\begin{array}{ccc} -1 & 1 & 0 \\ 0 & -1 & 1 \\ 2 & 1 & -3 \end{array}$ $\begin{array}{ccc} x \\ y \\ z \end{array}$ = $\begin{array}{ccc} 0 \\ 0 \\ 0 \end{array}$
$

Is there some reason why you have to go through the process of finding the eigenvalues and eigenvectors yourself? Why not just use a mathematical package such as Matlab? Having found them, the part you need to do is set up the product $P*E^'*P^{-1}$

Previous error fixed. In post #18, I said "Create P, a matrix whose columns are two eigenvectors of A. Create E, a 2x2 matrix whose diagonal elements are the eigenvalues of A."

That should have been "Create P, a matrix whose columns are the eigenvectors of A, with each eigenvector in the same column as the associated eigenvalue in the matrix E. Create E, a 3x3 matrix whose diagonal elements are the eigenvalues of A, the other elements being zero."

Last edited: Jun 17, 2010
FBorges22 likes this.