Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a $2x2$ matrix $M$. $M$ has the following form:

M = {{a, bExp[-2ikz]}, {bExp[2ikz], a}}

$a, b, k - const.$

z is variable that takes values from the range 0, 10, 20, 30, 40 ......300. I need 30 different matrices M1, M2....M30 corresponding to the values of z - 0, 10, 20.....300 and then multiply those matrices. How can I do that with Mathematica ?

share|improve this question
Don't define 30 variables... define one function M[k_Integer] := {{a, b Exp[-2I k z]}, {b Exp[2I k z], a}}, and call it as M[1], M[2], etc. Note that the imaginary quantity is I, not i. You also need spaces between variables – kz is different from k z. This is quite possibly a duplicate of several and will most likely be closed. – R. M. Sep 19 '13 at 17:17

I think the following codes are for your problem ;

In order to obtain the M[1], M[2],... M[30] matrices, you can define them as a function. Namely,

M[z_] := {{a, b*Exp[-2 I*k*10z]}, {b*Exp[2 I*k*10z], a}}

To product two matrices, you can use the . between two matrices. For example;

M[1].M[2]={{a^2 + b^2 E^(420 I),a b E^(-420 I) + a b E^(-840 I)}, {a b E^(420 I) + a b E^(840 I),a^2 + b^2 E^(-420 I)}}

where I is i.

share|improve this answer
Thank you for the suggestions. Now how does the full codes look like? What kind of looping do I need here? – Hpaudel Sep 19 '13 at 18:26
@Hpaudel, try Array[M, 30, 1, Dot] – Simon Woods Sep 19 '13 at 18:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.