-
Notifications
You must be signed in to change notification settings - Fork 68
Use MathML for math formatting #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
441c5e9
a0ea2db
513323b
5b3a7da
2a42d73
a60bab2
65c395b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,14 +17,14 @@ Recursion is actually a way of defining functions in which the function is appli | |
| Definitions in mathematics are often given recursively. | ||
| For instance, the fibonacci sequence is defined recursively. | ||
| First, we define the first two fibonacci numbers non-recursively. | ||
| We say that *F(0) = 0* and *F(1) = 1*, meaning that the 0th and 1st fibonacci numbers are 0 and 1, respectively. | ||
| We say that $F(0) = 0$ and $F(1) = 1$, meaning that the 0<sup>th</sup> and 1<sup>st</sup> fibonacci numbers are $0$ and $1$, respectively. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a Pandoc option for superscripts: https://pandoc.org/MANUAL.html#extension-superscript-subscript
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, so that's why there were these paired |
||
| Then we say that for any other natural number, that fibonacci number is the sum of the previous two fibonacci numbers. | ||
| So *F(n) = F(n-1) + F(n-2)*. | ||
| That way, *F(3)* is *F(2) + F(1)*, which is *(F(1) + F(0)) + F(1)*. | ||
| Because we've now come down to only non-recursively defined fibonacci numbers, we can safely say that *F(3)* is 2. | ||
| Having an element or two in a recursion definition defined non-recursively (like *F(0)* and *F(1)* here) is also called the **edge condition** and is important if you want your recursive function to terminate. | ||
| If we hadn't defined *F(0)* and *F(1)* non recursively, you'd never get a solution any number because you'd reach 0 and then you'd go into negative numbers. | ||
| All of a sudden, you'd be saying that *F(-2000)* is *F(-2001) + F(-2002)* and there still wouldn't be an end in sight! | ||
| So $F(n) = F(n-1) + F(n-2)$. | ||
| That way, $F(3)$ is $F(2) + F(1)$, which is $(F(1) + F(0)) + F(1)$. | ||
| Because we've now come down to only non-recursively defined fibonacci numbers, we can safely say that $F(3)$ is $2$. | ||
| Having an element or two in a recursion definition defined non-recursively (like $F(0)$ and $F(1)$ here) is also called the **edge condition** and is important if you want your recursive function to terminate. | ||
| If we hadn't defined $F(0)$ and $F(1)$ non recursively, you'd never get a solution any number because you'd reach $0$ and then you'd go into negative numbers. | ||
| All of a sudden, you'd be saying that $F(-2000)$ is $F(-2001) + F(-2002)$ and there still wouldn't be an end in sight! | ||
|
|
||
| Recursion is important to Haskell because unlike imperative languages, you do computations in Haskell by declaring what something *is* instead of declaring *how* you get it. | ||
| That's why there are no while loops or for loops in Haskell and instead we many times have to use recursion to declare what something is. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -626,8 +626,8 @@ Although it's simpler to just use the `replicate`{.label .function} function if | |
| {.left width=180 height=156} | ||
| If you've ever taken a course in mathematics, you've probably run into *set comprehensions*. | ||
| They're normally used for building more specific sets out of general sets. | ||
| A basic comprehension for a set that contains the first ten even natural numbers is . | ||
| The part before the pipe is called the output function, `x` is the variable, `N` is the input set and `x <= 10` is the predicate. | ||
| A basic comprehension for a set that contains the first ten even natural numbers is $S = \left\{ 2 \cdot x \mid x \in \mathbb N, x \le 10 \right\}$. | ||
| The part before the pipe is called the output function, $x$ is the variable, $\mathbb N$ is the input set and $x \le 10$ is the predicate. | ||
| That means that the set contains the doubles of all natural numbers that satisfy the predicate. | ||
|
|
||
| If we wanted to write that in Haskell, we could do something like `take 10 [2,4..]`. | ||
|
|
@@ -884,7 +884,7 @@ ghci> triangles = [ (a,b,c) | c <- [1..10], a <- [1..10], b <- [1..10] ] | |
| We're just drawing from three lists and our output function is combining them into a triple. | ||
| If you evaluate that by typing out `triangles` in GHCi, you'll get a list of all possible triangles with sides under or equal to 10. | ||
| Next, we'll add a condition that they all have to be right triangles. | ||
| We'll also modify this function by taking into consideration that side *a* isn't larger than the hypotenuse and that side *b* isn't larger than side *a*. | ||
| We'll also modify this function by taking into consideration that side $a$ isn't larger than the hypotenuse and that side $b$ isn't larger than side $a$. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a good reason to switch from * to $? the former looks simpler to me and I naturally prefer simpler approaches.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this one is really up to personal preferences. |
||
|
|
||
| ```{.haskell: .ghci} | ||
| ghci> rightTriangles = [ (a,b,c) | c <- [1..10], a <- [1..c], b <- [1..a], a^2 + b^2 == c^2] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you really need to use \left and \right in these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but it looks slightly nicer:

Though still not as nice as I'd like. Ideally, the parentheses would share a horizontal symmetry access, and the bigger ones would therefore cross the baseline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer same-sized parenthesis for expressions as simple as these for uniformity sake. I only resort to \left and \right when the expressions are big and it's hard to match the parenthesis. But I don't feel too strong about it in this case.