Updated documentation.
This commit is contained in:
114
EXAMPLES.md
114
EXAMPLES.md
@@ -1,13 +1,13 @@
|
||||
# MathRender Examples
|
||||
# SwiftMath Examples
|
||||
|
||||
## Square of sums
|
||||
```LaTeX
|
||||
(a_1 + a_2)^2 = a_1^2 + 2a_1a_2 + a_2^2
|
||||
```
|
||||
|
||||
As rendered by MathJax: $(a_1 + a_2)^2 = a_1^2 + 2a_1a_2 + a_2^2$
|
||||
MathJax: $(a_1 + a_2)^2 = a_1^2 + 2a_1a_2 + a_2^2$
|
||||
|
||||
MathRender:
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
@@ -16,12 +16,21 @@ MathRender:
|
||||
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
|
||||
```
|
||||
|
||||
MathJax: $x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Standard Deviation
|
||||
```LaTeX
|
||||
\sigma = \sqrt{\frac{1}{N}\sum_{i=1}^N (x_i - \mu)^2}
|
||||
```
|
||||
|
||||
MathJax: $\sigma = \sqrt{\frac{1}{N}\sum_{i=1}^N (x_i - \mu)^2}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## De Morgan's laws
|
||||
@@ -29,6 +38,10 @@ x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
|
||||
\neg(P\land Q) \iff (\neg P)\lor(\neg Q)
|
||||
```
|
||||
|
||||
MathJax: $\neg(P\land Q) \iff (\neg P)\lor(\neg Q)$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Log Change of Base
|
||||
@@ -36,6 +49,10 @@ x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
|
||||
\log_b(x) = \frac{\log_a(x)}{\log_a(b)}
|
||||
```
|
||||
|
||||
MathJax: $\log_b(x) = \frac{\log_a(x)}{\log_a(b)}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Cosine addition
|
||||
@@ -43,6 +60,10 @@ x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
|
||||
\cos(\theta + \varphi) = \cos(\theta)\cos(\varphi) - \sin(\theta)\sin(\varphi)
|
||||
```
|
||||
|
||||
MathJax: $\cos(\theta + \varphi) = \cos(\theta)\cos(\varphi) - \sin(\theta)\sin(\varphi)$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Limit e^k
|
||||
@@ -50,6 +71,10 @@ x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
|
||||
\lim_{x\to\infty}\left(1 + \frac{k}{x}\right)^x = e^k
|
||||
```
|
||||
|
||||
MathJax: $\lim_{x\to\infty}\left(1 + \frac{k}{x}\right)^x = e^k$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Calculus
|
||||
@@ -57,6 +82,10 @@ x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
|
||||
f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\xi
|
||||
```
|
||||
|
||||
MathJax: $f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\xi$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Stirling Numbers of the Second Kind
|
||||
@@ -64,6 +93,10 @@ f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\
|
||||
{n \brace k} = \frac{1}{k!}\sum_{j=0}^k (-1)^{k-j}\binom{k}{j}(k-j)^n
|
||||
```
|
||||
|
||||
MathJax: ${n \brace k} = \frac{1}{k!}\sum_{j=0}^k (-1)^{k-j}\binom{k}{j}(k-j)^n$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Gaussian Integral
|
||||
@@ -71,6 +104,10 @@ f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\
|
||||
\int_{-\infty}^{\infty} \! e^{-x^2} dx = \sqrt{\pi}
|
||||
```
|
||||
|
||||
MathJax: $\int_{-\infty}^{\infty} \! e^{-x^2} dx = \sqrt{\pi}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Arithmetic mean, geometric mean inequality
|
||||
@@ -78,12 +115,21 @@ f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\
|
||||
\frac{1}{n}\sum_{i=1}^{n}x_i \geq \sqrt[n]{\prod_{i=1}^{n}x_i}
|
||||
```
|
||||
|
||||
MathJax: $\frac{1}{n}\sum_{i=1}^{n}x_i \geq \sqrt[n]{\prod_{i=1}^{n}x_i}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Cauchy-Schwarz inequality
|
||||
```LaTeX
|
||||
\left(\sum_{k=1}^n a_k b_k \right)^2 \le \left(\sum_{k=1}^n a_k^2\right)\left(\sum_{k=1}^n b_k^2\right)
|
||||
```
|
||||
|
||||
MathJax: $\left(\sum_{k=1}^n a_k b_k \right)^2 \le \left(\sum_{k=1}^n a_k^2\right)\left(\sum_{k=1}^n b_k^2\right)$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Cauchy integral formula
|
||||
@@ -91,13 +137,23 @@ f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\
|
||||
f^{(n)}(z_0) = \frac{n!}{2\pi i}\oint_\gamma\frac{f(z)}{(z-z_0)^{n+1}}dz
|
||||
```
|
||||
|
||||
MathJax: $f^{(n)}(z_0) = \frac{n!}{2\pi i}\oint_\gamma\frac{f(z)}{(z-z_0)^{n+1}}dz$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Schroedinger's Equation
|
||||
```LaTeX
|
||||
i\hbar\frac{\partial}{\partial t}\mathbf\Psi(\mathbf{x},t) = -\frac{\hbar}{2m}\nabla^2\mathbf\Psi(\mathbf{x},t)
|
||||
+ V(\mathbf{x})\mathbf\Psi(\mathbf{x},t)
|
||||
```
|
||||
|
||||
MathJax: $i\hbar\frac{\partial}{\partial t}\mathbf\Psi(\mathbf{x},t) = -\frac{\hbar}{2m}\nabla^2\mathbf\Psi(\mathbf{x},t)
|
||||
+ V(\mathbf{x})\mathbf\Psi(\mathbf{x},t)$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Lorentz Equations
|
||||
@@ -111,6 +167,14 @@ equations.
|
||||
\end{gather}
|
||||
```
|
||||
|
||||
MathJax: $\begin{gather}
|
||||
\dot{x} = \sigma(y-x) \\
|
||||
\dot{y} = \rho x - y - xz \\
|
||||
\dot{z} = -\beta z + xy"
|
||||
\end{gather}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Cross product
|
||||
@@ -122,6 +186,14 @@ equations.
|
||||
\end{vmatrix}
|
||||
```
|
||||
|
||||
MathJax: $\vec \bf V_1 \times \vec \bf V_2 = \begin{vmatrix}
|
||||
\hat \imath &\hat \jmath &\hat 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}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Maxwell's Equations
|
||||
@@ -136,6 +208,15 @@ multiple equations.
|
||||
\end{eqalign}
|
||||
```
|
||||
|
||||
MathJax: $begin{eqalign}
|
||||
\nabla \cdot \vec{\bf E} & = \frac {\rho} {\varepsilon_0} \\
|
||||
\nabla \cdot \vec{\bf B} & = 0 \\
|
||||
\nabla \times \vec{\bf E} &= - \frac{\partial\vec{\bf B}}{\partial t} \\
|
||||
\nabla \times \vec{\bf B} & = \mu_0\vec{\bf J} + \mu_0\varepsilon_0 \frac{\partial\vec{\bf E}}{\partial t}
|
||||
\end{eqalign}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Matrix multiplication
|
||||
@@ -154,6 +235,19 @@ c\alpha + d\gamma & c\beta + d \delta
|
||||
\end{pmatrix}
|
||||
```
|
||||
|
||||
MathJax: $\begin{pmatrix}
|
||||
a & b\\ c & d
|
||||
\end{pmatrix}
|
||||
\begin{pmatrix}
|
||||
\alpha & \beta \\ \gamma & \delta
|
||||
\end{pmatrix} =
|
||||
\begin{pmatrix}
|
||||
a\alpha + b\gamma & a\beta + b \delta \\
|
||||
c\alpha + d\gamma & c\beta + d \delta
|
||||
\end{pmatrix}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Cases
|
||||
@@ -164,6 +258,13 @@ f(x) = \begin{cases}
|
||||
\end{cases}
|
||||
```
|
||||
|
||||
MathJax: $f(x) = \begin{cases}
|
||||
\frac{e^x}{2} & x \geq 0 \\
|
||||
1 & x < 0
|
||||
\end{cases}$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
## Splitting long equations
|
||||
@@ -174,4 +275,11 @@ f(x) = \begin{cases}
|
||||
\left( o_t - \hat{\mu}_m^{(s)} \right) ^T \cal C_m^{(s)-1} \right)
|
||||
```
|
||||
|
||||
MathJax: $\frak Q(\lambda,\hat{\lambda}) =
|
||||
-\frac{1}{2} \mathbb P(O \mid \lambda ) \sum_s \sum_m \sum_t \gamma_m^{(s)} (t) +\\
|
||||
\quad \left( \log(2 \pi ) + \log \left| \cal C_m^{(s)} \right| +
|
||||
\left( o_t - \hat{\mu}_m^{(s)} \right) ^T \cal C_m^{(s)-1} \right)$
|
||||
|
||||
SwiftMath:
|
||||
|
||||

