Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

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

Is it possible to insert a trigonometric function into a matrix which will be able to be used dynamically, as an element of one of the vectors of the matrix?

I'm trying to perform an operation like the following:

A1 = {{1,        0,        0},
      {Sin[phi], Cos[phi], 0},
      {0,        0,        1}};

A2 = {{Sec[phi], -Tan[phi] ,0},
      {0,        1,         0},
      {0,        0,         1}};

I'd like to be able to multiply those two matrices:

A1.A2 (*For mathematica*)
- or -
A1*A2 (*For humans*)

Figuring this out will hopefully allow me to create a function such that it simplifies the transformation process. This will allow me to write a function like the following:

trans[x_,y_]:= A1.A2.{x,y,1};

Note that phi represents a random value which I'd like the matrix to respond to, for example:

x = {2,4};

A = {{Sin[phi], 0},
     {0,        1}};

A.x = {Sin[2], 4};
share|improve this question

closed as off-topic by m_goldberg, Pinguin Dirk, Sjoerd C. de Vries, Michael E2, R. M. Nov 23 '13 at 0:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – R. M.
If this question can be reworded to fit the rules in the help center, please edit the question.

I'm still confused because A.x represents the matrix/vector multiplication of A and x, which in your example would result in {2 Sin[phi],4}, but it seems you want the first term replaced with Sin[2]. Is that correct? – Cassini Nov 22 '13 at 1:36
up vote 1 down vote accepted

If I understand your question correctly, you just need:

A[x_] = {{1,0,0},{Sin[x], Cos[x], 0},{0,0,1}}

Also if you are just looking for the rotation matrix, you can use RotationTransform function

share|improve this answer
I'm experimenting with manual transformations, thanks for the reference but it's not needed. However you did show what I needed. Basically to create a function out of the matrices, such that the vales are in fact, variable. – MayBee Nov 22 '13 at 2:27
Also you notice that I use = instead of :=. This is more convenient if the rhs can be computed ahead of assignment. Though not too much difference here. – Shenghui Nov 22 '13 at 5:07

Not sure I understand your question, but it seems like you just need to format your trig function calls in Mathematica syntax to accomplish what you're asking.

A1 = {{1, 0, 0}, {Sin[phi], Cos[phi], 0}, {0, 0, 1}};
A2 = {{Sec[phi], -Tan[phi], 0}, {0, 1, 0}, {0, 0, 1}};
trans[x_, y_] := A1.A2.{x, y, 1};
trans[x, y]
{x Sec[phi] - y Tan[phi], x Tan[phi] + y (Cos[phi] - Sin[phi] Tan[phi]), 1}
share|improve this answer
It's not the syntax, I corrected that above btw, I mean, there must be something I'm not doing correctly because when I try to use the function it returns the functions as if they hadn't taken phi as anything. – MayBee Nov 22 '13 at 0:12
Does phi have a value? Are you trying to use it as an argument. Sorry, but I guess I still don't understand. – Cassini Nov 22 '13 at 0:14
Phi is supposed to be the argument which will be anything which I'd like to multiply by. For example: {Sin[x],0} x (π/2) = {1,0} So no value, just as some type of argument. – MayBee Nov 22 '13 at 0:19
I understood your explanation completely and it worked, but I wanted to make the function more dynamic. I'd gladly up this answer if I could but apparently it takes 15+ reputation to do such thing. Thank you for your help. – MayBee Nov 22 '13 at 2:25

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