Writing a Matrix: Tips & Suggestions

  • Thread starter Thread starter trap101
  • Start date Start date
  • Tags Tags
    Matrix Writing
trap101
Messages
339
Reaction score
0
My apologies if this is in the wring place, but is there any way that I can write a matrix out on this forum? Maybe set up a table in excel or word and copy over? Any suggestions?
 
Physics news on Phys.org
trap101 said:
My apologies if this is in the wring place, but is there any way that I can write a matrix out on this forum? Maybe set up a table in excel or word and copy over? Any suggestions?

You can use plain text, like this: A = [[a,b],[c,d]] (and explain that this means [row1,row2]), or you can use tex, like this:
A = \left[ \begin{array}{cc} a & b \\ c & d \end{array} \right].

The instructions used for the latter are:
"[t e x] A = \left[ \b e g i n{a r r a y}{cc} a & b \\ c & d \e n d{a r r a y} \right]. [/ t e x]"
When you type it out, remove the quotation marks and remove the spaces within words, so type 'tex' instead of 't e x', type 'begin' instead of 'b e g i n', type 'array' instead of 'a r r a y', etc. You don't need to remove spaces inside formulas, so it is OK to type a & b \\ c & d, etc. If you prefer rounded brackets, change '\left[' to '\left(', and similarly for '\right'. That would give
A = \left( \begin{array}{cc} a & b \\ c & d \end{array} \right).

RGV
 
trap101 said:
My apologies if this is in the wring place, but is there any way that I can write a matrix out on this forum? Maybe set up a table in excel or word and copy over? Any suggestions?

The nicest way is to use LaTeX. Here's an example with the tags showing (with extra spaces in the tags so that they will show).

[ tex] \ begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \ end{bmatrix}[ /tex]

Removing the extra spaces in the tex tags and the begin and end statements produces this 3 x 3 matrix:
\begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{bmatrix}
 
Thank you gentlemen.
 
\begin{bmatrix}2&0&6\\6&8&8\\0&6&8\end{bmatrix}
 
\ begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \ end{bmatrix}
 
begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \ end{bmatrix}
 
begin{bmatrix}2&0&6\\6&8&8\\0&6&8\end{bmatrix}
 
A = \left[ \begin{array}{cc} 3&4\\ 2&2\end{array}\right].
 
  • #10
[ tex]\begin{bmatrix} 2&6&0\\0&2&0\\0&0&3\end{bmatrix}[ /tex]
 
  • #11
\begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{bmatrix}
 
  • #12
Looks good.

As you can see, the LaTeX that Ray Vickson and I wrote, both produce matrices. For simple matrices, the \begin{bmatrix} ... \end{bmatrix} style is easier, IMO.

The b in bmatrix stands for bracket - []. There's also a pmatrix style that uses parentheses () to surround the matrix. There's another form that I don't recall at the moment - I think it surrounds the matrix with vertical lines, like you would use for a determinant.

There are lots of summaries and tutorials on the Web, so a search for "latex tutorial" will get you a bunch of links. There's also a sticky post in Forum Feedback and Announcements here at PF (https://www.physicsforums.com/showthread.php?t=546968) that gives an overview of the things you can do.

If you need to do more complicated matrices, then the style that Ray showed is more versatile, allowing you to write augmented matrices and other stuff.
 
  • #13
Appreciated. Definitely something I'll probably have to use in the future when it comes to programming too, so i might as well get a fix on it.

Cheers
 
  • #14
trap101 said:
Appreciated. Definitely something I'll probably have to use in the future when it comes to programming too, so i might as well get a fix on it.

Cheers

It might not have been obvious to you, but between the column separators " & " you can put any formula; and, if you use the "array" form you can justify the columns (separately); for example, "{ccc}" means "center" the items in each column; "lcr" means left-justify column 1, center column 2 and right-justify column 3; you might want to do this for something like:
<br /> A = \left[ \begin{array}{lcr} <br /> abba &amp; a_{11}x_1^2 + \ln(x_2) &amp; 12.0 \\ <br /> aaabbbaa &amp; \sqrt{x_1^2 + x_2^2} &amp; 125.4 \end{array} \right].

RGV
 
Back
Top