|
| 1 | +--- |
| 2 | +title: "MathJax" |
| 3 | +description: "Display engine for LaTeX, MathML, and AsciiMath |
| 4 | +notation that works in all modern browsers." |
| 5 | +--- |
| 6 | + |
| 7 | +[Mathjax](https://github.com/mathjax/MathJax) is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath |
| 8 | +notation that works in all modern browsers. By default mathjax is **enabled** in the config.toml by default and can be |
| 9 | +disabled if library is not used. |
| 10 | + |
| 11 | +Examples, in this page are taken from [here](https://mathjax.github.io/MathJax-demos-web/tex-svg.html). |
| 12 | + |
| 13 | +Automatic equation numbering is on by default as shown in Example 2 |
| 14 | + |
| 15 | +Just insert your mathjax code in the `mathjax` shortcode and that's it. |
| 16 | + |
| 17 | + |
| 18 | +### Example 1 |
| 19 | + |
| 20 | +``` |
| 21 | +{{</*mathjax*/>}} |
| 22 | +
|
| 23 | + When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are |
| 24 | + $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ |
| 25 | +
|
| 26 | +{{</*/mathjax*/>}} |
| 27 | +``` |
| 28 | +renders as |
| 29 | + |
| 30 | +{{<mathjax>}} |
| 31 | + |
| 32 | + When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are |
| 33 | + |
| 34 | + $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ |
| 35 | + |
| 36 | +{{</mathjax>}} |
| 37 | + |
| 38 | +### Example 2 |
| 39 | + |
| 40 | +The Lorenz Equations |
| 41 | + |
| 42 | +``` |
| 43 | +{{</*mathjax*/>}} |
| 44 | +
|
| 45 | + \begin{align} |
| 46 | + \dot{x} & = \sigma(y-x) \\ |
| 47 | + \dot{y} & = \rho x - y - xz \\ |
| 48 | + \dot{z} & = -\beta z + xy |
| 49 | + \end{align} |
| 50 | +
|
| 51 | +{{</*/mathjax*/>}} |
| 52 | +``` |
| 53 | +renders as |
| 54 | + |
| 55 | +{{<mathjax>}} |
| 56 | + |
| 57 | + \begin{align} |
| 58 | + \dot{x} & = \sigma(y-x) \\ |
| 59 | + \dot{y} & = \rho x - y - xz \\ |
| 60 | + \dot{z} & = -\beta z + xy |
| 61 | + \end{align} |
| 62 | + |
| 63 | +{{</mathjax>}} |
| 64 | + |
| 65 | +### Example 3 |
| 66 | + |
| 67 | +The Cauchy-Schwarz Inequality |
| 68 | + |
| 69 | +``` |
| 70 | +{{</*mathjax*/>}} |
| 71 | +
|
| 72 | +\[ |
| 73 | + \left( \sum_{k=1}^n a_k b_k \right)^{\!\!2} \leq |
| 74 | + \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) |
| 75 | + \]< |
| 76 | +
|
| 77 | +{{</*/mathjax*/>}} |
| 78 | +``` |
| 79 | + |
| 80 | +renders as |
| 81 | + |
| 82 | +{{<mathjax>}} |
| 83 | + |
| 84 | +\[ |
| 85 | + \left( \sum_{k=1}^n a_k b_k \right)^{\!\!2} \leq |
| 86 | + \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) |
| 87 | + \]< |
| 88 | + |
| 89 | +{{</mathjax>}} |
| 90 | + |
| 91 | +### Example 4 |
| 92 | + |
| 93 | +A Cross Product Formula |
| 94 | + |
| 95 | +``` |
| 96 | +{{</*mathjax*/>}} |
| 97 | +
|
| 98 | +\[ |
| 99 | + \mathbf{V}_1 \times \mathbf{V}_2 = |
| 100 | + \begin{vmatrix} |
| 101 | + \mathbf{i} & \mathbf{j} & \mathbf{k} \\ |
| 102 | + \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\ |
| 103 | + \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\ |
| 104 | + \end{vmatrix} |
| 105 | + \] |
| 106 | +
|
| 107 | +{{</*/mathjax*/>}} |
| 108 | +``` |
| 109 | + |
| 110 | +renders as |
| 111 | + |
| 112 | +{{<mathjax>}} |
| 113 | +\[ |
| 114 | + \mathbf{V}_1 \times \mathbf{V}_2 = |
| 115 | + \begin{vmatrix} |
| 116 | + \mathbf{i} & \mathbf{j} & \mathbf{k} \\ |
| 117 | + \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\ |
| 118 | + \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\ |
| 119 | + \end{vmatrix} |
| 120 | + \] |
| 121 | + |
| 122 | +{{</mathjax>}} |
| 123 | + |
| 124 | +### Example 5 |
| 125 | + |
| 126 | +The probability of getting \(k\) heads when flipping \(n\) coins is: |
| 127 | + |
| 128 | +``` |
| 129 | +{{</*mathjax*/>}} |
| 130 | +
|
| 131 | + \[P(E) = {n \choose k} p^k (1-p)^{ n-k} \] |
| 132 | + |
| 133 | +{{</*/mathjax*/>}} |
| 134 | +
|
| 135 | +``` |
| 136 | + |
| 137 | +renders as |
| 138 | + |
| 139 | +{{<mathjax>}} |
| 140 | + |
| 141 | +\[P(E) = {n \choose k} p^k (1-p)^{ n-k} \] |
| 142 | + |
| 143 | +{{</mathjax>}} |
| 144 | + |
| 145 | +### Example 6 |
| 146 | + |
| 147 | +An Identity of Ramanujan |
| 148 | + |
| 149 | +``` |
| 150 | +{{</*mathjax*/>}} |
| 151 | +
|
| 152 | + \[ |
| 153 | + \frac{1}{(\sqrt{\phi \sqrt{5}}-\phi) e^{\frac25 \pi}} = |
| 154 | + 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} |
| 155 | + {1+\frac{e^{-8\pi}} {1+\ldots} } } } |
| 156 | + \] |
| 157 | +
|
| 158 | +{{</*/mathjax*/>}} |
| 159 | +``` |
| 160 | + |
| 161 | +renders as |
| 162 | + |
| 163 | +{{<mathjax>}} |
| 164 | + |
| 165 | +\[ |
| 166 | + \frac{1}{(\sqrt{\phi \sqrt{5}}-\phi) e^{\frac25 \pi}} = |
| 167 | + 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} |
| 168 | + {1+\frac{e^{-8\pi}} {1+\ldots} } } } |
| 169 | + \] |
| 170 | + |
| 171 | +{{</mathjax>}} |
| 172 | + |
| 173 | + |
| 174 | +### Example 7 |
| 175 | + |
| 176 | +In-line Mathematics |
| 177 | + |
| 178 | +``` |
| 179 | +{{</*mathjax*/>}} |
| 180 | +
|
| 181 | + Finally, while display equations look good for a page of samples, the |
| 182 | + ability to mix math and text in a paragraph is also important. This |
| 183 | + expression $\sqrt{3x-1}+(1+x)^2$ is an example of an inline equation. As |
| 184 | + you see, MathJax equations can be used this way as well, without unduly |
| 185 | + disturbing the spacing between lines. |
| 186 | +
|
| 187 | +{{</*/mathjax*/>}} |
| 188 | +
|
| 189 | +``` |
| 190 | + |
| 191 | +renders as |
| 192 | + |
| 193 | +{{<mathjax>}} |
| 194 | + Finally, while display equations look good for a page of samples, the |
| 195 | + ability to mix math and text in a paragraph is also important. This |
| 196 | + expression $\sqrt{3x-1}+(1+x)^2$ is an example of an inline equation. As |
| 197 | + you see, MathJax equations can be used this way as well, without unduly |
| 198 | + disturbing the spacing between lines. |
| 199 | +{{</mathjax>}} |
| 200 | + |
| 201 | + |
0 commit comments