====== Math formulas ======
You can include math formulas inside your wiki pages, like this:
<math block>a^2 + b^2 = c^2</math>
<math block>f(x) = \int_{-\infty}^\infty
\hat f(\xi)\,e^{2 \pi i \xi x}
\,d\xi</math>
or even inline (inside the body of your text, like so:
We know <math>\frac {1}{0}</math> is indeterminant.
===== Syntax =====
The general syntax for including a math formula is:
''%%<math>%%//LaTex math formula//%%</math>%%''
for inline formulas, and:
''%%<math block>%%//LaTex math formula//%%</math>%%''
for block formulas.
The syntax for math formulas inside the ''%%<math>%%...%%</math>%%'' tag is [[https://www.latex-project.org/|LaTeX]].
===== Supported LaTeX commands =====
To render LaTeX math formulas, Polifonic uses the excellent [[http://khan.github.io/KaTeX/|KaTex]] library, so the LaTeX commands supported are those supported by KaTeX. The list of supported commands is available [[https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX|here]]. Please note that katex supports a smaller set of features than MathJax. Comparison between the 2 libraries can be found [[http://www.intmath.com/cg5/katex-mathjax-comparison.php|here]].
<alert warning>Please note that Polifonic is neither related to, nor endorsed by, KaTex, MathJax nor LaTex.</alert>
===== Examples =====
<col sm:6>
%%<math block>c = \pm\sqrt{a^2 + b^2}</math>%%
</col>
<col sm:6>
<math block>c = \pm\sqrt{a^2 + b^2}</math>
</col>
<col sm:6>
%%<math block>\forall x \in X, \quad \exists y \leq \epsilon</math>%%
</col>
<col sm:6>
<math block>\forall x \in X, \quad \exists y \leq \epsilon</math>
</col>
<col sm:6>
%%<math block>\cos (2\theta) = \cos^2 \theta - \sin^2 \theta</math>%%
</col>
<col sm:6>
<math block>\cos (2\theta) = \cos^2 \theta - \sin^2 \theta</math>
</col>
<col sm:6>
%%<math block>\lim_{x \to \infty} \exp(-x) = 0</math>%%
</col>
<col sm:6>
<math block>\lim_{x \to \infty} \exp(-x) = 0</math>
</col>
<col sm:6>
%%<math block>\frac{3}{7}</math>%%
</col>
<col sm:6>
<math block>\frac{3}{7}</math>
</col>
<col sm:6>
%%Take <math>\frac{1}{2}</math> cup of sugar, ...%%
%%<math block>3\times\frac{1}{2}=1\frac{1}{2}</math><math block>\frac{3}{7}</math>%%
</col>
<col sm:6>
Take <math>\frac{1}{2}</math> cup of sugar, ...
<math block>3\times\frac{1}{2}=1\frac{1}{2}</math>
</col>
<col sm:6>
%%Take <math>{}^1/_2</math> cup of sugar, ...%%
%%<math block>3\times{}^1/_2=1{}^1/_2</math>%%
</col>
<col sm:6>
Take <math>{}^1/_2</math> cup of sugar, ...
<math block>3\times{}^1/_2=1{}^1/_2</math>
</col>
<col sm:6>
%%<math block>
x = a_0 + \frac{1}{a_1
+ \frac{1}{a_2
+ \frac{1}{a_3 + \frac{1}{a_4} } } }
</math>%%
</col>
<col sm:6>
<math block>
x = a_0 + \frac{1}{a_1
+ \frac{1}{a_2
+ \frac{1}{a_3 + \frac{1}{a_4} } } }
</math>
</col>
===== Other examples =====
The examples below are all taken from the [[http://www.intmath.com/cg5/katex-mathjax-comparison.php|Katex and MathJax comparison demo]] page.
==== Repeating fractions ====
<math block>\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }</math>
==== Summation notation ====
<math block>\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)</math>
==== Sum of a series ====
<math block>\displaystyle\sum_{i=1}^{k+1}i</math>
<math block>\displaystyle= \left(\sum_{i=1}^{k}i\right) +(k+1)</math>
<math block>\displaystyle= \frac{k(k+1)}{2}+k+1</math>
<math block>\displaystyle= \frac{k(k+1)+2(k+1)}{2}</math>
<math block>\displaystyle= \frac{(k+1)(k+2)}{2}</math>
==== Product notation ====
<math block>
\displaystyle
1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots
= \displaystyle \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
\displaystyle\text{ for }\lvert q\rvert < 1.
</math>
==== Inline math ====
And here is some in-line math: <math>k_{n+1} = n^2 + k_n^2 - k_{n-1}</math>, followed by some more text.
==== Greek letters ====
<math block>\Gamma\ \Delta\ \Theta\ \Lambda\ \Xi\ \Pi\ \Sigma\ \Upsilon\ \Phi\ \Psi\ \Omega</math>
<math block>\alpha\ \beta\ \gamma\ \delta\ \epsilon\ \zeta\ \eta\ \theta\ \iota\ \kappa\ \lambda\ \mu\ \nu\ \xi \ \omicron\ \pi\ \rho\ \sigma\ \tau\ \upsilon\ \phi\ \chi\ \psi\ \omega\ \varepsilon\ \vartheta\ \varpi\ \varrho\ \varsigma\ \varphi</math>
==== Arrows ====
<math block>\gets\ \to\ \leftarrow\ \rightarrow\ \uparrow\ \Uparrow\ \downarrow\ \Downarrow\ \updownarrow\ \Updownarrow </math>
<math block>\Leftarrow\ \Rightarrow\ \leftrightarrow\ \Leftrightarrow\ \mapsto\ \hookleftarrow</math>
<math block>\leftharpoonup\ \leftharpoondown\ \rightleftharpoons\ \longleftarrow\ \Longleftarrow\ \longrightarrow</math>
<math block>\Longrightarrow\ \longleftrightarrow\ \Longleftrightarrow\ \longmapsto\ \hookrightarrow\ \rightharpoonup</math>
<math block>\rightharpoondown\ \leadsto\ \nearrow\
\searrow\ \swarrow\ \nwarrow</math>
==== Symbols ====
<math block>\surd\ \barwedge\ \veebar\ \odot\ \oplus\ \otimes\ \oslash\ \circledcirc\ \boxdot\
\bigtriangleup</math>
<math block>\bigtriangledown\ \dagger\ \diamond\ \star\ \triangleleft\
\triangleright\ \angle\ \infty\ \prime\ \triangle</math>
==== Calculus ====
<math block>\int u \frac{dv}{dx}\,dx=uv-\int \frac{du}{dx}v\,dx</math>
<math block>f(x) = \int_{-\infty}^\infty \hat f(\xi)\,e^{2 \pi i \xi x}</math>
<math block>\oint \vec{F} \cdot d\vec{s}=0</math>
==== Lorenz equations ====
Alignment is not supported by KaTex.
<math block>\dot{x} = \sigma(y-x)</math>
<math block>\dot{y} = \rho x - y - xz</math>
<math block>\dot{z} = -\beta z + xy</math>
==== Cross products ====
=== Not working quite well in KaTex ===
<math block>
\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \\
\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0
\end{vmatrix}
</math>
==== Accents ====
<math block>\hat{x}\ \vec{x}\ \ddot{x} </math>
=== Not working in Katex ====
<math block>\overrightarrow{AB}</math>
<math block>A\underset{0^{\circ}C }{\overset{100^{\circ}C}{\rightleftarrows}}B</math>
==== Stretchy brackets ====
<math block>\left(\frac{x^2}{y^3}\right)</math>
==== Evaluation at limits ====
<math block>\left.\frac{x^3}{3}\right|_0^1</math>
==== Case definitions ====
<math block>f(n) = \begin{cases} \frac{n}{2}, & \text{if } n\text{ is even} \\ 3n+1, & \text{if } n\text{ is odd} \end{cases}</math>
==== Maxwell's equations ====
<math block>
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} = \frac{4\pi}{c}\vec{\mathbf{j}}</math>
<math block> \nabla \cdot \vec{\mathbf{E}} = 4 \pi \rho
</math>
<math block>
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} = \vec{\mathbf{0}}
</math>
<math block>
\nabla \cdot \vec{\mathbf{B}} = 0
</math>
==== Statistics ====
Definition of combination:
<math block>\frac{n!}{k!(n-k)!} = {^n}C_k</math>
<math block>{n \choose k}</math>
==== Fractions on fractions ====
<math block>\frac{\frac{1}{x}+\frac{1}{y}}{y-z}</math>
==== n-th root ====
<math block>\sqrt[n]{1+x+x^2+x^3+\ldots}</math>
==== Matrices ====
<math block>\begin{pmatrix}
a_{11} & a_{12} & a_{13}\\
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33}
\end{pmatrix}</math>
<math block>
\begin{bmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{bmatrix}
</math>
==== Punctuation ====
<math block>f(x) = \sqrt{1+x} \quad (x \ge -1)</math>
<math block>f(x) \sim x^2 \quad (x\to\infty)</math>
<math block>f(x) = \sqrt{1+x}, \quad x \ge -1</math>
<math block>f(x) \sim x^2, \quad x\to\infty</math>
<math block></math>
<math block></math>
<math block></math>