forked from njtierney/qmd4sci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath.qmd
253 lines (187 loc) · 3.35 KB
/
math.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# Math
Want to include equations in your writing? Easy. Quarto supports
LaTeX style equation writing. This section introduces the two types equations, inline, and display form, as well as numbering equations.
## Overview
* **Teaching**: 10 minutes
* **Exercises**: 10 minutes
## Questions
- How to I create an equation?
- LaTeX is funky, what are the basic math commands?
<!-- ## Objectives -->
:::{.callout-caution title="Some History about LaTeX" collapse="true"}
Equation editing was first made available in TeX, which later become LaTeX, named after [Leslie Lamport](https://en.wikipedia.org/wiki/Leslie_Lamport).
:::
## Anatomy of Equations
This section shows you some basic equations types that you want to be familiar with.
Inline equations are referenced by a pair of dollar signs: `$`.
```
So this text would have an equation here: $E = mc^2$
```
Generates:
> So this text would have an equation here: $E = mc^2$
Display equations are referenced by two pairs of dollar signs:
```
$$
E = mc^2
$$
```
Gives:
$$
E = mc^2
$$
#### Viewing equations
Understanding whether or not you have created the right equation can be difficult. Rstudio provides previews of your equations in text (**demo**).
## Example math commands
LaTeX is an amazing language, but understanding how to create the equations can be (more than) a bit confusing at times. This section demonstrates some example equations that you might be familiar with.
#### Fractions
:::: columns
::: {.column width="45%"}
```
$$
\frac{1}{2}
$$
```
:::
::: {.column width="45%"}
$$
\frac{1}{2}
$$
:::
::::
#### Sub and Super Scripts
:::: columns
::: {.column width="45%"}
```
$$
Y = X_1 + X_2
$$
```
:::
::: {.column width="45%"}
$$
Y = X_1 + X_2
$$
:::
::::
:::: columns
::: {.column width="45%"}
```
$$
a^2 + b^2 = c^2
$$
```
:::
::: {.column width="45%"}
$$
a^2 + b^2 = c^2
$$
:::
::::
#### Square roots
:::: columns
::: {.column width="45%"}
```
$$
\sqrt{p}
$$
```
:::
::: {.column width="45%"}
$$
\sqrt{p}
$$
:::
::::
:::: columns
::: {.column width="45%"}
```
$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$
```
:::
::: {.column width="45%"}
$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$
:::
::::
#### Summations
:::: columns
::: {.column width="45%"}
```
$$
\sum_{i = 1}^{n}{(\bar{x} - x_i)^2}
$$
```
:::
::: {.column width="45%"}
$$
\sum_{i = 1}^{n}{(\bar{x} - x_i)^2}
$$
:::
::::
#### Bayes Rule
:::: columns
::: {.column width="45%"}
```
$$
Pr(\theta | y) = \frac{Pr(y | \theta) Pr(\theta)}{Pr(y)}
$$
```
:::
::: {.column width="45%"}
$$
Pr(\theta | y) = \frac{Pr(y | \theta) Pr(\theta)}{Pr(y)}
$$
:::
::::
:::: columns
::: {.column width="45%"}
```
$$
Pr(\theta | y) \propto Pr(y | \theta) Pr(\theta)
$$
```
:::
::: {.column width="45%"}
$$
Pr(\theta | y) \propto Pr(y | \theta) Pr(\theta)
$$
:::
::::
#### Linear Model
:::: columns
::: {.column width="45%"}
```
$$
Y \sim X\beta_0 + X\beta_1 + \epsilon
$$
```
:::
::: {.column width="45%"}
$$
Y \sim X\beta_0 + X\beta_1 + \epsilon
$$
:::
::::
:::: columns
::: {.column width="45%"}
```
$$
\epsilon \sim N(0,\sigma^2)
$$
```
:::
::: {.column width="45%"}
$$
\epsilon \sim N(0,\sigma^2)
$$
:::
::::
::: {.callout-note title="Your Turn"}
1. Add some math to your "02-qmd-figures-chunks.qmd" document
:::
## Further Reading:
<https://quarto.org/docs/visual-editor/technical.html#equations>
<https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols>