CalculusWithJuliaNotes.jl/quarto/0e7f54ed/integrals/area_between_curves.html
2022-08-11 13:15:19 -04:00

1924 lines
118 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.0.32">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Calculus with Julia - 43&nbsp; Area between two curves</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script src="../site_libs/quarto-nav/quarto-nav.js"></script>
<script src="../site_libs/quarto-nav/headroom.min.js"></script>
<script src="../site_libs/clipboard/clipboard.min.js"></script>
<script src="../site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="../site_libs/quarto-search/fuse.min.js"></script>
<script src="../site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="../">
<link href="../integrals/center_of_mass.html" rel="next">
<link href="../integrals/mean_value_theorem.html" rel="prev">
<script src="../site_libs/quarto-html/quarto.js"></script>
<script src="../site_libs/quarto-html/popper.min.js"></script>
<script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="../site_libs/quarto-html/anchor.min.js"></script>
<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">
<link href="../site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="../site_libs/bootstrap/bootstrap.min.js"></script>
<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="../site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script id="quarto-search-options" type="application/json">{
"location": "navbar",
"copy-button": false,
"collapse-after": 3,
"panel-placement": "end",
"type": "overlay",
"limit": 20,
"language": {
"search-no-results-text": "No results",
"search-matching-documents-text": "matching documents",
"search-copy-link-title": "Copy link to search",
"search-hide-matches-text": "Hide additional matches",
"search-more-match-text": "more match in this document",
"search-more-matches-text": "more matches in this document",
"search-clear-button-title": "Clear",
"search-detached-cancel-button-title": "Cancel",
"search-submit-button-title": "Submit"
}
}</script>
<script async="" src="https://hypothes.is/embed.js"></script>
<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>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
<script type="application/javascript">define('jquery', [],function() {return window.jQuery;})</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
</head>
<body class="nav-sidebar floating nav-fixed">
<div id="quarto-search-results"></div>
<header id="quarto-header" class="headroom fixed-top">
<nav class="navbar navbar-expand-lg navbar-dark ">
<div class="navbar-container container-fluid">
<a class="navbar-brand" href="../index.html">
<img src="../logo.png" alt="">
<span class="navbar-title">Calculus with Julia</span>
</a>
<div id="quarto-search" class="" title="Search"></div>
</div> <!-- /container-fluid -->
</nav>
<nav class="quarto-secondary-nav" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<div class="container-fluid d-flex justify-content-between">
<h1 class="quarto-secondary-nav-title"><span class="chapter-number">43</span>&nbsp; <span class="chapter-title">Area between two curves</span></h1>
<button type="button" class="quarto-btn-toggle btn" aria-label="Show secondary navigation">
<i class="bi bi-chevron-right"></i>
</button>
</div>
</nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
<!-- sidebar -->
<nav id="quarto-sidebar" class="sidebar collapse sidebar-navigation floating overflow-auto">
<div class="mt-2 flex-shrink-0 align-items-center">
<div class="sidebar-search">
<div id="quarto-search" class="" title="Search"></div>
</div>
</div>
<div class="sidebar-menu-container">
<ul class="list-unstyled mt-1">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../index.html" class="sidebar-item-text sidebar-link">Preface</a>
</div>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="false">Precalculus Concepts</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/calculator.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">From calculator to computer</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/variables.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Variables</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/numbers_types.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Number systems</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/logical_expressions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Inequalities, Logical expressions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/vectors.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Vectors</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/ranges.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">6</span>&nbsp; <span class="chapter-title">Ranges and Sets</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/functions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Functions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/plotting.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">8</span>&nbsp; <span class="chapter-title">The Graph of a Function</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/transformations.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">9</span>&nbsp; <span class="chapter-title">Function manipulations</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/inversefunctions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">10</span>&nbsp; <span class="chapter-title">The Inverse of a Function</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/polynomial.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">Polynomials</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/polynomial_roots.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">12</span>&nbsp; <span class="chapter-title">Roots of a polynomial</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/polynomials_package.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">13</span>&nbsp; <span class="chapter-title">The Polynomials package</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/rational_functions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">14</span>&nbsp; <span class="chapter-title">Rational functions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/exp_log_functions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">15</span>&nbsp; <span class="chapter-title">Exponential and logarithmic functions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/trig_functions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">16</span>&nbsp; <span class="chapter-title">Trigonometric functions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../precalc/julia_overview.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">17</span>&nbsp; <span class="chapter-title">Overview of Julia commands</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="false">Limits</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-2" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../limits/limits.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">18</span>&nbsp; <span class="chapter-title">Limits</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../limits/limits_extensions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">19</span>&nbsp; <span class="chapter-title">Limits, issues, extensions of the concept</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../limits/continuity.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">20</span>&nbsp; <span class="chapter-title">Continuity</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../limits/intermediate_value_theorem.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">21</span>&nbsp; <span class="chapter-title">Implications of continuity</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="false">Derivatives</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-3" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/derivatives.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">22</span>&nbsp; <span class="chapter-title">Derivatives</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/numeric_derivatives.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">23</span>&nbsp; <span class="chapter-title">Numeric derivatives</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/symbolic_derivatives.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">24</span>&nbsp; <span class="chapter-title">Symbolic derivatives</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/mean_value_theorem.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">25</span>&nbsp; <span class="chapter-title">The mean value theorem for differentiable functions.</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/optimization.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">26</span>&nbsp; <span class="chapter-title">Optimization</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/first_second_derivatives.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">27</span>&nbsp; <span class="chapter-title">The first and second derivatives</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/curve_sketching.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">28</span>&nbsp; <span class="chapter-title">Curve Sketching</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/linearization.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">29</span>&nbsp; <span class="chapter-title">Linearization</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/newtons_method.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">30</span>&nbsp; <span class="chapter-title">Newtons method</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/more_zeros.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">31</span>&nbsp; <span class="chapter-title">Derivative-free alternatives to Newtons method</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/lhospitals_rule.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">32</span>&nbsp; <span class="chapter-title">LHospitals Rule</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/implicit_differentiation.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">33</span>&nbsp; <span class="chapter-title">Implicit Differentiation</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/related_rates.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">34</span>&nbsp; <span class="chapter-title">Related rates</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../derivatives/taylor_series_polynomials.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">35</span>&nbsp; <span class="chapter-title">Taylor Polynomials and other Approximating Polynomials</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" aria-expanded="true">Integrals</a>
<a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" aria-expanded="true">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-4" class="collapse list-unstyled sidebar-section depth1 show">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/area.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">36</span>&nbsp; <span class="chapter-title">Area under a curve</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/ftc.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">37</span>&nbsp; <span class="chapter-title">Fundamental Theorem or Calculus</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/substitution.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">38</span>&nbsp; <span class="chapter-title">Substitution</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/integration_by_parts.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">39</span>&nbsp; <span class="chapter-title">Integration By Parts</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/partial_fractions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">40</span>&nbsp; <span class="chapter-title">Partial Fractions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/improper_integrals.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">41</span>&nbsp; <span class="chapter-title">Improper Integrals</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/mean_value_theorem.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">42</span>&nbsp; <span class="chapter-title">Mean value theorem for integrals</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/area_between_curves.html" class="sidebar-item-text sidebar-link active"><span class="chapter-number">43</span>&nbsp; <span class="chapter-title">Area between two curves</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/center_of_mass.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">44</span>&nbsp; <span class="chapter-title">Center of Mass</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/volumes_slice.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">45</span>&nbsp; <span class="chapter-title">Volumes by slicing</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/arc_length.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">46</span>&nbsp; <span class="chapter-title">Arc length</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integrals/surface_area.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">47</span>&nbsp; <span class="chapter-title">Surface Area</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-5" aria-expanded="false">ODEs</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-5" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-5" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../ODEs/odes.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">48</span>&nbsp; <span class="chapter-title">ODEs</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../ODEs/euler.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">49</span>&nbsp; <span class="chapter-title">Eulers method</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../ODEs/solve.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">50</span>&nbsp; <span class="chapter-title">The problem-algorithm-solve interface</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../ODEs/differential_equations.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">51</span>&nbsp; <span class="chapter-title">The <code>DifferentialEquations</code> suite</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-6" aria-expanded="false">Differential vector calculus</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-6" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-6" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../differentiable_vector_calculus/polar_coordinates.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">52</span>&nbsp; <span class="chapter-title">Polar Coordinates and Curves</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../differentiable_vector_calculus/vectors.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">53</span>&nbsp; <span class="chapter-title">Vectors and matrices</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../differentiable_vector_calculus/vector_valued_functions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">54</span>&nbsp; <span class="chapter-title">Vector-valued functions, <span class="math inline">\(f:R \rightarrow R^n\)</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../differentiable_vector_calculus/scalar_functions.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">55</span>&nbsp; <span class="chapter-title">Scalar functions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../differentiable_vector_calculus/scalar_functions_applications.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">56</span>&nbsp; <span class="chapter-title">Applications with scalar functions</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../differentiable_vector_calculus/vector_fields.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">57</span>&nbsp; <span class="chapter-title">Functions <span class="math inline">\(R^n \rightarrow R^m\)</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../differentiable_vector_calculus/plots_plotting.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">58</span>&nbsp; <span class="chapter-title">2D and 3D plots in Julia with Plots</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="false">Integral vector calculus</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-7" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/double_triple_integrals.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">59</span>&nbsp; <span class="chapter-title">Multi-dimensional integrals</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/line_integrals.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">60</span>&nbsp; <span class="chapter-title">Line and Surface Integrals</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/div_grad_curl.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">61</span>&nbsp; <span class="chapter-title">The Gradient, Divergence, and Curl</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/stokes_theorem.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">62</span>&nbsp; <span class="chapter-title">Greens Theorem, Stokes Theorem, and the Divergence Theorem</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/review.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">63</span>&nbsp; <span class="chapter-title">Quick Review of Vector Calculus</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-8" aria-expanded="false">Alternatives</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-8" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-8" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../alternatives/plotly_plotting.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">64</span>&nbsp; <span class="chapter-title">JavaScript based plotting libraries</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../alternatives/makie_plotting.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">65</span>&nbsp; <span class="chapter-title">Calculus plots with Makie</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-9" aria-expanded="false">Appendices</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-9" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-9" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/getting_started_with_julia.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">66</span>&nbsp; <span class="chapter-title">Getting started with Julia</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/julia_interfaces.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">67</span>&nbsp; <span class="chapter-title">Julia interfaces</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/calculus_with_julia.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">68</span>&nbsp; <span class="chapter-title">The <code>CalculusWithJulia</code> package</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/unicode.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">69</span>&nbsp; <span class="chapter-title">Usages of Unicode symbols</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/quick_notes.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">70</span>&nbsp; <span class="chapter-title">Quick introduction to Calculus with Julia</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../references.html" class="sidebar-item-text sidebar-link">References</a>
</div>
</li>
</ul>
</div>
</nav>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#questions" id="toc-questions" class="nav-link active" data-scroll-target="#questions"> <span class="header-section-number">43.1</span> Questions</a></li>
</ul>
<div class="toc-actions"><div><i class="bi bi-github"></i></div><div class="action-links"><p><a href="https://github.com/jverzani/CalculusWithJuliaNotes.jl/edit/main/quarto/integrals/area_between_curves.qmd" class="toc-action">Edit this page</a></p><p><a href="https://github.com/jverzani/CalculusWithJuliaNotes.jl/issues/new" class="toc-action">Report an issue</a></p></div></div></nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title d-none d-lg-block"><span class="chapter-number">43</span>&nbsp; <span class="chapter-title">Area between two curves</span></h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<p>This section uses these add-on packages:</p>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">CalculusWithJulia</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">Plots</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">Roots</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">QuadGK</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">SymPy</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<hr>
<p>The definite integral gives the “signed” area between the function <span class="math inline">\(f(x)\)</span> and the <span class="math inline">\(x\)</span>-axis over <span class="math inline">\([a,b]\)</span>. Conceptually, this is the area between two curves, <span class="math inline">\(f(x)\)</span> and <span class="math inline">\(g(x)=0\)</span>. More generally, this integral:</p>
<p><span class="math display">\[
\int_a^b (f(x) - g(x)) dx
\]</span></p>
<p>can be interpreted as the “signed” area between <span class="math inline">\(f(x)\)</span> and <span class="math inline">\(g(x)\)</span> over <span class="math inline">\([a,b]\)</span>. If on this interval <span class="math inline">\([a,b]\)</span> it is true that <span class="math inline">\(f(x) \geq g(x)\)</span>, then this would just be the area, as seen in this figure. The rectangle in the figure has area: <span class="math inline">\((f(a)-g(a)) \cdot (b-a)\)</span> which could be a term in a left Riemann sum of the integral of <span class="math inline">\(f(x) - g(x)\)</span>:</p>
<div class="cell" data-hold="true" data-execution_count="4">
<div class="cell-output cell-output-display" data-execution_count="5">
<p><img src="area_between_curves_files/figure-html/cell-5-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>For the figure, we have <span class="math inline">\(f(x) = \sqrt{x}\)</span>, <span class="math inline">\(g(x)= x^2\)</span> and <span class="math inline">\([a,b] = [1/4, 3/4]\)</span>. The shaded area is then found by:</p>
<p><span class="math display">\[
\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}.
\]</span></p>
<section id="examples" class="level4">
<h4 class="anchored" data-anchor-id="examples">Examples</h4>
<p>Find the area bounded by the line <span class="math inline">\(y=2x\)</span> and the curve <span class="math inline">\(y=2 - x^2\)</span>.</p>
<p>We can plot to see the area in question:</p>
<div class="cell" data-execution_count="5">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> <span class="fl">2</span> <span class="op">-</span> x<span class="op">^</span><span class="fl">2</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">g</span>(x) <span class="op">=</span> <span class="fl">2</span>x</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(f, <span class="op">-</span><span class="fl">3</span>,<span class="fl">3</span>)</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(g)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="6">
<p><img src="area_between_curves_files/figure-html/cell-6-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>For this problem we need to identify <span class="math inline">\(a\)</span> and <span class="math inline">\(b\)</span>. These are found numerically through:</p>
<div class="cell" data-execution_count="6">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>a,b <span class="op">=</span> <span class="fu">find_zeros</span>(x <span class="op">-&gt;</span> <span class="fu">f</span>(x) <span class="op">-</span> <span class="fu">g</span>(x), <span class="op">-</span><span class="fl">3</span>, <span class="fl">3</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="7">
<pre><code>2-element Vector{Float64}:
-2.732050807568877
0.7320508075688773</code></pre>
</div>
</div>
<p>The answer then can be found numerically:</p>
<div class="cell" data-execution_count="7">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">f</span>(x) <span class="op">-</span> <span class="fu">g</span>(x), a, b)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="8">
<pre><code>6.928203230275509</code></pre>
</div>
</div>
<section id="example" class="level5">
<h5 class="anchored" data-anchor-id="example">Example</h5>
<p>Find the integral between <span class="math inline">\(f(x) = \sin(x)\)</span> and <span class="math inline">\(g(x)=\cos(x)\)</span> over <span class="math inline">\([0,2\pi]\)</span> where <span class="math inline">\(f(x) \geq g(x)\)</span>.</p>
<p>A plot shows the areas:</p>
<div class="cell" data-execution_count="8">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">𝒇</span>(x) <span class="op">=</span> <span class="fu">sin</span>(x)</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="fu">𝒈</span>(x) <span class="op">=</span> <span class="fu">cos</span>(x)</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(𝒇, <span class="fl">0</span>, <span class="fl">2</span>pi)</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(𝒈)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="9">
<p><img src="area_between_curves_files/figure-html/cell-9-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>There is a single interval when <span class="math inline">\(f \geq g\)</span> and this can be found algebraically using basic trigonometry, or numerically:</p>
<div class="cell" data-execution_count="9">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>𝒂,𝒃 <span class="op">=</span> <span class="fu">find_zeros</span>(x <span class="op">-&gt;</span> <span class="fu">𝒇</span>(x) <span class="op">-</span> <span class="fu">𝒈</span>(x), <span class="fl">0</span>, <span class="fl">2</span>pi) <span class="co"># pi/4, 5pi/4</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">𝒇</span>(x) <span class="op">-</span> <span class="fu">𝒈</span>(x), 𝒂, 𝒃)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="10">
<pre><code>2.8284271247461903</code></pre>
</div>
</div>
</section>
<section id="example-1" class="level5">
<h5 class="anchored" data-anchor-id="example-1">Example</h5>
<p>Find the area between <span class="math inline">\(x^n\)</span> and <span class="math inline">\(x^{n+1}\)</span> over <span class="math inline">\([0,1]\)</span> for <span class="math inline">\(n=1,2,\dots\)</span>.</p>
<p>We have on this interval <span class="math inline">\(x^n \geq x^{n+1}\)</span>, so the integral can be found symbolically through:</p>
<div class="cell" data-execution_count="10">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x<span class="op">::</span><span class="dt">positive </span>n<span class="op">::</span><span class="dt">positive</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>ex <span class="op">=</span> <span class="fu">integrate</span>(x<span class="op">^</span>n <span class="op">-</span> x<span class="op">^</span>(n<span class="op">+</span><span class="fl">1</span>), (x, <span class="fl">0</span>, <span class="fl">1</span>))</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="fu">together</span>(ex)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="11">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{1}{\left(n + 1\right) \left(n + 2\right)}
\]
</span>
</div>
</div>
<p>Based on this answer, what is the value of this</p>
<p><span class="math display">\[
\frac{1}{2\cdot 3} + \frac{1}{3\cdot 4} + \frac{1}{4\cdot 5} + \cdots?
\]</span></p>
<p>This should should be no surprise, given how the areas computed carve up the area under the line <span class="math inline">\(y=x^1\)</span> over <span class="math inline">\([0,1]\)</span>, so the answer should be <span class="math inline">\(1/2\)</span>.</p>
<div class="cell" data-execution_count="11">
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>p <span class="op">=</span> <span class="fu">plot</span>(x, <span class="fl">0</span>, <span class="fl">1</span>, legend<span class="op">=</span><span class="cn">false</span>)</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>[<span class="fu">plot!</span>(p, x<span class="op">^</span>n, <span class="fl">0</span>, <span class="fl">1</span>) for n <span class="kw">in</span> <span class="fl">2</span><span class="op">:</span><span class="fl">20</span>]</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>p</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="12">
<p><img src="area_between_curves_files/figure-html/cell-12-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>We can check using the <code>summation</code> function of <code>SymPy</code> which is similar in usage to <code>integrate</code>:</p>
<div class="cell" data-execution_count="12">
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">summation</span>(<span class="fl">1</span><span class="op">/</span>(n<span class="op">+</span><span class="fl">1</span>)<span class="op">/</span>(n<span class="op">+</span><span class="fl">2</span>), (n, <span class="fl">1</span>, oo))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="13">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{1}{2}
\]
</span>
</div>
</div>
</section>
<section id="example-2" class="level5">
<h5 class="anchored" data-anchor-id="example-2">Example</h5>
<p>Verify <a href="http://en.wikipedia.org/wiki/The_Quadrature_of_the_Parabola">Archimedes</a> finding that the area of the parabolic segment is <span class="math inline">\(4/3\)</span>rds that of the triangle joining <span class="math inline">\(a\)</span>, <span class="math inline">\((a+b)/2\)</span> and <span class="math inline">\(b\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="13">
<div class="cell-output cell-output-display" data-execution_count="14">
<p><img src="area_between_curves_files/figure-html/cell-14-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>For concreteness, let <span class="math inline">\(f(x) = 2-x^2\)</span> and <span class="math inline">\([a,b] = [-1, 1/2]\)</span>, as in the figure. Then the area of the triangle can be computed through:</p>
<div class="cell" data-execution_count="14">
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">𝐟</span>(x) <span class="op">=</span> <span class="fl">2</span> <span class="op">-</span> x<span class="op">^</span><span class="fl">2</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>𝐚, 𝐛 <span class="op">=</span> <span class="op">-</span><span class="fl">1</span>, <span class="fl">1</span><span class="op">/</span><span class="fl">2</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>𝐜 <span class="op">=</span> (𝐚 <span class="op">+</span> 𝐛)<span class="op">/</span><span class="fl">2</span></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a>sac, sab, scb <span class="op">=</span> <span class="fu">secant</span>(𝐟, 𝐚, 𝐜), <span class="fu">secant</span>(𝐟, 𝐚, 𝐛), <span class="fu">secant</span>(𝐟, 𝐜, 𝐛)</span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="fu">f1</span>(x) <span class="op">=</span> <span class="fu">min</span>(<span class="fu">sac</span>(x), <span class="fu">scb</span>(x))</span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="fu">f2</span>(x) <span class="op">=</span> <span class="fu">sab</span>(x)</span>
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a>A1 <span class="op">=</span> <span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">f1</span>(x) <span class="op">-</span> <span class="fu">f2</span>(x), 𝐚, 𝐛)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="15">
<pre><code>0.421875</code></pre>
</div>
</div>
<p>As we needed three secant lines, we used the <code>secant</code> function from <code>CalculusWithJulia</code> to create functions representing each. Once that was done, we used the <code>max</code> function to facilitate integrating over the top bounding curve, alternatively, we could break the integral over <span class="math inline">\([a,c]\)</span> and <span class="math inline">\([c,b]\)</span>.</p>
<p>The area of the parabolic segment is more straightforward.</p>
<div class="cell" data-execution_count="15">
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>A2 <span class="op">=</span> <span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">𝐟</span>(x) <span class="op">-</span> <span class="fu">f2</span>(x), 𝐚, 𝐛)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="16">
<pre><code>0.5625000000000001</code></pre>
</div>
</div>
<p>Finally, if Archimedes was right, this relationship should bring about <span class="math inline">\(0\)</span> (or something within round-off error):</p>
<div class="cell" data-execution_count="16">
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>A1 <span class="op">*</span> <span class="fl">4</span><span class="op">/</span><span class="fl">3</span> <span class="op">-</span> A2</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="17">
<pre><code>-1.1102230246251565e-16</code></pre>
</div>
</div>
</section>
<section id="example-3" class="level5">
<h5 class="anchored" data-anchor-id="example-3">Example</h5>
<p>Find the area bounded by <span class="math inline">\(y=x^4\)</span> and <span class="math inline">\(y=e^x\)</span> when <span class="math inline">\(x^4 \geq e^x\)</span> and <span class="math inline">\(x &gt; 0\)</span>.</p>
<p>A graph over <span class="math inline">\([0,10]\)</span> shows clearly the largest zero, for afterwards the exponential dominates the power.</p>
<div class="cell" data-execution_count="17">
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">h1</span>(x) <span class="op">=</span> x<span class="op">^</span><span class="fl">4</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="fu">h2</span>(x) <span class="op">=</span> <span class="fu">exp</span>(x)</span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(h1, <span class="fl">0</span>, <span class="fl">10</span>)</span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(h2)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="18">
<p><img src="area_between_curves_files/figure-html/cell-18-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>There must be another zero, though it is hard to see from the graph over <span class="math inline">\([0,10]\)</span>, as <span class="math inline">\(0^4=0\)</span> and <span class="math inline">\(e^0=1\)</span>, so the polynomial must cross below the exponential to the left of <span class="math inline">\(5\)</span>. (Otherwise, plotting over <span class="math inline">\([0,2]\)</span> will clearly reveal the other zero.) We now find these intersection points numerically and then integrate:</p>
<div class="cell" data-hold="true" data-execution_count="18">
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>a,b <span class="op">=</span> <span class="fu">find_zeros</span>(x <span class="op">-&gt;</span> <span class="fu">h1</span>(x) <span class="op">-</span> <span class="fu">h2</span>(x), <span class="fl">0</span>, <span class="fl">10</span>)</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">h1</span>(x) <span class="op">-</span> <span class="fu">h2</span>(x), a, b)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="19">
<pre><code>3980.1173881924947</code></pre>
</div>
</div>
</section>
<section id="examples-1" class="level5">
<h5 class="anchored" data-anchor-id="examples-1">Examples</h5>
<p>The area between <span class="math inline">\(y=\sin(x)\)</span> and <span class="math inline">\(y=m\cdot x\)</span> between <span class="math inline">\(0\)</span> and the first positive intersection depends on <span class="math inline">\(m\)</span> (where <span class="math inline">\(0 \leq m \leq 1\)</span>. The extremes are when <span class="math inline">\(m=0\)</span>, the area is <span class="math inline">\(2\)</span> and when <span class="math inline">\(m=1\)</span> (the line is tangent at <span class="math inline">\(x=0\)</span>), the area is <span class="math inline">\(0\)</span>. What is it for other values of <span class="math inline">\(m\)</span>? The picture for <span class="math inline">\(m=1/2\)</span> is:</p>
<div class="cell" data-execution_count="19">
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>m <span class="op">=</span> <span class="fl">1</span><span class="op">/</span><span class="fl">2</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(sin, <span class="fl">0</span>, <span class="cn">pi</span>)</span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(x <span class="op">-&gt;</span> m<span class="op">*</span>x)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="20">
<p><img src="area_between_curves_files/figure-html/cell-20-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>For a given <span class="math inline">\(m\)</span>, the area is found after computing <span class="math inline">\(b\)</span>, the intersection point. We express this as a function of <span class="math inline">\(m\)</span> for later reuse:</p>
<div class="cell" data-execution_count="20">
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="fu">intersection_point</span>(m) <span class="op">=</span> <span class="fu">maximum</span>(<span class="fu">find_zeros</span>(x <span class="op">-&gt;</span> <span class="fu">sin</span>(x) <span class="op">-</span> m<span class="op">*</span>x, <span class="fl">0</span>, <span class="cn">pi</span>))</span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a>a1 <span class="op">=</span> <span class="fl">0</span></span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a>b1 <span class="op">=</span> <span class="fu">intersection_point</span>(m)</span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">sin</span>(x) <span class="op">-</span> m<span class="op">*</span>x, a1, b1)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="21">
<pre><code>0.4207978950529467</code></pre>
</div>
</div>
<p>In general, the area then as a function of <code>m</code> is found by substituting <code>intersection_point(m)</code> for <code>b</code>:</p>
<div class="cell" data-execution_count="21">
<div class="sourceCode cell-code" id="cb25"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="fu">area</span>(m) <span class="op">=</span> <span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">sin</span>(x) <span class="op">-</span> m<span class="op">*</span>x, <span class="fl">0</span>, <span class="fu">intersection_point</span>(m))[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="22">
<pre><code>area (generic function with 1 method)</code></pre>
</div>
</div>
<p>A plot shows the relationship:</p>
<div class="cell" data-execution_count="22">
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(area, <span class="fl">0</span>, <span class="fl">1</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="23">
<p><img src="area_between_curves_files/figure-html/cell-23-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>While here, lets also answer the question of which <span class="math inline">\(m\)</span> gives an area of <span class="math inline">\(1\)</span>, or one-half the total? This can be done as follows:</p>
<div class="cell" data-execution_count="23">
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="fu">find_zero</span>(m <span class="op">-&gt;</span> <span class="fu">area</span>(m) <span class="op">-</span> <span class="fl">1</span>, (<span class="fl">0</span>, <span class="fl">1</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="24">
<pre><code>0.2566498569701879</code></pre>
</div>
</div>
<p>(Which is a nice combination of using <code>find_zeros</code>, <code>quadgk</code> and <code>find_zero</code> to answer a problem.)</p>
</section>
<section id="example-4" class="level5">
<h5 class="anchored" data-anchor-id="example-4">Example</h5>
<p>Find the area bounded by the <span class="math inline">\(x\)</span> axis, the line <span class="math inline">\(x-1\)</span> and the function <span class="math inline">\(\log(x+1)\)</span>.</p>
<p>A plot shows us the basic area:</p>
<div class="cell" data-execution_count="24">
<div class="sourceCode cell-code" id="cb30"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="fu">j1</span>(x) <span class="op">=</span> <span class="fu">log</span>(x<span class="op">+</span><span class="fl">1</span>)</span>
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a><span class="fu">j2</span>(x) <span class="op">=</span> x <span class="op">-</span> <span class="fl">1</span></span>
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(j1, <span class="fl">0</span>, <span class="fl">3</span>)</span>
<span id="cb30-4"><a href="#cb30-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(j2)</span>
<span id="cb30-5"><a href="#cb30-5" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(zero)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="25">
<p><img src="area_between_curves_files/figure-html/cell-25-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The value for “<span class="math inline">\(b\)</span>” is found from the intersection point of <span class="math inline">\(\log(x+1)\)</span> and <span class="math inline">\(x-1\)</span>, which is near <span class="math inline">\(2\)</span>:</p>
<div class="cell" data-execution_count="25">
<div class="sourceCode cell-code" id="cb31"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a>ja <span class="op">=</span> <span class="fl">0</span></span>
<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a>jb <span class="op">=</span> <span class="fu">find_zero</span>(x <span class="op">-&gt;</span> <span class="fu">j1</span>(x) <span class="op">-</span> <span class="fu">j2</span>(x), <span class="fl">2</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="26">
<pre><code>2.1461932206205825</code></pre>
</div>
</div>
<p>We see that the lower part of the area has a condition: if <span class="math inline">\(x &lt; 1\)</span> then use <span class="math inline">\(0\)</span>, otherwise use <span class="math inline">\(g(x)\)</span>. We can handle this many different ways:</p>
<ul>
<li>break the integral into two pieces and add:</li>
</ul>
<div class="cell" data-execution_count="26">
<div class="sourceCode cell-code" id="cb33"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">j1</span>(x) <span class="op">-</span> <span class="fu">zero</span>(x), ja, <span class="fl">1</span>)[<span class="fl">1</span>] <span class="op">+</span> <span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">j1</span>(x) <span class="op">-</span> <span class="fu">j2</span>(x), <span class="fl">1</span>, jb)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="27">
<pre><code>0.8030726701188743</code></pre>
</div>
</div>
<ul>
<li>make a new function for the bottom bound:</li>
</ul>
<div class="cell" data-execution_count="27">
<div class="sourceCode cell-code" id="cb35"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="fu">j3</span>(x) <span class="op">=</span> x <span class="op">&lt;</span> <span class="fl">1</span> ? <span class="fl">0.0</span> <span class="op">:</span> <span class="fu">j2</span>(x)</span>
<span id="cb35-2"><a href="#cb35-2" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(x <span class="op">-&gt;</span> <span class="fu">j1</span>(x) <span class="op">-</span> <span class="fu">j3</span>(x), ja, jb)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="28">
<pre><code>0.8030726629434394</code></pre>
</div>
</div>
<ul>
<li>Turn the picture on its side and integrate in the <span class="math inline">\(y\)</span> variable. To do this, we need to solve for inverse functions:</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="28">
<div class="sourceCode cell-code" id="cb37"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a>a1<span class="op">=</span><span class="fu">j1</span>(ja)</span>
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a>b1<span class="op">=</span><span class="fu">j1</span>(jb)</span>
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a><span class="fu">f1</span>(y)<span class="op">=</span>y<span class="op">+</span><span class="fl">1</span> <span class="co"># y=x-1, so x=y+1</span></span>
<span id="cb37-4"><a href="#cb37-4" aria-hidden="true" tabindex="-1"></a><span class="fu">g1</span>(y)<span class="op">=</span><span class="fu">exp</span>(y)<span class="op">-</span><span class="fl">1</span> <span class="co"># y=log(x+1) so e^y = x + 1, x = e^y - 1</span></span>
<span id="cb37-5"><a href="#cb37-5" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(y <span class="op">-&gt;</span> <span class="fu">f1</span>(y) <span class="op">-</span> <span class="fu">g1</span>(y), a1, b1)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="29">
<pre><code>0.8030726701188743</code></pre>
</div>
</div>
<div class="callout-note callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-caption-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>When 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.</p>
</div>
</div>
</section>
</section>
<section id="integrating-in-different-directions" class="level4">
<h4 class="anchored" data-anchor-id="integrating-in-different-directions">Integrating in different directions</h4>
<p>The last example suggested integrating in the <span class="math inline">\(y\)</span> variable. This could have more explanation.</p>
<p>It has been noted that different symmetries can aid in computing integrals through their interpretation as areas. For example, if <span class="math inline">\(f(x)\)</span> is odd, then <span class="math inline">\(\int_{-b}^b f(x)dx=0\)</span> and if <span class="math inline">\(f(x)\)</span> is even, <span class="math inline">\(\int_{-b}^b f(x) dx = 2\int_0^b f(x) dx\)</span>.</p>
<p>Another symmetry of the <span class="math inline">\(x-y\)</span> plane is the reflection through the line <span class="math inline">\(y=x\)</span>. This has the effect of taking the graph of <span class="math inline">\(f(x)\)</span> to the graph of <span class="math inline">\(f^{-1}(x)\)</span> and vice versa. Here is an example with <span class="math inline">\(f(x) = x^3\)</span> over <span class="math inline">\([-1,1]\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="29">
<div class="sourceCode cell-code" id="cb39"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> x<span class="op">^</span><span class="fl">3</span></span>
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a>xs <span class="op">=</span> <span class="fu">range</span>(<span class="op">-</span><span class="fl">1</span>, stop<span class="op">=</span><span class="fl">1</span>, length<span class="op">=</span><span class="fl">50</span>)</span>
<span id="cb39-3"><a href="#cb39-3" aria-hidden="true" tabindex="-1"></a>ys <span class="op">=</span> <span class="fu">f</span>.(xs)</span>
<span id="cb39-4"><a href="#cb39-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(ys, xs)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="30">
<p><img src="area_between_curves_files/figure-html/cell-30-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>By switching the order of the <code>xs</code> and <code>ys</code> we “flip” the graph through the line <span class="math inline">\(x=y\)</span>.</p>
<p>We can use this symmetry to our advantage. Suppose instead of being given an equation <span class="math inline">\(y=f(x)\)</span>, we are given it in “inverse” style: <span class="math inline">\(x = f(y)\)</span>, for example suppose we have <span class="math inline">\(x = y^3\)</span>. We can plot this as above via:</p>
<div class="cell" data-hold="true" data-execution_count="30">
<div class="sourceCode cell-code" id="cb40"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a>ys <span class="op">=</span> <span class="fu">range</span>(<span class="op">-</span><span class="fl">1</span>, stop<span class="op">=</span><span class="fl">1</span>, length<span class="op">=</span><span class="fl">50</span>)</span>
<span id="cb40-2"><a href="#cb40-2" aria-hidden="true" tabindex="-1"></a>xs <span class="op">=</span> [y<span class="op">^</span><span class="fl">3</span> for y <span class="kw">in</span> ys]</span>
<span id="cb40-3"><a href="#cb40-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(xs, ys)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="31">
<p><img src="area_between_curves_files/figure-html/cell-31-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Suppose we wanted the area in the first quadrant between this graph, the <span class="math inline">\(y\)</span> axis and the line <span class="math inline">\(y=1\)</span>. What to do? With the problem “flipped” through the <span class="math inline">\(y=x\)</span> line, this would just be <span class="math inline">\(\int_0^1 x^3dx\)</span>. Rather than mentally flipping the picture to integrate, instead we can just integrate in the <span class="math inline">\(y\)</span> variable. That is, the area is <span class="math inline">\(\int_0^1 y^3 dy\)</span>. The mental picture for Riemann sums would be have the approximating rectangles laying flat and as a function of <span class="math inline">\(y\)</span>, are given a length of <span class="math inline">\(y^3\)</span> and height of “<span class="math inline">\(dy\)</span>”.</p>
<hr>
<div class="cell" data-hold="true" data-execution_count="31">
<div class="cell-output cell-output-display" data-execution_count="32">
<p><img src="area_between_curves_files/figure-html/cell-32-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The figure above suggests that the area under <span class="math inline">\(f(x)\)</span> over <span class="math inline">\([a,b]\)</span> could be represented as the area between the curves <span class="math inline">\(f^{-1}(y)\)</span> and <span class="math inline">\(y=b\)</span> from <span class="math inline">\([f(a), f(b)]\)</span>.</p>
<hr>
<p>For a less trivial problem, consider the area between <span class="math inline">\(x = y^2\)</span> and <span class="math inline">\(x = 2-y\)</span> in the first quadrant.</p>
<div class="cell" data-hold="true" data-execution_count="32">
<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>ys <span class="op">=</span> <span class="fu">range</span>(<span class="fl">0</span>, stop<span class="op">=</span><span class="fl">2</span>, length<span class="op">=</span><span class="fl">50</span>)</span>
<span id="cb41-2"><a href="#cb41-2" aria-hidden="true" tabindex="-1"></a>xs <span class="op">=</span> [y<span class="op">^</span><span class="fl">2</span> for y <span class="kw">in</span> ys]</span>
<span id="cb41-3"><a href="#cb41-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(xs, ys)</span>
<span id="cb41-4"><a href="#cb41-4" aria-hidden="true" tabindex="-1"></a>xs <span class="op">=</span> [<span class="fl">2</span><span class="op">-</span>y for y <span class="kw">in</span> ys]</span>
<span id="cb41-5"><a href="#cb41-5" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(xs, ys)</span>
<span id="cb41-6"><a href="#cb41-6" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(zero)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="33">
<p><img src="area_between_curves_files/figure-html/cell-33-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>We see the bounded area could be described in the “<span class="math inline">\(x\)</span>” variable in terms of two integrals, but in the <span class="math inline">\(y\)</span> variable in terms of the difference of two functions with the limits of integration running from <span class="math inline">\(y=0\)</span> to <span class="math inline">\(y=1\)</span>. So, this area may be found as follows:</p>
<div class="cell" data-hold="true" data-execution_count="33">
<div class="sourceCode cell-code" id="cb42"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(y) <span class="op">=</span> <span class="fl">2</span><span class="op">-</span>y</span>
<span id="cb42-2"><a href="#cb42-2" aria-hidden="true" tabindex="-1"></a><span class="fu">g</span>(y) <span class="op">=</span> y<span class="op">^</span><span class="fl">2</span></span>
<span id="cb42-3"><a href="#cb42-3" aria-hidden="true" tabindex="-1"></a>a, b <span class="op">=</span> <span class="fl">0</span>, <span class="fl">1</span></span>
<span id="cb42-4"><a href="#cb42-4" aria-hidden="true" tabindex="-1"></a><span class="fu">quadgk</span>(y <span class="op">-&gt;</span> <span class="fu">f</span>(y) <span class="op">-</span> <span class="fu">g</span>(y), a, b)[<span class="fl">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="34">
<pre><code>1.1666666666666667</code></pre>
</div>
</div>
</section>
<section id="questions" class="level2" data-number="43.1">
<h2 data-number="43.1" class="anchored" data-anchor-id="questions"><span class="header-section-number">43.1</span> Questions</h2>
<section id="question" class="level6">
<h6 class="anchored" data-anchor-id="question">Question</h6>
<p>Find the area enclosed by the curves <span class="math inline">\(y=2-x^2\)</span> and <span class="math inline">\(y=x^2 - 3\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="34">
<div class="cell-output cell-output-display" data-execution_count="35">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="4182757992065460885" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_4182757992065460885">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="4182757992065460885" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="4182757992065460885_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("4182757992065460885").addEventListener("change", function() {
var correct = (Math.abs(this.value - 10.5409255338946) <= 0.001);
var msgBox = document.getElementById('4182757992065460885_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_4182757992065460885")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_4182757992065460885")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-1" class="level6">
<h6 class="anchored" data-anchor-id="question-1">Question</h6>
<p>Find the area between <span class="math inline">\(f(x) = \cos(x)\)</span>, <span class="math inline">\(g(x) = x\)</span> and the <span class="math inline">\(y\)</span> axis.</p>
<div class="cell" data-hold="true" data-execution_count="35">
<div class="cell-output cell-output-display" data-execution_count="36">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="5293205821370954206" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_5293205821370954206">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="5293205821370954206" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="5293205821370954206_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("5293205821370954206").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.400488612113379) <= 0.001);
var msgBox = document.getElementById('5293205821370954206_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_5293205821370954206")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_5293205821370954206")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-2" class="level6">
<h6 class="anchored" data-anchor-id="question-2">Question</h6>
<p>Find the area between the line <span class="math inline">\(y=1/2(x+1)\)</span> and half circle <span class="math inline">\(y=\sqrt{1 - x^2}\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="36">
<div class="cell-output cell-output-display" data-execution_count="37">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="15764201500988510336" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_15764201500988510336">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="15764201500988510336" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="15764201500988510336_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("15764201500988510336").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.7071487182097226) <= 0.001);
var msgBox = document.getElementById('15764201500988510336_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_15764201500988510336")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_15764201500988510336")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-3" class="level6">
<h6 class="anchored" data-anchor-id="question-3">Question</h6>
<p>Find the area in the first quadrant between the lines <span class="math inline">\(y=x\)</span>, <span class="math inline">\(y=1\)</span>, and the curve <span class="math inline">\(y=x^2 + 4\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="37">
<div class="cell-output cell-output-display" data-execution_count="38">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="3130065107179365315" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_3130065107179365315">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="3130065107179365315" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="3130065107179365315_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("3130065107179365315").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.8333333333333333) <= 0.001);
var msgBox = document.getElementById('3130065107179365315_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_3130065107179365315")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_3130065107179365315")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-4" class="level6">
<h6 class="anchored" data-anchor-id="question-4">Question</h6>
<p>Find the area between <span class="math inline">\(y=x^2\)</span> and <span class="math inline">\(y=-x^4\)</span> for <span class="math inline">\(\lvert x \rvert \leq 1\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="38">
<div class="cell-output cell-output-display" data-execution_count="39">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="16419465179386962742" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_16419465179386962742">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="16419465179386962742" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="16419465179386962742_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("16419465179386962742").addEventListener("change", function() {
var correct = (Math.abs(this.value - 1.0666666666666667) <= 0.001);
var msgBox = document.getElementById('16419465179386962742_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_16419465179386962742")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_16419465179386962742")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-5" class="level6">
<h6 class="anchored" data-anchor-id="question-5">Question</h6>
<p>Let <code>f(x) = 1/(sqrt(pi)*gamma(1/2)) * (1 + t^2)^(-1)</code> and <code>g(x) = 1/sqrt(2*pi) * exp(-x^2/2)</code>. These graphs intersect in two points. Find the area bounded by them.</p>
<div class="cell" data-hold="true" data-execution_count="39">
<div class="cell-output cell-output-display" data-execution_count="40">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="1723349430821404018" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_1723349430821404018">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="1723349430821404018" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="1723349430821404018_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("1723349430821404018").addEventListener("change", function() {
var correct = (Math.abs(this.value - -0.25116455428885115) <= 0.001);
var msgBox = document.getElementById('1723349430821404018_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_1723349430821404018")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_1723349430821404018")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
<p>(Where <code>gamma(1/2)</code> is a call to the <a href="http://en.wikipedia.org/wiki/Gamma_function">gamma</a> function.)</p>
</section>
<section id="question-6" class="level6">
<h6 class="anchored" data-anchor-id="question-6">Question</h6>
<p>Find the area in the first quadrant bounded by the graph of <span class="math inline">\(x = (y-1)^2\)</span>, <span class="math inline">\(x=3-y\)</span> and <span class="math inline">\(x=2\sqrt{y}\)</span>. (Hint: integrate in the <span class="math inline">\(y\)</span> variable.)</p>
<div class="cell" data-hold="true" data-execution_count="40">
<div class="cell-output cell-output-display" data-execution_count="41">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="17266847721960966746" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_17266847721960966746">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="17266847721960966746" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="17266847721960966746_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("17266847721960966746").addEventListener("change", function() {
var correct = (Math.abs(this.value - 2.166666667488131) <= 0.001);
var msgBox = document.getElementById('17266847721960966746_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_17266847721960966746")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_17266847721960966746")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-7" class="level6">
<h6 class="anchored" data-anchor-id="question-7">Question</h6>
<p>Find the total area bounded by the lines <span class="math inline">\(x=0\)</span>, <span class="math inline">\(x=2\)</span> and the curves <span class="math inline">\(y=x^2\)</span> and <span class="math inline">\(y=x\)</span>. This would be <span class="math inline">\(\int_a^b \lvert f(x) - g(x) \rvert dx\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="41">
<div class="cell-output cell-output-display" data-execution_count="42">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="17370757440416876331" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_17370757440416876331">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="17370757440416876331" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="17370757440416876331_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("17370757440416876331").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.9999999999999999) <= 0.001);
var msgBox = document.getElementById('17370757440416876331_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_17370757440416876331")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_17370757440416876331")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-8" class="level6">
<h6 class="anchored" data-anchor-id="question-8">Question</h6>
<p>Look at the sculpture <a href="https://www.google.com/search?q=Le+Tamanoir+by+Calder.&amp;num=50&amp;tbm=isch&amp;tbo=u&amp;source=univ&amp;sa=X&amp;ved=0ahUKEwiy8eO2tqzVAhVMPz4KHXmgBpgQsAQILQ&amp;biw=1556&amp;bih=878">Le Tamanoir</a> by Calder. A large scale work. How much does it weigh? Approximately?</p>
<p>Lets 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/<span class="math inline">\(m^3\)</span> which we convert into pounds/in<span class="math inline">\(^3\)</span> via:</p>
<div class="cell" data-execution_count="42">
<div class="sourceCode cell-code" id="cb44"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="fl">7850</span> <span class="op">*</span> <span class="fl">2.2</span> <span class="op">*</span> (<span class="fl">1</span><span class="op">/</span><span class="fl">39.3</span>)<span class="op">^</span><span class="fl">3</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="43">
<pre><code>0.28452123585283234</code></pre>
</div>
</div>
<p>The two parabolas, after rotating, might look like the following (with <span class="math inline">\(x\)</span> in inches):</p>
<p><span class="math display">\[
f(x) = x^2/70, \quad g(x) = 35 + x^2/140
\]</span></p>
<p>Put this altogether to give an estimated weight in pounds.</p>
<div class="cell" data-hold="true" data-execution_count="43">
<div class="cell-output cell-output-display" data-execution_count="44">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="2373352576497228507" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_2373352576497228507">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="2373352576497228507" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="2373352576497228507_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("2373352576497228507").addEventListener("change", function() {
var correct = (Math.abs(this.value - 4647.180185596263) <= 0.001);
var msgBox = document.getElementById('2373352576497228507_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_2373352576497228507")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_2373352576497228507")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
<p>Is the guess that the entire sculpture is more than two tons?</p>
<div class="cell" data-hold="true" data-execution_count="44">
<div class="cell-output cell-output-display" data-execution_count="45">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="10439356238567321653" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_10439356238567321653">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_10439356238567321653_1">
<input class="form-check-input" type="radio" name="radio_10439356238567321653" id="radio_10439356238567321653_1" value="1">
<span class="label-body px-1">
Less than two tons
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_10439356238567321653_2">
<input class="form-check-input" type="radio" name="radio_10439356238567321653" id="radio_10439356238567321653_2" value="2">
<span class="label-body px-1">
More than two tons
</span>
</label>
</div>
</div>
</div>
<div id="10439356238567321653_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_10439356238567321653"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 2;
var msgBox = document.getElementById('10439356238567321653_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_10439356238567321653")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_10439356238567321653")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
<div class="callout-note callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-caption-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>We used area to estimate weight in this example, but Galileo used weight to estimate area. It is <a href="https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf">mentioned</a> 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 <span class="math inline">\(3\)</span> times that of the circle, a conjecture proved by Roberval in 1634.</p>
</div>
</div>
</section>
<section id="question-9" class="level6">
<h6 class="anchored" data-anchor-id="question-9">Question</h6>
<p>Formulas from the business world say that revenue is the integral of <em>marginal revenue</em> or the additional money from selling 1 more unit. (This is basically the derivative of profit). Cost is the integral of <em>marginal cost</em>, or the cost to produce 1 more. Suppose we have</p>
<p><span class="math display">\[
\text{mr}(x) = 2 - \frac{e^{-x/10}}{1 + e^{-x/10}}, \quad
\text{mc}(x) = 1 - \frac{1}{2} \cdot \frac{e^{-x/5}}{1 + e^{-x/5}}.
\]</span></p>
<p>Find the profit to produce 100 units: <span class="math inline">\(P = \int_0^{100} (\text{mr}(x) - \text{mc}(x)) dx\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="45">
<div class="cell-output cell-output-display" data-execution_count="46">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="16621730428325515662" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_16621730428325515662">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="16621730428325515662" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="16621730428325515662_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("16621730428325515662").addEventListener("change", function() {
var correct = (Math.abs(this.value - 105.19814987036037) <= 0.001);
var msgBox = document.getElementById('16621730428325515662_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_16621730428325515662")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_16621730428325515662")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-10" class="level6">
<h6 class="anchored" data-anchor-id="question-10">Question</h6>
<p>Can <code>SymPy</code> do what Archimedes did?</p>
<p>Consider the following code which sets up the area of an inscribed triangle, <code>A1</code>, and the area of a parabolic segment, <code>A2</code> for a general parabola:</p>
<div class="cell" data-hold="true" data-execution_count="46">
<div class="sourceCode cell-code" id="cb46"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x<span class="op">::</span><span class="dt">real </span>A<span class="op">::</span><span class="dt">real </span>B<span class="op">::</span><span class="dt">real </span>C<span class="op">::</span><span class="dt">real </span>a<span class="op">::</span><span class="dt">real </span>b<span class="op">::</span><span class="dt">real</span></span>
<span id="cb46-2"><a href="#cb46-2" aria-hidden="true" tabindex="-1"></a>c <span class="op">=</span> (a <span class="op">+</span> b) <span class="op">/</span> <span class="fl">2</span></span>
<span id="cb46-3"><a href="#cb46-3" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> A<span class="op">*</span>x<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> B<span class="op">*</span>x <span class="op">+</span> C</span>
<span id="cb46-4"><a href="#cb46-4" aria-hidden="true" tabindex="-1"></a><span class="fu">Secant</span>(f, a, b) <span class="op">=</span> <span class="fu">f</span>(a) <span class="op">+</span> (<span class="fu">f</span>(b)<span class="fu">-f</span>(a))<span class="op">/</span>(b<span class="op">-</span>a) <span class="op">*</span> (x <span class="op">-</span> a)</span>
<span id="cb46-5"><a href="#cb46-5" aria-hidden="true" tabindex="-1"></a>A1 <span class="op">=</span> <span class="fu">integrate</span>(<span class="fu">Secant</span>(f, a, c) <span class="op">-</span> <span class="fu">Secant</span>(f,a,b), (x,a,c)) <span class="op">+</span> <span class="fu">integrate</span>(<span class="fu">Secant</span>(f,c,b)<span class="fu">-Secant</span>(f,a,b), (x, c, b))</span>
<span id="cb46-6"><a href="#cb46-6" aria-hidden="true" tabindex="-1"></a>A2 <span class="op">=</span> <span class="fu">integrate</span>(<span class="fu">f</span>(x) <span class="op">-</span> <span class="fu">Secant</span>(f,a,b), (x, a, b))</span>
<span id="cb46-7"><a href="#cb46-7" aria-hidden="true" tabindex="-1"></a>out <span class="op">=</span> <span class="fl">4</span><span class="op">//</span><span class="fl">3</span> <span class="op">*</span> A1 <span class="op">-</span> A2</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="47">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\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}
\]
</span>
</div>
</div>
<p>Does <code>SymPy</code> get the correct output, <span class="math inline">\(0\)</span>, after calling <code>simplify</code>?</p>
<div class="cell" data-hold="true" data-execution_count="47">
<div class="cell-output cell-output-display" data-execution_count="48">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="5299709783455077424" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_5299709783455077424">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_5299709783455077424_1">
<input class="form-check-input" type="radio" name="radio_5299709783455077424" id="radio_5299709783455077424_1" value="1">
<span class="label-body px-1">
Yes
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_5299709783455077424_2">
<input class="form-check-input" type="radio" name="radio_5299709783455077424" id="radio_5299709783455077424_2" value="2">
<span class="label-body px-1">
No
</span>
</label>
</div>
</div>
</div>
<div id="5299709783455077424_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_5299709783455077424"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 1;
var msgBox = document.getElementById('5299709783455077424_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_5299709783455077424")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_5299709783455077424")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
</section>
<section id="question-11" class="level6">
<h6 class="anchored" data-anchor-id="question-11">Question</h6>
<p>In <a href="https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf">Martin</a> a fascinating history of the cycloid can be read.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="../integrals/figures/cycloid-companion-curve.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Figure from Martin showing the companion curve to the cycloid. As the generating circle rolls, from <code>A</code> to <code>C</code>, the original point of contact, <code>D</code>, traces out an arch of the cycloid. The companion curve is that found by congruent line segments. In the figure, when <code>D</code> was at point <code>P</code> the line segment <code>PQ</code> is congruent to <code>EF</code> (on the original position of the generating circle).</figcaption><p></p>
</figure>
</div>
<p>In 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 didnt know integration, so finding the area between two curves required other tricks. One is called “Cavalieris principle.” From the figure above, which of the following would you guess this principle to be:</p>
<div class="cell" data-hold="true" data-execution_count="49">
<div class="cell-output cell-output-display" data-execution_count="50">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="3691703451389918387" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_3691703451389918387">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_3691703451389918387_1">
<input class="form-check-input" type="radio" name="radio_3691703451389918387" id="radio_3691703451389918387_1" value="1">
<span class="label-body px-1">
If two regions bounded by parallel lines are such that any parallel between them cuts each region in segments of equal length, then the regions have equal area.
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_3691703451389918387_2">
<input class="form-check-input" type="radio" name="radio_3691703451389918387" id="radio_3691703451389918387_2" value="2">
<span class="label-body px-1">
The area of the cycloid is nearly the area of a semi-ellipse with known values, so one can approximate the area of the cycloid with formula for the area of an ellipse
</span>
</label>
</div>
</div>
</div>
<div id="3691703451389918387_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_3691703451389918387"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 1;
var msgBox = document.getElementById('3691703451389918387_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_3691703451389918387")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_3691703451389918387")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
<p>Suppose the generating circle has radius <span class="math inline">\(1\)</span>, so the area shown is <span class="math inline">\(\pi/2\)</span>. The companion curve is then <span class="math inline">\(1-\cos(\theta)\)</span> (a fact not used by Roberval). The area <em>under</em> this curve is then</p>
<div class="cell" data-hold="true" data-execution_count="50">
<div class="sourceCode cell-code" id="cb47"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb47-1"><a href="#cb47-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> theta</span>
<span id="cb47-2"><a href="#cb47-2" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fl">1</span> <span class="op">-</span> <span class="fu">cos</span>(theta), (theta, <span class="fl">0</span>, SymPy.PI))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="51">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\pi
\]
</span>
</div>
</div>
<p>That means the area under <strong>one-half</strong> arch of the cycloid is</p>
<div class="cell" data-hold="true" data-execution_count="51">
<div class="cell-output cell-output-display" data-execution_count="52">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="17707449545558135796" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_17707449545558135796">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_17707449545558135796_1">
<input class="form-check-input" type="radio" name="radio_17707449545558135796" id="radio_17707449545558135796_1" value="1">
<span class="label-body px-1">
\(\pi\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17707449545558135796_2">
<input class="form-check-input" type="radio" name="radio_17707449545558135796" id="radio_17707449545558135796_2" value="2">
<span class="label-body px-1">
\((3/2)\cdot \pi\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17707449545558135796_3">
<input class="form-check-input" type="radio" name="radio_17707449545558135796" id="radio_17707449545558135796_3" value="3">
<span class="label-body px-1">
\(2\pi\)
</span>
</label>
</div>
</div>
</div>
<div id="17707449545558135796_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_17707449545558135796"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 2;
var msgBox = document.getElementById('17707449545558135796_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_17707449545558135796")
if (explanation != null) {
explanation.style.display = "none";
}
} else {
msgBox.innerHTML = "<div class='pluto-output admonition alert alert-danger'><span>👎&nbsp; Incorrect </span></div>";
var explanation = document.getElementById("explanation_17707449545558135796")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
<p>Doubling the answer above gives a value that Galileo had struggled with for many years.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="../integrals/figures/companion-curve-bisects-rectangle.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Roberval, avoiding a trignometric integral, instead used symmetry to show that the area under the companion curve was half the area of the rectangle, which in this figure is <code>2\pi</code>.</figcaption><p></p>
</figure>
</div>
</section>
</section>
</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const clipboard = new window.ClipboardJS('.code-copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
setTimeout(function() {
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
let href = ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
});
}
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const cites = ref.parentNode.getAttribute('data-cites').split(' ');
tippyHover(ref, function() {
var popup = window.document.createElement('div');
cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
var filterRegex = new RegExp('/' + window.location.host + '/');
var isInternal = (href) => {
return filterRegex.test(href) || localhostRegex.test(href);
}
// Inspect non-navigation links and adorn them if external
var links = window.document.querySelectorAll('a:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external)');
for (var i=0; i<links.length; i++) {
const link = links[i];
if (!isInternal(link.href)) {
// target, if specified
link.setAttribute("target", "_blank");
}
}
});
</script>
<nav class="page-navigation">
<div class="nav-page nav-page-previous">
<a href="../integrals/mean_value_theorem.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">42</span>&nbsp; <span class="chapter-title">Mean value theorem for integrals</span></span>
</a>
</div>
<div class="nav-page nav-page-next">
<a href="../integrals/center_of_mass.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">44</span>&nbsp; <span class="chapter-title">Center of Mass</span></span> <i class="bi bi-arrow-right-short"></i>
</a>
</div>
</nav>
</div> <!-- /content -->
<footer class="footer">
<div class="nav-footer">
<div class="nav-footer-center">Copyright 2022, John Verzani</div>
</div>
</footer>
</body></html>