基本功能:数学公式

Page content

本文旨在测试博客模板(mainroad)对数学公式输入的支持效果。

模版支持mathJax插件,但其版本比较旧,相关的设置也不完善,比如不支持行内公式的渲染。因此首先在原模板的基础上需要进行一些修改,参考mathJax文档网站中的命令。

<script>
MathJax = {
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']]
  }
};
</script>
<script id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>

对数学公式进行一些测试。

来源:

行内公式

质能方程:$E=mc^2$。欧拉方程:$e^{i\pi}+1=0$。

块级公式

麦克斯韦方程组:

$$ \begin{aligned} \nabla \cdot \vec{E} &= \frac{\rho}{\varepsilon_0} \\ \nabla \cdot \vec{B} &= 0 \\ \nabla \times \vec{E} &= -\frac{\partial \vec{B}}{\partial t} \\ \nabla \times \vec{B} &= \mu_0 \left(\vec{J} + \varepsilon_0 \frac{\partial \vec{E}}{\partial t}\right) \end{aligned} $$

$$ \left. \frac{{\rm d}u}{{\rm d}x} \right| _{x=0} $$

公式编号

公式编号:

$$ \begin{aligned} \text{公式1} & = \int_{a}^{b} f(x) dx \label{eq1} \\ \text{公式2} & = \int_{a}^{b} g(x) dx \end{aligned} $$

公式1:

$$ \int_{a}^{b} f(x) dx = \frac{1}{2} \left[f(a) + f(b)\right] \tag {1.1} $$

公式2:

$$ \int_{a}^{b} g(x) dx = \frac{1}{2} \left[g(a) + g(b)\right] \tag {1.2} $$

$$ f\left( \left[ \frac{ 1+\left\{x,y\right\} }{ \left( \frac xy + \frac yx \right) (u+1) }+a \right]^{3/2} \right) \tag {1.3} $$

矩阵

$ \begin{matrix} 1 & 2 \\ 3 & 4 \\ \end{matrix} $ $ \begin{pmatrix} 1 & 2 \\ 3 & 4 \\ \end{pmatrix} $ $ \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} $ $ \begin{Bmatrix} 1 & 2 \\ 3 & 4 \\ \end{Bmatrix} $ $ \begin{vmatrix} 1 & 2 \\ 3 & 4 \\ \end{vmatrix} $ $ \begin{Vmatrix} 1 & 2 \\ 3 & 4 \\ \end{Vmatrix} $

$$ \begin{pmatrix} 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{pmatrix} $$

方程组

$$ \left\{ \begin{array}{c} a_1x+b_1y+c_1z &=d_1 \\ a_2x+b_2y+c_2z &=d_2 \\ a_3x+b_3y+c_3z &=d_3 \\ \end{array} \right. $$

分段函数

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

$$ \begin{array}{c|lcr} n & \text{左对齐} & \text{居中对齐} & \text{右对齐} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \end{array} $$