Ask Your Question

# How to calculate sine of a matrix

asked 2012-02-03 02:00:41 +0200 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 close merge delete

## 3 Answers

Sort by » oldest newest most voted

answered 2012-02-03 02:11:02 +0200 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}$$

more

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?

more

answered 2012-02-03 13:43:11 +0200 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)!}$?

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__??

## Your Answer

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

Add Answer

## Stats

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

Seen: 2,249 times

Last updated: Feb 03 '12