-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.qmd
211 lines (130 loc) · 8.41 KB
/
index.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
# Preface {.unnumbered}
> These projects use version v1.7 of Julia.
[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/mth229/229-projects/HEAD) (Binder can be used to access `Julia` remotely.)
## Introduction
MTH229 at the College of Staten Island is a course to introduce a
programming language to reinforce concepts of a first-semester
calculus course from numerical and graphical points of view.
Some sections use the [Julia](http://julialang.org) programming
language. For `Julia`, the computer-lab "projects" are on WeBWorK and
there *should* be sufficient background material therein to work
through the details. IN the notes here can be found additional detail
for those seeking it. For a more thorough introduction, visit
[Calculus with Julia](http://calculuswithjulia.github.io).
Installation details for `Julia` are at the end of this page
----
These notes are broken into different sections, where most all sections
have some self-grading questions at the end that allow you to test
your knowledge of that material. The code should be copy-and-pasteable
into a `Julia` session. The code output is similar to what would be
shown if evaluated in an `IJulia` cell, our recommended interface while
learning `Julia`, though some may like the `Pluto` interface as well.
The notes mostly follow topics of a standard first-semester
calculus course after some background material is presented for
learning `Julia` within a mathematical framework.
Each topic has a lab project. At CSI, sufficient time is allotted to
complete these projects during the lab class. These projects are
available as `IJulia` notebooks or `Pluto` notebooks. (There are also
`Pluto` notebooks with 5-10 minutes of commentary.) Find links for
these near the top of each page of notes.
For example, blank notebooks for test taking, etc. are found by following these links:
[ipynb](https://raw.githubusercontent.com/mth229/229-projects/master/00-blank-notebook.ipynb)
[(Pluto html)](./229-projects/00-blank-notebook.html)
#### Questions and Answers
Question and answers are now presented and completed through `WeBWorK`.
The `.ipynb` notebooks only contain modest background details.
There are a few idiosyncracies in the `WeBWorK` pages to be aware of:
* The code examples are typset in `WeBWorK` as though they appear in a *terminal*. A terminal displays the output of each command immediately after execution. In a notebook, when a cell is executed, all the commands are computed and *only* the last value is shown. (The use of `@show` or `print(...)` can be used to display intermediate values in a cell.)
* Copy and paste from a `WeBWorK` page into a notebook will usually be unsuccessful, as numbers in the font used to display computer markup do not copy as ASCII numbers into a cell. The numbers can be hand edited though.
* While `Julia` is very happy to express its output using scientific notation, `WeBWorK` is not happy to receive the exact output for an answer. Either replace `e` with `E` (as in `1.23e4` would be `1.23E4`) or use decimals.
* For *most* questions with a numeric answer it is best to copy all 16 digits of output. Several digits are expected to match a correct answer. For numeric questions where an estimate is made, say from a graph, this is significantly relaxed.
* If the answer is to be a function, the automatic grader is expecting just the rule of the function (an expression), as in for `f(x) = sin(x)` just enter `sin(x)`.
## Basic ideas
`Julia` makes an excellent choice as a computer supplement for this
material as its syntax is very similar to standard mathematical
syntax. The ability to define mathematical functions using the
familiar `f(x) = ...` notation makes getting started really
easy. Further, the fact that functions are *first-class objects* means
that it is possible to create *higher-order* `Julia` functions that
mirror the standard operations of calculus. The following pattern is
used throughout:
```verbatim
action(function_object, args...)
```
For example, the notes use:
* `plot(f, a, b)` to plot `f` over `[a,b]`; `plot!(g)` to add a curve (using `Plots`)
* `fzero(f, a, b)` or `find_zero(f, (a,b))` to find *a* zero inside the bracketing interval `[a,b]` (from `Roots`)
* `fzeros(f, a, b)` (or `find_zeros(f, (a,b))`) to find *all* the real zeros of a function `f` in `[a,b]` (from `Roots`)
* `fzero(f, a)` (or `find_zero(f, a)`) to find *a* zero using initial starting oint `a` (from `Roots`)
* `limit(f(x), x=>c)` to find the limit of `f` at `c` (from `SymPy`)
* `f'` to return a function that computes the derivative of `f` (Added in the `MTH229` package based on the `derivative` function from the `ForwardDiff` package)
* `diff(f(x),x)` to find a symbolic derivative of `f` (from `SymPy`)
* `quadgk(f, a, b)` to find the numeric integral of `f` over `(a,b)`
(from the `QuadGK` package)
* `integrate(f(x), x)` to find the symbolic integral of `f` (from the `SymPy` package)
* `integrate(f(x), (x, a, b))` to find the definite integral over `[a,b]`
symbolically (from the `SymPy` package).
With just this basic set of actions, akin to buttons on the calculator, a rich variety of problems can be addressed.
## How to use `Julia` in MTH 229
Using `Julia` to complete the projects of MTH 229 can be done in several ways.
### Using the `juliabox` server
CSI students have access to a server that gives access to the jupyter notebooks.
### Installing `Julia` on a personal laptop or computer.
This is not terribly difficult, but does involve a few additional steps:
* Download and install `Julia` from [julialang.org/](https://julialang.org/downloads/). This will install like any other software for you system. You should use the *latest* released version, currently `v1.8`.
* Start the application
This opens a terminal, appearing as follows:
```{julia}
#| echo: false
Base.banner()
```
Commands are typed after the prompt (`> julia`) and executed when the return key is pressed.
Try a few commands and see. Adding ``2`` and ``2`` should look like:
```
julia> 2 + 2
4
julia>
```
For this class, some external packages must be loaded. First issue the command
```
using MTH229, Plots
```
This installs and loads two external packages -- one containing functions for this class, the other providing a plotting environments.
Once these are installed and loaded, the projects for the class can be
installed following this command:
```
mth229()
```
Okay, that should set everything up.
When you want to actually use `Julia` for this class, you only need to use these two commands from the command line:
```
using IJulia
notebook()
```
If not already installed, `IJulia` will be installed and configured,
and then the `notebook` command will open a browser window allowing
the selection of one of the projects. Your work will be within a browser window, not the terminal.
The latter two commands are the only ones needed for subsequent usage, as the packages `MTH229` and `Plots` will be loaded within an `IJulia` notebook.
#### Using Pluto notebooks locally
`Pluto` notebooks are easier to install. At the terminal (assuming version 1.7 or higher) run:
```
using Pluto
Pluto.run()
```
This will open a `Pluto` landing page in a browser tab.
The html notebooks linked herein offer a means to "Edit or run this notebook." Download the notebook (it will make a `.jl` file) and then open this within `Pluto`.
### Using binder to run the projects remotely:
[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/mth229/229-projects/HEAD)
The link above allows the projects for MTH229 to be run through the web.
* `binder` is a service that runs interactive notebooks through the web. Each notebook is limited in memory and has a 10 minute *inactivity* timeout. Binder notebooks are not persistent, though they do have a button to save to local storage.
Binder takes between 30 seconds and one minute to get up and running. Once a notebook is selected, it takes another 30ish seconds to get the typical packages started.
----
This table covers pros and cons for the approaches mentioned above:
```
Using server Binder Local Installation
Setup ease ✓ ✓ ×
Speed ✓ × ✓
Persistence of work × × ✓
Free ✓ ✓ ✓
Use at home ✓ ✓ ✓
```