{ "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 \n\\[\n\\frac{1}{\\left(n + 1\\right) \\left(n + 2\\right)}\n\\]\n\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 \n\\[\n\\frac{1}{2}\n\\]\n\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 execution_count=14}\n{}\n:::\n:::\n\n\nFor concreteness, let $f(x) = 2-x^2$ and $[a,b] = [-1, 1/2]$, as in the figure. Then the area of the triangle can be computed through:\n\n::: {.cell execution_count=14}\n``` {.julia .cell-code}\nš(x) = 2 - x^2\nš, š = -1, 1/2\nš = (š + š)/2\n\nsac, sab, scb = secant(š, š, š), secant(š, š, š), secant(š, š, š)\nf1(x) = min(sac(x), scb(x))\nf2(x) = sab(x)\n\nA1 = quadgk(x -> f1(x) - f2(x), š, š)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=15}\n```\n0.421875\n```\n:::\n:::\n\n\nAs we needed three secant lines, we used the `secant` function from `CalculusWithJulia` to create functions representing each. Once that was done, we used the `max` function to facilitate integrating over the top bounding curve, alternatively, we could break the integral over $[a,c]$ and $[c,b]$.\n\n\nThe area of the parabolic segment is more straightforward.\n\n::: {.cell execution_count=15}\n``` {.julia .cell-code}\nA2 = quadgk(x -> š(x) - f2(x), š, š)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=16}\n```\n0.5625000000000001\n```\n:::\n:::\n\n\nFinally, if Archimedes was right, this relationship should bring about $0$ (or something within round-off error):\n\n::: {.cell execution_count=16}\n``` {.julia .cell-code}\nA1 * 4/3 - A2\n```\n\n::: {.cell-output .cell-output-display execution_count=17}\n```\n-1.1102230246251565e-16\n```\n:::\n:::\n\n\n##### Example\n\n\nFind the area bounded by $y=x^4$ and $y=e^x$ when $x^4 \\geq e^x$ and $x > 0$.\n\n\nA graph over $[0,10]$ shows clearly the largest zero, for afterwards the exponential dominates the power.\n\n::: {.cell execution_count=17}\n``` {.julia .cell-code}\nh1(x) = x^4\nh2(x) = exp(x)\nplot(h1, 0, 10)\nplot!(h2)\n```\n\n::: {.cell-output .cell-output-display execution_count=18}\n{}\n:::\n:::\n\n\nThere must be another zero, though it is hard to see from the graph over $[0,10]$, as $0^4=0$ and $e^0=1$, so the polynomial must cross below the exponential to the left of $5$. (Otherwise, plotting over $[0,2]$ will clearly reveal the other zero.) We now find these intersection points numerically and then integrate:\n\n::: {.cell hold='true' execution_count=18}\n``` {.julia .cell-code}\na,b = find_zeros(x -> h1(x) - h2(x), 0, 10)\nquadgk(x -> h1(x) - h2(x), a, b)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=19}\n```\n3980.1173881924947\n```\n:::\n:::\n\n\n##### Examples\n\n\nThe area between $y=\\sin(x)$ and $y=m\\cdot x$ between $0$ and the first positive intersection depends on $m$ (where $0 \\leq m \\leq 1$. The extremes are when $m=0$, the area is $2$ and when $m=1$ (the line is tangent at $x=0$), the area is $0$. What is it for other values of $m$? The picture for $m=1/2$ is:\n\n::: {.cell execution_count=19}\n``` {.julia .cell-code}\nm = 1/2\nplot(sin, 0, pi)\nplot!(x -> m*x)\n```\n\n::: {.cell-output .cell-output-display execution_count=20}\n{}\n:::\n:::\n\n\nFor a given $m$, the area is found after computing $b$, the intersection point. We express this as a function of $m$ for later reuse:\n\n::: {.cell execution_count=20}\n``` {.julia .cell-code}\nintersection_point(m) = maximum(find_zeros(x -> sin(x) - m*x, 0, pi))\na1 = 0\nb1 = intersection_point(m)\nquadgk(x -> sin(x) - m*x, a1, b1)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=21}\n```\n0.4207978950529467\n```\n:::\n:::\n\n\nIn general, the area then as a function of `m` is found by substituting `intersection_point(m)` for `b`:\n\n::: {.cell execution_count=21}\n``` {.julia .cell-code}\narea(m) = quadgk(x -> sin(x) - m*x, 0, intersection_point(m))[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=22}\n```\narea (generic function with 1 method)\n```\n:::\n:::\n\n\nA plot shows the relationship:\n\n::: {.cell execution_count=22}\n``` {.julia .cell-code}\nplot(area, 0, 1)\n```\n\n::: {.cell-output .cell-output-display execution_count=23}\n{}\n:::\n:::\n\n\nWhile here, let's also answer the question of which $m$ gives an area of $1$, or one-half the total? This can be done as follows:\n\n::: {.cell execution_count=23}\n``` {.julia .cell-code}\nfind_zero(m -> area(m) - 1, (0, 1))\n```\n\n::: {.cell-output .cell-output-display execution_count=24}\n```\n0.2566498569701879\n```\n:::\n:::\n\n\n(Which is a nice combination of using `find_zeros`, `quadgk` and `find_zero` to answer a problem.)\n\n\n##### Example\n\n\nFind the area bounded by the $x$ axis, the line $x-1$ and the function $\\log(x+1)$.\n\n\nA plot shows us the basic area:\n\n::: {.cell execution_count=24}\n``` {.julia .cell-code}\nj1(x) = log(x+1)\nj2(x) = x - 1\nplot(j1, 0, 3)\nplot!(j2)\nplot!(zero)\n```\n\n::: {.cell-output .cell-output-display execution_count=25}\n{}\n:::\n:::\n\n\nThe value for \"$b$\" is found from the intersection point of $\\log(x+1)$ and $x-1$, which is near $2$:\n\n::: {.cell execution_count=25}\n``` {.julia .cell-code}\nja = 0\njb = find_zero(x -> j1(x) - j2(x), 2)\n```\n\n::: {.cell-output .cell-output-display execution_count=26}\n```\n2.1461932206205825\n```\n:::\n:::\n\n\nWe see that the lower part of the area has a condition: if $x < 1$ then use $0$, otherwise use $g(x)$. We can handle this many different ways:\n\n\n * break the integral into two pieces and add:\n\n::: {.cell execution_count=26}\n``` {.julia .cell-code}\nquadgk(x -> j1(x) - zero(x), ja, 1)[1] + quadgk(x -> j1(x) - j2(x), 1, jb)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=27}\n```\n0.8030726701188743\n```\n:::\n:::\n\n\n * make a new function for the bottom bound:\n\n::: {.cell execution_count=27}\n``` {.julia .cell-code}\nj3(x) = x < 1 ? 0.0 : j2(x)\nquadgk(x -> j1(x) - j3(x), ja, jb)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=28}\n```\n0.8030726629434394\n```\n:::\n:::\n\n\n * Turn the picture on its side and integrate in the $y$ variable. To do this, we need to solve for inverse functions:\n\n::: {.cell hold='true' execution_count=28}\n``` {.julia .cell-code}\na1=j1(ja)\nb1=j1(jb)\nf1(y)=y+1 # y=x-1, so x=y+1\ng1(y)=exp(y)-1 # y=log(x+1) so e^y = x + 1, x = e^y - 1\nquadgk(y -> f1(y) - g1(y), a1, b1)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=29}\n```\n0.8030726701188743\n```\n:::\n:::\n\n\n:::{.callout-note}\n## Note\nWhen doing problems by hand this latter style can often reduce the complications, but when approaching the task numerically, the first two styles are generally easier, though computationally more expensive.\n\n:::\n\n#### Integrating in different directions\n\n\nThe last example suggested integrating in the $y$ variable. This could have more explanation.\n\n\nIt has been noted that different symmetries can aid in computing integrals through their interpretation as areas. For example, if $f(x)$ is odd, then $\\int_{-b}^b f(x)dx=0$ and if $f(x)$ is even, $\\int_{-b}^b f(x) dx = 2\\int_0^b f(x) dx$.\n\n\nAnother symmetry of the $x-y$ plane is the reflection through the line $y=x$. This has the effect of taking the graph of $f(x)$ to the graph of $f^{-1}(x)$ and vice versa. Here is an example with $f(x) = x^3$ over $[-1,1]$.\n\n::: {.cell hold='true' execution_count=29}\n``` {.julia .cell-code}\nf(x) = x^3\nxs = range(-1, stop=1, length=50)\nys = f.(xs)\nplot(ys, xs)\n```\n\n::: {.cell-output .cell-output-display execution_count=30}\n{}\n:::\n:::\n\n\nBy switching the order of the `xs` and `ys` we \"flip\" the graph through the line $x=y$.\n\n\nWe can use this symmetry to our advantage. Suppose instead of being given an equation $y=f(x)$, we are given it in \"inverse\" style: $x = f(y)$, for example suppose we have $x = y^3$. We can plot this as above via:\n\n::: {.cell hold='true' execution_count=30}\n``` {.julia .cell-code}\nys = range(-1, stop=1, length=50)\nxs = [y^3 for y in ys]\nplot(xs, ys)\n```\n\n::: {.cell-output .cell-output-display execution_count=31}\n{}\n:::\n:::\n\n\nSuppose we wanted the area in the first quadrant between this graph, the $y$ axis and the line $y=1$. What to do? With the problem \"flipped\" through the $y=x$ line, this would just be $\\int_0^1 x^3dx$. Rather than mentally flipping the picture to integrate, instead we can just integrate in the $y$ variable. That is, the area is $\\int_0^1 y^3 dy$. The mental picture for Riemann sums would be have the approximating rectangles laying flat and as a function of $y$, are given a length of $y^3$ and height of \"$dy$\".\n\n\n---\n\n::: {.cell hold='true' execution_count=31}\n\n::: {.cell-output .cell-output-display execution_count=32}\n{}\n:::\n:::\n\n\nThe figure above suggests that the area under $f(x)$ over $[a,b]$ could be represented as the area between the curves $f^{-1}(y)$ and $y=b$ from $[f(a), f(b)]$.\n\n---\n\n\nFor a less trivial problem, consider the area between $x = y^2$ and $x = 2-y$ in the first quadrant.\n\n::: {.cell hold='true' execution_count=32}\n``` {.julia .cell-code}\nys = range(0, stop=2, length=50)\nxs = [y^2 for y in ys]\nplot(xs, ys)\nxs = [2-y for y in ys]\nplot!(xs, ys)\nplot!(zero)\n```\n\n::: {.cell-output .cell-output-display execution_count=33}\n{}\n:::\n:::\n\n\nWe see the bounded area could be described in the \"$x$\" variable in terms of two integrals, but in the $y$ variable in terms of the difference of two functions with the limits of integration running from $y=0$ to $y=1$. So, this area may be found as follows:\n\n::: {.cell hold='true' execution_count=33}\n``` {.julia .cell-code}\nf(y) = 2-y\ng(y) = y^2\na, b = 0, 1\nquadgk(y -> f(y) - g(y), a, b)[1]\n```\n\n::: {.cell-output .cell-output-display execution_count=34}\n```\n1.1666666666666667\n```\n:::\n:::\n\n\n## Questions\n\n\n###### Question\n\n\nFind the area enclosed by the curves $y=2-x^2$ and $y=x^2 - 3$.\n\n::: {.cell hold='true' execution_count=34}\n\n::: {.cell-output .cell-output-display execution_count=35}\n```{=html}\n
\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nFind the area between $f(x) = \\cos(x)$, $g(x) = x$ and the $y$ axis.\n\n::: {.cell hold='true' execution_count=35}\n\n::: {.cell-output .cell-output-display execution_count=36}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nFind the area between the line $y=1/2(x+1)$ and half circle $y=\\sqrt{1 - x^2}$.\n\n::: {.cell hold='true' execution_count=36}\n\n::: {.cell-output .cell-output-display execution_count=37}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nFind the area in the first quadrant between the lines $y=x$, $y=1$, and the curve $y=x^2 + 4$.\n\n::: {.cell hold='true' execution_count=37}\n\n::: {.cell-output .cell-output-display execution_count=38}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nFind the area between $y=x^2$ and $y=-x^4$ for $\\lvert x \\rvert \\leq 1$.\n\n::: {.cell hold='true' execution_count=38}\n\n::: {.cell-output .cell-output-display execution_count=39}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nLet `f(x) = 1/(sqrt(pi)*gamma(1/2)) * (1 + t^2)^(-1)` and `g(x) = 1/sqrt(2*pi) * exp(-x^2/2)`. These graphs intersect in two points. Find the area bounded by them.\n\n::: {.cell hold='true' execution_count=39}\n\n::: {.cell-output .cell-output-display execution_count=40}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n(Where `gamma(1/2)` is a call to the [gamma](http://en.wikipedia.org/wiki/Gamma_function) function.)\n\n\n###### Question\n\n\nFind the area in the first quadrant bounded by the graph of $x = (y-1)^2$, $x=3-y$ and $x=2\\sqrt{y}$. (Hint: integrate in the $y$ variable.)\n\n::: {.cell hold='true' execution_count=40}\n\n::: {.cell-output .cell-output-display execution_count=41}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nFind the total area bounded by the lines $x=0$, $x=2$ and the curves $y=x^2$ and $y=x$. This would be $\\int_a^b \\lvert f(x) - g(x) \\rvert dx$.\n\n::: {.cell hold='true' execution_count=41}\n\n::: {.cell-output .cell-output-display execution_count=42}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nLook at the sculpture [Le Tamanoir](https://www.google.com/search?q=Le+Tamanoir+by+Calder.&num=50&tbm=isch&tbo=u&source=univ&sa=X&ved=0ahUKEwiy8eO2tqzVAhVMPz4KHXmgBpgQsAQILQ&biw=1556&bih=878) by Calder. A large scale work. How much does it weigh? Approximately?\n\n\nLet's try to answer that with an educated guess. The right most figure looks to be about 1/5th the total amount. So if we estimate that piece and multiply by 5 we get a good guess. That part looks like an area of metal bounded by two quadratic polynomials. If we compute that area in square inches, then multiply by an assumed thickness of one inch, we have the cubic volume. The density of galvanized steel is 7850 kg/$m^3$ which we convert into pounds/in$^3$ via:\n\n::: {.cell execution_count=42}\n``` {.julia .cell-code}\n7850 * 2.2 * (1/39.3)^3\n```\n\n::: {.cell-output .cell-output-display execution_count=43}\n```\n0.28452123585283234\n```\n:::\n:::\n\n\nThe two parabolas, after rotating, might look like the following (with $x$ in inches):\n\n\n\n$$\nf(x) = x^2/70, \\quad g(x) = 35 + x^2/140\n$$\n\n\nPut this altogether to give an estimated weight in pounds.\n\n::: {.cell hold='true' execution_count=43}\n\n::: {.cell-output .cell-output-display execution_count=44}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\nIs the guess that the entire sculpture is more than two tons?\n\n::: {.cell hold='true' execution_count=44}\n\n::: {.cell-output .cell-output-display execution_count=45}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n:::{.callout-note}\n## Note\nWe used area to estimate weight in this example, but Galileo used weight to estimate area. It is [mentioned](https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf) by Martin that in order to estimate the area enclosed by one arch of a cycloid, Galileo cut the arch from from some material and compared the weight to the weight of the generating circle. He concluded the area is close to $3$ times that of the circle, a conjecture proved by Roberval in 1634.\n\n:::\n\n###### Question\n\n\nFormulas from the business world say that revenue is the integral of *marginal revenue* or the additional money from selling 1 more unit. (This is basically the derivative of profit). Cost is the integral of *marginal cost*, or the cost to produce 1 more. Suppose we have\n\n\n\n$$\n\\text{mr}(x) = 2 - \\frac{e^{-x/10}}{1 + e^{-x/10}}, \\quad\n\\text{mc}(x) = 1 - \\frac{1}{2} \\cdot \\frac{e^{-x/5}}{1 + e^{-x/5}}.\n$$\n\n\nFind the profit to produce 100 units: $P = \\int_0^{100} (\\text{mr}(x) - \\text{mc}(x)) dx$.\n\n::: {.cell hold='true' execution_count=45}\n\n::: {.cell-output .cell-output-display execution_count=46}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nCan `SymPy` do what Archimedes did?\n\n\nConsider the following code which sets up the area of an inscribed triangle, `A1`, and the area of a parabolic segment, `A2` for a general parabola:\n\n::: {.cell hold='true' execution_count=46}\n``` {.julia .cell-code}\n@syms x::real A::real B::real C::real a::real b::real\nc = (a + b) / 2\nf(x) = A*x^2 + B*x + C\nSecant(f, a, b) = f(a) + (f(b)-f(a))/(b-a) * (x - a)\nA1 = integrate(Secant(f, a, c) - Secant(f,a,b), (x,a,c)) + integrate(Secant(f,c,b)-Secant(f,a,b), (x, c, b))\nA2 = integrate(f(x) - Secant(f,a,b), (x, a, b))\nout = 4//3 * A1 - A2\n```\n\n::: {.cell-output .cell-output-display execution_count=47}\n```{=html}\n \n\\[\n\\frac{A a^{3}}{3} + A a^{2} b - A a b^{2} - \\frac{A b^{3}}{3} + a^{2} \\left(- \\frac{A a}{2} - \\frac{A b}{2}\\right) - \\frac{4 a^{2} \\left(\\frac{A a}{4} - \\frac{A b}{4}\\right)}{3} - \\frac{4 a \\left(- \\frac{A a^{2}}{2} + \\frac{A a b}{2}\\right)}{3} - b^{2} \\left(- \\frac{A a}{2} - \\frac{A b}{2}\\right) + \\frac{4 b^{2} \\left(- \\frac{A a}{4} + \\frac{A b}{4}\\right)}{3} + \\frac{4 b \\left(\\frac{A a b}{2} - \\frac{A b^{2}}{2}\\right)}{3} - \\frac{4 \\left(\\frac{a}{2} + \\frac{b}{2}\\right)^{2} \\left(- \\frac{A a}{4} + \\frac{A b}{4}\\right)}{3} + \\frac{4 \\left(\\frac{a}{2} + \\frac{b}{2}\\right)^{2} \\left(\\frac{A a}{4} - \\frac{A b}{4}\\right)}{3} + \\frac{4 \\left(\\frac{a}{2} + \\frac{b}{2}\\right) \\left(- \\frac{A a^{2}}{2} + \\frac{A a b}{2}\\right)}{3} - \\frac{4 \\left(\\frac{a}{2} + \\frac{b}{2}\\right) \\left(\\frac{A a b}{2} - \\frac{A b^{2}}{2}\\right)}{3}\n\\]\n\n```\n:::\n:::\n\n\nDoes `SymPy` get the correct output, $0$, after calling `simplify`?\n\n::: {.cell hold='true' execution_count=47}\n\n::: {.cell-output .cell-output-display execution_count=48}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\n###### Question\n\n\nIn [Martin](https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf) a fascinating history of the cycloid can be read.\n\n\n\n\n\nIn particular, it can be read that Roberval proved that the area between the cycloid and its companion curve is half the are of the generating circle. Roberval didn't know integration, so finding the area between two curves required other tricks. One is called \"Cavalieri's principle.\" From the figure above, which of the following would you guess this principle to be:\n\n::: {.cell hold='true' execution_count=49}\n\n::: {.cell-output .cell-output-display execution_count=50}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\nSuppose the generating circle has radius $1$, so the area shown is $\\pi/2$. The companion curve is then $1-\\cos(\\theta)$ (a fact not used by Roberval). The area *under* this curve is then\n\n::: {.cell hold='true' execution_count=50}\n``` {.julia .cell-code}\n@syms theta\nintegrate(1 - cos(theta), (theta, 0, SymPy.PI))\n```\n\n::: {.cell-output .cell-output-display execution_count=51}\n```{=html}\n \n\\[\n\\pi\n\\]\n\n```\n:::\n:::\n\n\nThat means the area under **one-half** arch of the cycloid is\n\n::: {.cell hold='true' execution_count=51}\n\n::: {.cell-output .cell-output-display execution_count=52}\n```{=html}\n\n\n\n```\n:::\n:::\n\n\nDoubling the answer above gives a value that Galileo had struggled with for many years.\n\n\n\n\n\n", "supporting": [ "area_between_curves_files" ], "filters": [], "includes": { "include-in-header": [ "\n\n\n" ] } } }