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

I'm new to Mathematica. I've been reading the 'Documentation Center' but can't find a clue about composing two functions which in my case are matrices.

Here's the setup. let T01 be a homogeneous transform matrix, and T12 another one. The two of them are function of q1 & q2 :

T01[q1_, q2_] = {{Cos[q1 Degree], 0, Sin[q1 Degree], 0}, {0, 1, 0, 0},
 {-Sin[q1 Degree], 0, Cos[q1 Degree], 0}, {0, 0, 0,  1}};

T12[q1_, q2_] = {{Cos[q2 Degree], 0, Sin[q2 Degree], 0}, {0, 1, 0,  0}, 
{-Sin[q2 Degree], 0, Cos[q2 Degree], -l1}, {0, 0, 0, 1}};

I'd like to create a function T02 so that T02[q1_,q_2]=T01[q1_,q2_].T02[q1_,q_2]

How should I do this? I tried the Composition[] function already but I may be missing something...

I tried this :

 Composition[T01,T02][q1_,q2_]

But I didn't get any results...

Thanks for the help in advance.

share|improve this question
2  
In the strict sense, composing T01 and T12 is not defined, because each of them are functions mapping an ordered pair (Mathematica Sequence) into a $4$ by $4$ matrix: because such a matrix is not an ordered pair, composition is impossible. If you want to compose the matrices that these functions return, considered as endomorphisms of a four-dimensional vector space, then matrix multiplication does the trick (this is a theorem but it's elementary). – whuber Jan 20 at 12:35

closed as too localized by Ajasja, Jens, Artes, ssch, rcollyer Jan 21 at 20:03

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

up vote 5 down vote accepted

I think T[q1_, q2_] = T01[q1, q2].T12[q1, q2] will be ok.

share|improve this answer
@whuber : Thanks for the explanation! Now I now when and how should the Composition[] function be used. – jrojasqu Jan 20 at 17:32
Thanks for the tip. I tried it and it worked just as needed. I just couldn't believe it would be so simple... Thanks again! @yulinlinyu – jrojasqu Jan 20 at 17:37

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