Skip to content

Commit c63ef37

Browse files
authored
Render mathematical expressions in documentation with mathjax (#97)
* Mathjax in docs * Added source of Javascripts * Removed odd whitespaces
1 parent 06f3af6 commit c63ef37

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

docs/javascripts/mathjax.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Taken from:
2+
// https://squidfunk.github.io/mkdocs-material/reference/mathjax/#docsjavascriptsmathjaxjs
3+
window.MathJax = {
4+
tex: {
5+
inlineMath: [["\\(", "\\)"]],
6+
displayMath: [["\\[", "\\]"]],
7+
processEscapes: true,
8+
processEnvironments: true
9+
},
10+
options: {
11+
ignoreHtmlClass: ".*|",
12+
processHtmlClass: "arithmatex"
13+
}
14+
};
15+
16+
document$.subscribe(() => {
17+
MathJax.typesetPromise()
18+
})

matfree/hutch.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ def quadform(vec):
2222

2323

2424
def frobeniusnorm_squared(matvec_fun, /, **kwargs):
25-
"""Estimate the squared Frobenius norm of a matrix stochastically."""
25+
r"""Estimate the squared Frobenius norm of a matrix stochastically.
26+
27+
The Frobenius norm of a matrix $A$ is defined as
28+
29+
$$
30+
\|A\|_F^2 = \text{trace}(A^\top A)
31+
$$
32+
33+
so computing squared Frobenius norms amounts to trace estimation.
34+
"""
2635

2736
def quadform(vec):
2837
Av = matvec_fun(vec)

mkdocs.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ extra:
5353
name: Nico
5454
generator: false
5555
copyright: Copyright © 2023 Nicholas Krämer
56-
markdown_extensions: [pymdownx.superfences]
56+
markdown_extensions:
57+
- pymdownx.superfences
58+
- pymdownx.arithmatex:
59+
generic: true
60+
extra_javascript:
61+
# From: https://squidfunk.github.io/mkdocs-material/reference/mathjax/#mkdocsyml
62+
- javascripts/mathjax.js
63+
- https://polyfill.io/v3/polyfill.min.js?features=es6
64+
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

0 commit comments

Comments
 (0)