This commit is contained in:
jverzani
2024-05-22 07:55:20 -04:00
parent f710cded15
commit 771bb06aa3
50 changed files with 120 additions and 426 deletions

View File

@@ -52,7 +52,7 @@ Packages can also be loaded through `import PackageName`. Importing does not add
## Types
Objects in `Julia` are "typed." Common numeric types are `Float64`, `Int64` for floating point numbers and integers. Less used here are types like `Rational{Int64}`, specifying rational numbers with a numerator and denominator as `Int64`; or `Complex{Float64}`, specifying a comlex number with floating point components. Julia also has `BigFloat` and `BigInt` for arbitrary precision types. Typically, operations use "promotion" to ensure the combination of types is appropriate. Other useful types are `Function`, an abstract type describing functions; `Bool` for true and false values; `Sym` for symbolic values (through `SymPy`); and `Vector{Float64}` for vectors with floating point components.
Objects in `Julia` are "typed." Common numeric types are `Float64`, `Int64` for floating point numbers and integers. Less used here are types like `Rational{Int64}`, specifying rational numbers with a numerator and denominator as `Int64`; or `Complex{Float64}`, specifying a complex number with floating point components. Julia also has `BigFloat` and `BigInt` for arbitrary precision types. Typically, operations use "promotion" to ensure the combination of types is appropriate. Other useful types are `Function`, an abstract type describing functions; `Bool` for true and false values; `Sym` for symbolic values (through `SymPy`); and `Vector{Float64}` for vectors with floating point components.
For the most part the type will not be so important, but it is useful to know that for some function calls the type of the argument will decide what method ultimately gets called. (This allows symbolic types to interact with Julia functions in an idiomatic manner.)
@@ -175,7 +175,7 @@ Here the number of arguments is used:
```{julia}
Area(w, h) = w * h # area of rectangle
Area(w) = Area(w, w) # area of square using area of rectangle defintion
Area(w) = Area(w, w) # area of square using area of rectangle definition
```
Calling `Area(5)` will call `Area(5,5)` which will return `5*5`.
@@ -294,7 +294,7 @@ We use a few different containers:
x1 = (1, "two", 3.0)
```
Tuples are useful for programming. For example, they are uesd to return multiple values from a function.
Tuples are useful for programming. For example, they are used to return multiple values from a function.
* Vectors. These are objects of the same type (typically) grouped together using square brackets, values separated by commas:
@@ -304,7 +304,7 @@ Tuples are useful for programming. For example, they are uesd to return multiple
x2 = [1, 2, 3.0] # 3.0 makes theses all floating point
```
Unlike tuples, the expected arithmatic from Linear Algebra is implemented for vectors.
Unlike tuples, the expected arithmetic from Linear Algebra is implemented for vectors.
* Matrices. Like vectors, combine values of the same type, only they are 2-dimensional. Use spaces to separate values along a row; semicolons to separate rows:
@@ -628,7 +628,7 @@ ys = [vs[i][2] for i in eachindex(vs)]
plot(xs, ys)
```
This approach is faciliated by the `unzip` function in `CalculusWithJulia` (and used internally by `plot_parametric`):
This approach is facilitated by the `unzip` function in `CalculusWithJulia` (and used internally by `plot_parametric`):
```{julia}
@@ -698,7 +698,7 @@ f(x, y) = 2 - x^2 + y^2
contour(xs, ys, f.(xs, ys'))
```
* An implicit equation. The constraint $f(x,y)=c$ generates an implicit equation. While `contour` can be used for this type of plot - by adjusting the requested contours - the `ImplicitPlots` package does this to make a plot of the equations $f(x,y) = 0$. (The `CalculusWithJulia` package re-uses the `implict_plot` function.)
* An implicit equation. The constraint $f(x,y)=c$ generates an implicit equation. While `contour` can be used for this type of plot - by adjusting the requested contours - the `ImplicitPlots` package does this to make a plot of the equations $f(x,y) = 0$. (The `CalculusWithJulia` package re-uses the `implicit_plot` function.)
```{julia}
@@ -785,7 +785,7 @@ Numerically, the `ForwardDiff.derivative(f, x)` function call will find the deri
ForwardDiff.derivative(sin, pi/3) - cos(pi/3)
```
The `CalculusWithJulia` package overides the `'` (`adjoint`) syntax for functions to provide a derivative which takes a function and returns a function, so its usage is familiar
The `CalculusWithJulia` package overrides the `'` (`adjoint`) syntax for functions to provide a derivative which takes a function and returns a function, so its usage is familiar
```{julia}