添加数学公式
常用公式代码
Markdown | 效果 | |
---|---|---|
上标 | x^2 | x 2 x^2 x2 |
下标(1) | y_1 | y 1 y_1 y1 |
下标(2) | y_{11} | y 11 y_{11} y11 |
分式(1) | 1/2 | 1 / 2 1/2 1/2 |
分式(2) | \frac{1}{2} | 1 2 \frac{1}{2} 21 |
省略号(横) | \cdots | ⋯ \cdots ⋯ |
省略号(竖) | \vdots | ⋮ \vdots ⋮ |
省略号(斜) | \ddots | ⋱ \ddots ⋱ |
开根号 | \sqrt{2} | 2 \sqrt{2} 2 |
积分(1) | \int{x}dx | ∫ x d x \int{x}dx ∫xdx |
积分(2) | \int_{1}^{2}dx | ∫ 1 2 d x \int_{1}^{2}dx ∫12dx |
微分 | \displaystyle \frac{\partial x}{\partial y} | ∂ x ∂ y \displaystyle \frac{\partial x}{\partial y} ∂y∂x |
大括号 | {x+y} | { x + y } \{x+y\} {x+y} |
大括号(上) | \overbrance{a+b}^{2} | a + b + c ⏞ 2.0 \overbrace{a+b+c}^{2.0} a+b+c 2.0 |
大括号(下) | a+\underbrance{b+c}_{2}+d | a + b + c ⏟ 2 + d a+\underbrace{b+c}_{2}+d a+2 b+c+d |
空格 | \qquad | x y x\qquad y xy |
绝对值 | |a| | ∥ a ∥ \|a\| ∥a∥ |
对数 | \log_2 5 | log 2 5 \log_2{5} log25 |
矩阵 | \begin{matrix} \end{matrix} | [ 1 x x 2 1 y y 2 1 z z 2 ] \left[\begin{matrix}1 & x & x^2\\1 & y & y^2\\1 & z & z^2\\\end{matrix} \right] ⎣⎡111xyzx2y2z2⎦⎤ |
大于 | \geq | x + y ≥ z x+y \geq z x+y≥z |
小于 | \leq | x + y ≤ z x+y \leq z x+y≤z |
不等于 | \neq | x ≠ z x \neq z x=z |
约等于 | \approx | 2 3 ≈ 0.66 \frac{2}{3} \approx 0.66 32≈0.66 |
属于 | \in | x ∈ A x \in A x∈A |
不属于 | \notin | x ∉ B x \notin B x∈/B |
子集 | \subset | A ⊂ B A \subset B A⊂B |
真子集 | \subseteq | A ⊆ B A \subseteq B A⊆B |
交集 | \cap | A ∩ B = C A \cap B = C A∩B=C |
并集 | \cup | A ∪ B = D A \cup B = D A∪B=D |
无穷 | \infty | ∞ \infty ∞ |
累加 | \sum | ∑ n = 1 + ∞ a n \sum_{n=1}^{+\infty}{a_n} ∑n=1+∞an |
累乘 | \prod | ∏ n = 1 + ∞ a n \prod_{n=1}^{+\infty}{a_n} ∏n=1+∞an |
三角函数(sin) | \sin | sin x 2 \sin{x^2} sinx2 |
三角函数(cos) | \cos | cos x 2 \cos{x^2} cosx2 |
三角函数(tan) | \tan | tan x \tan{x} tanx |
希腊字母
Markdown | 效果 |
---|---|
\alpha | α \alpha α |
\beta | β \beta β |
\gamma | γ \gamma γ |
\delta | δ \delta δ |
\epsilon | ϵ \epsilon ϵ |
\zeta | ζ \zeta ζ |
\varepsilon | ε \varepsilon ε |
\eta | η \eta η |
\theta | θ \theta θ |
\iota | ι \iota ι |
\kappa | κ \kappa κ |
\lambda | λ \lambda λ |
\mu | μ \mu μ |
\nu | ν \nu ν |
\xi | ξ \xi ξ |
\omicron | ο \omicron ο |
\pi | π \pi π |
\rho | ρ \rho ρ |
\sigma | σ \sigma σ |
\tau | τ \tau τ |
\upsilon | υ \upsilon υ |
\phi | ϕ \phi ϕ |
\varphi | φ \varphi φ |
\chi | χ \chi χ |
\psi | ψ \psi ψ |
\omega | ω \omega ω |
- 行列式
代码:
$$
x=\left|\begin{matrix}x_{11} & x_{12} & \cdots & x_{1d}\\x_{21} & x_{22} & \cdots & x_{2d}\\\vdots & \vdots & \ddots & \vdots \\x_{11} & x_{12} & \cdots & x_{1d}\\\end{matrix}\right|
$$
效果:
x = ∣ x 11 x 12 ⋯ x 1 d x 21 x 22 ⋯ x 2 d ⋮ ⋮ ⋱ ⋮ x 11 x 12 ⋯ x 1 d ∣ x=\left|\begin{matrix}x_{11} & x_{12} & \cdots & x_{1d}\\x_{21} & x_{22} & \cdots & x_{2d}\\\vdots & \vdots & \ddots & \vdots \\x_{11} & x_{12} & \cdots & x_{1d}\\\end{matrix}\right| x=∣∣∣∣∣∣∣∣∣x11x21⋮x11x12x22⋮x12⋯⋯⋱⋯x1dx2d⋮x1d∣∣∣∣∣∣∣∣∣
- 矩阵
代码:
$$
\left[\begin{matrix}1 & x & x^2\\1 & y & y^2\\1 & z & z^2\\\end{matrix} \right]
$$
效果:
[
1
x
x
2
1
y
y
2
1
z
z
2
]
\left[\begin{matrix}1 & x & x^2\\1 & y & y^2\\1 & z & z^2\\\end{matrix} \right]
⎣⎡111xyzx2y2z2⎦⎤
- 方程组
代码:
$$
\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.
$$
效果:
{
a
1
x
+
b
1
y
+
c
1
z
=
d
1
a
2
x
+
b
2
y
+
c
2
z
=
d
2
a
3
x
+
b
3
y
+
c
3
z
=
d
3
\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.
⎩⎨⎧a1x+b1y+c1z=d1a2x+b2y+c2z=d2a3x+b3y+c3z=d3
- 函数
代码:
$$
f(n)= \begin{cases} n/2, & \text{if $n$ is even}\\ 3n+1,& \text{if $n$ is odd} \end{cases}
$$
效果:
f
(
n
)
=
{
n
/
2
,
if
n
is even
3
n
+
1
,
if
n
is odd
f(n)= \begin{cases} n/2, & \text{if $n$ is even}\\ 3n+1,& \text{if $n$ is odd} \end{cases}
f(n)={n/2,3n+1,if n is evenif n is odd
- 推导公式
代码:
$$
\begin{aligned} \frac{\partial J(\theta)}{\partial\theta_j} & = -\frac1m\sum_{i=0}^m(y^i - h_\theta(x^i)) \frac{\partial}{\partial\theta_j}(y^i-h_\theta(x^i))\\ & = -\frac1m\sum_{i=0}^m(y^i-h_\theta(x^i)) \frac{\partial}{\partial\theta_j}(\sum_{j=0}^n\theta_j x^i_j-y^i)\\ &=-\frac1m\sum_{i=0}^m(y^i -h_\theta(x^i)) x^i_j\end{aligned}
$$
效果:
∂ J ( θ ) ∂ θ j = − 1 m ∑ i = 0 m ( y i − h θ ( x i ) ) ∂ ∂ θ j ( y i − h θ ( x i ) ) = − 1 m ∑ i = 0 m ( y i − h θ ( x i ) ) ∂ ∂ θ j ( ∑ j = 0 n θ j x j i − y i ) = − 1 m ∑ i = 0 m ( y i − h θ ( x i ) ) x j i \begin{aligned} \frac{\partial J(\theta)}{\partial\theta_j} & = -\frac1m\sum_{i=0}^m(y^i - h_\theta(x^i)) \frac{\partial}{\partial\theta_j}(y^i-h_\theta(x^i))\\ & = -\frac1m\sum_{i=0}^m(y^i-h_\theta(x^i)) \frac{\partial}{\partial\theta_j}(\sum_{j=0}^n\theta_j x^i_j-y^i)\\ &=-\frac1m\sum_{i=0}^m(y^i -h_\theta(x^i)) x^i_j\end{aligned} ∂θj∂J(θ)=−m1i=0∑m(yi−hθ(xi))∂θj∂(yi−hθ(xi))=−m1i=0∑m(yi−hθ(xi))∂θj∂(j=0∑nθjxji−yi)=−m1i=0∑m(yi−hθ(xi))xji
流程图
代码示例:
(```mermaid
flowchat
graph LR
st=>start: 开始框
op=>operation: 处理框
cond=>condition: 判断框(是或否?)
sub1=>subroutine: 子流程
io=>inputoutput: 输入输出框
e=>end: 结束框
st->op->cond
cond(yes)->io->e
cond(no)->sub1(right)->op
```)