Ask Your Question
1

How to calculate sine of a matrix

asked 2012-02-03 02:00:41 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi I want to calcilate sin(Mt) which M is a 3 by 3 matrix. I have no problem with calculating exp(Mt) but it seems the sine is different! I will be pleased if anyone could help...

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2012-02-03 02:11:02 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

You could just use

$$ sin(x) = \frac{exp(ix)-exp(-ix)}{2*i} $$

edit flag offensive delete link more
0

answered 2012-02-03 10:50:00 +0100

kcrisman gravatar image

I'm just putting down some thoughts here that hopefully someone else will know about.

sage: M = matrix([[2,3],[3,2]])
sage: e^M
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: mutable matrices are unhashable
sage: exp(M)
[1/2*(e^6 + 1)*e^(-1) 1/2*(e^6 - 1)*e^(-1)]
[1/2*(e^6 - 1)*e^(-1) 1/2*(e^6 + 1)*e^(-1)]
sage: M.exp()
[1/2*(e^6 + 1)*e^(-1) 1/2*(e^6 - 1)*e^(-1)]
[1/2*(e^6 - 1)*e^(-1) 1/2*(e^6 + 1)*e^(-1)]

Naturally, this is really because there isn't any sin method. However:

sage: M = matrix([[2,3],[3,2]])
sage: M.simp[tab] # nothing
sage: M = matrix(SR,[[2,3],[3,2]])
sage: M.simp[tab]
M.simplify           M.simplify_rational  M.simplify_trig

There still isn't a sin. But this could be doable. Of course, the question remains as to how many such things we would want to add. Thoughts?

edit flag offensive delete link more
0

answered 2012-02-03 13:43:11 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I'm trying to understand what you are doing with sin(Mt). Is one of these what you want?

sage: m=random_matrix(QQ,3); m
[-1  0 -1]
[-1  1  2]
[-2  0  1]
sage: m.apply_map(sin)
[-sin(1)       0 -sin(1)]
[-sin(1)  sin(1)  sin(2)]
[-sin(2)       0  sin(1)]
sage: t=var('t')
sage: (m*t).apply_map(sin)
[  sin(-t)         0   sin(-t)]
[  sin(-t)    sin(t)  sin(2*t)]
[sin(-2*t)         0    sin(t)]

Or do you mean you want to calculate the series $\sum_{k=0}^{\infty} (-1)^{k}\frac{M^{2k+1}}{(2k+1)!}$?

edit flag offensive delete link more

Comments

Ah, I *knew* there was a way to do this that we had already added. But seriously, I think @saeed1922 wants the latter. Why doesn't e^M work, though? Or more precisely, where does the error come from? I can't find it in e.__pow__??

kcrisman gravatar imagekcrisman ( 2012-02-03 20:25:12 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-02-03 02:00:41 +0100

Seen: 2,832 times

Last updated: Feb 03 '12