Update functions.qmd

some typos
This commit is contained in:
Fang Liu 2023-04-07 16:51:48 +08:00
parent d30bc690d7
commit 3ff21db7e6

View File

@ -65,7 +65,7 @@ g(x) = x^2 - x
h(x) = sqrt(x)
```
The left-hand sign of the equals sign is an assignment. In this use, a function with a given signature is defined and attached to a method table for the given function name. The right-hand side is simply `Julia` code to compute the *rule* corresponding to the function.
The left-hand side of the equals sign is an assignment. In this use, a function with a given signature is defined and attached to a method table for the given function name. The right-hand side is simply `Julia` code to compute the *rule* corresponding to the function.
Calling the function also follows standard math notation:
@ -183,7 +183,7 @@ else
end
```
The conditions for the `if` statements are expressions that evaluate to either `true` or `false`, such as generated by the Boolean operators `<`, `<=`, `==`, `!-`, `>=`, and `>`.
The conditions for the `if` statements are expressions that evaluate to either `true` or `false`, such as generated by the Boolean operators `<`, `<=`, `==`, `!=`, `>=`, and `>`.
If familiar with `if` conditions, they are natural to use. However, for simpler cases of "if-else" `Julia` provides the more convenient *ternary* operator: `cond ? if_true : if_false`. (The name comes from the fact that there are three arguments specified.) The ternary operator checks the condition and if true returns the first expression, whereas if the condition is false the second condition is returned. (Another useful control flow construct is [short-circuit](https://docs.julialang.org/en/v1/manual/control-flow/#Short-Circuit-Evaluation) evaluation.)
@ -363,7 +363,7 @@ q(𝒄)
q(𝒄)
```
Yes, now the function value at this new $c$ is even closer to $0$. Trying a few more times we see we just get closer and closer. He we start again to see the progress
Yes, now the function value at this new $c$ is even closer to $0$. Trying a few more times we see we just get closer and closer. Here we start again to see the progress
```{julia}
@ -609,7 +609,7 @@ But the other fact about this problem - that the perimeter is $20$ - means that
height(w) = (20 - 2*w)/2
```
By hand we would substitute this last expression into that for the area and simplify (to get $A=w\cdot (20-2 \cdot w)/2 = -w^2 + 10$). However, within `Julia` we can let *composition* do the substitution and leave the algebraic simplification for `Julia` to do:
By hand we would substitute this last expression into that for the area and simplify (to get $A=w\cdot (20-2 \cdot w)/2 = -w^2 + 10w$). However, within `Julia` we can let *composition* do the substitution and leave the algebraic simplification for `Julia` to do:
```{julia}
@ -1315,7 +1315,7 @@ For this problem, the actual range can easily be identified. Does the bound comp
yesnoq("yes")
```
Does `sin(0..pi)` **exactly** match the interval of $[-1,1]$?
Does `sin(0..pi)` **exactly** match the interval of $[0,1]$?
```{julia}
@ -1330,7 +1330,7 @@ Guess why or why not?
```{julia}
#| hold: true
#| echo: false
choices = ["Well it does, because ``[-1,1]`` is the range",
choices = ["Well it does, because ``[0,1]`` is the range",
"""It does not. The bound found is a provably known bound. The small deviation is due to the possible errors in evalution of the `sin` function near the floating point approximation of `pi`,
"""]
radioq(choices, 2)