|
||||
|
||||
21
README.md
21
README.md
@@ -4,6 +4,10 @@
|
||||
for displaying beautifully rendered math equations in iOS and MacOS applications. It typesets formulae written
|
||||
using LaTeX in a `UILabel` equivalent class. It uses the same typesetting rules as LaTeX and
|
||||
so the equations are rendered exactly as LaTeX would render them.
|
||||
`
|
||||
SwiftMath` is a Swift translation of the latest `iosMath` v0.9.5 release but includes bug fixes
|
||||
and enhancements like a new \lbar (lambda bar) character and cyrillic alphabet support.
|
||||
Please let me know of any bugs or bug fixes that you find.
|
||||
|
||||
`SwiftMath` prepackages everything needed for direct access via the Swift Package Manager.
|
||||
No need for complicated alien pods that never seem to work quite right.
|
||||
@@ -16,12 +20,29 @@ importantly, it is significantly faster than using a `UIWebView`.
|
||||
## Examples
|
||||
Here are screenshots of some formulae that were rendered with this library:
|
||||
|
||||
```LaTeX
|
||||
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
|
||||
```
|
||||
|
||||

|
||||
|
||||
```LaTeX
|
||||
f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\xi
|
||||
```
|
||||
|
||||

|
||||
|
||||
```LaTeX
|
||||
\frac{1}{n}\sum_{i=1}^{n}x_i \geq \sqrt[n]{\prod_{i=1}^{n}x_i}
|
||||
```
|
||||
|
||||

|
||||
|
||||
```LaTex
|
||||
\frac{1}{\left(\sqrt{\phi \sqrt{5}}-\phi\\right) 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} } } }
|
||||
```
|
||||
|
||||

|
||||
|
||||
More examples are included in [EXAMPLES](EXAMPLES.md)
|
||||
|
||||
Reference in New Issue
Block a user