Update to README.md and graphic files.

This commit is contained in:
Michael Griebling
2024-10-06 16:29:28 -04:00
parent 9fecdcf563
commit 99dc4ad8de
46 changed files with 81 additions and 33 deletions

View File

@@ -5,91 +5,104 @@
(a_1 + a_2)^2 = a_1^2 + 2a_1a_2 + a_2^2
```
![Square Formula](img/square.png)
![Square Formula](img/square-light.png#gh-light-mode-only)
![Square Formula](img/square-dark.png#gh-dark-mode-only)
## Quadratic Formula
```LaTeX
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
```
![Quadratic Formula](img/quadratic.png)
![Quadratic Formula](img/quadratic-light.png#gh-light-mode-only)
![Quadratic Formula](img/quadratic-dark.png#gh-dark-mode-only)
## Standard Deviation
```LaTeX
\sigma = \sqrt{\frac{1}{N}\sum_{i=1}^N (x_i - \mu)^2}
```
![Standard Deviation](img/standard.png)
![Standard Deviation](img/standard-light.png#gh-light-mode-only)
![Standard Deviation](img/standard-dark.png#gh-dark-mode-only)
## De Morgan's laws
```LaTeX
\neg(P\land Q) \iff (\neg P)\lor(\neg Q)
```
![De Morgan](img/demorgan.png)
![De Morgan](img/demorgan-light.png#gh-light-mode-only)
![De Morgan](img/demorgan-dark.png#gh-dark-mode-only)
## Log Change of Base
```LaTeX
\log_b(x) = \frac{\log_a(x)}{\log_a(b)}
```
![Log Base Change](img/log.png)
![Log Base Change](img/log-light.png#gh-light-mode-only)
![Log Base Change](img/log-dark.png#gh-dark-mode-only)
## Cosine addition
```LaTeX
\cos(\theta + \varphi) = \cos(\theta)\cos(\varphi) - \sin(\theta)\sin(\varphi)
```
![Cos Sum](img/trig.png)
![Cos Sum](img/trig-light.png#gh-light-mode-only)
![Cos Sum](img/trig-dark.png#gh-dark-mode-only)
## Limit e^k
```LaTeX
\lim_{x\to\infty}\left(1 + \frac{k}{x}\right)^x = e^k
```
![Limit](img/limit.png)
![Limit](img/limit-light.png#gh-light-mode-only)
![Limit](img/limit-dark.png#gh-dark-mode-only)
## Calculus
```LaTeX
f(x) = \int\limits_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\xi
```
![Calculus](img/calculus.png)
![Calculus](img/calculus-light.png#gh-light-mode-only)
![Calculus](img/calculus-dark.png#gh-dark-mode-only)
## Stirling Numbers of the Second Kind
```LaTeX
{n \brace k} = \frac{1}{k!}\sum_{j=0}^k (-1)^{k-j}\binom{k}{j}(k-j)^n
```
![Stirling Numbers](img/stirling.png)
![Stirling Numbers](img/stirling-light.png#gh-light-mode-only)
![Stirling Numbers](img/stirling-dark.png#gh-dark-mode-only)
## Gaussian Integral
```LaTeX
\int_{-\infty}^{\infty} \! e^{-x^2} dx = \sqrt{\pi}
```
![Gauss Integral](img/gaussintegral.png)
![Gauss Integral](img/gaussintegral-light.png#gh-light-mode-only)
![Gauss Integral](img/gaussintegral-dark.png#gh-dark-mode-only)
## Arithmetic mean, geometric mean inequality
```LaTeX
\frac{1}{n}\sum_{i=1}^{n}x_i \geq \sqrt[n]{\prod_{i=1}^{n}x_i}
```
![AM-GM](img/amgm.png)
![AM-GM](img/amgm-light.png#gh-light-mode-only)
![AM-GM](img/amgm-dark.png#gh-dark-mode-only)
## 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)
```
![Cauchy Schwarz](img/cauchyschwarz.png)
![Cauchy Schwarz](img/cauchyschwarz-light.png#gh-light-mode-only)
![Cauchy Schwarz](img/cauchyschwarz-dark.png#gh-dark-mode-only)
## Cauchy integral formula
```LaTeX
f^{(n)}(z_0) = \frac{n!}{2\pi i}\oint_\gamma\frac{f(z)}{(z-z_0)^{n+1}}dz
```
![Cauchy Integral](img/cauchyintegral.png)
![Cauchy Integral](img/cauchyintegral-light.png#gh-light-mode-only)
![Cauchy Integral](img/cauchyintegral-dark.png#gh-dark-mode-only)
## Schroedinger's Equation
```LaTeX
@@ -97,7 +110,8 @@ i\hbar\frac{\partial}{\partial t}\mathbf\Psi(\mathbf{x},t) = -\frac{\hbar}{2m}\n
+ V(\mathbf{x})\mathbf\Psi(\mathbf{x},t)
```
![Schroedinger](img/schroedinger.png)
![Schroedinger](img/schroedinger-light.png#gh-light-mode-only)
![Schroedinger](img/schroedinger-dark.png#gh-dark-mode-only)
## Lorentz Equations
Use the `gather` or `displaylines` environments to center multiple
@@ -110,7 +124,8 @@ equations.
\end{gather}
```
![Lorentz](img/lorentz.png)
![Lorentz](img/lorentz-light.png#gh-light-mode-only)
![Lorentz](img/lorentz-dark.png#gh-dark-mode-only)
## Cross product
```LaTeX
@@ -121,7 +136,8 @@ equations.
\end{vmatrix}
```
![Cross Product](img/cross.png)
![Cross Product](img/cross-light.png#gh-light-mode-only)
![Cross Product](img/cross-dark.png#gh-dark-mode-only)
## Maxwell's Equations
Use the `aligned`, `eqalign` or `split` environments to align
@@ -135,7 +151,8 @@ multiple equations.
\end{eqalign}
```
![Maxwell's Equations](img/maxwell.png)
![Maxwell's Equations](img/maxwell-light.png#gh-light-mode-only)
![Maxwell's Equations](img/maxwell-dark.png#gh-dark-mode-only)
## Matrix multiplication
Supported matrix environments: `matrix`, `pmatrix`, `bmatrix`, `Bmatrix`,
@@ -153,7 +170,8 @@ c\alpha + d\gamma & c\beta + d \delta
\end{pmatrix}
```
![Matrix Multiplication](img/matrixmult.png)
![Matrix Multiplication](img/matrixmult-light.png#gh-light-mode-only)
![Matrix Multiplication](img/matrixmult-dark.png#gh-dark-mode-only)
## Cases
```LaTeX
@@ -163,7 +181,8 @@ f(x) = \begin{cases}
\end{cases}
```
![Cases](img/cases.png)
![Cases](img/cases-light.png#gh-light-mode-only)
![Cases](img/cases-dark.png#gh-dark-mode-only)
## Splitting long equations
```LaTeX
@@ -173,4 +192,5 @@ f(x) = \begin{cases}
\left( o_t - \hat{\mu}_m^{(s)} \right) ^T \cal C_m^{(s)-1} \right)
```
![Long equation](img/long.png)
![Long equation](img/long-light.png#gh-light-mode-only)
![Long equation](img/long-dark.png#gh-dark-mode-only)

View File

@@ -3,7 +3,10 @@
`SwiftMath` provides a full Swift implementation of [iosMath](https://travis-ci.org/kostub/iosMath)
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.
so the equations are rendered exactly as LaTeX would render them.
Please also check out [SwiftMathDemo](https://github.com/mgriebling/SwiftMathDemo.git) for examples of how to use `SwiftMath`
from SwiftUI.
`SwiftMath` is similar to [MathJax](https://www.mathjax.org) or
[KaTeX](https://github.com/Khan/KaTeX) for the web but for native iOS or MacOS
@@ -25,31 +28,35 @@ Here are screenshots of some formulae that were rendered with this library:
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
```
![Quadratic Formula](img/quadratic.png)
![Quadratic Formula](img/quadratic-light.png#gh-light-mode-only)
![Quadratic Formula](img/quadratic-dark.png#gh-dark-mode-only)
```LaTeX
f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\xi
```
![Calculus](img/calculus.png)
![Calculus](img/calculus-light.png#gh-light-mode-only)
![Calculus](img/calculus-dark.png#gh-dark-mode-only)
```LaTeX
\frac{1}{n}\sum_{i=1}^{n}x_i \geq \sqrt[n]{\prod_{i=1}^{n}x_i}
```
![AM-GM](img/amgm.png)
![AM-GM](img/amgm-light.png#gh-light-mode-only)
![AM-GM](img/amgm-dark.png#gh-dark-mode-only)
```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} } } }
```
![Ramanujan Identity](img/ramanujan.png)
![Ramanujan Identity](img/ramanujan-light.png#gh-light-mode-only)
![Ramanujan Identity](img/ramanujan-dark.png#gh-dark-mode-only)
More examples are included in [EXAMPLES](EXAMPLES.md)
## Requirements
`SwiftMath` works on iOS 11+ or MacOS 11+. It depends
`SwiftMath` works on iOS 11+ or MacOS 12+. It depends
on the following Apple frameworks:
* Foundation.framework
@@ -155,7 +162,7 @@ This is a list of formula types that the library currently supports:
* Greek alphabet
* Combinatorics (\\binom, \\choose etc.)
* Geometry symbols (e.g. angle, congruence etc.)
* Ratios, proportions, percents
* Ratios, proportions, percentages
* Math spacing
* Overline and underline
* Math accents
@@ -165,6 +172,18 @@ This is a list of formula types that the library currently supports:
* Most commonly used math symbols
* Colors
Note: SwiftMath only supports the commands in LaTeX's math mode. There is
also no language support for other than west European langugages and some
Cyrillic characters. There would be two ways to support more languages:
1) Find a math font compatible with `SwiftMath` that contains all the glyphs
for that language.
2) Add support to `SwiftMath` for standard Unicode fonts that contain all
langauge glyphs.
Of these two, the first is much easier. However, if you want a challenge,
try to tackle the second option.
### Example
The [SwiftMathDemo](https://github.com/mgriebling/SwiftMathDemo) is a SwiftUI version
@@ -194,10 +213,10 @@ label.textAlignment = .center
```
##### Font size
The default font-size is 25pt. You can change it as follows:
The default font-size is 30pt. You can change it as follows:
```swift
label.fontSize = 30
label.fontSize = 25
```
##### Font
The default font is *Latin Modern Math*. This can be changed as:
@@ -206,11 +225,18 @@ The default font is *Latin Modern Math*. This can be changed as:
label.font = MTFontManager.fontmanager.termesFont(withSize:20)
```
This project has 3 fonts bundled with it, but you can use any OTF math
font. Note: I couldn't get the `iosMath` Python script to work. If
you do manage to get it working, please let me know.
This project has five fonts bundled with it, but you can use any OTF math
font. A python script is included that generates the `.plist` files
required for an `.otf` font to work with `SwiftMath`. If you generate
(and test) any other fonts please contribute them back to this project for
others to benefit.
##### Color
Note: The `KpMath-Light` and `KpMath-Sans` fonts current do not correctly
render very large radicals correctly. It appears that the font files do
not correctly define the offsets required to typeset these glyphs. If
anyone can fix this, it would be greatly appreciated.
##### Text Color
The default color of the rendered equation is black. You can change
it to any other color as follows:
@@ -278,3 +304,5 @@ licensed as follows:
[GUST Font License](GUST-FONT-LICENSE.txt)
* [XITS Math](https://github.com/khaledhosny/xits-math):
[Open Font License](OFL.txt)
* [KpMath Light/KpMath Sans](http://scripts.sil.org/OFL):
[SIL Open Font License](OFL.txt)

BIN
img/amgm-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
img/calculus-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

BIN
img/cases-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
img/cauchyintegral-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

BIN
img/cauchyschwarz-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

BIN
img/cross-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

BIN
img/demorgan-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
img/gaussintegral-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
img/limit-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
img/log-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
img/long-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

BIN
img/lorentz-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

BIN
img/matrixmult-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/maxwell-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

BIN
img/quadratic-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
img/ramanujan-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/schroedinger-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/square-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
img/st-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
img/standard-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

BIN
img/stirling-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/trig-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB