专注于快乐的事情

Latex表示矩阵和其他用法

矩阵

基本用法

使用$$\begin{matrix}...\end{matrix}$$来表示矩阵,在\begin与\end之间加入矩阵的元素即可。矩阵的行之间用\分隔,列之间用&分隔。

例如 $$\begin{matrix} 1 & x & x^2 \\\\ 1 & y & y^2 \\\\ 1 & z & z^2 \end{matrix}$$ 结果:

$$\begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \end{matrix}$$

加括号

可以使用特殊的matrix,即替换\begin{matrix}...\end{matrix}中的matrix为pmatrix , bmatrix , Bmatrix , vmatrix , Vmatrix.

pmatrix

\begin{pmatrix} 1 & 2 \\\\ 3 & 4 \\\\ \end{pmatrix}:$$\begin{pmatrix} 1 & 2 \\ 3 & 4 \\ \end{pmatrix}$$

bmatrix

\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\\\ \end{bmatrix}:$$\begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix}$$

省略元素

可以使用\cdots ⋯ \ddots ⋱ \vdots ⋮来省略矩阵中的元素,如:

\begin{Vmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^n \\\\ 1 & a_2 & a_2^2 & \cdots & a_2^n \\\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\\ 1 & a_m & a_m^2 & \cdots & a_m^n \end{Vmatrix}

$$\begin{Vmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^n \\ 1 & a_2 & a_2^2 & \cdots & a_2^n \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & a_m & a_m^2 & \cdots & a_m^n \end{Vmatrix}$$

对齐的公式

\begin{align} \sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\ & = \sqrt{\frac{73^2}{12^2} \cdot \frac{73^2-1}{73^2}} \\ & = \frac{73}{12} \sqrt{1 - \frac{1}{73^2}} \\ & \approx \frac{73}{12} \left( 1 - \frac{1}{2 \cdot 73^2} \right) \end{align}

需要使用形如\begin{align}...\end{align}的格式,其中需要使用&来指示需要对齐的位置

$$\begin{align} \sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}}\\
& = \sqrt{\frac{73^2}{12^2} \cdot \frac{73^2-1}{73^2}} \\\
& = \frac{73}{12} \sqrt{1 - \frac{1}{73^2}} \\
& \approx \frac{73}{12} \left( 1 - \frac{1}{2 \cdot 73^2} \right) \end{align}$$

分类表达式

定义函数的时候经常需要分情况给出表达式,可使用\begin{cases}...\end{cases}。其中,使用\来分类,使用&指示需要对齐的位置。如:

f(n) = \begin{cases} n/2, & \text{if $n$ is even} \\\\\ 3n+1, & \text{if $n$ is odd} \end{cases}

$$f(n) = \begin{cases} n/2, & \text{if $n$ is even} \\\ 3n+1, & \text{if $n$ is odd} \end{cases}$$

参考资料

https://www.cnblogs.com/linxd/p/4955530.html

评论系统未开启,无法评论!