mirror of
https://github.com/TeachBooks/template.git
synced 2026-11-12 22:25:52 +00:00
93 lines
3.8 KiB
Markdown
93 lines
3.8 KiB
Markdown
# Exercise 9: Use equations
|
|
|
|
In this exercise, you will learn how to write and format mathematical equations in your TeachBook, both inline and as standalone blocks.
|
|
|
|
::::::{topic} Exercise objective
|
|
Can you write and format equations correctly in your book?
|
|
::::::
|
|
|
|
```{tip}
|
|
Using properly formatted equations makes mathematical expressions clearer and more professional. More details can be found in the [JupyterBook documentation](https://jupyterbook.org/en/stable/content/math.html).
|
|
```
|
|
|
|
## Writing equations
|
|
|
|
1. Open a new or existing Markdown file where you want to include an equation.
|
|
2. Start with a simple block equation using double dollar signs. Try adding the following equation in your Markdown file:
|
|
|
|
```md
|
|
$$ F_{res} = m \cdot a $$
|
|
```
|
|
|
|
```{tip}
|
|
The syntax used for creation equations is TeX, a markup language for math. It's often part of the software-system LaTeX, which allows to create full documents in this language. There's plenty of documentation online on how to use it, including graphical interfaces (for example [this one](https://latexeditor.lagrida.com/))
|
|
```
|
|
|
|
3. Now let's add another equation with an error:
|
|
|
|
```md
|
|
$$ E = m \ccdot c^2 $$
|
|
```
|
|
|
|
4. Check whether the equations renders correctly by clicking `preview` if you're making this edit in the GitHub single file editor. Make sure you already defined the file type as `<title>.md` to enable rendering. Note that all ill-formatted equation are indicated in red, i.e. $\red{\text{\ccdot}}$
|
|
|
|
5. As an alternative you try and use the 'math directive'. This will have the same results + adds a equation number which can be used for referencing (refer to [Exercise 11](011.md)):
|
|
|
|
````md
|
|
```{math}
|
|
v = a \cdot t
|
|
```
|
|
````
|
|
|
|
6. Click on `preview` again. Note that these equations don't render. That's because these 'directives' is a MyST feature (an extension of markdown), which is not supported by the GitHub previewer that only support markdown.
|
|
|
|
7. Now, add an inline equation by enclosing the equation with single dollar signs. Try this example:
|
|
|
|
|
|
```md
|
|
The displacement can be found using the equation $s = v \cdot t$.
|
|
```
|
|
|
|
## Formatting mathematical symbols
|
|
|
|
8. In this step we will experiment with different TeX symbols. Use the following table and test each example in your Markdown file:
|
|
|
|
|
|
| Name | Script |
|
|
|---|---|
|
|
| Square root | `\sqrt{4}` |
|
|
| Power | `^{2x}` |
|
|
| Fraction | `\frac{2}{3}` |
|
|
| Subscript | `_{gem}` |
|
|
| Superscript | `^{N}` |
|
|
| Multiplication | `\cdot` |
|
|
|
|
9. Extend this exercise by trying more advanced mathematical expressions:
|
|
|
|
| Name | Script |
|
|
|---|---|
|
|
| Derivative | `\frac{\Delta f}{\Delta t}` |
|
|
| Integral | `\int_a^b dx` |
|
|
| Sine function | `\sin(x)` |
|
|
|
|
10. Test your understanding by adding a new equation of your choice, ideally one that requires many LaTex symbols!
|
|
|
|
11. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button.
|
|
|
|
12. Add a commit message.
|
|
|
|
13. To see your changes, go to {octicon}`play` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting).
|
|
|
|
14. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page.
|
|
|
|
|
|
```{admonition} Check your understanding
|
|
:class: note
|
|
|
|
Before moving on to the next exercise, make sure you understand the following:
|
|
- What is the difference between inline and block equations?
|
|
- How do you use TeX formatting for different mathematical symbols?
|
|
- What is the purpose of using single vs. double dollar signs for equations?
|
|
- How do you troubleshoot if your equations are not rendering correctly?
|
|
```
|
|
|