rm WeaveSupport
This commit is contained in:
@@ -6,14 +6,6 @@
|
||||
```{julia}
|
||||
#| echo: false
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
frontmatter = (
|
||||
title = "From calculator to computer",
|
||||
description = "Calculus with Julia: Replacing the calculator with a computer",
|
||||
tags = ["CalculusWithJulia", "precalc", "replacing the calculator with a computer"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -25,6 +17,7 @@ The following image is the calculator that Google presents upon searching for "c
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#
|
||||
imgfile = "figures/calculator.png"
|
||||
caption = "Screenshot of a calculator provided by the Google search engine."
|
||||
ImageFile(:precalc, imgfile, caption)
|
||||
@@ -50,7 +43,7 @@ txt = """
|
||||
</iframe>
|
||||
</center>
|
||||
"""
|
||||
CalculusWithJulia.WeaveSupport.HTMLoutput(txt)
|
||||
HTMLoutput(txt)
|
||||
```
|
||||
|
||||
## Operations
|
||||
@@ -90,23 +83,19 @@ An expression like $6 - -3$, subtracting minus three from six, must be handled w
|
||||
6 - -3
|
||||
```
|
||||
|
||||
(If no space is included, the value "`--`" is parsed like a different, undefined, operation.)
|
||||
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
warning(L"""
|
||||
(If no space is included, the value "`--`" is parsed like a different, invalid, operation.)
|
||||
|
||||
:::{.callout-warning}
|
||||
## Warning
|
||||
`Julia` only uses one symbol for minus, but web pages may not! Copying
|
||||
and pasting an expression with a minus sign can lead to hard to
|
||||
understand errors such as: `invalid character "−"`. There are several
|
||||
Unicode symbols that look similar to the ASCII minus sign, but are
|
||||
Unicode symbols that look similar to the ASCII minus sign, though
|
||||
different. These notes use a different character for the minus sign for
|
||||
the typeset math (e.g., $1 - \pi$) than for the code within cells
|
||||
(e.g. `1 - 2`). Thus, copying and pasting the typeset math may not work as expected.
|
||||
:::
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
@@ -369,14 +358,14 @@ In most cases. There are occasional (basically rare) spots where using `pi` by i
|
||||
### Numeric literals
|
||||
|
||||
|
||||
For some special cases, Julia implements *multiplication* without a multiplication symbol. This is when the value on the left is a number, as in `2pi`, which has an equivalent value to `2*pi`. *However* the two are not equivalent, in that multiplication with *numeric literals* does not have the same precedence as regular multiplication - it is higher. This has practical importance when used in division or powers. For instance, these two are **not** the same:
|
||||
For some special cases, Julia parses *multiplication* without a multiplication symbol. This is when the value on the left is a number, as in `2pi`, which has an equivalent value to `2*pi`. *However* the two are not equivalent, in that multiplication with *numeric literals* does not have the same precedence as regular multiplication - it is higher. This has practical importance when used in division or powers. For instance, these two are **not** the same:
|
||||
|
||||
|
||||
```{julia}
|
||||
1/2pi, 1/2*pi
|
||||
```
|
||||
|
||||
Why? Because the first `2pi` is performed before division, as multiplication with numeric literals has higher precedence than regular multiplication, which is at the same level as division.
|
||||
Why? Because the first `2pi` is performed before division, as multiplication with numeric literals has higher precedence than regular multiplication, which is at the same level as division.
|
||||
|
||||
|
||||
To confuse things even more, consider
|
||||
@@ -436,7 +425,8 @@ julia = [
|
||||
"`factorial`"
|
||||
]
|
||||
|
||||
CalculusWithJulia.WeaveSupport.table(DataFrame(Calculator=calc, Julia=julia))
|
||||
d = DataFrame(Calculator=calc, Julia=julia)
|
||||
Table(d)
|
||||
```
|
||||
|
||||
Using a function is very straightforward. A function is called using parentheses, in a manner visually similar to how a function is called mathematically. So if we consider the `sqrt` function, we have:
|
||||
@@ -1068,4 +1058,3 @@ choices = [
|
||||
answ=1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -11,19 +11,6 @@ using CalculusWithJulia
|
||||
using Plots
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "Exponential and logarithmic functions",
|
||||
description = "Calculus with julia",
|
||||
tags = ["CalculusWithJulia", "precalc", "exponential and logarithmic functions"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -692,4 +679,3 @@ L"as $a^x < 1$, $a^y < a^x$",
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,19 +10,6 @@ This section will use the following add-on packages:
|
||||
using CalculusWithJulia, Plots
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "Functions",
|
||||
description = "Calculus with Julia: Functions",
|
||||
tags = ["CalculusWithJulia", "precalc", "functions"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -11,20 +11,6 @@ using CalculusWithJulia
|
||||
using Plots
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "The Inverse of a Function",
|
||||
description = "Calculus with Julia: The Inverse of a Function",
|
||||
tags = ["CalculusWithJulia", "precalc", "the inverse of a function"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -775,4 +761,3 @@ What about the value of $g_1(g_2(g_3(g_4(f_4(f_3(f_2(f_1(10))))))))$?
|
||||
val = g1(g2(g3(g4(f4(f3(f2(f1(10))))))))
|
||||
numericq(val)
|
||||
```
|
||||
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
const frontmatter = (
|
||||
title = "Overview of Julia commands",
|
||||
description = "Calculus with Julia: Overview of Julia commands",
|
||||
tags = ["CalculusWithJulia", "precalc", "overview of julia commands"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -13,14 +13,7 @@ using CalculusWithJulia # loads the `SpecialFunctions` package
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using Plots
|
||||
|
||||
const frontmatter = (
|
||||
title = "Inequalities, Logical expressions",
|
||||
description = "Calculus with Julia: Inequalities, Logical expressions",
|
||||
tags = ["CalculusWithJulia", "precalc", "inequalities, logical expressions"],
|
||||
);
|
||||
nothing
|
||||
```
|
||||
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
const frontmatter = (
|
||||
title = "Number systems",
|
||||
description = "Calculus with Julia: Number systems",
|
||||
tags = ["CalculusWithJulia", "precalc", "number systems"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
@@ -630,5 +624,3 @@ yesnoq(false)
|
||||
```
|
||||
|
||||
(This shows the special casing that is done when powers use literal numbers.)
|
||||
|
||||
|
||||
|
||||
@@ -14,17 +14,10 @@ using Plots
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using Roots
|
||||
using SymPy
|
||||
using DataFrames
|
||||
|
||||
const frontmatter = (
|
||||
title = "The Graph of a Function",
|
||||
description = "Calculus with Julia: The Graph of a Function",
|
||||
tags = ["CalculusWithJulia", "precalc", "the graph of a function"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -957,5 +950,3 @@ The slow "time to first plot" in `Julia` is a well-known hiccup that is related
|
||||
|
||||
|
||||
`Julia` is an interactive language that attains its speed by compiling functions on the fly using the [llvm](llvm.org) compiler. When `Julia` encounters a new combination of a function method and argument types it will compile and cache a function for subsequent speedy execution. The first plot is slow, as there are many internal functions that get compiled. This has sped up of late, as excessive recompilations have been trimmed down, but still has a way to go. This is different from "precompilation" which also helps trim down time for initial executions. There are also some more technically challenging means to create `Julia` images for faster start up that can be pursued if needed.
|
||||
|
||||
|
||||
|
||||
@@ -15,15 +15,6 @@ using Plots
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
fig_size = (800, 600) #400, 300)
|
||||
|
||||
const frontmatter = (
|
||||
title = "Polynomials",
|
||||
description = "Calculus with Julia: Polynomials",
|
||||
tags = ["CalculusWithJulia", "precalc", "polynomials"],
|
||||
);
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -835,4 +826,3 @@ q"0"]
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -15,16 +15,9 @@ using SymPy
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using Roots
|
||||
import LinearAlgebra: norm
|
||||
|
||||
const frontmatter = (
|
||||
title = "Roots of a polynomial",
|
||||
description = "Calculus with Julia: Roots of a polynomial",
|
||||
tags = ["CalculusWithJulia", "precalc", "roots of a polynomial"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -1039,5 +1032,3 @@ If the bottom row represents $q_7, q_6, \dots, q_0$ and the top row $p_8, p_7,
|
||||
|
||||
|
||||
As such, the `var(p)` $\geq 1 +$ `var(q)`.
|
||||
|
||||
|
||||
|
||||
@@ -14,20 +14,6 @@ using RealPolynomialRoots
|
||||
import SymPy # imported only: some functions, e.g. degree, need qualification
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "The Polynomials package",
|
||||
description = "Calculus with Julia: The Polynomials package",
|
||||
tags = ["CalculusWithJulia", "precalc", "the polynomials package"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -592,4 +578,3 @@ The `Polynomials` package has an implementation, so you can check your answer th
|
||||
The `ApproxFun` package is built on top of polynomials expressed in this basis, as the Chebyshev polynomials have special properties which make them very suitable when approximating functions with polynomials. The `ApproxFun` package uses easier-to-manipulate polynomials to approximate functions very accurately, thereby being useful for investigating properties of non-linear functions leveraging properties for polynomials.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
@@ -3,19 +3,6 @@
|
||||
|
||||
{{< include ../_common_code.qmd >}}
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
frontmatter = (
|
||||
title = "Ranges and Sets",
|
||||
description = "Calculus with Julia: Ranges and Sets",
|
||||
tags = ["CalculusWithJulia", "precalc", "ranges and sets"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
## Arithmetic sequences
|
||||
|
||||
|
||||
@@ -17,21 +17,6 @@ using RealPolynomialRoots
|
||||
The `Polynomials` package is "imported" to avoid naming collisions with `SymPy`; names will need to be qualified.
|
||||
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "Rational functions",
|
||||
description = "Calculus with Julia: Rational functions",
|
||||
tags = ["CalculusWithJulia", "precalc", "rational functions"],
|
||||
);
|
||||
|
||||
using Roots
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -427,41 +412,6 @@ The usual recipe for construction follows these steps:
|
||||
With the computer, where it is convenient to draw a graph, it might be better to emphasize the sign on the graph of the function. The `sign_chart` function from `CalculusWithJulia` does this by numerically identifying points where the function is $0$ or $\infty$ and indicating the sign as $x$ crosses over these points.
|
||||
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
# in CalculusWithJuia
|
||||
function sign_chart(f, a, b; atol=1e-6)
|
||||
pm(x) = x < 0 ? "-" : x > 0 ? "+" : "0"
|
||||
summarize(f,cp,d) = (∞0=cp, sign_change=pm(f(cp-d)) * " → " * pm(f(cp+d)))
|
||||
|
||||
zs = find_zeros(f, a, b)
|
||||
pts = vcat(a, zs, b)
|
||||
for (u,v) ∈ zip(pts[1:end-1], pts[2:end])
|
||||
zs′ = find_zeros(x -> 1/f(x), u, v)
|
||||
for z′ ∈ zs′
|
||||
flag = false
|
||||
for z ∈ zs
|
||||
if isapprox(z′, z, atol=atol)
|
||||
flag = true
|
||||
break
|
||||
end
|
||||
end
|
||||
!flag && push!(zs, z′)
|
||||
end
|
||||
end
|
||||
sort!(zs)
|
||||
|
||||
length(zs) == 0 && return []
|
||||
m,M = extrema(zs)
|
||||
d = min((m-a)/2, (b-M)/2)
|
||||
if length(zs) > 0
|
||||
d′ = minimum(diff(zs))/2
|
||||
d = min(d, d′ )
|
||||
end
|
||||
summarize.(f, zs, d)
|
||||
end
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
f(x) = x^3 - x
|
||||
@@ -1046,4 +996,3 @@ L"The $\sin(x)$ oscillates, but the rational function has a horizontal asymptote
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -14,14 +14,7 @@ using Plots
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using DataFrames
|
||||
|
||||
const frontmatter = (
|
||||
title = "Function manipulations",
|
||||
description = "Calculus with Julia: Function manipulations",
|
||||
tags = ["CalculusWithJulia", "precalc", "function manipulations"],
|
||||
);
|
||||
nothing
|
||||
```
|
||||
|
||||
|
||||
@@ -12,22 +12,6 @@ using Plots
|
||||
using SymPy
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
fig_size = (800, 600)
|
||||
|
||||
const frontmatter = (
|
||||
title = "Trigonometric functions",
|
||||
description = "Calculus with Julia: Trigonometric functions",
|
||||
tags = ["CalculusWithJulia", "precalc", "trigonometric functions"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -378,9 +362,7 @@ As can be seen, even a somewhat simple combination can produce complicated graph
|
||||
txt ="""
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/rrmx2Q3sO1Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
"""
|
||||
tpl = CalculusWithJulia.WeaveSupport.centered_content_tpl
|
||||
txt = CalculusWithJulia.WeaveSupport.Mustache.render(tpl, content=txt, caption="Julia logo animated")
|
||||
CalculusWithJulia.WeaveSupport.HTMLoutput(txt)
|
||||
HTMLoutput(txt; centered=true, caption="Julia logo animated")
|
||||
```
|
||||
|
||||
### Functions using degrees
|
||||
@@ -884,4 +866,3 @@ Is this identical to the pattern for the regular sine function?
|
||||
#| echo: false
|
||||
yesnoq(false)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,13 +10,6 @@
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "Variables",
|
||||
description = "Calculus with Julia: Variables",
|
||||
tags = ["CalculusWithJulia", "precalc", "variables"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
@@ -493,4 +486,3 @@ choices = ["Assign all three variables at once to a value of `3`",
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -8,20 +8,10 @@
|
||||
#| echo: false
|
||||
#| results: "hidden"
|
||||
using CalculusWithJulia
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using Plots
|
||||
using Measures
|
||||
using LaTeXStrings
|
||||
|
||||
#fig_size = (400, 300)
|
||||
fig_size = (800, 600)
|
||||
|
||||
const frontmatter = (
|
||||
title = "Vectors",
|
||||
description = "Calculus with Julia: Vectors",
|
||||
tags = ["CalculusWithJulia", "precalc", "vectors"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -711,11 +701,11 @@ The style generally employed here is to use plural variable names for a collecti
|
||||
## Other container types
|
||||
|
||||
|
||||
Vectors in `Julia` are a container, one of many different types. Another useful type for programming purposes are *tuples*. If a vector is formed by placing comma-separated values within a `[]` pair (e.g., `[1,2,3]`), a tuple is formed by placing comma-separated values withing a `()` pair. A tuple of length $1$ uses a convention of a trailing comma to distinguish it from a parenthesized expression (e.g. `(1,)` is a tuple, `(1)` is just the value `1`).
|
||||
Vectors in `Julia` are a container, one of many different types. Another useful type for programming purposes are *tuples*. If a vector is formed by placing comma-separated values within a `[]` pair (e.g., `[1,2,3]`), a tuple is formed by placing comma-separated values withing a `()` pair. A tuple of length $1$ uses a convention of a trailing comma to distinguish it from a parenthesized expression (e.g. `(1,)` is a tuple, `(1)` is just the value `1`).
|
||||
|
||||
:::{.callout-note}
|
||||
## Well, actually...
|
||||
Technically, the tuple is formed by the use of commas, which separate different expressions. The parentheses are typically used, as they clarify the intent. In a notebook interface, it is useful to just use commas to separate values to output, as typically the only the last command is displayed. This usage just forms a tuple of the values and displays that.
|
||||
Technically, the tuple is formed just by the use of commas, which separate different expressions. The parentheses are typically used, as they clarify the intent and disambiguate some usage. In a notebook interface, it is useful to just use commas to separate values to output, as typically the only the last command is displayed. This usage just forms a tuple of the values and displays that.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user