add freeze
This commit is contained in:
1 parent
3862d89a69
commit
954f9a96d5
675 files changed
+572480
-2
No files matched your search
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"hash": "92ad0f7616c34c6fe2dd644bc61877a5",
|
||||
"result": {
|
||||
"markdown": "# Area between two curves\n\n\n\nThis section uses these add-on packages:\n\n``` {.julia .cell-code}\nusing CalculusWithJulia\nusing Plots\nusing Roots\nusing QuadGK\nusing SymPy\n```\n\n\n\n\n---\n\n\nThe definite integral gives the \"signed\" area between the function $f(x)$ and the $x$-axis over $[a,b]$. Conceptually, this is the area between two curves, $f(x)$ and $g(x)=0$. More generally, this integral:\n\n\n\n$$\n\\int_a^b (f(x) - g(x)) dx\n$$\n\n\ncan be interpreted as the \"signed\" area between $f(x)$ and $g(x)$ over $[a,b]$. If on this interval $[a,b]$ it is true that $f(x) \\geq g(x)$, then this would just be the area, as seen in this figure. The rectangle in the figure has area: $(f(a)-g(a)) \\cdot (b-a)$ which could be a term in a left Riemann sum of the integral of $f(x) - g(x)$:\n\n::: {.cell hold='true' execution_count=4}\n\n::: {.cell-output .cell-output-display execution_count=5}\n{}\n:::\n:::\n\n\nFor the figure, we have $f(x) = \\sqrt{x}$, $g(x)= x^2$ and $[a,b] = [1/4, 3/4]$. The shaded area is then found by:\n\n\n\n$$\n\\int_{1/4}^{3/4} (x^{1/2} - x^2) dx = (\\frac{x^{3/2}}{3/2} - \\frac{x^3}{3})\\big|_{1/4}^{3/4} = \\frac{\\sqrt{3}}{4} -\\frac{7}{32}.\n$$\n\n\n#### Examples\n\n\nFind the area bounded by the line $y=2x$ and the curve $y=2 - x^2$.\n\n\nWe can plot to see the area in question:\n\n::: {.cell execution_count=5}\n``` {.julia .cell-code}\nf(x) = 2 - x^2\ng(x) = 2x\nplot(f, -3,3)\nplot!(g)\n```\n\n::: {.cell-output .cell-output-display execution_count=6}\n{}\n:::\n:::\n\n\nFor this problem we need to identify $a$ and $b$. These are found numerically through:\n\n::: {.cell execution_count=6}\n``` {.julia .cell-code}\na,b = find_zeros(x -> f(x) - g(x), -3, 3)\n```\n\n::: {.cell-output .cell-output-display execution_count=7}\n```\n2-element Vector{Float64}:\n -2.732050807568877\n 0.7320508075688773\n```\n:::\n:::\n\n\nThe answer then can be found numerically:\n\n::: {.cell execution_count=7}\n``` {.julia .cell-code}\nquadgk(x -> f(x) - g(x), a, b)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=8}\n```\n6.928203230275509\n```\n:::\n:::\n\n\n##### Example\n\n\nFind the integral between $f(x) = \\sin(x)$ and $g(x)=\\cos(x)$ over $[0,2\\pi]$ where $f(x) \\geq g(x)$.\n\n\nA plot shows the areas:\n\n::: {.cell execution_count=8}\n``` {.julia .cell-code}\n𝒇(x) = sin(x)\n𝒈(x) = cos(x)\nplot(𝒇, 0, 2pi)\nplot!(𝒈)\n```\n\n::: {.cell-output .cell-output-display execution_count=9}\n{}\n:::\n:::\n\n\nThere is a single interval when $f \\geq g$ and this can be found algebraically using basic trigonometry, or numerically:\n\n::: {.cell execution_count=9}\n``` {.julia .cell-code}\n𝒂,𝒃 = find_zeros(x -> 𝒇(x) - 𝒈(x), 0, 2pi) # pi/4, 5pi/4\nquadgk(x -> 𝒇(x) - 𝒈(x), 𝒂, 𝒃)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=10}\n```\n2.8284271247461903\n```\n:::\n:::\n\n\n##### Example\n\n\nFind the area between $x^n$ and $x^{n+1}$ over $[0,1]$ for $n=1,2,\\dots$.\n\n\nWe have on this interval $x^n \\geq x^{n+1}$, so the integral can be found symbolically through:\n\n::: {.cell execution_count=10}\n``` {.julia .cell-code}\n@syms x::positive n::positive\nex = integrate(x^n - x^(n+1), (x, 0, 1))\ntogether(ex)\n```\n\n::: {.cell-output .cell-output-display execution_count=11}\n```{=html}\n<span class=\"math-left-align\" style=\"padding-left: 4px; width:0; float:left;\"> \n\\[\n\\frac{1}{\\left(n + 1\\right) \\left(n + 2\\right)}\n\\]\n</span>\n```\n:::\n:::\n\n\nBased on this answer, what is the value of this\n\n\n\n$$\n\\frac{1}{2\\cdot 3} + \\frac{1}{3\\cdot 4} + \\frac{1}{4\\cdot 5} + \\cdots?\n$$\n\n\nThis should should be no surprise, given how the areas computed carve up the area under the line $y=x^1$ over $[0,1]$, so the answer should be $1/2$.\n\n::: {.cell execution_count=11}\n``` {.julia .cell-code}\np = plot(x, 0, 1, legend=false)\n[plot!(p, x^n, 0, 1) for n in 2:20]\np\n```\n\n::: {.cell-output .cell-output-display execution_count=12}\n{}\n:::\n:::\n\n\nWe can check using the `summation` function of `SymPy` which is similar in usage to `integrate`:\n\n::: {.cell execution_count=12}\n``` {.julia .cell-code}\nsummation(1/(n+1)/(n+2), (n, 1, oo))\n```\n\n::: {.cell-output .cell-output-display execution_count=13}\n```{=html}\n<span class=\"math-left-align\" style=\"padding-left: 4px; width:0; float:left;\"> \n\\[\n\\frac{1}{2}\n\\]\n</span>\n```\n:::\n:::\n\n\n##### Example\n\n\nVerify [Archimedes'](http://en.wikipedia.org/wiki/The_Quadrature_of_the_Parabola) finding that the area of the parabolic segment is $4/3$rds that of the triangle joining $a$, $(a+b)/2$ and $b$.\n\n::: {.cell hold='true' execution_count=13}\n\n::: {.cell-output .cell-output-display executiLine truncated
|
||||
"supporting": [
|
||||
"area_between_curves_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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user