CalculusWithJuliaNotes.jl/quarto/_freeze/precalc/logical_expressions/execute-results/html.json
2022-09-08 07:03:08 -04:00

15 lines
61 KiB
JSON

{
"hash": "3ea7ce121d0ff8bbd6b6eabe22898d02",
"result": {
"markdown": "# Inequalities, Logical expressions\n\n\n\nIn this section we use the following package:\n\n``` {.julia .cell-code}\nusing CalculusWithJulia # loads the `SpecialFunctions` package\n```\n\n\n\n\n## Boolean values\n\n\nIn mathematics it is common to test if an expression is true or false. For example, is the point $(1,2)$ inside the disc $x^2 + y^2 \\leq 1$? We would check this by substituting $1$ for $x$ and $2$ for $y$, evaluating both sides of the inequality and then assessing if the relationship is true or false. In this case, we end up with a comparison of $5 \\leq 1$, which we of course know is false.\n\n\n`Julia` provides numeric comparisons that allow this notation to be exactly mirrored:\n\n::: {.cell hold='true' execution_count=4}\n``` {.julia .cell-code}\nx, y = 1, 2\nx^2 + y^2 <= 1\n```\n\n::: {.cell-output .cell-output-display execution_count=5}\n```\nfalse\n```\n:::\n:::\n\n\nThe response is `false`, as expected. `Julia` provides [Boolean](http://en.wikipedia.org/wiki/Boolean_data_type) values `true` and `false` for such questions. The same process is followed as was described mathematically.\n\n\nThe set of numeric comparisons is nearly the same as the mathematical counterparts: `<`, `<=`, `==`, `>=`, `>`. The syntax for less than or equal can also be represented with the Unicode `≤` (generated by `\\le[tab]`). Similarly, for greater than or equal, there is `\\ge[tab]`.\n\n\n:::{.callout-warning}\n## Warning\nThe use of `==` is necessary, as `=` is used for assignment and mutation.\n\n:::\n\nThe `!` operator takes a boolean value and negates it. It uses prefix notation:\n\n::: {.cell execution_count=5}\n``` {.julia .cell-code}\n!true\n```\n\n::: {.cell-output .cell-output-display execution_count=6}\n```\nfalse\n```\n:::\n:::\n\n\nFor convenience, `a != b` can be used in place of `!(a == b)`.\n\n\n## Algebra of inequalities\n\n\nTo illustrate, let's see that the algebra of expressions works as expected.\n\n\nFor example, if $a < b$ then for any $c$ it is also true that $a + c < b + c$.\n\n\nWe can't \"prove\" this through examples, but we can investigate it by the choice of various values of $a$, $b$, and $c$. For example:\n\n::: {.cell hold='true' execution_count=6}\n``` {.julia .cell-code}\na,b,c = 1,2,3\na < b, a + c < b + c\n```\n\n::: {.cell-output .cell-output-display execution_count=7}\n```\n(true, true)\n```\n:::\n:::\n\n\nOr in reverse:\n\n::: {.cell hold='true' execution_count=7}\n``` {.julia .cell-code}\na,b,c = 3,2,1\na < b, a + c < b + c\n```\n\n::: {.cell-output .cell-output-display execution_count=8}\n```\n(false, false)\n```\n:::\n:::\n\n\nTrying other choices will show that the two answers are either both `false` or both `true`.\n\n\n:::{.callout-warning}\n## Warning\nWell, almost... When `Inf` or `NaN` are involved, this may not hold, for example `1 + Inf < 2 + Inf` is actually `false`. As would be `1 + (typemax(1)-1) < 2 + (typemax(1)-1)`.\n\n:::\n\nSo adding or subtracting most any finite value from an inequality will preserve the inequality, just as it does for equations.\n\n\nWhat about addition and multiplication?\n\n\nConsider the case $a < b$ and $c > 0$. Then $ca < cb$. Here we investigate using $3$ random values (which will be positive):\n\n::: {.cell hold='true' execution_count=8}\n``` {.julia .cell-code}\na,b,c = rand(3) # 3 random numbers in [0,1)\na < b, c*a < c*b\n```\n\n::: {.cell-output .cell-output-display execution_count=9}\n```\n(false, false)\n```\n:::\n:::\n\n\nWhenever these two commands are run, the two logical values should be identical, even though the specific values of `a`, `b`, and `c` will vary.\n\n\nThe restriction that $c > 0$ is needed. For example, if $c = -1$, then we have $a < b$ if and only if $-a > -b$. That is the inequality is \"flipped.\"\n\n::: {.cell hold='true' execution_count=9}\n``` {.julia .cell-code}\na,b = rand(2)\na < b, -a > -b\n```\n\n::: {.cell-output .cell-output-display execution_count=10}\n```\n(true, true)\n```\n:::\n:::\n\n\nAgain, whenever this is run, the two logical values should be the same. The values $a$ and $-a$ are the same distance from $0$, but on opposite sides. Hence if $0 < a < b$, then $b$ is farther from $0$ than $a$, so $-b$ will be farther from $0$ than $-a$, which in this case says $-b < -a$, as expected.\n\n\nFinally, we have the case of division. The relation of $x$ and $1/x$ (for $x > 0$) is that the farther $x$ is from $0$, the closer $1/x$ is to $0$. So large values of $x$ make small values of $1/x$. This leads to this fact for $a,b > 0$: $a < b$ if and only if $1/a > 1/b$.\n\n\nWe can check with random values again:\n\n::: {.cell hold='true' execution_count=10}\n``` {.julia .cell-code}\na,b = rand(2)\na < b, 1/a > 1/b\n```\n\n::: {.cell-output .cell-output-display execution_count=11}\n```\n(false, false)\n```\n:::\n:::\n\n\nIn summary we investigated numerically that the following hold:\n\n\n * `a < b` if and only if `a + c < b + c` for all finite `a`, `b`, and `c`.\n * `a < b` if and only if `c*a < c*b` for all finite `a` and `b`, and finite, positive `c`.\n * `a < b` if and only if `-a > -b` for all finite `a` and `b`.\n * `a < b` if and only if `1/a > 1/b` for all finite, positive `a` and `b`.\n\n\n### Examples\n\n\nWe now show some inequalities highlighted on this [Wikipedia](http://en.wikipedia.org/wiki/Inequality_%28mathematics%29) page.\n\n\nNumerically investigate the fact $e^x \\geq 1 + x$ by showing it is true for three different values of $x$. We pick $x=-1$, $0$, and $1$:\n\n::: {.cell hold='true' execution_count=11}\n``` {.julia .cell-code}\nx = -1; exp(x) >= 1 + x\nx = 0; exp(x) >= 1 + x\nx = 1; exp(x) >= 1 + x\n```\n\n::: {.cell-output .cell-output-display execution_count=12}\n```\ntrue\n```\n:::\n:::\n\n\nNow, let's investigate that for any distinct real numbers, $a$ and $b$, that\n\n\n\n$$\n\\frac{e^b - e^a}{b - a} > e^{(a+b)/2}\n$$\n\n\nFor this, we use `rand(2)` to generate two random numbers in $[0,1)$:\n\n::: {.cell hold='true' execution_count=12}\n``` {.julia .cell-code}\na, b = rand(2)\n(exp(b) - exp(a)) / (b-a) > exp((a+b)/2)\n```\n\n::: {.cell-output .cell-output-display execution_count=13}\n```\ntrue\n```\n:::\n:::\n\n\nThis should evaluate to `true` for any random choice of `a` and `b` returned by `rand(2)`.\n\n\nFinally, let's investigate the fact that the harmonic mean, $2/(1/a + 1/b)$ is less than or equal to the geometric mean, $\\sqrt{ab}$, which is less than or equal to the quadratic mean, $\\sqrt{a^2 + b^2}/\\sqrt{2}$, using two randomly chosen values:\n\n::: {.cell hold='true' execution_count=13}\n``` {.julia .cell-code}\na, b = rand(2)\nh = 2 / (1/a + 1/b)\ng = (a * b) ^ (1 / 2)\nq = sqrt((a^2 + b^2) / 2)\nh <= g, g <= q\n```\n\n::: {.cell-output .cell-output-display execution_count=14}\n```\n(true, true)\n```\n:::\n:::\n\n\n## Chaining, combining expressions: absolute values\n\n\nThe absolute value notation can be defined through cases:\n\n\n\n$$\n\\lvert x\\rvert = \\begin{cases}\nx & x \\geq 0\\\\\n-x & \\text{otherwise}.\n\\end{cases}\n$$\n\n\nThe interpretation of $\\lvert x\\rvert$, as the distance on the number line of $x$ from $0$, means that many relationships are naturally expressed in terms of absolute values. For example, a simple shift: $\\lvert x -c\\rvert$ is related to the distance $x$ is from the number $c$. As common as they are, the concept can still be confusing when inequalities are involved.\n\n\nFor example, the expression $\\lvert x - 5\\rvert < 7$ has solutions which are all values of $x$ within $7$ units of $5$. This would be the values $-2< x < 12$. If this isn't immediately intuited, then formally $\\lvert x - 5\\rvert <7$ is a compact representation of a chain of inequalities: $-7 < x-5 < 7$. (Which is really two combined inequalities: $-7 < x-5$ *and* $x-5 < 7$.) We can \"add\" $5$ to each side to get $-2 < x < 12$, using the fact that adding by a finite number does not change the inequality sign.\n\n\nJulia's precedence for logical expressions, allows such statements to mirror the mathematical notation:\n\n::: {.cell execution_count=14}\n``` {.julia .cell-code}\nx = 18\nabs(x - 5) < 7\n```\n\n::: {.cell-output .cell-output-display execution_count=15}\n```\nfalse\n```\n:::\n:::\n\n\nThis is to be expected, but we could also have written:\n\n::: {.cell execution_count=15}\n``` {.julia .cell-code}\n-7 < x - 5 < 7\n```\n\n::: {.cell-output .cell-output-display execution_count=16}\n```\nfalse\n```\n:::\n:::\n\n\nRead aloud this would be \"minus $7$ is less than $x$ minus $5$ **and** $x$ minus $5$ is less than $7$\".\n\n\nThe \"and\" equations can be combined as above with a natural notation. However, an equation like $\\lvert x - 5\\rvert > 7$ would emphasize an **or** and be \"$x$ minus $5$ less than minus $7$ **or** $x$ minus $5$ greater than $7$\". Expressing this requires some new notation.\n\n\nThe *boolean shortcut operators* `&&` and `||` implement \"and\" and \"or.\" (There are also *bitwise* boolean operators `&` and `|`, but we only describe the former.)\n\n\nThus we could write $-7 < x-5 < 7$ as\n\n::: {.cell execution_count=16}\n``` {.julia .cell-code}\n(-7 < x - 5) && (x - 5 < 7)\n```\n\n::: {.cell-output .cell-output-display execution_count=17}\n```\nfalse\n```\n:::\n:::\n\n\nand could write $\\lvert x-5\\rvert > 7$ as\n\n::: {.cell execution_count=17}\n``` {.julia .cell-code}\n(x - 5 < -7) || (x - 5 > 7)\n```\n\n::: {.cell-output .cell-output-display execution_count=18}\n```\ntrue\n```\n:::\n:::\n\n\n(The first expression is false for $x=18$ and the second expression true, so the \"or\"ed result is `true` and the \"and\" result if `false`.)\n\n\n##### Example\n\n\nOne of [DeMorgan's Laws](http://en.wikipedia.org/wiki/De_Morgan%27s_laws) states that \"not (A and B)\" is the same as \"(not A) or (not B)\". This is a kind of distributive law for \"not\", but note how the \"and\" changes to \"or\". We can verify this law systematically. For example, the following shows it true for $1$ of the $4$ possible cases for the pair `A`, `B` to take:\n\n::: {.cell execution_count=18}\n``` {.julia .cell-code}\nA,B = true, false ## also true, true; false, true; and false, false\n!(A && B) == !A || !B\n```\n\n::: {.cell-output .cell-output-display execution_count=19}\n```\ntrue\n```\n:::\n:::\n\n\n## Precedence\n\n\nThe question of when parentheses are needed and when they are not is answered by the [precedence](https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity) rules implemented. Earlier, we wrote\n\n::: {.cell execution_count=19}\n``` {.julia .cell-code}\n(x - 5 < -7) || (x - 5 > 7)\n```\n\n::: {.cell-output .cell-output-display execution_count=20}\n```\ntrue\n```\n:::\n:::\n\n\nTo represent $\\lvert x-5\\rvert > 7$. Were the parentheses necessary? Let's just check.\n\n::: {.cell execution_count=20}\n``` {.julia .cell-code}\nx - 5 < -7 || x - 5 > 7\n```\n\n::: {.cell-output .cell-output-display execution_count=21}\n```\ntrue\n```\n:::\n:::\n\n\nSo no, they were not in this case.\n\n\nAn operator (such as `<`, `>`, `||` above) has an associated associativity and precedence. The associativity is whether an expression like `a - b - c` is `(a-b) - c` or `a - (b-c)`. The former being left associative, the latter right. Of issue here is *precedence*, as in with two or more different operations, which happens first, second, $\\dots$.\n\n\nThe table in the manual on [operator precedence and associativity](https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity) shows that for these operations \"control flow\" (the `&&` above) is lower than \"comparisons\" (the `<`, `>`), which are lower than \"Addition\" (the `-` above). So the expression without parentheses would be equivalent to:\n\n::: {.cell execution_count=21}\n``` {.julia .cell-code}\n((x-5) < -7) && ((x-5) > 7)\n```\n\n::: {.cell-output .cell-output-display execution_count=22}\n```\nfalse\n```\n:::\n:::\n\n\n(This is different than the precedence of the bitwise boolean operators, which have `&` with \"Multiplication\" and `|` with \"Addition\", so `x-5 < 7 | x - 5 > 7` would need parentheses.)\n\n\nA thorough understanding of the precedence rules can help eliminate unnecessary parentheses, but in most cases it is easier just to put them in.\n\n\n## Arithmetic with\n\n\nFor convenience, basic arithmetic can be performed with Boolean values, `false` becomes $0$ and true $1$. For example, both these expressions make sense:\n\n::: {.cell execution_count=22}\n``` {.julia .cell-code}\ntrue + true + false, false * 1000\n```\n\n::: {.cell-output .cell-output-display execution_count=23}\n```\n(2, 0)\n```\n:::\n:::\n\n\nThe first example shows a common means used to count the number of `true` values in a collection of Boolean values - just add them.\n\n\nThis can be cleverly exploited. For example, the following expression returns `x` when it is positive and $0$ otherwise:\n\n::: {.cell execution_count=23}\n``` {.julia .cell-code}\n(x > 0) * x\n```\n\n::: {.cell-output .cell-output-display execution_count=24}\n```\n18\n```\n:::\n:::\n\n\nThere is a built in function, `max` that can be used for this: `max(0, x)`.\n\n\nThis expression returns `x` if it is between $-10$ and $10$ and otherwise $-10$ or $10$ depending on whether $x$ is negative or positive.\n\n::: {.cell execution_count=24}\n``` {.julia .cell-code}\n(x < -10)*(-10) + (x >= -10)*(x < 10) * x + (x>=10)*10\n```\n\n::: {.cell-output .cell-output-display execution_count=25}\n```\n10\n```\n:::\n:::\n\n\nThe `clamp(x, a, b)` performs this task more generally, and is used as in `clamp(x, -10, 10)`.\n\n\n## Questions\n\n\n###### Question\n\n\nIs `e^pi` or `pi^e` greater?\n\n::: {.cell hold='true' execution_count=25}\n\n::: {.cell-output .cell-output-display execution_count=26}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='11413183315770854612' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_11413183315770854612\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_11413183315770854612_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_11413183315770854612\"\n id=\"radio_11413183315770854612_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n <code>e^pi</code> is equal to <code>pi^e</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_11413183315770854612_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_11413183315770854612\"\n id=\"radio_11413183315770854612_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n <code>e^pi</code> is greater than <code>pi^e</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_11413183315770854612_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_11413183315770854612\"\n id=\"radio_11413183315770854612_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n <code>e^pi</code> is less than <code>pi^e</code>\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='11413183315770854612_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_11413183315770854612\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('11413183315770854612_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_11413183315770854612\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_11413183315770854612\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nIs $\\sin(1000)$ positive?\n\n::: {.cell hold='true' execution_count=26}\n\n::: {.cell-output .cell-output-display execution_count=27}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='7813187935024034952' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_7813187935024034952\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_7813187935024034952_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_7813187935024034952\"\n id=\"radio_7813187935024034952_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n Yes\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_7813187935024034952_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_7813187935024034952\"\n id=\"radio_7813187935024034952_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n No\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='7813187935024034952_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_7813187935024034952\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 1;\n var msgBox = document.getElementById('7813187935024034952_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_7813187935024034952\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_7813187935024034952\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nSuppose you know $0 < a < b$. What can you say about the relationship between $-1/a$ and $-1/b$?\n\n::: {.cell hold='true' execution_count=27}\n\n::: {.cell-output .cell-output-display execution_count=28}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='1164892194751639474' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_1164892194751639474\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_1164892194751639474_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_1164892194751639474\"\n id=\"radio_1164892194751639474_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n \\(-1/a < -1/b\\)\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_1164892194751639474_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_1164892194751639474\"\n id=\"radio_1164892194751639474_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n \\(-1/a \\geq -1/b\\)\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_1164892194751639474_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_1164892194751639474\"\n id=\"radio_1164892194751639474_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n \\(-1/a > -1/b\\)\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='1164892194751639474_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_1164892194751639474\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('1164892194751639474_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_1164892194751639474\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_1164892194751639474\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nSuppose you know $a < 0 < b$, is it true that $1/a > 1/b$?\n\n::: {.cell hold='true' execution_count=28}\n\n::: {.cell-output .cell-output-display execution_count=29}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='3703049347056112452' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_3703049347056112452\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_3703049347056112452_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_3703049347056112452\"\n id=\"radio_3703049347056112452_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n It can sometimes be true, though not always.\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_3703049347056112452_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_3703049347056112452\"\n id=\"radio_3703049347056112452_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n It is never true, as \\(1/a\\) is negative and \\(1/b\\) is positive\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_3703049347056112452_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_3703049347056112452\"\n id=\"radio_3703049347056112452_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n Yes, it is always true.\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='3703049347056112452_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_3703049347056112452\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('3703049347056112452_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_3703049347056112452\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_3703049347056112452\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nThe `airyai` [function](http://en.wikipedia.org/wiki/Airy_function) is a special function named after a British Astronomer who realized the function's value in his studies of the rainbow. The `SpecialFunctions` package must be loaded to include this function, which is done with the accompanying package `CalculusWithJulia`.\n\n::: {.cell execution_count=29}\n``` {.julia .cell-code}\nairyai(0)\n```\n\n::: {.cell-output .cell-output-display execution_count=30}\n```\n0.3550280538878172\n```\n:::\n:::\n\n\nIt is known that this function is always positive for $x > 0$, though not so for negative values of $x$. Which of these indicates the first negative value : `airyai(-1) <0`, `airyai(-2) < 0`, ..., or `airyai(-5) < 0`?\n\n::: {.cell hold='true' execution_count=30}\n\n::: {.cell-output .cell-output-display execution_count=31}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='16586549001634797469' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_16586549001634797469\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_16586549001634797469_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_16586549001634797469\"\n id=\"radio_16586549001634797469_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n <code>airyai&#40;-1&#41; &lt; 0</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_16586549001634797469_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_16586549001634797469\"\n id=\"radio_16586549001634797469_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n <code>airyai&#40;-2&#41; &lt; 0</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_16586549001634797469_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_16586549001634797469\"\n id=\"radio_16586549001634797469_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n <code>airyai&#40;-3&#41; &lt; 0</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_16586549001634797469_4\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_16586549001634797469\"\n id=\"radio_16586549001634797469_4\" value=\"4\">\n </input>\n <span class=\"label-body px-1\">\n <code>airyai&#40;-4&#41; &lt; 0</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_16586549001634797469_5\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_16586549001634797469\"\n id=\"radio_16586549001634797469_5\" value=\"5\">\n </input>\n <span class=\"label-body px-1\">\n <code>airyai&#40;-5&#41; &lt; 0</code>\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='16586549001634797469_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_16586549001634797469\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 3;\n var msgBox = document.getElementById('16586549001634797469_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_16586549001634797469\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_16586549001634797469\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nBy trying three different values of $x > 0$ which of these could possibly be always true:\n\n::: {.cell hold='true' execution_count=31}\n\n::: {.cell-output .cell-output-display execution_count=32}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='8545236243146220994' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_8545236243146220994\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_8545236243146220994_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_8545236243146220994\"\n id=\"radio_8545236243146220994_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n <code>x^x &lt;&#61; &#40;1/e&#41;^&#40;1/e&#41;</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_8545236243146220994_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_8545236243146220994\"\n id=\"radio_8545236243146220994_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n <code>x^x &gt;&#61; &#40;1/e&#41;^&#40;1/e&#41;</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_8545236243146220994_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_8545236243146220994\"\n id=\"radio_8545236243146220994_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n <code>x^x &#61;&#61; &#40;1/e&#41;^&#40;1/e&#41;</code>\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='8545236243146220994_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_8545236243146220994\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('8545236243146220994_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_8545236243146220994\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_8545236243146220994\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nStudent logic says $(x+y)^p = x^p + y^p$. Of course, this isn't correct for all $p$ and $x$. By trying a few points, which is true when $x,y > 0$ and $0 < p < 1$:\n\n::: {.cell hold='true' execution_count=32}\n\n::: {.cell-output .cell-output-display execution_count=33}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='18251082348676263742' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_18251082348676263742\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_18251082348676263742_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_18251082348676263742\"\n id=\"radio_18251082348676263742_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n <code>&#40;x&#43;y&#41;^p &gt; x^p &#43; y^p</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_18251082348676263742_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_18251082348676263742\"\n id=\"radio_18251082348676263742_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n <code>&#40;x&#43;y&#41;^p &#61;&#61; x^p &#43; y^p</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_18251082348676263742_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_18251082348676263742\"\n id=\"radio_18251082348676263742_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n <code>&#40;x&#43;y&#41;^p &lt; x^p &#43; y^p</code>\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='18251082348676263742_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_18251082348676263742\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 3;\n var msgBox = document.getElementById('18251082348676263742_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_18251082348676263742\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_18251082348676263742\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nAccording to Wikipedia, one of the following inequalities is always true for $a, b > 0$ (as proved by I. Ilani in JSTOR, AMM, Vol.97, No.1, 1990). Which one?\n\n::: {.cell hold='true' execution_count=33}\n\n::: {.cell-output .cell-output-display execution_count=34}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='10996810664410450712' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_10996810664410450712\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10996810664410450712_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10996810664410450712\"\n id=\"radio_10996810664410450712_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n <code>a^a &#43; b^b &gt;&#61; a^b &#43; b^a</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10996810664410450712_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10996810664410450712\"\n id=\"radio_10996810664410450712_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n <code>a^a &#43; b^b &lt;&#61; a^b &#43; b^a</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10996810664410450712_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10996810664410450712\"\n id=\"radio_10996810664410450712_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n <code>a^b &#43; b^a &lt;&#61; 1</code>\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='10996810664410450712_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_10996810664410450712\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 1;\n var msgBox = document.getElementById('10996810664410450712_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_10996810664410450712\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_10996810664410450712\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nIs $3$ in the set $\\lvert x - 2\\rvert < 1/2$?\n\n::: {.cell hold='true' execution_count=34}\n\n::: {.cell-output .cell-output-display execution_count=35}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='1147052047687814721' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_1147052047687814721\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_1147052047687814721_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_1147052047687814721\"\n id=\"radio_1147052047687814721_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n Yes\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_1147052047687814721_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_1147052047687814721\"\n id=\"radio_1147052047687814721_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n No\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='1147052047687814721_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_1147052047687814721\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('1147052047687814721_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_1147052047687814721\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_1147052047687814721\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nWhich of the following is equivalent to $\\lvert x - a\\rvert > b$:\n\n::: {.cell hold='true' execution_count=35}\n\n::: {.cell-output .cell-output-display execution_count=36}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='10158045351516717901' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_10158045351516717901\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10158045351516717901_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10158045351516717901\"\n id=\"radio_10158045351516717901_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n \\(x - a < -b \\text{ or } x - a > b\\)\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10158045351516717901_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10158045351516717901\"\n id=\"radio_10158045351516717901_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n \\(-b < x-a \\text{ and } x - a < b\\)\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10158045351516717901_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10158045351516717901\"\n id=\"radio_10158045351516717901_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n \\(-b < x - a < b\\)\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='10158045351516717901_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_10158045351516717901\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 1;\n var msgBox = document.getElementById('10158045351516717901_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_10158045351516717901\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_10158045351516717901\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nIf $\\lvert x - \\pi\\rvert < 1/10$ is $\\lvert \\sin(x) - \\sin(\\pi)\\rvert < 1/10$?\n\n\nGuess an answer based on a few runs of\n\n``` {.julia .cell-code}\nx = pi + 1/10 * (2rand()-1)\nabs(x - pi) < 1/10, abs(sin(x) - sin(pi)) < 1/10\n```\n\n\n::: {.cell hold='true' execution_count=37}\n\n::: {.cell-output .cell-output-display execution_count=37}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='7227831966619753102' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_7227831966619753102\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_7227831966619753102_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_7227831966619753102\"\n id=\"radio_7227831966619753102_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n true\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_7227831966619753102_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_7227831966619753102\"\n id=\"radio_7227831966619753102_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n false\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='7227831966619753102_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_7227831966619753102\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 1;\n var msgBox = document.getElementById('7227831966619753102_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_7227831966619753102\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_7227831966619753102\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nDoes `12` satisfy $\\lvert x - 3\\rvert + \\lvert x-9\\rvert > 12$?\n\n::: {.cell hold='true' execution_count=38}\n\n::: {.cell-output .cell-output-display execution_count=38}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='16106224290387360683' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_16106224290387360683\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_16106224290387360683_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_16106224290387360683\"\n id=\"radio_16106224290387360683_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n Yes\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_16106224290387360683_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_16106224290387360683\"\n id=\"radio_16106224290387360683_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n No\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='16106224290387360683_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_16106224290387360683\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('16106224290387360683_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_16106224290387360683\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_16106224290387360683\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nWhich of these will show DeMorgan's law holds when both values are `false`:\n\n::: {.cell hold='true' execution_count=39}\n\n::: {.cell-output .cell-output-display execution_count=39}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='10576008723239918174' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_10576008723239918174\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10576008723239918174_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10576008723239918174\"\n id=\"radio_10576008723239918174_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n <code>&#33;&#40;false &amp;&amp; false&#41; &#61;&#61; &#40;&#33;false || &#33;false&#41;</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10576008723239918174_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10576008723239918174\"\n id=\"radio_10576008723239918174_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n <code>&#33;&#40;false &amp;&amp; false&#41; &#61;&#61; &#40;false || false&#41;</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_10576008723239918174_3\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_10576008723239918174\"\n id=\"radio_10576008723239918174_3\" value=\"3\">\n </input>\n <span class=\"label-body px-1\">\n <code>&#33;&#40;false &amp;&amp; false&#41; &#61;&#61; &#40;&#33;false &amp;&amp; &#33;false&#41;</code>\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='10576008723239918174_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_10576008723239918174\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 1;\n var msgBox = document.getElementById('10576008723239918174_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_10576008723239918174\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_10576008723239918174\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nFor floating point numbers there are two special values `Inf` and `NaN`. For which of these is the answer always `false`:\n\n::: {.cell hold='true' execution_count=40}\n\n::: {.cell-output .cell-output-display execution_count=40}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='4339635152598883575' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_4339635152598883575\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_4339635152598883575_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_4339635152598883575\"\n id=\"radio_4339635152598883575_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n <code>Inf &lt; 3.0</code> and <code>3.0 &lt;&#61; Inf</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_4339635152598883575_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_4339635152598883575\"\n id=\"radio_4339635152598883575_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n <code>NaN &lt; 3.0</code> and <code>3.0 &lt;&#61; NaN</code>\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='4339635152598883575_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_4339635152598883575\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('4339635152598883575_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_4339635152598883575\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_4339635152598883575\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nThe IEEE 754 standard is about floating point numbers, for which there are the special values `Inf`, `-Inf`, `NaN`, and, surprisingly, `-0.0` (as a floating point number and not `-0`, an integer). Here are 4 facts that seem reasonable:\n\n\n * Positive zero is equal but not greater than negative zero.\n * `Inf` is equal to itself and greater than everything else except `NaN`.\n * `-Inf` is equal to itself and less then everything else except `NaN`.\n * `NaN` is not equal to, not less than, and not greater than anything, including itself.\n\n\nDo all four seem to be the case within `Julia`? Find your answer by trial and error.\n\n::: {.cell hold='true' execution_count=41}\n\n::: {.cell-output .cell-output-display execution_count=41}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='5235820977621675811' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_5235820977621675811\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_5235820977621675811_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_5235820977621675811\"\n id=\"radio_5235820977621675811_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n Yes\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_5235820977621675811_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_5235820977621675811\"\n id=\"radio_5235820977621675811_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n No\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='5235820977621675811_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_5235820977621675811\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 1;\n var msgBox = document.getElementById('5235820977621675811_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_5235820977621675811\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_5235820977621675811\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nThe `NaN` value is meant to signal an error in computation. `Julia` has value to indicate some data is missing or unavailable. This is `missing`. For `missing` values we have these computations:\n\n::: {.cell execution_count=42}\n``` {.julia .cell-code}\ntrue && missing, true || missing\n```\n\n::: {.cell-output .cell-output-display execution_count=42}\n```\n(missing, true)\n```\n:::\n:::\n\n\nWe see the value of `true || missing` is `true`. Why?\n\n::: {.cell hold='true' execution_count=43}\n\n::: {.cell-output .cell-output-display execution_count=43}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='1915473009724726032' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_1915473009724726032\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_1915473009724726032_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_1915473009724726032\"\n id=\"radio_1915473009724726032_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n Since the second value is &quot;<code>missing</code>&quot;, only the first is used. So <code>false || missing</code> would also be <code>false</code>\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_1915473009724726032_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_1915473009724726032\"\n id=\"radio_1915473009724726032_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n In the manual we can read that &quot;In the expression <code>a || b</code>, the subexpression <code>b</code> is only evaluated if <code>a</code> evaluates to false.&quot; In this case <code>a</code> is <code>true</code> and so <code>a</code> is returned.\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='1915473009724726032_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_1915473009724726032\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 2;\n var msgBox = document.getElementById('1915473009724726032_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_1915473009724726032\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_1915473009724726032\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\nThe value for `true && missing` is `missing`, not a boolean value. What happens?\n\n::: {.cell hold='true' execution_count=44}\n\n::: {.cell-output .cell-output-display execution_count=44}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='17278210994401465258' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_17278210994401465258\">\n <div style=\"padding-top: 5px\">\n <div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_17278210994401465258_1\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_17278210994401465258\"\n id=\"radio_17278210994401465258_1\" value=\"1\">\n </input>\n <span class=\"label-body px-1\">\n In the manual we can read that &quot;In the expression <code>a &amp;&amp; b</code>, the subexpression <code>b</code> is only evaluated if <code>a</code> evaluates to true.&quot; In this case, <code>a</code> is <code>false</code> so <code>b</code> is evaluated and returned. As <code>b</code> is just <code>missing</code> that is the return value.\n </span>\n </label>\n</div>\n<div class=\"form-check\">\n <label class=\"form-check-label\" for=\"radio_17278210994401465258_2\">\n <input class=\"form-check-input\" type=\"radio\" name=\"radio_17278210994401465258\"\n id=\"radio_17278210994401465258_2\" value=\"2\">\n </input>\n <span class=\"label-body px-1\">\n Since the second value is &quot;<code>missing</code>&quot; all such answers would be missing.\n </span>\n </label>\n</div>\n\n \n </div>\n </div>\n <div id='17278210994401465258_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.querySelectorAll('input[name=\"radio_17278210994401465258\"]').forEach(function(rb) {\nrb.addEventListener(\"change\", function() {\n var correct = rb.value == 1;\n var msgBox = document.getElementById('17278210994401465258_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_17278210994401465258\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_17278210994401465258\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n})});\n\n</script>\n```\n:::\n:::\n\n\n",
"supporting": [
"logical_expressions_files"
],
"filters": [],
"includes": {
"include-in-header": [
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\" integrity=\"sha512-c3Nl8+7g4LMSTdrm621y7kf9v3SDPnhxLNhcjFJbKECVnmZHTdo+IRO05sNLTH/D3vA6u1X32ehoLC7WFVdheg==\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js\" integrity=\"sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==\" crossorigin=\"anonymous\"></script>\n<script type=\"application/javascript\">define('jquery', [],function() {return window.jQuery;})</script>\n"
]
}
}
}