use quarto, not Pluto to render pages
This commit is contained in:
@@ -8,7 +8,8 @@ using Plots
|
||||
using Measures
|
||||
using LaTeXStrings
|
||||
|
||||
fig_size = (400, 300)
|
||||
#fig_size = (400, 300)
|
||||
fig_size = (800, 600)
|
||||
|
||||
const frontmatter = (
|
||||
title = "Vectors",
|
||||
@@ -463,23 +464,13 @@ component. However, the special keyword `end` will do so as well, when
|
||||
put into the context of indexing. So `v[end]` is more idiomatic. (Similarly, there is a `begin` keyword that is useful when the vector is not ``1``-based, as is typical but not mandatory.)
|
||||
|
||||
|
||||
```julia; echo=false;
|
||||
note("""
|
||||
There is [much more](http://julia.readthedocs.org/en/latest/manual/arrays/#indexing)
|
||||
to indexing than just indexing by a single integer value. For example, the following can be used for indexing:
|
||||
|
||||
* a scalar integer (as seen)
|
||||
|
||||
* a range
|
||||
|
||||
* a vector of integers
|
||||
|
||||
* a boolean vector
|
||||
|
||||
Some add-on packages extend this further.
|
||||
""",
|
||||
title="More on indexing", label="More on indexing")
|
||||
```
|
||||
!!! note "More on indexing"
|
||||
There is [much more](http://julia.readthedocs.org/en/latest/manual/arrays/#indexing) to indexing than just indexing by a single integer value. For example, the following can be used for indexing:
|
||||
* a scalar integer (as seen)
|
||||
* a range
|
||||
* a vector of integers
|
||||
* a boolean vector
|
||||
Some add-on packages extend this further.
|
||||
|
||||
### Assignment and indexing
|
||||
|
||||
@@ -668,10 +659,9 @@ performant `abs2` function which, in general, efficiently finds $|x|^2$
|
||||
for various number types. The `.-` uses broadcasting to subtract a scalar (`mean(xs)`) from a vector (`xs`). Without the `.`, this would error.
|
||||
|
||||
|
||||
```julia; echo=false;
|
||||
note("""The `map` function is very much related to broadcasting and similarly named functions are found in many different programming languages. (The "dot" broadcast is mostly limited to `Julia` and mirrors on a similar usage of a dot in `MATLAB`.) For those familiar with other programming languages, using `map` may seem more natural. Its syntax is `map(f, xs)`.
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
The `map` function is very much related to broadcasting and similarly named functions are found in many different programming languages. (The "dot" broadcast is mostly limited to `Julia` and mirrors on a similar usage of a dot in `MATLAB`.) For those familiar with other programming languages, using `map` may seem more natural. Its syntax is `map(f, xs)`.
|
||||
|
||||
|
||||
### Comprehensions
|
||||
|
||||
@@ -763,15 +753,9 @@ In the sequel, we will typically use broadcasting for this task using two
|
||||
steps: one to define a function the second to broadcast it.
|
||||
|
||||
|
||||
```julia; echo=false;
|
||||
note(L"""
|
||||
!!! note
|
||||
The style generally employed here is to use plural variable names for a collection of values, such as the vector of $y$ values and singular names when a single value is being referred to, leading to expressions like "`x in xs`".
|
||||
|
||||
The style generally employed here is to use plural variable names for a collection
|
||||
of values, such as the vector of $y$ values and singular names when a
|
||||
single value is being referred to, leading to expressions like "`x in xs`".
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
## Other container types
|
||||
|
||||
@@ -805,8 +789,8 @@ q"v = {4, 3}",
|
||||
q"v = '4, 3'",
|
||||
q"v = (4,3)",
|
||||
q"v = <4,3>"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -815,8 +799,8 @@ Which command will create the vector with components "4,3,2,1"?
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = [q"v = [4,3,2,1]", q"v = (4,3,2,1)", q"v = {4,3,2,1}", q"v = '4, 3, 2, 1'", q"v = <4,3,2,1>"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -840,8 +824,8 @@ Which of the following is the unit vector in the direction of $\vec{v} = \langle
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = [q"[3, 4]", q"[0.6, 0.8]", q"[1.0, 1.33333]", q"[1, 1]"]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -851,8 +835,8 @@ What vector is in the same direction as $\vec{v} = \langle 3,~ 4 \rangle$ but is
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = [q"[3, 4]", q"[30, 40]", q"[9.48683, 12.6491 ]", q"[10, 10]"]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -861,8 +845,8 @@ If $\vec{v} = \langle 3,~ 4 \rangle$ and $\vec{w} = \langle 1,~ 2 \rangle$ find
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = [q"[4, 6]", q"[6, 8]", q"[11, 18]", q"[5, 10]"]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
answ = 3
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -939,24 +923,24 @@ Express vector **c** in terms of **a** and **b**:
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = ["3a", "3b", "a + b", "a - b", "b-a"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
Express vector **d** in terms of **a** and **b**:
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = ["3a", "3b", "a + b", "a - b", "b-a"]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
answ = 3
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
Express vector **e** in terms of **a** and **b**:
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = ["3a", "3b", "a + b", "a - b", "b-a"]
|
||||
ans = 4
|
||||
radioq(choices, ans)
|
||||
answ = 4
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -966,8 +950,8 @@ If `xs=[1, 2, 3, 4]` and `f(x) = x^2` which of these will not produce the vector
|
||||
|
||||
```julia; hold=true; echo=false;
|
||||
choices = [q"f.(xs)", q"map(f, xs)", q"[f(x) for x in xs]", "All three of them work"]
|
||||
ans = 4
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 4
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -982,8 +966,8 @@ What construct will give the function values of $f$ at the zeros of $g$?
|
||||
|
||||
```julia;hold=true; echo=false;
|
||||
choices = [q"sin(zs)", q"sin.(zs)", q"sin(.zs)", q".sin(zs)"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -997,6 +981,6 @@ q"sqrt.(zs)",
|
||||
q"zs^(1/2)",
|
||||
q"zs^(1./2)"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user