3

I've tried the following in order to reproduce the screenshot below, but I haven't been successful. Any suggestions?

\begin{gather*}
    [p(\theta)]= \sqrt{\frac{2}{3}}
    {\left[
    \cos({\theta}) \cos (\theta -\frac{2\pi}{3}) \cos{\theta + \frac{2\pi}{3}}  
    -\sin({\theta}) -\sin (\theta -\frac{2\pi}{3}) -\sin{\theta + \frac{2\pi}{3}} 
    \frac{1}{\sqrt{2}} \frac{1}{\sqrt{2}} \frac{1}{\sqrt{2}}
    \right]}
\end{gather*}

enter image description here

Ingmar
  • 6,690
  • 5
  • 26
  • 47

3 Answers3

7

What you need is a bmatrix -- short for "matrix surrounded by square brackets" -- environment. I suppose it's a matter of taste whether one prefers \frac notation or inline-fraction notation for the terms in the cells of the matrix.

Both possibilities are illustrated in the following screenshot. For the upper matrix -- the one that uses \frac notation -- I suggest (a) using \bigl( and \bigr) for the parentheses that enclose the \frac{2\pi}{3} terms and (b) increasing the spacing between the rows by \jot (a length parameter with a default value of 3pt) in order to keep the cell contents from touching each other. Note that these adjustments aren't necessary in the lower matrix -- the one that employs inline-fraction notation. The lower matrix is wider than the upper matrix, but takes up less vertical space.

enter image description here

Note the use of \phantom{-} directives in row 1 of each matrix to align the cells' contents with those in row 2.

\documentclass{article}
\usepackage{amsmath} % for 'bmatrix' env.

\begin{document}

\begin{align} [P(\theta)] &= \sqrt{\frac{2}{3}} \begin{bmatrix} \phantom{-}\cos(\theta) & \phantom{-}\cos\bigl(\theta - \frac{2\pi}{3}\bigr) & \phantom{-}\cos\bigl(\theta + \frac{2\pi}{3}\bigr) \[\jot] -\sin(\theta) & -\sin\bigl(\theta - \frac{2\pi}{3}\bigr) & -\sin\bigl(\theta + \frac{2\pi}{3}\bigr) \[\jot] \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \end{bmatrix} \[2\jot] % end of first row &= \sqrt{2/3} \begin{bmatrix} \phantom{-}\cos(\theta) & \phantom{-}\cos(\theta - 2\pi/3) & \phantom{-}\cos(\theta + 2\pi/3) \ -\sin(\theta) & -\sin(\theta - 2\pi/3) & -\sin(\theta + 2\pi/3) \ 1/\sqrt{2} & 1/\sqrt{2} & 1/\sqrt{2} \end{bmatrix} \end{align}

\end{document}

Mico
  • 506,678
7

You can use tabularray to enhence the bmatrix. In the second example, I add a blank before first row to align with second row.

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\begin{document}
\begin{equation}
[P(\theta)]=\sqrt{\frac{2}{3}}
\begin{+bmatrix}
\cos({\theta})     & \cos (\theta -\frac{2\pi}{3})  & \cos(\theta + \frac{2\pi}{3})  \\
-\sin({\theta})    & -\sin (\theta -\frac{2\pi}{3}) & -\sin(\theta + \frac{2\pi}{3}) \\
\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}             & \frac{1}{\sqrt{2}}             \\
\end{+bmatrix}
\end{equation}

\begin{equation} [P(\theta)]=\sqrt{\frac{2}{3}} \begin{+bmatrix}[row{1}={preto=\hphantom{-}}] \cos({\theta}) & \cos (\theta -\frac{2\pi}{3}) & \cos(\theta + \frac{2\pi}{3}) \ -\sin({\theta}) & -\sin (\theta -\frac{2\pi}{3}) & -\sin(\theta + \frac{2\pi}{3}) \ \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \ \end{+bmatrix} \end{equation} \end{document}

enter image description here

Clara
  • 6,012
4

You can reproduce the picture

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathptmx}

\begin{document}

[ [P(\theta)]=\sqrt{\frac{2}{3}} \begin{bmatrix} \cos\theta & \cos(\theta-\dfrac{2\pi}{3}) & \cos(\theta+\dfrac{2\pi}{3}) \ -\sin\theta & -\sin(\theta-\dfrac{2\pi}{3}) & -\sin(\theta+\dfrac{2\pi}{3}) \ \dfrac{1}{\sqrt{2}} & \dfrac{1}{\sqrt{2}} & \dfrac{1}{\sqrt{2}} \end{bmatrix} ]

\end{document}

enter image description here

But, looking at the output, you clearly see that there are several aspects to fix:

  1. the parentheses are wrong, because too short;
  2. the first two lines touch each other;
  3. the symbols are too big inside the matrix.

You might fix just the first two aspects noted above. First of all with NewTX instead of mathptmx, larger parentheses and some vertical space:

\documentclass{article}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}

\begin{document}

[ [P(\theta)]=\sqrt{\frac{2}{3}} \begin{bmatrix} \cos\theta & \cos\Bigl(\theta-\dfrac{2\pi}{3}\Bigr) & \cos\Bigl(\theta+\dfrac{2\pi}{3}\Bigr) \[2ex] -\sin\theta & -\sin\Bigl(\theta-\dfrac{2\pi}{3}\Bigr) & -\sin\Bigl(\theta+\dfrac{2\pi}{3}\Bigr) \[1.5ex] \dfrac{1}{\sqrt{2}} & \dfrac{1}{\sqrt{2}} & \dfrac{1}{\sqrt{2}} \end{bmatrix} ]

\end{document}

enter image description here

However, I'd use smaller fractions in the first two rows and slashed fractions in the last row.

\documentclass{article}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}

\begin{document}

[ [P(\theta)]=\sqrt{\frac{2}{3}} \begin{bmatrix} \cos\theta & \cos\bigl(\theta-\frac{2\pi}{3}\bigr) & \cos\bigl(\theta+\frac{2\pi}{3}\bigr) \[1ex] -\sin\theta & -\sin\bigl(\theta-\frac{2\pi}{3}\bigr) & -\sin\bigl(\theta+\frac{2\pi}{3}\bigr) \[1ex] 1/\sqrt{2} & 1/\sqrt{2} & 1/\sqrt{2} \end{bmatrix} ]

\end{document}

enter image description here

egreg
  • 1,121,712
  • 1
    Going with the OP's screenshot, what may be needed is not so much \lvert P(\theta)\rvert but, rather, \begin{bmatrix} P(\theta) \end{bmatrix}. +1, otherwise. (I employed the OP's own code, [p(\theta)], in my answer, but I agree that P is more precise than p.) – Mico Apr 29 '23 at 22:00
  • 1
    @Mico Thanks: i need to check my glasses… – egreg Apr 30 '23 at 10:24