Skip to content
Projects
These are the docs of the development version (the devel branch). See the docs of the latest release.

First steps

A notebook that exercises what the converter handles: math, printed output, an image, an HTML table and the cell tags.

The grid spacing is h=(b−a)/nh = (b - a)/n, and the midpoint rule reads

∫abf(x) dx≈h∑i=1nf(xi−1/2).\int_a^b f(x)\,dx \approx h \sum_{i=1}^{n} f(x_{i-1/2}).

Braces {like these} and a stray < are escaped for MDX.

import numpy as np
from example_pkg import Grid, linspace_midpoints
grid = Grid(0.0, np.pi, 8)
print(grid.spacing)
print(grid.spacing * np.sin(linspace_midpoints(0.0, np.pi, 8)).sum())
0.39269908169872414
2.012909085599128
print(grid)
print(grid.nodes())
Show the grid
Grid(start=0.0, stop=3.141592653589793, cells=8)
[0. 0.39269908 0.78539816 1.17809725 1.57079633 1.96349541
2.35619449 2.74889357 3.14159265]
Show code
import matplotlib.pyplot as plt
x = grid.nodes()
fig, ax = plt.subplots(figsize=(5, 2.5))
ax.plot(x, np.sin(x), "o-")
ax.set_xlabel("x")
plt.show()
Notebook output
from IPython.display import HTML
HTML(
"<table><tr><th>cells</th><th>spacing</th></tr>"
+ "".join(f"<tr><td>{n}</td><td>{np.pi / n:.4f}</td></tr>" for n in (4, 8, 16))
+ "</table>"
)
cellsspacing
40.7854
80.3927
160.1963
raise ValueError(
"shown on the page, and not a failure: the cell is tagged raises-exception"
)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[5], line 1
----> 1 raise ValueError(
2 "shown on the page, and not a failure: the cell is tagged raises-exception"
3 )
ValueError: shown on the page, and not a failure: the cell is tagged raises-exception