working on bulid
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
```julia; echo=false; results="hidden"
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using Plots
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -14,18 +13,25 @@ As it is open source, indeed with a liberal MIT license, it can be
|
||||
installed for free on many types of computers (though not phones or
|
||||
tablets).
|
||||
|
||||
## Running Julia through the web
|
||||
|
||||
There are a few services for running `Julia` through the
|
||||
web. Mentioned here is [Binder](https://mybinder.org), which provides
|
||||
a web-based interface to `Julia` built around `Jupyter`. `Jupyter` is
|
||||
a wildly succesful platform for interacting with different open-source
|
||||
software programs.
|
||||
|
||||
[lauch binder](https://mybinder.org/v2/gh/CalculusWithJulia/CwJScratchPad.git/master)
|
||||
|
||||
### Installing Julia locally
|
||||
|
||||
There is the service [Binder](https://mybinder.org), which
|
||||
provides a web-based interface to `Julia` built around `Jupyter`, a
|
||||
wildly succesful platform for interacting with different open-source
|
||||
software programs. Clicking the launch button above will open a web
|
||||
page which provides a blank notebook, save for a package used by these
|
||||
notes. However, `Binder` is nowhere near as reliable as a local installation.
|
||||
Clicking the launch link above will open a web page which provides a
|
||||
blank notebook, save for a package used by these notes. However,
|
||||
`Binder` is nowhere near as reliable as a local installation.
|
||||
|
||||
Installing `Julia` locally is not more difficult than installing other softward.
|
||||
|
||||
## Installing Julia locally
|
||||
|
||||
Installing `Julia` locally is not more difficult than installing other software.
|
||||
|
||||
Binaries of `Julia` are provided at
|
||||
[julialang.org](http://julialang.org/downloads/). Julia has an
|
||||
@@ -39,7 +45,10 @@ For Windows users, there is a `juliaup` program for managing the installation of
|
||||
The base `Julia` provides a *command-line interface*, or REPL
|
||||
(read-evaluate-parse).
|
||||
|
||||
### Basic interactive usage
|
||||
|
||||
|
||||
|
||||
## Basic interactive usage
|
||||
|
||||
Once installed, `Julia` can be started by clicking on an icon or
|
||||
typing `julia` at the command line. Either will open a *command line
|
||||
@@ -75,103 +84,32 @@ coloring. For example:
|
||||
2 + 2
|
||||
```
|
||||
|
||||
Other interfaces to `Julia` are described briefly in [Julia interfaces](./julia_interfaces.html). The notebook interface provided through `IJulia` most closely matches the style of the notes.
|
||||
While many prefer a command line for interacting with `Julia`, when learning a notebook interfaces is suggested. (An IDE like [Julia for Visual Studio Code](https://www.julia-vscode.org/) might be preferred for experienced programmers). In [Julia interfaces](./julia_interfaces.html), we describe two different notebook interfaces that are available through add-on packages. (These notes use `Pluto`, one of the two.)
|
||||
|
||||
|
||||
|
||||
## Add-on packages
|
||||
|
||||
`Julia` has well over a 1000 external, add-on packages that enhance the
|
||||
offerings of base `Julia`. We refer to one, `CalculusWithJulia`, that is designed to accompany these notes. This package installs several other packages that provide the needed functionality. The package (and its dependencies) can be installed through:
|
||||
offerings of base `Julia`. We refer to one, `CalculusWithJulia`, that is designed to accompany these notes. [Installation notes](./calculus_with_julia.html) are available.
|
||||
|
||||
|
||||
```julia; eval=false
|
||||
using Pkg
|
||||
Pkg.add("CalculusWithJulia")
|
||||
```
|
||||
|
||||
(Or the one liner `] add CalculusWithJulia`. Some additional details on packages is provided [here](./calculus_with_julia.html).)
|
||||
In `Julia` graphics are provided only by add-on packages -- there is no built-in
|
||||
graphing. This is the case under `Pluto` or `Jupyter` or the command line.
|
||||
|
||||
Installation only needs to be done once, but to use a package it must be loaded into each new session. This can be done with this command:
|
||||
|
||||
```julia;
|
||||
using CalculusWithJulia
|
||||
```
|
||||
|
||||
|
||||
## The basics of working with Pluto
|
||||
|
||||
The `Pluto` notebook interface is a Julia-specific interface that is started by:
|
||||
|
||||
```julia; eval=false
|
||||
using Pluto
|
||||
Pluto.run()
|
||||
```
|
||||
|
||||
These commands will cause a tab in a web browser to open to `Pluto`'s landing page. From here a new or existing notebook can be opened. Notebooks can even be opened from urls or from Pluto-generated HTML pages, such as some of the sections of these notes.
|
||||
|
||||
Pluto cells are reactive, so modifications of a variable in the top-level scope will propagate to all references of that variable. This is very useful for explorations, but does require unique variable names in the top-level scope. (Names can be reused in functions and `let` blocks.)
|
||||
|
||||
A Pluto cell holds a single command, which may be a block holding multiple statements. Cells are executed, typically, by typing "shift-enter". The output of the cell appears *above* the cell.
|
||||
|
||||
|
||||
## The basics of working with IJulia
|
||||
|
||||
The **very** basics of the Jupyter notebook interface provided by `IJulia` are covered here.
|
||||
|
||||
An `IJulia` notebook is made up of cells. Within a cell a collection of commands may be typed (one or more).
|
||||
|
||||
When a cell is executed (by the triangle icon or under the Cell menu) the contents of the cell are evaluated by the `Julia` kernel and any output is displayed below the cell. Typically this is just the output of the last command.
|
||||
|
||||
```julia;
|
||||
2 + 2
|
||||
3 + 3
|
||||
```
|
||||
|
||||
|
||||
If the last commands are separated by commas, then a "tuple" will be formed and each output will be displayed, separated by commas.
|
||||
|
||||
```julia;
|
||||
2 + 2, 3 + 3
|
||||
```
|
||||
|
||||
Comments can be made in a cell. Anything after a `#` will be ignored.
|
||||
|
||||
```julia;
|
||||
2 + 2 # this is a comment, you can ignore me...
|
||||
```
|
||||
|
||||
Graphics are provided by external packages. There is no built-in
|
||||
graphing. We use the `Plots` package and its default backend. The
|
||||
In these notes, we use the `Plots` package and its default backend. The
|
||||
`Plots` package provides a common interface to several different
|
||||
backends, so this choice is easily changed. The `pyplot` backend is used in these notes, though for interactive use both the `GR` and `Plotly` backends have advantages.
|
||||
backends; this choice is easily changed. The `gr` backend is used in these notes, though for interactive use the `Plotly` backend has advantages; for more complicated graphics, `pyplot` has some advantages; for publication `PGFPlotsX` has advantages.
|
||||
|
||||
The package, if installed, is loaded as any other package:
|
||||
|
||||
```julia;
|
||||
using CalculusWithJulia
|
||||
using Plots
|
||||
```
|
||||
|
||||
```julia; echo=false
|
||||
pyplot()
|
||||
```
|
||||
|
||||
With that in hand, to make a graph of a function over a range, we follow this pattern:
|
||||
|
||||
```julia;
|
||||
plot(sin, 0, 2pi)
|
||||
```
|
||||
|
||||
A few things:
|
||||
|
||||
* Cells are numbered in the order they were evaluated.
|
||||
|
||||
* This order need not be from top to bottom of the notebook.
|
||||
|
||||
* The evaluation of a cell happens within the state of the workspace,
|
||||
which depends on what was evaluated earlier.
|
||||
|
||||
* The workspace can be cleared by the "Restart" menu item under
|
||||
"Kernel". After restarting the "Run All" menu item under "Cell" can
|
||||
be used to re-run all the commands in the notebook - from top to bottom. "Run all" will also
|
||||
reload any packages.
|
||||
|
||||
Reference in New Issue
Block a user