CalculusWithJuliaNotes.jl/quarto/308797b5/integral_vector_calculus/double_triple_integrals.html
2022-08-11 13:00:43 -04:00

2982 lines
226 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 - 59&nbsp; Multi-dimensional integrals</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="../integral_vector_calculus/line_integrals.html" rel="next">
<link href="../differentiable_vector_calculus/plots_plotting.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">59</span>&nbsp; <span class="chapter-title">Multi-dimensional integrals</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 collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" aria-expanded="false">Integrals</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-4" class="collapse list-unstyled sidebar-section depth1 ">
<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"><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" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="true">Integral vector calculus</a>
<a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="true">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-7" class="collapse list-unstyled sidebar-section depth1 show">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/double_triple_integrals.html" class="sidebar-item-text sidebar-link active"><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="#integration-theory" id="toc-integration-theory" class="nav-link active" data-scroll-target="#integration-theory"> <span class="header-section-number">59.1</span> Integration theory</a>
<ul class="collapse">
<li><a href="#hcubature" id="toc-hcubature" class="nav-link" data-scroll-target="#hcubature"> <span class="header-section-number">59.1.1</span> HCubature</a></li>
</ul></li>
<li><a href="#integrals-over-more-general-regions" id="toc-integrals-over-more-general-regions" class="nav-link" data-scroll-target="#integrals-over-more-general-regions"> <span class="header-section-number">59.2</span> Integrals over more general regions</a></li>
<li><a href="#fubinis-theorem" id="toc-fubinis-theorem" class="nav-link" data-scroll-target="#fubinis-theorem"> <span class="header-section-number">59.3</span> Fubinis theorem</a>
<ul class="collapse">
<li><a href="#sympys-integrate" id="toc-sympys-integrate" class="nav-link" data-scroll-target="#sympys-integrate"> <span class="header-section-number">59.3.1</span> <code>SymPy</code>s <code>integrate</code></a></li>
<li><a href="#a-fubini-function" id="toc-a-fubini-function" class="nav-link" data-scroll-target="#a-fubini-function"> <span class="header-section-number">59.3.2</span> A “Fubini” function</a></li>
</ul></li>
<li><a href="#triple-integrals" id="toc-triple-integrals" class="nav-link" data-scroll-target="#triple-integrals"> <span class="header-section-number">59.4</span> Triple integrals</a></li>
<li><a href="#change-of-variables" id="toc-change-of-variables" class="nav-link" data-scroll-target="#change-of-variables"> <span class="header-section-number">59.5</span> Change of variables</a>
<ul class="collapse">
<li><a href="#two-dimensional-change-of-variables" id="toc-two-dimensional-change-of-variables" class="nav-link" data-scroll-target="#two-dimensional-change-of-variables"> <span class="header-section-number">59.5.1</span> Two dimensional change of variables</a></li>
<li><a href="#examples" id="toc-examples" class="nav-link" data-scroll-target="#examples"> <span class="header-section-number">59.5.2</span> Examples</a></li>
<li><a href="#three-dimensional-change-of-variables" id="toc-three-dimensional-change-of-variables" class="nav-link" data-scroll-target="#three-dimensional-change-of-variables"> <span class="header-section-number">59.5.3</span> Three dimensional change of variables</a></li>
</ul></li>
<li><a href="#questions" id="toc-questions" class="nav-link" data-scroll-target="#questions"> <span class="header-section-number">59.6</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/integral_vector_calculus/double_triple_integrals.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">59</span>&nbsp; <span class="chapter-title">Multi-dimensional integrals</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">QuadGK</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">SymPy</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">HCubature</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<hr>
<p>The definition of the definite integral, <span class="math inline">\(\int_a^b f(x)dx\)</span>, is based on Riemann sums.</p>
<p>We review, using a more general form than <a href="../integrals/area.html">previously</a>. Consider a bounded function <span class="math inline">\(f\)</span> over <span class="math inline">\([a,b]\)</span>. A partition, <span class="math inline">\(P\)</span>, is based on <span class="math inline">\(a = x_0 &lt; x_1 &lt; \cdots &lt; x_n = b\)</span>. For each subinterval <span class="math inline">\([x_{i-1}, x_{i}]\)</span> take <span class="math inline">\(m_i(f) = \inf_{u \text{ in } [x_{i-1},x_i]} f(u)\)</span> and <span class="math inline">\(M_i(f) = \sup_{u \text{ in } [x_{i-1},x_i]} f(u)\)</span>. (When <span class="math inline">\(f\)</span> is continuous, <span class="math inline">\(m_i\)</span> and <span class="math inline">\(M_i\)</span> are realized at points of <span class="math inline">\([x_{i-1},x_i]\)</span>, though that isnt assumed here. The use of “<span class="math inline">\(\sup\)</span>” and “<span class="math inline">\(\inf\)</span>” is a mathematically formal means to replace this in general.) Let <span class="math inline">\(\Delta x_i = x_i - x_{i-1}\)</span>. Form the sums <span class="math inline">\(m(f, P) = \sum_i m_i(f) \Delta x_i\)</span> and <span class="math inline">\(M(f, P) = \sum_i M_i(f) \Delta x_i\)</span>. These are the <em>lower</em> and <em>upper</em> Riemann sums for a partition. A general Riemann sum would be formed by selecting <span class="math inline">\(c_i\)</span> from <span class="math inline">\([x_{i-1}, x_i]\)</span> and forming <span class="math inline">\(S(f,P) = \sum f(c_i) \Delta x_i\)</span>. It will be the case that <span class="math inline">\(m(f,P) \leq S(f,P) \leq M(f,P)\)</span>, as this is true for <em>each</em> sub-interval of the partition.</p>
<p>If, as the largest diameter (<span class="math inline">\(\Delta x_i\)</span>) of the partition <span class="math inline">\(P\)</span> goes to <span class="math inline">\(0\)</span>, the upper and lower sums converge to the same limit, then <span class="math inline">\(f\)</span> is called Riemann integrable over <span class="math inline">\([a,b]\)</span>. If <span class="math inline">\(f\)</span> is Riemann integrable, any Riemann sum will converge to the definite integral as the partitioning shrinks.</p>
<p>Continuous functions are known to be Riemann integrable, as are functions with only finitely many discontinuities, though this isnt the most general case of integrable functions, which will be stated below.</p>
<p>In practice, we dont typically compute integrals using a limit of a partition, though the approach may provide direction to numeric answers, as the Fundamental Theorem of Calculus relates the definite integral with an antiderivative of the integrand.</p>
<p>The multidimensional case will prove to be similar where a Riemann sum is used to define the value being discussed, but a theorem of Fubini will allow the computation of integrals using the Fundamental Theorem of Calculus.</p>
<hr>
<section id="integration-theory" class="level2" data-number="59.1">
<h2 data-number="59.1" class="anchored" data-anchor-id="integration-theory"><span class="header-section-number">59.1</span> Integration theory</h2>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="../integral_vector_calculus/figures/chrysler-building-in-new-york.jpg" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">How to estimate the volume contained within the Chrysler Building? One way might be to break the building up into tall vertical blocks based on its skyline; compute the volume of each block using the formula of volume as area of the base times the height; and, finally, adding up the computed volumes This is the basic idea of finding volumes under surfaces using Riemann integration.</figcaption><p></p>
</figure>
</div>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="../integral_vector_calculus/figures/chrysler-nano-block.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Computing the volume of a nano-block construction of the Chrysler building is easier than trying to find an actual tree at the Chrysler building, as we can easily compute the volume of columns of equal-sized blocks. Riemann sums are similar.</figcaption><p></p>
</figure>
</div>
<p>The definition of the multi-dimensional integral is more involved then the one-dimensional case due to the possibly increased complexity of the region. This will require additional <a href="https://math.okstate.edu/people/lebl/osu4153-s16/chapter10-ver1.pdf">steps</a>. The basic approach is as follows.</p>
<p>First, let <span class="math inline">\(R = [a_1, b_1] \times [a_2, b_2] \times \cdots \times [a_n, b_n]\)</span> be a closed rectangular region. If <span class="math inline">\(n=2\)</span>, this is a rectangle, and if <span class="math inline">\(n=3\)</span>, a box. We begin by defining integration over closed rectangular regions. For each side, a partition <span class="math inline">\(P_i\)</span> is chosen based on <span class="math inline">\(a_i = x_{i0} &lt; x_{i1} &lt; \cdots &lt; x_{ik} = b_i\)</span>. Then a sub-rectangular region would be of the form <span class="math inline">\(R' = P_{1j_1} \times P_{2j_2} \times \cdots \times P_{nj_n}\)</span>, where <span class="math inline">\(P_{ij_i}\)</span> is one of the partitioning sub intervals of <span class="math inline">\([a_i, b_i]\)</span>. Set <span class="math inline">\(\Delta R' = \Delta P_{1j_1} \cdot \Delta P_{2j_2} \cdot\cdots\cdot\Delta P_{nj_n}\)</span> to be the <span class="math inline">\(n\)</span>-dimensional volume of the sub-rectangular region.</p>
<p>For each sub-rectangular region, we can define <span class="math inline">\(m(f,R')\)</span> to be <span class="math inline">\(\inf_{u \text{ in } R'} f(u)\)</span> and <span class="math inline">\(M(f, R') = \sup_{u \text{ in } R'} f(u)\)</span>. If we enumerate all the sub-rectangular regions, we can define <span class="math inline">\(m(f, P) = \sum_i m(f, R_i) \Delta R_i\)</span> and <span class="math inline">\(M(f,P) = \sum_i M(f, R_i)\Delta R_i\)</span>, as in the one-dimensional case. These are upper and lower sums, and, as before, would bound the Riemann sum formed by choosing any <span class="math inline">\(c_i\)</span> in <span class="math inline">\(R_i\)</span> and computing <span class="math inline">\(S(f,P) = \sum_i f(c_i) \Delta R_i\)</span>.</p>
<p>As with the one-dimensional case, <span class="math inline">\(f\)</span> is Riemann integrable over <span class="math inline">\(R\)</span> if the limits of <span class="math inline">\(m(f,P)\)</span> and <span class="math inline">\(M(f,P)\)</span> exist and are identical as the diameter of the partition (defined as the largest diameter of each side) goes to <span class="math inline">\(0\)</span>. If the limits are equal, then so is the limit of any Riemann sum.</p>
<p>When <span class="math inline">\(f\)</span> is Riemann integrable over a rectangular region <span class="math inline">\(R\)</span>, we denote the limit by any of:</p>
<p><span class="math display">\[
\iint_R f(x) dV, \quad \iint_R fdV, \quad \iint_R f(x_1, \dots, x_n) dx_1 \cdot\cdots\cdot dx_n, \quad\iint_R f(\vec{x}) d\vec{x}.
\]</span></p>
<p>A key fact, requiring proof, is:</p>
<blockquote class="blockquote">
<p>Any continuous function, <span class="math inline">\(f\)</span>, is Riemann integrable over a closed, bounded rectangular region.</p>
</blockquote>
<hr>
<p>As with one-dimensional integrals, from the Riemann sum definition, several familiar properties for integrals follow. Let <span class="math inline">\(V(R)\)</span> be the volume of <span class="math inline">\(R\)</span> found by multiplying the side-lengths together.</p>
<p><strong>Constants:</strong></p>
<ul>
<li>A constant is Riemann integrable and: <span class="math inline">\(\iint_R c dV = c V(R)\)</span>.</li>
</ul>
<p><strong>Linearity:</strong></p>
<ul>
<li>For integrable <span class="math inline">\(f\)</span> and <span class="math inline">\(g\)</span> and constants <span class="math inline">\(a\)</span> and <span class="math inline">\(b\)</span>:</li>
</ul>
<p><span class="math display">\[
\iint_R (af(x) + bg(x))dV = a\iint_R f(x)dV + b\iint_R g(x) dV.
\]</span></p>
<p><strong>Disjoint:</strong></p>
<ul>
<li>If <span class="math inline">\(R\)</span> and <span class="math inline">\(R'\)</span> are <em>disjoint</em> rectangular regions (possibly sharing a boundary), then the integral over the union is defined by linearity:</li>
</ul>
<p><span class="math display">\[
\iint_{R \cup R'} f(x) dV = \iint_R f(x)dV + \iint_{R'} f(x) dV.
\]</span></p>
<p><strong>Monotonicity:</strong></p>
<ul>
<li>As <span class="math inline">\(f\)</span> is bounded, let <span class="math inline">\(m \leq f(x) \leq M\)</span> for all <span class="math inline">\(x\)</span> in <span class="math inline">\(R\)</span>. Then</li>
</ul>
<p><span class="math display">\[
m V(R) \leq \iint_R f(x) dV \leq MV(R).
\]</span></p>
<ul>
<li>If <span class="math inline">\(f\)</span> and <span class="math inline">\(g\)</span> are integrable <em>and</em> <span class="math inline">\(f(x) \leq g(x)\)</span>, then the integrals have the same property, namely <span class="math inline">\(\iint_R f dV \leq \iint_R gdV\)</span>.</li>
<li>If <span class="math inline">\(S \subset R\)</span>, both closed rectangles, then if <span class="math inline">\(f\)</span> is integrable over <span class="math inline">\(R\)</span> it will be also over <span class="math inline">\(S\)</span> and, when <span class="math inline">\(f\geq 0\)</span>, <span class="math inline">\(\iint_S f dV \leq \iint_R fdV\)</span>.</li>
</ul>
<p><strong>Triangle inequality:</strong></p>
<ul>
<li>If <span class="math inline">\(f\)</span> is bounded and integrable, then <span class="math inline">\(|\iint_R fdV| \leq \iint_R |f| dV\)</span>.</li>
</ul>
<section id="hcubature" class="level3" data-number="59.1.1">
<h3 data-number="59.1.1" class="anchored" data-anchor-id="hcubature"><span class="header-section-number">59.1.1</span> HCubature</h3>
<p>To numerically compute multidimensional integrals over rectangular regions in <code>Julia</code> is efficiently done with the <code>HCubature</code> package. The <code>hcubature</code> function is defined for <span class="math inline">\(n\)</span>-dimensional integrals, so the integrand is specified through a function which takes a vector as an input. The region to integrate over is of rectangular form. It is specified by a tuple of left endpoints and a tuple of right endpoints. The order is in terms of the order of the vector.</p>
<p>To elaborate, if we think of <span class="math inline">\(f(\vec{x}) = f(x_1, x_2, \dots, x_n)\)</span> and we are integrating over <span class="math inline">\([a_1, b_1] \times \cdots \times [a_n, b_n]\)</span>, then the region would be specified through two tuples: <code>(a1, a2, ..., an)</code> and <code>(b1, b2, ..., bn)</code>.</p>
<p>To illustrate, to integrate the function <span class="math inline">\(f(x,y) = x^2 + 5y^2\)</span> over the region <span class="math inline">\([0,1] \times [0,2]\)</span> using <code>HCubature</code>s <code>hcubature</code> function, we would proceed as follows:</p>
<div class="cell" data-hold="true" data-execution_count="6">
<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,y) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fl">5</span>y<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">f</span>(v) <span class="op">=</span> <span class="fu">f</span>(v<span class="op">...</span>) <span class="co"># f accepts a vector</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>a0, b0 <span class="op">=</span> <span class="fl">0</span>, <span class="fl">1</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>a1, b1 <span class="op">=</span> <span class="fl">0</span>, <span class="fl">2</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="fu">hcubature</span>(f, (a0, a1), (b0, b1))</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>(14.0, 1.7763568394002505e-15)</code></pre>
</div>
</div>
<p>The computed value and a worst case estimate for the error is returned, in a manner similar to the <code>quadgk</code> function (from the <code>QuadGK</code> package) used previously for one-dimensional numeric integrals.</p>
<p>The order above is <code>x</code> then <code>y</code>, which is clear from the first definition of <code>f</code> and as belabored in the tuples passed to <code>hcubature</code>. A more convenient use is to just put the constants into the function call, as in <code>hcubature(f, (0,0), (1,2))</code>.</p>
<section id="example" class="level5">
<h5 class="anchored" data-anchor-id="example">Example</h5>
<p>Lets verify the numeric approach works for figures where an answer is known from the geometry of the problem.</p>
<ul>
<li>A constant function <span class="math inline">\(c=f(x,y)\)</span>. In this case, the volume is simply a box, so the volume will come from multiplying the three dimensions. Here is an example:</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="7">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y) <span class="op">=</span> <span class="fl">3</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(v) <span class="op">=</span> <span class="fu">f</span>(v<span class="op">...</span>)</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>a0, b0 <span class="op">=</span> <span class="fl">0</span>, <span class="fl">4</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>a1, b1 <span class="op">=</span> <span class="fl">0</span>, <span class="fl">5</span> <span class="co"># R is area 20, so V = 60 = 3 ⋅ 20</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="fu">hcubature</span>(f, (a0, a1), (b0, b1))</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>(60.0, 7.105427357601002e-15)</code></pre>
</div>
</div>
<ul>
<li>A wedge. Let <span class="math inline">\(f(x,y) = x\)</span> and <span class="math inline">\(R= [0,1] \times [0,1]\)</span>. The the volume is a wedge, and should be half the value of the unit cube, or simply <span class="math inline">\(1/2\)</span>:</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="8">
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y) <span class="op">=</span> x</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(v) <span class="op">=</span> <span class="fu">f</span>(v<span class="op">...</span>)</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>a0, b0 <span class="op">=</span> <span class="fl">0</span>, <span class="fl">1</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>a1, b1 <span class="op">=</span> <span class="fl">0</span>, <span class="fl">1</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="fu">hcubature</span>(f, (a0, a1), (b0, b1))</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">
<pre><code>(0.5, 0.0)</code></pre>
</div>
</div>
<ul>
<li>The volume of a right square pyramid is <span class="math inline">\(V=(1/3)a^2 h\)</span>, or a third of an enclosing box. We computed this area previously using the method of <a href="../integrals/volumes_slice.html">slices</a>. Here we do it thinking of the pyramid as the volume formed by the surface over the region <span class="math inline">\([-a,a] \times [-a,a]\)</span> generated by <span class="math inline">\(f(x,y) = h \cdot (l(x,y) - d(x,y))/l(x,y)\)</span> where <span class="math inline">\(d(x,y)\)</span> is the distance to the origin, or <span class="math inline">\(\sqrt{x^2 + y^2}\)</span> and <span class="math inline">\(l(x,y)\)</span> is the length of the line segment from the origin to the boundary of <span class="math inline">\(R\)</span> that goes through <span class="math inline">\((x,y)\)</span>.</li>
</ul>
<p>Identifying a formula for this is a bit tricky. Here we use a brute force approach; later we will simplify this. Using polar coordinates, we know <span class="math inline">\(r\cos(\theta) = a\)</span> describes the line <span class="math inline">\(x=a\)</span> and <span class="math inline">\(r\sin(\theta)=a\)</span> describes the line <span class="math inline">\(y=a\)</span>. Using the square, we have to alternate between these depending on where <span class="math inline">\(\theta\)</span> is (e.g., between <span class="math inline">\(-\pi/4\)</span> and <span class="math inline">\(\pi/4\)</span> it would be <span class="math inline">\(r\cos(\theta)=a\)</span> or <span class="math inline">\(a/\cos(\theta)\)</span> is <span class="math inline">\(l(x,y)\)</span>. We write a function for this:</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="fu">𝒅</span>(x, y) <span class="op">=</span> <span class="fu">sqrt</span>(x<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> y<span class="op">^</span><span class="fl">2</span>)</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="kw">function</span> <span class="fu">𝒍</span>(x, y, a)</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> theta <span class="op">=</span> <span class="fu">atan</span>(y,x)</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> atheta <span class="op">=</span> <span class="fu">abs</span>(theta)</span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (<span class="cn">pi</span><span class="op">/</span><span class="fl">4</span> <span class="op">&lt;=</span> atheta <span class="op">&lt;</span> <span class="fl">3</span>pi<span class="op">/</span><span class="fl">4</span>) <span class="co"># this is the y=a or y=-a case</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> (a<span class="op">/</span><span class="fl">2</span>)<span class="op">/</span><span class="fu">sin</span>(atheta)</span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span></span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> (a<span class="op">/</span><span class="fl">2</span>)<span class="op">/</span><span class="fu">abs</span>(<span class="fu">cos</span>(atheta))</span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">end</span></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a><span class="kw">end</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>𝒍 (generic function with 1 method)</code></pre>
</div>
</div>
<p>And then</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="fu">𝒇</span>(x,y,a,h) <span class="op">=</span> h <span class="op">*</span> (<span class="fu">𝒍</span>(x,y,a) <span class="op">-</span> <span class="fu">𝒅</span>(x,y))<span class="op">/</span><span class="fu">𝒍</span>(x,y,a)</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>𝒂, 𝒉 <span class="op">=</span> <span class="fl">2</span>, <span class="fl">3</span></span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="fu">𝒇</span>(x,y) <span class="op">=</span> <span class="fu">𝒇</span>(x, y, 𝒂, 𝒉) <span class="co"># fix a and h</span></span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="fu">𝒇</span>(v) <span class="op">=</span> <span class="fu">𝒇</span>(v<span class="op">...</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="11">
<pre><code>𝒇 (generic function with 3 methods)</code></pre>
</div>
</div>
<p>We can visualize the volume to be computed, as follows:</p>
<div class="cell" data-hold="true" data-execution_count="11">
<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>xs <span class="op">=</span> ys <span class="op">=</span> <span class="fu">range</span>(<span class="op">-</span><span class="fl">1</span>, <span class="fl">1</span>, length<span class="op">=</span><span class="fl">20</span>)</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="fu">surface</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="12">
<p><img src="double_triple_integrals_files/figure-html/cell-12-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Trying this, we have:</p>
<div class="cell" data-execution_count="12">
<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">hcubature</span>(𝒇, (<span class="op">-</span>𝒂<span class="op">/</span><span class="fl">2</span>, <span class="op">-</span>𝒂<span class="op">/</span><span class="fl">2</span>), (𝒂<span class="op">/</span><span class="fl">2</span>, 𝒂<span class="op">/</span><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="13">
<pre><code>(4.000000009419327, 5.9590510310780554e-8)</code></pre>
</div>
</div>
<p>The answer agrees with that known from the formula, <span class="math inline">\(4 = (1/3)a^2 h\)</span>, but the answer takes a long time to be produce. The <code>hcubature</code> function is slow with functions defined in terms of conditions. For this problem, volumes by <a href="../integrals/volumes_slice.html">slicing</a> is more direct. But also symmetry can be used, were we able to compute the volume above the triangular region formed by the <span class="math inline">\(x\)</span>-axis, the line <span class="math inline">\(x=a/2\)</span> and the line <span class="math inline">\(y=x\)</span>, which would be <span class="math inline">\(1/8\)</span>th the total volume. (As then <span class="math inline">\(l(x,y,a) = (a/2)/\sin(\tan^{-1}(y,x))\)</span>.).</p>
<ul>
<li>The volume of a sphere is <span class="math inline">\(4/3 \pi r^3\)</span>. We could verify this by integrating <span class="math inline">\(z = f(x,y) = \sqrt{r^2 - (x^2 + y^2)}\)</span> over <span class="math inline">\(R = \{(x,y): x^2 + y^2 \leq r^2\}\)</span>. <em>However</em>, this is not a <em>rectangular</em> region, so we couldnt directly proceed.</li>
</ul>
<p>We might try integrating a function with a condition:</p>
<div class="cell" data-hold="true" data-execution_count="13">
<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><span class="kw">function</span> <span class="fu">f</span>(x, y, r)</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> x<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> y<span class="op">^</span><span class="fl">2</span> <span class="op">&lt;</span> r</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">sqrt</span>(z <span class="op">-</span> x<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> y<span class="op">^</span><span class="fl">2</span>)</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span></span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a> <span class="fl">0.0</span></span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">end</span></span>
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="kw">end</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="14">
<pre><code>f (generic function with 3 methods)</code></pre>
</div>
</div>
<p><strong>But</strong> <code>hcubature</code> is <strong>very</strong> slow to integrate such functions. We will see our instincts are good this is the approach taken to discuss integrals over general regions but this is not practical here. There are two alternative approaches to be discussed: approach the integral <em>iteratively</em> or <em>transform</em> the circular region into a rectangular region and integrate. Before doing so, we discuss how the integral is developed for more general regions.</p>
<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>The approach above takes a nice smooth function and makes it non smooth at the boundary. In general this is not a good idea for numeric solutions, as many algorithms work better with assumptions of smoothness.</p>
</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>The <code>Quadrature</code> package provides a uniform interface for <code>QuadGK</code>, <code>HCubature</code>, and other numeric integration routines available in <code>Julia</code>.</p>
</div>
</div>
</section>
</section>
</section>
<section id="integrals-over-more-general-regions" class="level2" data-number="59.2">
<h2 data-number="59.2" class="anchored" data-anchor-id="integrals-over-more-general-regions"><span class="header-section-number">59.2</span> Integrals over more general regions</h2>
<p>To proceed further, it is necessary to discuss certain types of sets that will be used to describe the boundaries of regions that can be integrated over, though we dont dig into the details.</p>
<p>Let the <em>measure</em> of a rectangular region be its volume and for any subset of <span class="math inline">\(S \subset R^n\)</span>, define the <em>outer</em> measure of <span class="math inline">\(S\)</span> by <span class="math inline">\(m^*(S) = \inf\sum_{j=1}^\infty V(R_j)\)</span> where the infimum is taken over all closed, countable, rectangles with <span class="math inline">\(S \subset \cup_{j=1}^\infty R_j\)</span>.</p>
<p>In two dimensions, if <span class="math inline">\(S\)</span> is viewed on a grid, then this would be <em>area</em> of the smallest collection of cells that contain any part of <span class="math inline">\(S\)</span>. This is the smallest this value takes as the grid becomes infinite.</p>
<p>For the following graph, there are <span class="math inline">\(100\)</span> cells each of area <span class="math inline">\(8/100\)</span>. Their are 58 cells covering the curve and its interior. So the outer measure is less than <span class="math inline">\(58\cdot 8/100\)</span>, as this is just one possible covering.</p>
<div class="cell" data-hold="true" data-execution_count="14">
<div class="cell-output cell-output-display" data-execution_count="15">
<p><img src="double_triple_integrals_files/figure-html/cell-15-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>A set has measure <span class="math inline">\(0\)</span> if the outer measure is <span class="math inline">\(0\)</span>. An alternate definition, among other characterizations, is a set has measure <span class="math inline">\(0\)</span> if for any <span class="math inline">\(\epsilon &gt; 0\)</span> there exists rectangular regions <span class="math inline">\(R_1, R_2, \dots, R_n\)</span> (for some <span class="math inline">\(n\)</span>) with <span class="math inline">\(\sum V(R_i) &lt; \epsilon\)</span>. Measure zero sets have many properties not discussed here.</p>
<p>For now, lets see that graph of <span class="math inline">\(y=f(x)\)</span> over <span class="math inline">\([a,b]\)</span>, as a two dimensional set, has measure zero when <span class="math inline">\(f(x)\)</span> has a bounded derivative (<span class="math inline">\(|f'|\)</span> bounded by <span class="math inline">\(M\)</span>). Fix some <span class="math inline">\(\epsilon&gt;0\)</span>. Take <span class="math inline">\(n\)</span> with <span class="math inline">\(2M(b-a)^2/n &lt; \epsilon\)</span>, then divide <span class="math inline">\([a,b]\)</span> into <span class="math inline">\(n\)</span> equal length intervals (of length <span class="math inline">\(\delta = (b-a)/n)\)</span>. For each interval, we consider the box <span class="math inline">\([a_i, b_i] \times [f(a_i)-\delta M, f(a_i) + \delta M]\)</span>. By the mean value theorem, we have <span class="math inline">\(|f(x) - f(a_i)| \leq |b_i-a_i|M\)</span> so <span class="math inline">\(f(a_i) - \delta M \leq f(x) \leq f(a_i) + \delta M\)</span>, so the curve will stay in the boxes. These boxes have total area <span class="math inline">\(n \cdot \delta \cdot 2\delta M = 2M(b-a)^2/n\)</span>, an area less than <span class="math inline">\(\epsilon\)</span>.</p>
<p>The above can be extended to any graph of a continuous function over <span class="math inline">\([a,b]\)</span>.</p>
<p>For a function <span class="math inline">\(f\)</span> the set of discontinuities in <span class="math inline">\(R\)</span> is all points where <span class="math inline">\(f\)</span> is not continuous. A formal definition is often given in terms of oscillation. Let <span class="math inline">\(o(f, \vec{x}, \delta) = \sup_{\{\vec{y} : \| \vec{y}-\vec{x}\| &lt; \delta\}}f(\vec{y}) - \inf_{\{\vec{y}: \|\vec{y}-\vec{x}\|&lt;\delta\}}f(\vec{y})\)</span>. A function is discontinuous at <span class="math inline">\(\vec{x}\)</span> if the limit as <span class="math inline">\(\delta \rightarrow 0+\)</span> (which must exist) is not <span class="math inline">\(0\)</span>.</p>
<p>With this, we can state the Riemann-Lebesgue theorem on integrable functions:</p>
<blockquote class="blockquote">
<p>Let <span class="math inline">\(R\)</span> be a closed, rectangular region, and <span class="math inline">\(f:R^n \rightarrow R\)</span> a bounded function. Then <span class="math inline">\(f\)</span> is Riemann integrable over <span class="math inline">\(R\)</span> if and only if the set of discontinuities is a set of measure <span class="math inline">\(0\)</span>.</p>
</blockquote>
<p>It was said at the outset we would generalize the regions we can integrate over, but this theorem generalizes the functions. We can tie the two together as follows. Define the integral over any <em>bounded</em> set <span class="math inline">\(S\)</span> with boundary of measure <span class="math inline">\(0\)</span>. Bounded means <span class="math inline">\(S\)</span> is contained in some bounded rectangle <span class="math inline">\(R\)</span>. Let <span class="math inline">\(f\)</span> be defined on <span class="math inline">\(S\)</span> and extend it to be <span class="math inline">\(0\)</span> on points in <span class="math inline">\(R\)</span> that are not in <span class="math inline">\(S\)</span>. If this extended function is integrable over <span class="math inline">\(R\)</span>, then we can define the integral over <span class="math inline">\(S\)</span> in terms of that. This is why the <em>boundary</em> of <span class="math inline">\(S\)</span> must have measure zero, as in general it is among the set of discontinuities of the extend function <span class="math inline">\(f\)</span>. Such regions are also called Jordan regions.</p>
</section>
<section id="fubinis-theorem" class="level2" data-number="59.3">
<h2 data-number="59.3" class="anchored" data-anchor-id="fubinis-theorem"><span class="header-section-number">59.3</span> Fubinis theorem</h2>
<p>Consider again this figure</p>
<div class="cell" data-hold="true" data-execution_count="15">
<div class="cell-output cell-output-display" data-execution_count="16">
<p><img src="double_triple_integrals_files/figure-html/cell-16-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Let <span class="math inline">\(C_i\)</span> enumerate all the cells shown, assume <span class="math inline">\(f\)</span> is extended to be <span class="math inline">\(0\)</span> outside the region, and let <span class="math inline">\(c_i\)</span> be a point in the cell. Then the Riemann sum <span class="math inline">\(\sum_i f(c_i) V(C_i)\)</span> can be visualized three identical ways:</p>
<ul>
<li>as a linear sum over the indices <span class="math inline">\(i\)</span>, as written, leading to <span class="math inline">\(\iint_R f(x) dV\)</span>.</li>
<li>by indexing the cells by row (<span class="math inline">\(i\)</span>) and column (<span class="math inline">\(j\)</span>) and summing as <span class="math inline">\(\sum_i (\sum_j f(x_{ij}, y_{ij}) \Delta y_j) \Delta x_i\)</span>.</li>
<li>by indexing the cells by row (<span class="math inline">\(i\)</span>) and column (<span class="math inline">\(j\)</span>) and summing as <span class="math inline">\(\sum_j (\sum_i f(x_{ij}, y_{ij}) \Delta x_i) \Delta y_j\)</span>.</li>
</ul>
<p>The last two suggest that their limit will be <em>iterated</em> integrals of the form <span class="math inline">\(\int_{-1}^1 (\int_{-2}^2 f(x,y) dy) dx\)</span> and <span class="math inline">\(\int_{-2}^2 (\int_{-1}^1 f(x,y) dx) dy\)</span>.</p>
<p>By “iterated” we mean performing two different definite integrals. For example, to compute <span class="math inline">\(\int_{-1}^1 (\int_{-2}^2 f(x,y) dy) dx\)</span> the first task would be to compute <span class="math inline">\(I(x) = \int_{-2}^2 f(x,y) dy\)</span>. Like partial derivatives, this integrates in <span class="math inline">\(y\)</span> while treating <span class="math inline">\(x\)</span> as a constant. Once the interior integral is computed, then the integral <span class="math inline">\(\int_{-1}^1 I(x) dx\)</span> would be computed to find the answer.</p>
<p>The question then: under what conditions will the three integrals be equal?</p>
<blockquote class="blockquote">
<p><a href="https://math.okstate.edu/people/lebl/osu4153-s16/chapter10-ver1.pdf">Fubini</a>. Let <span class="math inline">\(R \times S\)</span> be a closed rectangular region in <span class="math inline">\(R^n \times R^m\)</span>. Suppose <span class="math inline">\(f\)</span> is bounded. Define <span class="math inline">\(f_x(y) = f(x,y)\)</span> and <span class="math inline">\(f^y(x) = f(x,y)\)</span> where <span class="math inline">\(x\)</span> is in <span class="math inline">\(R^n\)</span> and <span class="math inline">\(y\)</span> in <span class="math inline">\(R^m\)</span>. <em>If</em> <span class="math inline">\(f_x\)</span> and <span class="math inline">\(f^y\)</span> are integrable then</p>
<p><span class="math display">\[
\iint_{R\times S}fdV = \iint_R \left(\iint_S f_x(y) dy\right) dx
= \iint_S \left(\iint_R f^y(x) dx\right) dy.
\]</span></p>
</blockquote>
<p>Similarly, if <span class="math inline">\(f^y\)</span> is integrable for all <span class="math inline">\(y\)</span>, then <span class="math inline">\(\iint_{R\times S}fdV =\iint_S \iint_R f(x,y) dx dy\)</span>.</p>
<p>An immediate corollary is that the above holds for continuous functions when <span class="math inline">\(R\)</span> and <span class="math inline">\(S\)</span> are bounded, the case described here.</p>
<p>The case of continuous functions was known to <a href="https://en.wikipedia.org/wiki/Fubini%27s_theorem#History">Euler</a>, Lebesgue (1904) discussed bounded functions, as in our statement, and Fubini and Tonnelli (1907 and 1909) generalized the statement to more general functions than continuous functions, thereby earning naming rights.</p>
<p>In <a href="https://doi.org/10.2307/2687130">Ferzola</a> we can read a summary of Eulers thinking of 1769 when trying to understand the integral of a function <span class="math inline">\(f(x,y)\)</span> over a bounded domain <span class="math inline">\(R\)</span> enclosed by arcs in the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane. (That is, the area below <span class="math inline">\(g(x)\)</span> and above <span class="math inline">\(h(x)\)</span> over the interval <span class="math inline">\([a,b]\)</span>.) Euler wrote the answer as <span class="math inline">\(\int_a^b dx (\int_{g(x)}^{h(x)} f(x,y)dy)\)</span>. Ferzola writes that Euler saw this integral yielding a <em>volume</em> as the integral <span class="math inline">\(\int_{g(x)}^{h(x)} f(x,y)dy\)</span> gives the area of a slice (parallel to the <span class="math inline">\(y\)</span> axis) and integrating in <span class="math inline">\(x\)</span> adds these slices to give a volume. This is the typical usage of Fubinis theorem today.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="../integral_vector_calculus/figures/strang-slicing.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Figure 14.2 of Strang illustrating the slice when either <span class="math inline">\(x\)</span> is fixed or <span class="math inline">\(y\)</span> is fixed. The inner integral computes the shared area, the outer integral adds the areas up to compute volume.</figcaption><p></p>
</figure>
</div>
<p>In <a href="../integrals/volumes_slice.html">Volumes</a> the formula for a volume with a known cross-sectional area is given by <span class="math inline">\(V = \int_a^b CA(x) dx\)</span>. The inner integral, <span class="math inline">\(\int_{R_x} f(x,y) dy\)</span> is a function depending on <span class="math inline">\(x\)</span> that yields the area of the slice (where <span class="math inline">\(R_x\)</span> is the region sliced by the line of constant <span class="math inline">\(x\)</span> value). This is consistent with Eulers view of the iterated integral.</p>
<p>A domain, as described above, is known as a <a href="https://en.wikipedia.org/wiki/Multiple_integral#Normal_domains_on_R2">normal</a> domain. Using Fubinis theorem to integrate iteratively, employing the fundamental theorem of calculus at each step, is the standard approach.</p>
<p>For example, we return to the problem of a square pyramid, only now using symmetry, we integrate only over the triangular region between <span class="math inline">\(0 \leq x \leq a/2\)</span> and <span class="math inline">\(0 \leq y \leq x\)</span>. The answer is then (the <span class="math inline">\(8\)</span> by symmetry)</p>
<p><span class="math display">\[
V = 8 \int_0^{a/2} \int_0^x h(l(x,y) - d(x,y))/l(x,y) dy dx.
\]</span></p>
<p>But, using similar triangles, we have <span class="math inline">\(d/x = l/(a/2)\)</span> so <span class="math inline">\((l-d)/l = 1 - 2x/a\)</span>. Continuing, our answer becomes</p>
<p><span class="math display">\[
V = 8 \int_0^{a/2} (\int_0^x h(1-\frac{2x}{a}) dy) dx =
8 \int_0^{a/2} (h(1-2x/a) \cdot x) dx =
8 (hx^2_2 \big\lvert_{0}^{a/2} - \frac{2}{a}\frac{x^3}{3}\big\lvert_0^{a/2})=
8 h(\frac{a^2}{8} - \frac{2}{24}a^2) = \frac{a^2h}{3}.
\]</span></p>
<section id="sympys-integrate" class="level3" data-number="59.3.1">
<h3 data-number="59.3.1" class="anchored" data-anchor-id="sympys-integrate"><span class="header-section-number">59.3.1</span> <code>SymPy</code>s <code>integrate</code></h3>
<p>The <code>integrate</code> function of <code>SymPy</code> uses various algorithms to symbolically integrate definite (and indefinite) integrals. In the section on <a href="../integrals/ftc.html">integrals</a> its use for one-dimensional integrals was shown. For multi-dimensional integrals the usage is similar, the syntax following, somewhat, the Fubini-like notation.</p>
<p>For example, to perform the integral</p>
<p><span class="math display">\[
\int_a^b \int_{h(x)}^{g(x)} f(x,y) dy dx
\]</span></p>
<p>the call would look like:</p>
<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><span class="fu">integrate</span>(<span class="fu">f</span>(x,y), (y, <span class="fu">h</span>(x), <span class="fu">g</span>(x)), (x, a, b))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>That is, the variable to integrate and the endpoints are passed as tuples. (Unlike <code>hcubature</code> which always uses two tuples to specify the bounds, <code>integrate</code> uses <span class="math inline">\(n\)</span> tuples to specify an <span class="math inline">\(n\)</span>-dimensional integral.) The iteration happens from left to write, so in the above the <code>y</code> integral is done (and, as seen, may depend on the variable <code>x</code>) and then the <code>x</code> integral is performed. The above uses <code>f(x,y)</code>, <code>h(x)</code> and <code>g(x)</code>, but these may be simple symbolic expressions and not function calls using symbolic variables.</p>
<p>We define <code>x</code> and <code>y</code> below for use throughout:</p>
<div class="cell" data-execution_count="18">
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x<span class="op">::</span><span class="dt">real </span>y<span class="op">::</span><span class="dt">real </span>z<span class="op">::</span><span class="dt">real</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="18">
<pre><code>(x, y, z)</code></pre>
</div>
</div>
<section id="example-1" class="level5">
<h5 class="anchored" data-anchor-id="example-1">Example</h5>
<p>For example, the last integral to compute the volume of a square pyramid, could be computed through</p>
<div class="cell" data-hold="true" data-execution_count="19">
<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><span class="pp">@syms</span> a height</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="fl">8</span> <span class="op">*</span> <span class="fu">integrate</span>(height <span class="op">*</span> (<span class="fl">1</span> <span class="op">-</span> <span class="fl">2</span>x<span class="op">/</span>a), (y, <span class="fl">0</span>, x), (x, <span class="fl">0</span>, a<span class="op">/</span><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="19">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{a^{2} height}{3}
\]
</span>
</div>
</div>
</section>
<section id="example-2" class="level5">
<h5 class="anchored" data-anchor-id="example-2">Example</h5>
<p>Find the integral <span class="math inline">\(\int_0^1\int_{y^2}^1 y \sin(x^2) dx dy\)</span>.</p>
<p>Without concerning ourselves with what or why, we just translate:</p>
<div class="cell" data-hold="true" data-execution_count="20">
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>( y <span class="op">*</span> <span class="fu">sin</span>(x<span class="op">^</span><span class="fl">2</span>), (x, y<span class="op">^</span><span class="fl">2</span>, <span class="fl">1</span>), (y, <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="20">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
- \frac{3 \sqrt{2} \sqrt{\pi} \left(\frac{3 \sqrt{2} \cos{\left(1 \right)} \Gamma\left(\frac{3}{4}\right)}{16 \sqrt{\pi} \Gamma\left(\frac{7}{4}\right)} + \frac{3 S\left(\frac{\sqrt{2}}{\sqrt{\pi}}\right) \Gamma\left(\frac{3}{4}\right)}{8 \Gamma\left(\frac{7}{4}\right)}\right) \Gamma\left(\frac{3}{4}\right)}{8 \Gamma\left(\frac{7}{4}\right)} + \frac{3 \sqrt{2} \sqrt{\pi} S\left(\frac{\sqrt{2}}{\sqrt{\pi}}\right) \Gamma\left(\frac{3}{4}\right)}{16 \Gamma\left(\frac{7}{4}\right)} + \frac{9 \Gamma^{2}\left(\frac{3}{4}\right)}{64 \Gamma^{2}\left(\frac{7}{4}\right)}
\]
</span>
</div>
</div>
</section>
<section id="example-3" class="level5">
<h5 class="anchored" data-anchor-id="example-3">Example</h5>
<p>Find the volume enclosed by <span class="math inline">\(y = x^2\)</span>, <span class="math inline">\(y = 5\)</span>, <span class="math inline">\(z = x^2\)</span>, and <span class="math inline">\(z = 0\)</span>.</p>
<p>The limits on <span class="math inline">\(z\)</span> say this is the volume under the surface <span class="math inline">\(f(x,y) = x^2\)</span>, over the region defined by <span class="math inline">\(y=5\)</span> and <span class="math inline">\(y = x^2\)</span>. The region is a parabola with <span class="math inline">\(y\)</span> running from <span class="math inline">\(x^2\)</span> to <span class="math inline">\(5\)</span>, while <span class="math inline">\(x\)</span> ranges from <span class="math inline">\(-\sqrt{5}\)</span> to <span class="math inline">\(\sqrt{5}\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="21">
<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><span class="fu">f</span>(x, y) <span class="op">=</span> x<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">h</span>(x) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span></span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a><span class="fu">g</span>(x) <span class="op">=</span> <span class="fl">5</span></span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(x,y), (y, <span class="fu">h</span>(x), <span class="fu">g</span>(x)), (x, <span class="fu">-sqrt</span>(<span class="fu">Sym</span>(<span class="fl">5</span>)), <span class="fu">sqrt</span>(<span class="fu">Sym</span>(<span class="fl">5</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">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{20 \sqrt{5}}{3}
\]
</span>
</div>
</div>
</section>
<section id="example-4" class="level5">
<h5 class="anchored" data-anchor-id="example-4">Example</h5>
<p>Find the volume above the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane when a cylinder, <span class="math inline">\(x^2 + y^2 = 2^2\)</span> is intersected by a plane <span class="math inline">\(3x + 4y + 5z = 6\)</span>.</p>
<p>We solve for <span class="math inline">\(z = (1/5)\cdot(6 - 3x - 4y)\)</span> and take <span class="math inline">\(R\)</span> as the disk at the origin of radius <span class="math inline">\(2\)</span>:</p>
<div class="cell" data-hold="true" data-execution_count="22">
<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">f</span>(x,y) <span class="op">=</span> <span class="fl">6</span> <span class="op">-</span> <span class="fl">3</span>x <span class="op">-</span> <span class="fl">4</span>y</span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a><span class="fu">g</span>(x) <span class="op">=</span> <span class="fu">sqrt</span>(<span class="fl">2</span><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="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a><span class="fu">h</span>(x) <span class="op">=</span> <span class="fu">-sqrt</span>(<span class="fl">2</span><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="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a>(<span class="fl">1</span><span class="op">//</span><span class="fl">5</span>) <span class="op">*</span> <span class="fu">integrate</span>(<span class="fu">f</span>(x,y), (y, <span class="fu">h</span>(x), <span class="fu">g</span>(x)), (x, <span class="op">-</span><span class="fl">2</span>, <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="22">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{24 \pi}{5}
\]
</span>
</div>
</div>
</section>
<section id="example-5" class="level5">
<h5 class="anchored" data-anchor-id="example-5">Example</h5>
<p>Find the volume:</p>
<ul>
<li>in the first octant</li>
<li>bounded by <span class="math inline">\(x+y+z = 10\)</span>, <span class="math inline">\(2x + 3y = 20\)</span>, and <span class="math inline">\(x + 3y = 10\)</span></li>
</ul>
<p>The first plane can be expressed as <span class="math inline">\(z = f(x,y) = 10 - x - y\)</span> and the volume is that below the surface of <span class="math inline">\(f\)</span> over the region <span class="math inline">\(R\)</span> formed by the two lines and the <span class="math inline">\(x\)</span> and <span class="math inline">\(y\)</span> axes. Plotting that we have:</p>
<div class="cell" data-hold="true" data-execution_count="23">
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="fu">g1</span>(x) <span class="op">=</span> (<span class="fl">20</span> <span class="op">-</span> <span class="fl">2</span>x)<span class="op">/</span><span class="fl">3</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a><span class="fu">g2</span>(x) <span class="op">=</span> (<span class="fl">10</span> <span class="op">-</span> x)<span class="op">/</span><span class="fl">3</span></span>
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(g1, <span class="fl">0</span>, <span class="fl">20</span>)</span>
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(g2, <span class="fl">0</span>, <span class="fl">20</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="double_triple_integrals_files/figure-html/cell-24-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>We see the intersection is when <span class="math inline">\(x=10\)</span>, so this becomes</p>
<div class="cell" data-hold="true" data-execution_count="24">
<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">f</span>(x,y) <span class="op">=</span> <span class="fl">10</span> <span class="op">-</span> x <span class="op">-</span> y</span>
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a><span class="fu">h</span>(x) <span class="op">=</span> (<span class="fl">10</span> <span class="op">-</span> x)<span class="op">/</span><span class="fl">3</span></span>
<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a><span class="fu">g</span>(x) <span class="op">=</span> (<span class="fl">20</span> <span class="op">-</span> <span class="fl">3</span>x)<span class="op">/</span><span class="fl">3</span></span>
<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(x,y), (y, <span class="fu">h</span>(x), <span class="fu">g</span>(x)), (x, <span class="fl">0</span>, <span class="fl">10</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">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{500}{27}
\]
</span>
</div>
</div>
</section>
<section id="example-6" class="level5">
<h5 class="anchored" data-anchor-id="example-6">Example</h5>
<p>Let <span class="math inline">\(r=1\)</span> and define three cylinders along the <span class="math inline">\(x\)</span>, <span class="math inline">\(y\)</span>, and <span class="math inline">\(z\)</span> axes by: <span class="math inline">\(y^2+z^2 = r^2\)</span>, <span class="math inline">\(x^2 + z^2 = r^2\)</span>, and <span class="math inline">\(x^2 + y^2 = r^2\)</span>. What is the enclosed <a href="http://mathworld.wolfram.com/SteinmetzSolid.html">volume</a>?</p>
<p>Using the cylinder along the <span class="math inline">\(z\)</span> axis, we have the volume sits above and below the disk <span class="math inline">\(R = x^2 + y^2 \leq r^2\)</span>. By symmetry, we can double the volume that sits above the disk to answer the question.</p>
<p>Using symmetry, we can tell that the the wedge between <span class="math inline">\(x=0\)</span>, <span class="math inline">\(y=x\)</span>, and <span class="math inline">\(x^2 + y^2 \leq 1\)</span> (corresponding to a polar angle in <span class="math inline">\([0,\pi/4]\)</span> in <span class="math inline">\(R\)</span> contains <span class="math inline">\(1/8\)</span> the volume of the top, so <span class="math inline">\(1/16\)</span> of the total.</p>
<div class="cell" data-hold="true" data-execution_count="25">
<div class="cell-output cell-output-display" data-execution_count="25">
<p><img src="double_triple_integrals_files/figure-html/cell-26-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Over this wedge the height is given by the cylinder along the <span class="math inline">\(y\)</span> axis, <span class="math inline">\(x^2 + z^2 = r^2\)</span>. We <em>could</em> break this wedge into a triangle and a semicircle to integrate piece by piece. However, from the figure we can integrate in the <span class="math inline">\(y\)</span> direction on the outside, and use only one intergral:</p>
<div class="cell" data-hold="true" data-execution_count="26">
<div class="sourceCode cell-code" id="cb26"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a>r <span class="op">=</span> <span class="fl">1</span> <span class="co"># if using r as a symbolic variable specify `positive=true`</span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y) <span class="op">=</span> <span class="fu">sqrt</span>(r<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="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a><span class="fl">16</span> <span class="op">*</span> <span class="fu">integrate</span>(<span class="fu">f</span>(x,y), (x, y, <span class="fu">sqrt</span>(r<span class="op">^</span><span class="fl">2</span><span class="op">-</span>y<span class="op">^</span><span class="fl">2</span>)), (y, <span class="fl">0</span>, <span class="fu">r*cos</span>(PI<span class="op">/</span><span class="fl">4</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">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
16 - 8 \sqrt{2}
\]
</span>
</div>
</div>
</section>
<section id="example-7" class="level5">
<h5 class="anchored" data-anchor-id="example-7">Example</h5>
<p>Find the volume under <span class="math inline">\(f(x,y) = xy\)</span> in the cone swept out by <span class="math inline">\(r(\theta) = 1\)</span> as <span class="math inline">\(\theta\)</span> goes between <span class="math inline">\([0, \pi/4]\)</span>.</p>
<p>The region <span class="math inline">\(R\)</span>, the same as the last one. As seen, it can be described in two pieces as a function of <span class="math inline">\(x\)</span>, but needs only <span class="math inline">\(1\)</span> as a function of <span class="math inline">\(y\)</span>, so we use that below:</p>
<div class="cell" data-hold="true" data-execution_count="27">
<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">f</span>(x,y) <span class="op">=</span> x<span class="op">*</span>y</span>
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a><span class="fu">g</span>(y) <span class="op">=</span> <span class="fu">sqrt</span>(<span class="fl">1</span> <span class="op">-</span> y<span class="op">^</span><span class="fl">2</span>)</span>
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a><span class="fu">h</span>(y) <span class="op">=</span> y</span>
<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(x,y), (x, <span class="fu">h</span>(y), <span class="fu">g</span>(y)), (y, <span class="fl">0</span>, <span class="fu">sin</span>(PI<span class="op">/</span><span class="fl">4</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">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{1}{16}
\]
</span>
</div>
</div>
</section>
<section id="example-average-value" class="level5">
<h5 class="anchored" data-anchor-id="example-average-value">Example: Average value</h5>
<p>The average value of a function, <span class="math inline">\(f(x,y)\)</span>, over a region <span class="math inline">\(R\)</span> is the integral of <span class="math inline">\(f\)</span> over <span class="math inline">\(R\)</span> divided by the area of <span class="math inline">\(R\)</span>. It can be computed through two integrals, as below.</p>
<p>let <span class="math inline">\(R\)</span> be the region in the first quadrant bounded by <span class="math inline">\(x - y = 0\)</span> and <span class="math inline">\(f(x,y) = x^2 + y^2\)</span>. Find the average value.</p>
<div class="cell" data-hold="true" data-execution_count="28">
<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">f</span>(x,y) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> y<span class="op">^</span><span class="fl">2</span></span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a><span class="fu">g</span>(x) <span class="op">=</span> x <span class="co"># solve x - y = 0 for y</span></span>
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a><span class="fu">h</span>(x) <span class="op">=</span> <span class="fl">0</span></span>
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a>A <span class="op">=</span> <span class="fu">integrate</span>(<span class="fu">f</span>(x,y), (y, <span class="fu">h</span>(x), <span class="fu">g</span>(x)), (x, <span class="fl">0</span>, <span class="fl">1</span>))</span>
<span id="cb28-5"><a href="#cb28-5" aria-hidden="true" tabindex="-1"></a>B <span class="op">=</span> <span class="fu">integrate</span>(<span class="fu">Sym</span>(<span class="fl">1</span>), (y, <span class="fu">h</span>(x), <span class="fu">g</span>(x)), (x, <span class="fl">0</span>, <span class="fl">1</span>))</span>
<span id="cb28-6"><a href="#cb28-6" aria-hidden="true" tabindex="-1"></a>A<span class="op">/</span>B</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">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{2}{3}
\]
</span>
</div>
</div>
<p>(We integrate <code>Sym(1)</code> and not just <code>1</code>, as we either need to have a symbolic value for the first argument or use the <code>sympy.integrate</code> method directly.)</p>
</section>
<section id="example-density" class="level5">
<h5 class="anchored" data-anchor-id="example-density">Example: Density</h5>
<p>The area of a region <span class="math inline">\(R\)</span> can be computed by <span class="math inline">\(\iint_R 1 dA\)</span>. If the region is physical, say a disc, then its mass can be of interest. If the mass is uniform with density <span class="math inline">\(\rho\)</span>, then the mass would be <span class="math inline">\(\iint_R \rho dA\)</span>. If the mass is non uniform, say it is a function <span class="math inline">\(\rho(x,y)\)</span>, then the integral to find the mass becomes <span class="math inline">\(\iint_R \rho(x,y) dA\)</span>. (In a Riemann sum, the term <span class="math inline">\(\rho(c_{ij}) \Delta x_i\Delta y_j\)</span> would be the mass of a constant-density solid, the integral just adds these up to find total mass.)</p>
<p>Find the mass of a disc bounded by the two parabolas <span class="math inline">\(y=2 - x^2\)</span> and <span class="math inline">\(y = -3 + 2x^2\)</span> with density function given by <span class="math inline">\(\rho(x,y) = x^2y^2\)</span>.</p>
<p>First we need the intersection points of the two parabolas. Solving <span class="math inline">\(2-x^2 = -3 + 2x^2\)</span> for <span class="math inline">\(x\)</span> yields: <span class="math inline">\(5 = x^2\)</span>.</p>
<p>So we get a mass of:</p>
<div class="cell" data-hold="true" data-execution_count="29">
<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="fu">rho</span>(x,y) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span><span class="op">*</span>y<span class="op">^</span><span class="fl">2</span></span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a><span class="fu">g</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="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a><span class="fu">h</span>(x) <span class="op">=</span> <span class="op">-</span><span class="fl">3</span> <span class="op">+</span> <span class="fl">2</span>x<span class="op">^</span><span class="fl">2</span></span>
<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a>a <span class="op">=</span> <span class="fu">sqrt</span>(<span class="fu">Sym</span>(<span class="fl">5</span>))</span>
<span id="cb29-5"><a href="#cb29-5" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">rho</span>(x,y), (y, <span class="fu">h</span>(x), <span class="fu">g</span>(x)), (x, <span class="op">-</span>a, a))</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">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
- \frac{880 \sqrt{5}}{9}
\]
</span>
</div>
</div>
</section>
<section id="example-strang" class="level5">
<h5 class="anchored" data-anchor-id="example-strang">Example (Strang)</h5>
<p>Integrate <span class="math inline">\(\int_0^1 \int_y^1 \cos(x^2) dx dy\)</span> avoiding the <em>impossible</em> integral of <span class="math inline">\(\cos(x^2)\)</span>. As the integrand is continuous, Fubinis Theorem allows the interchange of the variable of integraton. The region, <span class="math inline">\(R\)</span>, is a triangle in the first quadrant below the line <span class="math inline">\(y=x\)</span> and left of the line <span class="math inline">\(x=1\)</span>. So we have:</p>
<p><span class="math display">\[
\int_0^1 \int_0^x \cos(x^2) dy dx
\]</span></p>
<p>We can integrate this, as the interior integral leaves <span class="math inline">\(x \cos(x^2)\)</span> to integrate:</p>
<div class="cell" data-execution_count="30">
<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">integrate</span>(<span class="fu">cos</span>(x<span class="op">^</span><span class="fl">2</span>), (y, <span class="fl">0</span>, x), (x, <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="30">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{\sin{\left(1 \right)}}{2}
\]
</span>
</div>
</div>
</section>
</section>
<section id="a-fubini-function" class="level3" data-number="59.3.2">
<h3 data-number="59.3.2" class="anchored" data-anchor-id="a-fubini-function"><span class="header-section-number">59.3.2</span> A “Fubini” function</h3>
<p>The computationally efficient way to perform multiple integrals numerically would be to use <code>hcubature</code>. However, this function is defined only for <em>rectangular</em> regions. In the event of non-rectangular regions, the suggested performant way would be to find a suitable transformation (below).</p>
<p>However, for simple problems, where ease of expressing a region is preferred to computational efficiency, something can be implemented using repeated uses of <code>quadgk</code>. Again, this isnt recommended, save for its relationship to how iteration is approached algebraically.</p>
<p>In the <code>CalculusWithJulia</code> package, the <code>fubini</code> function is provided. For these notes, we define three operations using Unicode operators entered with <code>\int[tab]</code>, <code>\iint[tab]</code>, <code>\iiint[tab]</code>. (Using this, better shows the mechanics involved.)</p>
<div class="cell" data-execution_count="31">
<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><span class="co"># adjust endpoints when expressed as a functions of outer variables</span></span>
<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a><span class="fu">callf</span>(f<span class="op">::</span><span class="dt">Number</span>, x) <span class="op">=</span> f</span>
<span id="cb31-3"><a href="#cb31-3" aria-hidden="true" tabindex="-1"></a><span class="fu">callf</span>(f, x) <span class="op">=</span> <span class="fu">f</span>(x<span class="op">...</span>)</span>
<span id="cb31-4"><a href="#cb31-4" aria-hidden="true" tabindex="-1"></a><span class="fu">endpoints</span>(ys, x) <span class="op">=</span> <span class="fu">callf</span>.(ys, <span class="fu">Ref</span>(x))</span>
<span id="cb31-5"><a href="#cb31-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb31-6"><a href="#cb31-6" aria-hidden="true" tabindex="-1"></a><span class="co"># integrate f(x) dx</span></span>
<span id="cb31-7"><a href="#cb31-7" aria-hidden="true" tabindex="-1"></a><span class="fu"></span>(<span class="pp">@nospecialize</span>(f), xs) <span class="op">=</span> <span class="fu">quadgk</span>(f, xs<span class="op">...</span>)[<span class="fl">1</span>] <span class="co"># @nospecialize is not necessary, but offers a speed boost</span></span>
<span id="cb31-8"><a href="#cb31-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb31-9"><a href="#cb31-9" aria-hidden="true" tabindex="-1"></a><span class="co"># integrate int_a^b int_h(x)^g(y) f(x,y) dy dx</span></span>
<span id="cb31-10"><a href="#cb31-10" aria-hidden="true" tabindex="-1"></a><span class="fu"></span>(f, ys, xs) <span class="op">=</span> <span class="fu"></span>(x <span class="op">-&gt;</span> <span class="fu"></span>(y <span class="op">-&gt;</span> <span class="fu">f</span>(x,y), <span class="fu">endpoints</span>(ys, x)), xs)</span>
<span id="cb31-11"><a href="#cb31-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb31-12"><a href="#cb31-12" aria-hidden="true" tabindex="-1"></a><span class="co"># integrate f(x,y,z) dz dy dx</span></span>
<span id="cb31-13"><a href="#cb31-13" aria-hidden="true" tabindex="-1"></a><span class="fu"></span>(f, zs, ys, xs) <span class="op">=</span> <span class="fu"></span>(</span>
<span id="cb31-14"><a href="#cb31-14" aria-hidden="true" tabindex="-1"></a> x <span class="op">-&gt;</span> <span class="fu"></span>(</span>
<span id="cb31-15"><a href="#cb31-15" aria-hidden="true" tabindex="-1"></a> y <span class="op">-&gt;</span> <span class="fu"></span>(</span>
<span id="cb31-16"><a href="#cb31-16" aria-hidden="true" tabindex="-1"></a> z <span class="op">-&gt;</span> <span class="fu">f</span>(x,y,z),</span>
<span id="cb31-17"><a href="#cb31-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">endpoints</span>(zs, (x,y))),</span>
<span id="cb31-18"><a href="#cb31-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">endpoints</span>(ys,x)),</span>
<span id="cb31-19"><a href="#cb31-19" aria-hidden="true" tabindex="-1"></a> 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="31">
<pre><code>∭ (generic function with 1 method)</code></pre>
</div>
</div>
<section id="example-8" class="level5">
<h5 class="anchored" data-anchor-id="example-8">Example</h5>
<p>Compare the integral of <span class="math inline">\(f(x,y) = \exp(-x^2 -2y^2)\)</span> over the region <span class="math inline">\(R=[0,3]\times[0,3]\)</span> using <code>hcubature</code> and the above.</p>
<div class="cell" data-hold="true" data-execution_count="32">
<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">f</span>(x,y) <span class="op">=</span> <span class="fu">exp</span>(<span class="op">-</span>x<span class="op">^</span><span class="fl">2</span> <span class="op">-</span> <span class="fl">2</span>y<span class="op">^</span><span class="fl">2</span>)</span>
<span id="cb33-2"><a href="#cb33-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(v) <span class="op">=</span> <span class="fu">f</span>(v<span class="op">...</span>)</span>
<span id="cb33-3"><a href="#cb33-3" aria-hidden="true" tabindex="-1"></a><span class="fu">hcubature</span>(f, (<span class="fl">0</span>,<span class="fl">0</span>), (<span class="fl">3</span>,<span class="fl">3</span>)) <span class="co"># (a0, a1), (b0, b1)</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="32">
<pre><code>(0.5553480979840428, 8.155874399598429e-9)</code></pre>
</div>
</div>
<div class="cell" data-hold="true" data-execution_count="33">
<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">f</span>(x,y) <span class="op">=</span> <span class="fu">exp</span>(<span class="op">-</span>x<span class="op">^</span><span class="fl">2</span> <span class="op">-</span> <span class="fl">2</span>y<span class="op">^</span><span class="fl">2</span>)</span>
<span id="cb35-2"><a href="#cb35-2" aria-hidden="true" tabindex="-1"></a><span class="fu"></span>(f, (<span class="fl">0</span>,<span class="fl">3</span>), (<span class="fl">0</span>,<span class="fl">3</span>)) <span class="co"># (a1, b1), (a0, b0)</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="33">
<pre><code>0.5553480979874703</code></pre>
</div>
</div>
</section>
<section id="example-9" class="level5">
<h5 class="anchored" data-anchor-id="example-9">Example</h5>
<p>Show the area of the unit circle is <span class="math inline">\(\pi\)</span> using the “Fubini” function.</p>
<div class="cell" data-hold="true" data-execution_count="34">
<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><span class="fu">f</span>(x,y) <span class="op">=</span> <span class="fl">1</span></span>
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a>a <span class="op">=</span> <span class="fu"></span>(f, (x<span class="op">-&gt;</span> <span class="fu">-sqrt</span>(<span class="fl">1</span><span class="op">-</span>x<span class="op">^</span><span class="fl">2</span>), x<span class="op">-&gt;</span> <span class="fu">sqrt</span>(<span class="fl">1</span><span class="op">-</span>x<span class="op">^</span><span class="fl">2</span>)), (<span class="op">-</span><span class="fl">1</span>, <span class="fl">1</span>))</span>
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a>a, a <span class="op">-</span> <span class="cn">pi</span> <span class="co"># answer and error</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>(3.1415926559132474, 2.3234543178318745e-9)</code></pre>
</div>
</div>
<p>(The error is similar to that returned by <code>quadgk(x -&gt; sqrt(1-x^2), -1, 1)</code>.)</p>
<section id="example-10" class="level6">
<h6 class="anchored" data-anchor-id="example-10">Example</h6>
<p>Show the volume of a sphere of radius <span class="math inline">\(1\)</span> is <span class="math inline">\(4/3\pi = 4/3\pi\cdot 1^3\)</span> by doubling the integral of <span class="math inline">\(f(x,y) = \sqrt{1-x^2-y^2}\)</span> over <span class="math inline">\(R\)</span>, the unit disk.</p>
<div class="cell" data-hold="true" data-execution_count="35">
<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,y) <span class="op">=</span> <span class="fu">sqrt</span>(<span class="fl">1</span> <span class="op">-</span> x<span class="op">^</span><span class="fl">2</span> <span class="op">-</span> y<span class="op">^</span><span class="fl">2</span>)</span>
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a>a <span class="op">=</span> <span class="fl">2</span> <span class="op">*</span> <span class="fu"></span>(f, (x<span class="op">-&gt;</span> <span class="fu">-sqrt</span>(<span class="fl">1</span><span class="op">-</span>x<span class="op">^</span><span class="fl">2</span>), x<span class="op">-&gt;</span> <span class="fu">sqrt</span>(<span class="fl">1</span><span class="op">-</span>x<span class="op">^</span><span class="fl">2</span>)), (<span class="op">-</span><span class="fl">1</span>, <span class="fl">1</span>))</span>
<span id="cb39-3"><a href="#cb39-3" aria-hidden="true" tabindex="-1"></a>a, a <span class="op">-</span> <span class="fl">4</span><span class="op">/</span><span class="fl">3</span><span class="op">*</span><span class="cn">pi</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="35">
<pre><code>(4.188790207884331, 3.0979405707398655e-9)</code></pre>
</div>
</div>
</section>
</section>
<section id="example-11" class="level5">
<h5 class="anchored" data-anchor-id="example-11">Example</h5>
<p>Numeric integrals dont need to worry about integrands without antiderivatives. Their concerns are highly oscillatory integrands. Here we compute <span class="math inline">\(\int_0^1 \int_y^1 \cos(x^2) dx dy\)</span> directly. The limits are in a different order than the “Fubini” function expects, so we switch the variables:</p>
<div class="cell" data-execution_count="36">
<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><span class="fu"></span>((y,x) <span class="op">-&gt;</span> <span class="fu">cos</span>(x<span class="op">^</span><span class="fl">2</span>), (y <span class="op">-&gt;</span> y, <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="36">
<pre><code>0.4207354924039483</code></pre>
</div>
</div>
<p>Compare to</p>
<div class="cell" data-execution_count="37">
<div class="sourceCode cell-code" id="cb43"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sin</span>(<span class="fl">1</span>)<span class="op">/</span><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="37">
<pre><code>0.42073549240394825</code></pre>
</div>
</div>
</section>
</section>
</section>
<section id="triple-integrals" class="level2" data-number="59.4">
<h2 data-number="59.4" class="anchored" data-anchor-id="triple-integrals"><span class="header-section-number">59.4</span> Triple integrals</h2>
<p>Triple integrals are identical in theory to double integrals, though the computations can be more involved and the regions more complicated to describe. The main regions (emphasized by Strang) to understand are: box, prism, cylinder, cone, tetrahedron, and sphere.</p>
<div class="cell" data-execution_count="38">
<div class="cell-output cell-output-display" data-execution_count="38">
<p><img src="double_triple_integrals_files/figure-html/cell-39-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Here we compute the volumes of these using a triple integral of the form <span class="math inline">\(\iint_R 1 dV\)</span>.</p>
<ul>
<li>Box. Consider the box-like, or “rectangular,” region <span class="math inline">\([0,a]\times [0,b] \times [0,c]\)</span>. This has volume <span class="math inline">\(abc\)</span> which we see here using Fubinis theorem:</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="39">
<div class="sourceCode cell-code" id="cb45"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> a b c</span>
<span id="cb45-2"><a href="#cb45-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y,z) <span class="op">=</span> <span class="fu">Sym</span>(<span class="fl">1</span>) <span class="co"># need to integrate a symbolic object in integrand or call `sympy.integrate`</span></span>
<span id="cb45-3"><a href="#cb45-3" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(x,y,z), (x, <span class="fl">0</span>, a), (y, <span class="fl">0</span>, b), (z, <span class="fl">0</span>, c))</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="39">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
a b c
\]
</span>
</div>
</div>
<ul>
<li>Prism. Consider a prism or wedge formed by <span class="math inline">\(ay + bz = 1\)</span> with <span class="math inline">\(a,b &gt; 0\)</span> and over the region in the first quadrant <span class="math inline">\(0 \leq x \leq c\)</span>. Find its area.</li>
</ul>
<p>The function to integrate is <span class="math inline">\(f(x,y) = (1 - ay)/b\)</span> over the region bounded by <span class="math inline">\([0,c] \times [0,1/a]\)</span>:</p>
<div class="cell" data-hold="true" data-execution_count="40">
<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> a b c</span>
<span id="cb46-2"><a href="#cb46-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y,z) <span class="op">=</span> <span class="fu">Sym</span>(<span class="fl">1</span>)</span>
<span id="cb46-3"><a href="#cb46-3" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(x,y,z), (z, <span class="fl">0</span>, (<span class="fl">1</span> <span class="op">-</span> a<span class="op">*</span>y)<span class="op">/</span>b), (y, <span class="fl">0</span>, <span class="fl">1</span><span class="op">/</span>a), (x, <span class="fl">0</span>, c))</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="40">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{c}{2 a b}
\]
</span>
</div>
</div>
<p>Which, as expected, is half the volume of the box <span class="math inline">\([0,c] \times [0, 1/a] \times [0, 1/b]\)</span>.</p>
<ul>
<li>Tetrahedron. Consider the volume formed by <span class="math inline">\(x,y,z \geq 0\)</span> and bounded by <span class="math inline">\(ax+by+cz = 1\)</span> where <span class="math inline">\(a,b,c \geq 0\)</span>. The volume is a tetrahedron. The base in the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane is a triangle with vertices <span class="math inline">\((1/a, 0, 0)\)</span> and <span class="math inline">\((0, 1/b, 0)\)</span>.</li>
</ul>
<p>(The third easy-to-find point is <span class="math inline">\((0, 0, 1/c)\)</span>). The line connecting the points in the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane is <span class="math inline">\(ax + by = 1\)</span>. With this, the integral to compute the volume is</p>
<div class="cell" data-hold="true" data-execution_count="41">
<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> a b c</span>
<span id="cb47-2"><a href="#cb47-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y,z) <span class="op">=</span> <span class="fu">Sym</span>(<span class="fl">1</span>)</span>
<span id="cb47-3"><a href="#cb47-3" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(x,y,z), (z, <span class="fl">0</span>, (<span class="fl">1</span> <span class="op">-</span> a<span class="op">*</span>x <span class="op">-</span> b<span class="op">*</span>y)<span class="op">/</span>c), (y, <span class="fl">0</span>, (<span class="fl">1</span> <span class="op">-</span> a<span class="op">*</span>x)<span class="op">/</span>b), (x, <span class="fl">0</span>, <span class="fl">1</span><span class="op">/</span>a))</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="41">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{1}{6 a b c}
\]
</span>
</div>
</div>
<p>This is <span class="math inline">\(1/6\)</span>th the volume of the box.</p>
<ul>
<li>Cone. Consider a cone formed by the function <span class="math inline">\(z = f(x,y) = a - b(x^2+y^2)^{1/2}\)</span> (<span class="math inline">\(a,b &gt; 0\)</span>) and the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane. This will have radius <span class="math inline">\(r = a/b\)</span> and height <span class="math inline">\(a\)</span>. The volume is given by this integral:</li>
</ul>
<p><span class="math display">\[
\int_{x=-r}^r \int_{y=-\sqrt{r^2 - x^2}}^{\sqrt{r^2-x^2}} \int_0^{a - b(x^2 + y^2)} 1 dz dy dx.
\]</span></p>
<p>This integral is doable, but <code>SymPy</code> has trouble with it. We will return to this when cylindrical coordinates are defined.</p>
<ul>
<li>Sphere. The sphere <span class="math inline">\(x^2 + y^2 + z^2 \leq 1\)</span> has a known volume. Can we compute it using integration? In Cartesian coordinates, we can describe the region <span class="math inline">\(x^2 + y^2 \leq 1\)</span> and then the <span class="math inline">\(z\)</span>-limits will follow:</li>
</ul>
<p><span class="math display">\[
\int_{x=-1}^1 \int_{y=-\sqrt{1-x^2}}^{\sqrt{1-x^2}} \int_{z=-\sqrt{1 - x^2 - y^2}}^{\sqrt{1-x^2 - y^2}} 1 dz dy dx.
\]</span></p>
<p>This integral is doable, but <code>SymPy</code> has trouble with it. We will return to this when spherical coordinates are defined.</p>
</section>
<section id="change-of-variables" class="level2" data-number="59.5">
<h2 data-number="59.5" class="anchored" data-anchor-id="change-of-variables"><span class="header-section-number">59.5</span> Change of variables</h2>
<p>The change of variables, or substitution, formula from first-semester calculus is expressed, under assumptions, by:</p>
<p><span class="math display">\[
\int_{g(R)} f(x) dx = \int_R (f\circ g)(u)g'(u) du.
\]</span></p>
<p>The derivation comes from reversing the chain rule. When using it, we start on the right hand side and typically write <span class="math inline">\(x = g(u)\)</span> and from here derive an expression involving differentials: <span class="math inline">\(dx = g'(u) du\)</span> and the rest follows. In practice, this is used to simplify the integrand in the search for an antiderivative, as <span class="math inline">\((f\circ g)\)</span> is generally more complicated than <span class="math inline">\(f\)</span> alone.</p>
<p>In higher dimensions, we will see that change of variables can not only simplify the integrand, but is also of great use to simplify the region to integrate over. We mentioned, for example, that to use <code>hcubature</code> efficiently over a non-rectangular region, a transformation-or change of variables-is needed. The key to the multi-dimensional formula is understanding what should replace <span class="math inline">\(dx = g'(u) du\)</span>. We take a bit of a circuitous route to get there.</p>
<p>In <a href="http://www.jstor.org/stable/2689856">Katz</a> a review of the history of “change of variables” from Euler to Cartan is given. We follow Lagranges formal analysis to derive the change of variable formula in two dimensions.</p>
<p>We view <span class="math inline">\(R\)</span> in two coordinate systems <span class="math inline">\((x,y)\)</span> and <span class="math inline">\((u,v)\)</span>. We have that</p>
<p><span class="math display">\[
\begin{align}
dx &amp;= A du + B dv\\
dy &amp;= C du + D dv,
\end{align}
\]</span></p>
<p>where <span class="math inline">\(A = \partial{x}/\partial{u}\)</span>, <span class="math inline">\(B = \partial{x}/\partial{v}\)</span>, <span class="math inline">\(C= \partial{y}/\partial{u}\)</span>, and <span class="math inline">\(D = \partial{y}/\partial{v}\)</span>. Lagrange, following Euler, first sets <span class="math inline">\(x\)</span> to be constant (as is done in iterated integration). Hence, <span class="math inline">\(dx = 0\)</span> and so <span class="math inline">\(du = -C(B/A) dv\)</span> and, after substitution, <span class="math inline">\(dy = (D-C(B/A))dv\)</span>. Then Lagrange set <span class="math inline">\(y\)</span> to be a constant, so <span class="math inline">\(dy = 0\)</span> and hence <span class="math inline">\(dv=0\)</span> so <span class="math inline">\(dx = Adu\)</span>. The area “element” <span class="math inline">\(dx dy = A du \cdot (D - (B/A)) dv = (AD - BC) du dv\)</span>. Since areas and volumes are non-negative, the absolute value is used. With this, we have “<span class="math inline">\(dxdy = |AD-BC|du dv\)</span>” as the analog of <span class="math inline">\(dx = g'(u) du\)</span>.</p>
<p>The expression <span class="math inline">\(AD - BC\)</span> was also derived by Euler, by related means. Lagrange extended the analysis to 3 dimensions. Before doing so, it is helpful to understand the problem from a geometric perspective. Euler was attempting to understand the effects of the following change of variable:</p>
<p><span class="math display">\[
\begin{align}
x &amp;= a + mt + \sqrt{1-m^2} v\\
y &amp; = b + \sqrt{1-m^2}t -mv
\end{align}
\]</span></p>
<p>Euler knew this to be a clockwise <em>rotation</em> by an angle <span class="math inline">\(\theta\)</span> with <span class="math inline">\(\cos(\theta) = m\)</span>, a <em>reflection</em> through the <span class="math inline">\(x\)</span> axis, and a translation by <span class="math inline">\(\langle a, b\rangle\)</span>. All these <em>should</em> preserve the area represented by <span class="math inline">\(dx dy\)</span>, so he was <em>expecting</em> <span class="math inline">\(dx dy = dt dv\)</span>.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="../integral_vector_calculus/figures/euler-rotation.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Figure from Katz showing rotation of Euler.</figcaption><p></p>
</figure>
</div>
<p>The figure, taken from Katz, shows the translation, and rotation that should preserve area on a differential scale.</p>
<p>However Euler knew <span class="math inline">\(dx = (\partial{g_1}/\partial{t}) dt + (\partial{g_1}/\partial{v}) dv\)</span> and <span class="math inline">\(dy = (\partial{g_2}/{\partial{t}}) dt + (\partial{g_2}/\partial{v}) dv\)</span>. Just multiplying gives <span class="math inline">\(dx dy = m\sqrt{1-m^2} dt dt + (1-m^2) dv dt -m^2 dt dv -m\sqrt{1-m^2} dv dv\)</span>, a result that didnt make sense physically as <span class="math inline">\(dt dt\)</span> and <span class="math inline">\(dv dv\)</span> have no meaning in integration and <span class="math inline">\(1 - m^2 - m^2\)</span> is not <span class="math inline">\(1\)</span> as expected. Euler, like Lagrange, used a formal trick to proceed, but the geometric insight that the incremental areas for a change of variable should be related and for this change of variable identical is correct.</p>
<p>The following illustrates the polar-coordinate transformation <span class="math inline">\(\langle x,y\rangle = G(r, \theta) = r \langle \cos\theta, \sin\theta\rangle\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="43">
<div class="sourceCode cell-code" id="cb48"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(u, v) <span class="op">=</span> u <span class="op">*</span> [<span class="fu">cos</span>(v), <span class="fu">sin</span>(v)]</span>
<span id="cb48-2"><a href="#cb48-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-3"><a href="#cb48-3" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(v) <span class="op">=</span> <span class="fu">G</span>(v<span class="op">...</span>)</span>
<span id="cb48-4"><a href="#cb48-4" aria-hidden="true" tabindex="-1"></a><span class="fu">J</span>(v) <span class="op">=</span> ForwardDiff.<span class="fu">jacobian</span>(G, v) <span class="co"># [∇g1', ∇g2']</span></span>
<span id="cb48-5"><a href="#cb48-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-6"><a href="#cb48-6" aria-hidden="true" tabindex="-1"></a>n <span class="op">=</span> <span class="fl">6</span></span>
<span id="cb48-7"><a href="#cb48-7" aria-hidden="true" tabindex="-1"></a>us <span class="op">=</span> <span class="fu">range</span>(<span class="fl">0</span>, <span class="fl">1</span>, length<span class="op">=</span><span class="fl">3</span>n) <span class="co"># radius</span></span>
<span id="cb48-8"><a href="#cb48-8" aria-hidden="true" tabindex="-1"></a>vs <span class="op">=</span> <span class="fu">range</span>(<span class="fl">0</span>, <span class="fl">2</span>pi, length<span class="op">=</span><span class="fl">3</span>n) <span class="co"># angle</span></span>
<span id="cb48-9"><a href="#cb48-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-10"><a href="#cb48-10" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(<span class="fu">unzip</span>(<span class="fu">G</span>.(us<span class="op">'</span>, vs))<span class="op">...</span>, legend <span class="op">=</span> <span class="cn">false</span>, aspect_ratio<span class="op">=:</span>equal) <span class="co"># plots constant u lines</span></span>
<span id="cb48-11"><a href="#cb48-11" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(<span class="fu">unzip</span>(<span class="fu">G</span>.(us, vs<span class="op">'</span>))<span class="op">...</span>) <span class="co"># plots constant v lines</span></span>
<span id="cb48-12"><a href="#cb48-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-13"><a href="#cb48-13" aria-hidden="true" tabindex="-1"></a>pt <span class="op">=</span> [us[n],vs[n]]</span>
<span id="cb48-14"><a href="#cb48-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-15"><a href="#cb48-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-16"><a href="#cb48-16" aria-hidden="true" tabindex="-1"></a><span class="fu">arrow!</span>(<span class="fu">G</span>(pt), <span class="fu">J</span>(pt)<span class="op">*</span>[<span class="fl">1</span>,<span class="fl">0</span>], color<span class="op">=:</span>blue)</span>
<span id="cb48-17"><a href="#cb48-17" aria-hidden="true" tabindex="-1"></a><span class="fu">arrow!</span>(<span class="fu">G</span>(pt), <span class="fu">J</span>(pt)<span class="op">*</span>[<span class="fl">0</span>,<span class="fl">1</span>], color<span class="op">=:</span>blue)</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">
<p><img src="double_triple_integrals_files/figure-html/cell-44-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>This graphic shows the image of the box <span class="math inline">\([0,1] \times [0, 2\pi]\)</span> under the transformation. The <code>plot</code> commands draw lines for values of constant <code>u</code> or constant <code>v</code>. If <span class="math inline">\(G(u,v) = \langle g_1(u,v), g_2(u,v)\rangle\)</span>, then the Taylor expansion for <span class="math inline">\(g_i\)</span> is <span class="math inline">\(g_i(u+du, v+dv) \approx g_i(u,v) + (\nabla{g_i})^T \cdot \langle du, dv \rangle\)</span> and combining <span class="math inline">\(G(u+du, v+dv) \approx G(u,v) + J_G(u,v) \langle du, dv \rangle\)</span>. The vectors added above represent the images when <span class="math inline">\(u\)</span> is constant (so <span class="math inline">\(du=0\)</span>) and when <span class="math inline">\(v\)</span> is constant (so <span class="math inline">\(dv=0\)</span>). The two arrows define a parallelogram whose area gives the change of area undergone by the unit square under the transformation. The area is <span class="math inline">\(|\det(J_G)|\)</span>, the absolute value of the determinant of the Jacobian.</p>
<div class="cell" data-execution_count="44">
<div class="cell-output cell-output-display" data-execution_count="44">
<pre><code>showG (generic function with 3 methods)</code></pre>
</div>
</div>
<p>The tranformation to elliptical coordinates, <span class="math inline">\(G(u,v) = \langle \cosh(u)\cos(v), \sinh(u)\sin(v)\rangle\)</span>, may be viewed similarly:</p>
<div class="cell" data-hold="true" data-execution_count="45">
<div class="cell-output cell-output-display" data-execution_count="45">
<p><img src="double_triple_integrals_files/figure-html/cell-46-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The transformation <span class="math inline">\(G(u,v) = v \langle e^u, e^{-u} \rangle\)</span> uses hyperbolic coordinates:</p>
<div class="cell" data-hold="true" data-execution_count="46">
<div class="cell-output cell-output-display" data-execution_count="46">
<p><img src="double_triple_integrals_files/figure-html/cell-47-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The transformation <span class="math inline">\(G(u,v) = \langle u^2-v^2, u\cdot v \rangle\)</span> yields a partition of the plane:</p>
<div class="cell" data-hold="true" data-execution_count="47">
<div class="cell-output cell-output-display" data-execution_count="47">
<p><img src="double_triple_integrals_files/figure-html/cell-48-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The arrows are the images of the standard unit vectors. We see some transformations leave these <em>orthogonal</em> and some change the respective lengths. The area of the associated parallelogram can be found using the determinant of an accompanying matrix. For two dimensions, using the cross product formulation on the embedded vectors, the area is</p>
<p><span class="math display">\[
\| \det\left(\left[
\begin{array}{}
\hat{i} &amp; \hat{j} &amp; \hat{k}\\
u_1 &amp; u_2 &amp; 0\\
v_1 &amp; v_2 &amp; 0
\end{array}
\right]
\right) \|
=
\| \hat{k} \det\left(\left[
\begin{array}{}
u_1 &amp; u_2\\
v_1 &amp; v_2
\end{array}
\right]
\right) \|
= | \det\left(\left[
\begin{array}{}
u_1 &amp; u_2\\
v_1 &amp; v_2
\end{array}
\right]
\right)|.
\]</span></p>
<p>Using the fact that the two vectors involved are columns in the Jacobian of the transformation, this is just <span class="math inline">\(|\det(J_G)|\)</span>. For <span class="math inline">\(3\)</span> dimensions, the determinant gives the volume of the 3-dimensional parallelepiped in the same manner. This holds for higher dimensions.</p>
<p>The absolute value of the determinant of the Jacobian is the multiplying factor that is seen in the change of variable formula for all dimensions:</p>
<blockquote class="blockquote">
<p><a href="https://en.wikipedia.org/wiki/Integration_by_substitution#Substitution_for_multiple_variables">Change of variable</a> Let <span class="math inline">\(U\)</span> be an open set in <span class="math inline">\(R^n\)</span>, <span class="math inline">\(G:U \rightarrow R^n\)</span> be an <em>injective</em> differentiable function with <em>continuous</em> partial derivatives. If <span class="math inline">\(f\)</span> is continuous and compactly supported, then</p>
<p><span class="math display">\[
\iint_{G(S)} f(\vec{x}) dV = \iint_S (f \circ G)(\vec{u}) |\det(J_G)(\vec{u})| dU.
\]</span></p>
</blockquote>
<p>For the one-dimensional case, there is no absolute value, but there the interval is reversed, producing “negative” area. This is not the case here, where <span class="math inline">\(S\)</span> is parameterized to give positive volume.</p>
<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>The term “functional determinant” is found for the value <span class="math inline">\(\det(J_G)\)</span>, as is the notation <span class="math inline">\(\partial(x_1, x_2, \dots x_n)/\partial(u_1, u_2, \dots, u_n)\)</span>.</p>
</div>
</div>
<section id="two-dimensional-change-of-variables" class="level3" data-number="59.5.1">
<h3 data-number="59.5.1" class="anchored" data-anchor-id="two-dimensional-change-of-variables"><span class="header-section-number">59.5.1</span> Two dimensional change of variables</h3>
<p>Now we see several examples of two-dimensional transformations.</p>
<section id="polar-integrals" class="level4">
<h4 class="anchored" data-anchor-id="polar-integrals">Polar integrals</h4>
<p>We have <a href="../differentiable_vector_calculus/polar_coordinates.html">seen</a> how to compute area in polar coordinates through the formula <span class="math inline">\(A = \int (1/2) r^2(\theta) d\theta\)</span>. This formula can be derived as follows. Consider a region <span class="math inline">\(R\)</span> parameterized in polar coordinates by <span class="math inline">\(r(\theta)\)</span> for <span class="math inline">\(a \leq \theta \leq b\)</span>. The area of this region would be <span class="math inline">\(\iint_R fdA\)</span>. Let <span class="math inline">\(G(r, \theta) = r \langle \cos\theta, \sin\theta\rangle\)</span>. Then</p>
<p><span class="math display">\[
J_G = \left[
\begin{array}{}
\cos(\theta) &amp; - r\sin(\theta)\\
\sin(\theta) &amp; r\cos(\theta)
\end{array}
\right],
\]</span></p>
<p>with determinant <span class="math inline">\(r\)</span>.</p>
<p>That is, for <em>polar coordinates</em> <span class="math inline">\(dx dy = r dr d\theta\)</span> (<span class="math inline">\(r \geq 0\)</span>).</p>
<p>So by the change of variable formula, we have:</p>
<p><span class="math display">\[
A = \iint_R 1 dx dy = \int_a^b \int_0^{r(\theta)} 1 r dr d\theta = \int_a^b \frac{r^2(\theta)}{2} d\theta.
\]</span></p>
<p>The key is noting that the region, <span class="math inline">\(S\)</span>, described by <span class="math inline">\(\theta\)</span> running from <span class="math inline">\(a\)</span> to <span class="math inline">\(b\)</span> and <span class="math inline">\(r\)</span> running from <span class="math inline">\(0\)</span> to <span class="math inline">\(r(\theta)\)</span>, maps onto <span class="math inline">\(R\)</span> through the change of variables. As polar coordinates is just a renaming, this is clear to see.</p>
<hr>
<p>Now consider finding the volume of a sphere using polar coordinates. We have, with <span class="math inline">\(\rho\)</span> being the radius:</p>
<p><span class="math display">\[
V = 2 \iint_R \sqrt{\rho^2 - x^2 - y^2} dy dx,
\]</span></p>
<p>where <span class="math inline">\(R\)</span> is the disc of radius <span class="math inline">\(\rho\)</span>. Using polar coordinates, we have <span class="math inline">\(x^2 + y^2 = r^2\)</span> and the expression becomes:</p>
<p><span class="math display">\[
V = 2 \int_0^{2\pi} \int_0^\rho \sqrt{\rho^2 - r^2} r dr d\theta = 2 \int_0^{2\pi} -(1 - r^2)^{3/2}\frac{1}{3} \mid_0^\rho d\theta = 2\int_0^{2\pi} \frac{\rho^3}{3}d\theta = \frac{4\pi\rho^3}{3}.
\]</span></p>
<section id="linear-transformations" class="level5">
<h5 class="anchored" data-anchor-id="linear-transformations">Linear transformations</h5>
<p>Some <a href="https://en.wikipedia.org/wiki/Transformation_matrix#Examples_in_2D_computer_graphics">transformations</a> from <span class="math inline">\(2\)</span>D computer graphics are represented in matrix notation:</p>
<p><span class="math display">\[
\left[
\begin{array}{}
x\\
y
\end{array}
\right] =
\left[
\begin{array}{}
a &amp; b\\
c &amp; d
\end{array}
\right]
\left[
\begin{array}{}
u\\
v
\end{array}
\right],
\]</span></p>
<p>or <span class="math inline">\(G(u,v) = \langle au+bv, cu+dv\rangle\)</span>. The Jacobian of this <em>linear</em> transformation is the matrix itself.</p>
<p>Some common transformations are:</p>
<ul>
<li><strong>Stretching</strong> or <span class="math inline">\(G(u,v) = \langle ku, v \rangle\)</span> or <span class="math inline">\(G(u,v) = \langle u, kv\rangle\)</span> for some <span class="math inline">\(k &gt;0\)</span>. The former stretching the <span class="math inline">\(x\)</span> axis, the latter the <span class="math inline">\(y\)</span>. These have Jacobian determinant <span class="math inline">\(k\)</span></li>
</ul>
<div class="cell" data-hold="true" data-execution_count="48">
<div class="cell-output cell-output-display" data-execution_count="48">
<p><img src="double_triple_integrals_files/figure-html/cell-49-output-1.svg" class="img-fluid"></p>
</div>
</div>
<ul>
<li><strong>Rotation</strong>. Let <span class="math inline">\(\theta\)</span> be a clockwise rotation parameter, then <span class="math inline">\(G(u,v) = \langle\cos\theta u + \sin\theta v, -\sin\theta u + \cos\theta v\rangle\)</span> will be the transform. The Jacobian is <span class="math inline">\(1\)</span>. This figure rotates by <span class="math inline">\(\pi/6\)</span>:</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="49">
<div class="cell-output cell-output-display" data-execution_count="49">
<p><img src="double_triple_integrals_files/figure-html/cell-50-output-1.svg" class="img-fluid"></p>
</div>
</div>
<ul>
<li><strong>Shearing</strong>. Let <span class="math inline">\(k &gt; 0\)</span> and <span class="math inline">\(G(u,v) = \langle u + kv, v \rangle\)</span>. This transformation is shear parallel to the <span class="math inline">\(x\)</span> axis. (Use <span class="math inline">\(G(u,v) = \langle u, ku+v\rangle\)</span> for the <span class="math inline">\(y\)</span> axis). A shear has Jacobian <span class="math inline">\(1\)</span>.</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="50">
<div class="sourceCode cell-code" id="cb50"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a>k <span class="op">=</span> <span class="fl">2</span></span>
<span id="cb50-2"><a href="#cb50-2" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(u, v) <span class="op">=</span> [u <span class="op">+</span> <span class="fl">2</span>v, v]</span>
<span id="cb50-3"><a href="#cb50-3" aria-hidden="true" tabindex="-1"></a><span class="fu">showG</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="50">
<p><img src="double_triple_integrals_files/figure-html/cell-51-output-1.svg" class="img-fluid"></p>
</div>
</div>
<ul>
<li><strong>Reflection</strong> If <span class="math inline">\(\vec{l} = \langle l_x, l_y \rangle\)</span> with norm <span class="math inline">\(\|\vec{l}\|\)</span>. The reflection through the line in the direction of <span class="math inline">\(\vec{l}\)</span> through the origin is defined, using a matrix, by:</li>
</ul>
<p><span class="math display">\[
\frac{1}{\| \vec{l} \|^2}
\left[
\begin{array}{}
l_x^2 - l_y^2 &amp; 2 l_x l_y\\
2l_x l_y &amp; l_y^2 - l_x^2
\end{array}
\right]
\]</span></p>
<p>For some simple cases: <span class="math inline">\(\langle l_x, l_y \rangle = \langle 1, 1\rangle\)</span>, the diagonal, this is <span class="math inline">\(G(u,v) = (1/2) \langle 2v, 2u \rangle\)</span>; <span class="math inline">\(\langle l_x, l_y \rangle = \langle 0, 1\rangle\)</span> (the <span class="math inline">\(y\)</span>-axis) this is <span class="math inline">\(G(u,v) = \langle -u, v\rangle\)</span>.</p>
<ul>
<li>A translation by <span class="math inline">\(\langle a ,b \rangle\)</span> would be given by <span class="math inline">\(G(u,v) = \langle u+a, y+b \rangle\)</span> and would have Jacobian determinant <span class="math inline">\(1\)</span>.</li>
</ul>
<p>As an example, consider the transformation of reflecting through the line <span class="math inline">\(x = 1/2\)</span>. Let <span class="math inline">\(\vec{ab} = \langle 1/2, 0\rangle\)</span>. This would be found by translating by <span class="math inline">\(-\vec{ab}\)</span> then reflecting through the <span class="math inline">\(y\)</span> axis, then translating by <span class="math inline">\(\vec{ab}\)</span>:</p>
<div class="cell" data-hold="true" data-execution_count="51">
<div class="sourceCode cell-code" id="cb51"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb51-1"><a href="#cb51-1" aria-hidden="true" tabindex="-1"></a><span class="fu">T</span>(u, v, a, b) <span class="op">=</span> [u<span class="op">+</span>a, v<span class="op">+</span>b]</span>
<span id="cb51-2"><a href="#cb51-2" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(u, v) <span class="op">=</span> [<span class="op">-</span>u, v]</span>
<span id="cb51-3"><a href="#cb51-3" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> u v</span>
<span id="cb51-4"><a href="#cb51-4" aria-hidden="true" tabindex="-1"></a>a,b <span class="op">=</span> <span class="fl">1</span><span class="op">//</span><span class="fl">2</span>, <span class="fl">0</span></span>
<span id="cb51-5"><a href="#cb51-5" aria-hidden="true" tabindex="-1"></a>x1, y1 <span class="op">=</span> <span class="fu">T</span>(u,v, <span class="op">-</span>a, <span class="op">-</span>b)</span>
<span id="cb51-6"><a href="#cb51-6" aria-hidden="true" tabindex="-1"></a>x2, y2 <span class="op">=</span> <span class="fu">G</span>(x1, y1)</span>
<span id="cb51-7"><a href="#cb51-7" aria-hidden="true" tabindex="-1"></a>x, y <span class="op">=</span> <span class="fu">T</span>(x2, y2, a, b)</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">
<pre><code>2-element Vector{Sym}:
1 - u
v</code></pre>
</div>
</div>
</section>
<section id="triangle" class="level5">
<h5 class="anchored" data-anchor-id="triangle">Triangle</h5>
<p>Consider the problem of integrating <span class="math inline">\(f(x,y)\)</span> over the triangular region bounded by <span class="math inline">\(y=x\)</span>, <span class="math inline">\(y=0\)</span>, and <span class="math inline">\(x=1\)</span>. Such an integral may be computed through Fubinis theorem through <span class="math inline">\(\int_0^1 \int_0^x f(x,y) dy dx\)</span> or <span class="math inline">\(\int_0^1 \int_y^1 f(x,y) dx dy\)</span>, but <em>if</em> these can not be computed, and a numeric option is preferred, a transformation so that the integral is over a rectangle is preferred.</p>
<p>For this, the transformation <span class="math inline">\(x = u\)</span>, <span class="math inline">\(y=uv\)</span> for <span class="math inline">\((u,v)\)</span> in <span class="math inline">\([0,1] \times [0,1]\)</span> is possible:</p>
<div class="cell" data-hold="true" data-execution_count="52">
<div class="cell-output cell-output-display" data-execution_count="52">
<p><img src="double_triple_integrals_files/figure-html/cell-53-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The determinant of the Jacobian is</p>
<p><span class="math display">\[
\det(J_G) = \det\left(
\left[
\begin{array}{}
1 &amp; 0\\
v &amp; u
\end{array}
\right]
\right) = u.
\]</span></p>
<p>So, <span class="math inline">\(\iint_R f(x,y) dA = \int_0^1\int_0^1 f(u, uv) u du dv\)</span>. Here we illustrate with a generic monomial:</p>
<div class="cell" data-execution_count="53">
<div class="sourceCode cell-code" id="cb53"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb53-1"><a href="#cb53-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x y n<span class="op">::</span><span class="dt">positive </span>m<span class="op">::</span><span class="dt">positive</span></span>
<span id="cb53-2"><a href="#cb53-2" aria-hidden="true" tabindex="-1"></a><span class="fu">monomial</span>(x,y) <span class="op">=</span> x<span class="op">^</span>n<span class="op">*</span>y<span class="op">^</span>m</span>
<span id="cb53-3"><a href="#cb53-3" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">monomial</span>(x,y), (y, <span class="fl">0</span>, x), (x, <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="53">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{1}{\left(m + 1\right) \left(m + n + 2\right)}
\]
</span>
</div>
</div>
<p>And compare with:</p>
<div class="cell" data-hold="true" data-execution_count="54">
<div class="sourceCode cell-code" id="cb54"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb54-1"><a href="#cb54-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> u v</span>
<span id="cb54-2"><a href="#cb54-2" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">monomial</span>(u, u<span class="op">*</span>v)<span class="op">*</span>u, (u,<span class="fl">0</span>,<span class="fl">1</span>), (v,<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="54">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{1}{\left(m + 1\right) \left(m + n + 2\right)}
\]
</span>
</div>
</div>
<section id="composition-of-transformations" class="level6">
<h6 class="anchored" data-anchor-id="composition-of-transformations">Composition of transformations</h6>
<p>What about other triangles, say the triangle bounded by <span class="math inline">\(x=0\)</span>, <span class="math inline">\(y=0\)</span> and <span class="math inline">\(y-x=1\)</span>?</p>
<p>This can be seen as a reflection through the line <span class="math inline">\(x=1/2\)</span> of the triangle above. If <span class="math inline">\(G_1\)</span> represents the mapping from <span class="math inline">\(U [0,1]\times[0,1]\)</span> into the triangle of the last problem, and <span class="math inline">\(G_2\)</span> represents the reflection through the line <span class="math inline">\(x=1/2\)</span>, then the transformation <span class="math inline">\(G_2 \circ G_1\)</span> will map the box <span class="math inline">\(U\)</span> into the desired region. By the chain rule, we have:</p>
<p><span class="math display">\[
\begin{align*}
\int_{(G_2\circ G_1)(U))} f dx &amp;= \int_U (f\circ G_2 \circ G_1) |\det(J_{G_2 \circ G_1}| du \\
&amp;=
\int_U (f\circ G_2 \circ G_1) |\det(J_{G_2}(G_1(u))||\det J_{G_1}(u)| du.
\end{align*}
\]</span></p>
<p>(In <a href="http://www.jstor.org/stable/2689856">Katz</a> it is mentioned that Jacobi showed this in 1841.)</p>
<p>The flip through the <span class="math inline">\(x=1/2\)</span> line was done above and is <span class="math inline">\(\langle u, v\rangle \rightarrow \langle 1-u, v\rangle\)</span> which has Jacobian determinant <span class="math inline">\(-1\)</span>.</p>
<p>We compare now using and <code>hcubature</code> and our “Fubini” function:</p>
<div class="cell" data-hold="true" data-execution_count="55">
<div class="sourceCode cell-code" id="cb55"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb55-1"><a href="#cb55-1" aria-hidden="true" tabindex="-1"></a><span class="fu">G1</span>(u,v) <span class="op">=</span> [u, u<span class="op">*</span>v]</span>
<span id="cb55-2"><a href="#cb55-2" aria-hidden="true" tabindex="-1"></a><span class="fu">G1</span>(v) <span class="op">=</span> <span class="fu">G1</span>(v<span class="op">...</span>)</span>
<span id="cb55-3"><a href="#cb55-3" aria-hidden="true" tabindex="-1"></a><span class="fu">G2</span>(u,v) <span class="op">=</span> [<span class="fl">1</span><span class="op">-</span>u, v]</span>
<span id="cb55-4"><a href="#cb55-4" aria-hidden="true" tabindex="-1"></a><span class="fu">G2</span>(v) <span class="op">=</span> <span class="fu">G2</span>(v<span class="op">...</span>)</span>
<span id="cb55-5"><a href="#cb55-5" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span><span class="op">*</span>y<span class="op">^</span><span class="fl">3</span></span>
<span id="cb55-6"><a href="#cb55-6" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(v) <span class="op">=</span> <span class="fu">f</span>(v<span class="op">...</span>)</span>
<span id="cb55-7"><a href="#cb55-7" aria-hidden="true" tabindex="-1"></a>A <span class="op">=</span> <span class="fu"></span>((y,x) <span class="op">-&gt;</span> <span class="fu">f</span>(x,y), (<span class="fl">0</span>, x <span class="op">-&gt;</span> <span class="fl">1</span> <span class="op">-</span> x), (<span class="fl">0</span>, <span class="fl">1</span>))</span>
<span id="cb55-8"><a href="#cb55-8" aria-hidden="true" tabindex="-1"></a>B <span class="op">=</span> <span class="fu">hcubature</span>(v <span class="op">-&gt;</span> (f<span class="op"></span>G2<span class="op"></span>G1)(v) <span class="op">*</span> v[<span class="fl">1</span>] <span class="op">*</span> <span class="fl">1</span>, (<span class="fl">0</span>,<span class="fl">0</span>), (<span class="fl">1</span>, <span class="fl">1</span>))</span>
<span id="cb55-9"><a href="#cb55-9" aria-hidden="true" tabindex="-1"></a>A, B[<span class="fl">1</span>], A <span class="op">-</span> 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="55">
<pre><code>(0.0023809523809523807, 0.0023809523809509895, 1.3912482277333993e-15)</code></pre>
</div>
</div>
</section>
</section>
<section id="hyperbolic-transformation" class="level5">
<h5 class="anchored" data-anchor-id="hyperbolic-transformation">Hyperbolic transformation</h5>
<p>Consider the region, <span class="math inline">\(R\)</span>, bounded by <span class="math inline">\(y=0\)</span>, <span class="math inline">\(x=e^{-n}\)</span>, <span class="math inline">\(x=e^n\)</span>, and <span class="math inline">\(y=1/x\)</span>. An integral over this region may be computed with the help of the transform <span class="math inline">\(G(u,v) = v \langle e^u, e^{-u}\rangle\)</span> which takes the box <span class="math inline">\([-n, n] \times [0,1]\)</span> onto <span class="math inline">\(R\)</span>.</p>
<p>With this, we compute <span class="math inline">\(\iint_R x^2 y^3 dA\)</span> using <code>SymPy</code> to compute the Jacobian:</p>
<div class="cell" data-hold="true" data-execution_count="56">
<div class="sourceCode cell-code" id="cb57"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb57-1"><a href="#cb57-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> u v n</span>
<span id="cb57-2"><a href="#cb57-2" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(u,v) <span class="op">=</span> v <span class="op">*</span> [<span class="fu">exp</span>(u), <span class="fu">exp</span>(<span class="op">-</span>u)]</span>
<span id="cb57-3"><a href="#cb57-3" aria-hidden="true" tabindex="-1"></a>Jac <span class="op">=</span> <span class="fu">G</span>(u,v).<span class="fu">jacobian</span>([u,v])</span>
<span id="cb57-4"><a href="#cb57-4" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span> <span class="op">*</span> y<span class="op">^</span><span class="fl">3</span></span>
<span id="cb57-5"><a href="#cb57-5" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(v) <span class="op">=</span> <span class="fu">f</span>(v<span class="op">...</span>)</span>
<span id="cb57-6"><a href="#cb57-6" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(<span class="fu">G</span>(u,v)) <span class="op">*</span> <span class="fu">abs</span>(<span class="fu">det</span>(Jac)), (u, <span class="op">-</span>n, n), (v, <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="56">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{\left(2 e^{2 n} - 2\right) e^{- n}}{7}
\]
</span>
</div>
</div>
<hr>
<p>This collection shows a summary of the above <span class="math inline">\(2\)</span>D transformations:</p>
<div class="cell" data-hold="true" data-execution_count="57">
<div class="cell-output cell-output-display" data-execution_count="57">
<p><img src="double_triple_integrals_files/figure-html/cell-58-output-1.svg" class="img-fluid"></p>
</div>
</div>
</section>
</section>
</section>
<section id="examples" class="level3" data-number="59.5.2">
<h3 data-number="59.5.2" class="anchored" data-anchor-id="examples"><span class="header-section-number">59.5.2</span> Examples</h3>
<section id="centroid" class="level5">
<h5 class="anchored" data-anchor-id="centroid">Centroid:</h5>
<p>The center of mass is a balancing point of a region with density <span class="math inline">\(\rho(x,y)\)</span>. In two dimensions it is a point <span class="math inline">\(\langle \bar{x}, \bar{y}\rangle\)</span>. These are found by the following formulas:</p>
<p><span class="math display">\[
A = \iint_R \rho(x,y) dA, \quad \bar{x} = \frac{1}{A} \iint_R x \rho(x,y) dA, \quad
\bar{y} = \frac{1}{A} \iint_R y \rho(x,y) dA.
\]</span></p>
<p>The <span class="math inline">\(x\)</span> value can be seen in terms of Fubini by integrating in <span class="math inline">\(y\)</span> first:</p>
<p><span class="math display">\[
\iint_R x \rho(x,y) dA = \int_{x=a}^b (\int_{y=h(x)}^{g(x)} \rho(x,y) dy) dx.
\]</span></p>
<p>The inner integral is the mass of a slice at a value along the <span class="math inline">\(x\)</span> axis. The center of mass is formed then by the mass times the distance from the origin. The center of mass is a “balance” point, in the sense that <span class="math inline">\(\iint_R (x - \bar{x}) dA = 0\)</span> and <span class="math inline">\(\iint_R (y-\bar{y})dA = 0\)</span>.</p>
<p>For example, the center of mass of the upper half <em>unit</em> disc will have a centroid with <span class="math inline">\(\bar{x} = 0\)</span>, by symmetry. We can see this by integrating in <em>Cartesian</em> coordinates, as follows</p>
<p><span class="math display">\[
\iint_R x dA = \int_{y=0}^1 \int_{x=-\sqrt{1-y^2}}^{\sqrt{1 - y^2}} x dx dy.
\]</span></p>
<p>The inner integral is <span class="math inline">\(0\)</span> as it an integral of an <em>odd</em> function over an interval symmetric about <span class="math inline">\(0\)</span>.</p>
<p>The value of <span class="math inline">\(\bar{y}\)</span> is found using polar coordinate transformation from:</p>
<p><span class="math display">\[
\iint_R y dA = \int_{r=0}^1 \int_{\theta=0}^{\pi} (r\sin(\theta))r d\theta dr =
\int_{r=0}^1 r^2 dr \int_{\theta=0}^{\pi}\sin(\theta) = \frac{1}{3} \cdot 2.
\]</span></p>
<p>The third equals sign uses separability. The answer for ${ is this value divided by the area, or <span class="math inline">\(2/(3\pi)\)</span>.</p>
</section>
<section id="example-moment-of-inertia" class="level5">
<h5 class="anchored" data-anchor-id="example-moment-of-inertia">Example: Moment of inertia</h5>
<p>The moment of <a href="https://en.wikipedia.org/wiki/Moment_of_inertia">inertia</a> of a point mass about an axis is <span class="math inline">\(I = mr^2\)</span> where <span class="math inline">\(m\)</span> is the mass and <span class="math inline">\(r\)</span> the distance to the axis. The moment of inertia of a body is the sum of the moment of inertia of each piece. If <span class="math inline">\(R\)</span> is a region in the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane with density <span class="math inline">\(\rho(x,y)\)</span> and the axis is the <span class="math inline">\(y\)</span> axis, then an approximate moment of inertia would be <span class="math inline">\(\sum (x_i)^2\rho(x_i, y_i)\Delta x_i \Delta y_i\)</span> which would lead to <span class="math inline">\(I = \iint_R x^2\rho(x,y) dA\)</span>.</p>
<p>Let <span class="math inline">\(R\)</span> be the half disc contained by <span class="math inline">\(x^2 + y^2 = 1\)</span> and <span class="math inline">\(y \geq 0\)</span>. Let <span class="math inline">\(\rho(x,y) = xy^2\)</span>. Find the moment of inertia.</p>
<p><span class="math display">\[
R
\]</span></p>
<p>is best described in polar coordinates, so we try to compute</p>
<p><span class="math display">\[
\int_0^1 \int_{-\pi/2}^{\pi/2} (r\cos(\theta))^2 (r\cos(\theta))(r\sin(\theta)) r d\theta dr.
\]</span></p>
<p>That requires integrating <span class="math inline">\(\sin^2(\theta)\cos^3(\theta)\)</span>, a doable task, but best left to SymPy:</p>
<div class="cell" data-hold="true" data-execution_count="58">
<div class="sourceCode cell-code" id="cb58"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb58-1"><a href="#cb58-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> r theta</span>
<span id="cb58-2"><a href="#cb58-2" aria-hidden="true" tabindex="-1"></a>x <span class="op">=</span> <span class="fu">r*cos</span>(theta)</span>
<span id="cb58-3"><a href="#cb58-3" aria-hidden="true" tabindex="-1"></a>y <span class="op">=</span> <span class="fu">r*sin</span>(theta)</span>
<span id="cb58-4"><a href="#cb58-4" aria-hidden="true" tabindex="-1"></a><span class="fu">rho</span>(x,y) <span class="op">=</span> x<span class="op">*</span>y<span class="op">^</span><span class="fl">2</span></span>
<span id="cb58-5"><a href="#cb58-5" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(x<span class="op">^</span><span class="fl">2</span> <span class="op">*</span> <span class="fu">rho</span>(x, y), (theta, <span class="op">-</span>PI<span class="op">/</span><span class="fl">2</span>, PI<span class="op">/</span><span class="fl">2</span>), (r, <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="58">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{2}{45}
\]
</span>
</div>
</div>
</section>
<section id="example-12" class="level5">
<h5 class="anchored" data-anchor-id="example-12">Example</h5>
<p>(Strang) Find the moment of inertia about the <span class="math inline">\(y\)</span> axis of the unit square tilted <em>counter</em>-clockwise an angle <span class="math inline">\(0 \leq \alpha \leq \pi/2\)</span>.</p>
<p>The counterclockwise rotation of the unit square is <span class="math inline">\(G(u,v) = \langle \cos(\alpha)u-\sin(\alpha)v, \sin(\alpha)u + \cos(\alpha) v\rangle\)</span>. This comes from the above formula for clockwise rotation using <span class="math inline">\(-\alpha\)</span>. This transformation has Jacobian determinant <span class="math inline">\(1\)</span>, as the area is not deformed. With this, we have</p>
<p><span class="math display">\[
\iint_R x^2 dA = \iint_{G(U)} (f\circ G)(u) |\det(J_G(u))| dU,
\]</span></p>
<p>which is computed with:</p>
<div class="cell" data-hold="true" data-execution_count="59">
<div class="sourceCode cell-code" id="cb59"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb59-1"><a href="#cb59-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> u v alpha</span>
<span id="cb59-2"><a href="#cb59-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span></span>
<span id="cb59-3"><a href="#cb59-3" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(u,v) <span class="op">=</span> [<span class="fu">cos</span>(alpha)<span class="op">*</span>u <span class="op">-</span> <span class="fu">sin</span>(alpha)<span class="op">*</span>v, <span class="fu">sin</span>(alpha)<span class="op">*</span>u <span class="op">+</span> <span class="fu">cos</span>(alpha)<span class="op">*</span>v]</span>
<span id="cb59-4"><a href="#cb59-4" aria-hidden="true" tabindex="-1"></a>Jac <span class="op">=</span> <span class="fu">det</span>(<span class="fu">G</span>(u,v).<span class="fu">jacobian</span>([u,v])) <span class="op">|&gt;</span> simplify</span>
<span id="cb59-5"><a href="#cb59-5" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(<span class="fu">G</span>(u,v)<span class="op">...</span>) <span class="op">*</span> Jac , (u, <span class="fl">0</span>, <span class="fl">1</span>), (v, <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="59">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{\sin^{2}{\left(\alpha \right)}}{3} - \frac{\sin{\left(\alpha \right)} \cos{\left(\alpha \right)}}{2} + \frac{\cos^{2}{\left(\alpha \right)}}{3}
\]
</span>
</div>
</div>
</section>
<section id="example-13" class="level5">
<h5 class="anchored" data-anchor-id="example-13">Example</h5>
<p>Let <span class="math inline">\(R\)</span> be a ring with inner radius <span class="math inline">\(4\)</span> and outer radius <span class="math inline">\(5\)</span>. Find its moment of inertia about the <span class="math inline">\(y\)</span> axis.</p>
<p>The integral to compute is:</p>
<p><span class="math display">\[
\iint_R x^2 dA,
\]</span></p>
<p>with domain that is easy to describe in polar coordinates:</p>
<div class="cell" data-hold="true" data-execution_count="60">
<div class="sourceCode cell-code" id="cb60"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb60-1"><a href="#cb60-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> r theta</span>
<span id="cb60-2"><a href="#cb60-2" aria-hidden="true" tabindex="-1"></a>x <span class="op">=</span> <span class="fu">r*cos</span>(theta)</span>
<span id="cb60-3"><a href="#cb60-3" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(x<span class="op">^</span><span class="fl">2</span> <span class="op">*</span> r, (r, <span class="fl">4</span>, <span class="fl">5</span>), (theta, <span class="fl">0</span>, <span class="fl">2</span>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="60">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\frac{369 \pi}{4}
\]
</span>
</div>
</div>
</section>
</section>
<section id="three-dimensional-change-of-variables" class="level3" data-number="59.5.3">
<h3 data-number="59.5.3" class="anchored" data-anchor-id="three-dimensional-change-of-variables"><span class="header-section-number">59.5.3</span> Three dimensional change of variables</h3>
<p>The change of variables formula is no different between dimensions <span class="math inline">\(2\)</span> and <span class="math inline">\(3\)</span> (or higher), but the question of suitable transformation is more involved as the dimensions increase. We stick here to a few widely used ones.</p>
<section id="cylindrical-coordinates" class="level4">
<h4 class="anchored" data-anchor-id="cylindrical-coordinates">Cylindrical coordinates</h4>
<p>Polar coordinates describe the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane in terms of a radius <span class="math inline">\(r\)</span> and angle <span class="math inline">\(\theta\)</span>. <em>Cylindrical</em> coordinates describe the <span class="math inline">\(x-y-z\)</span> plane in terms of <span class="math inline">\(r, \theta\)</span>, and <span class="math inline">\(z\)</span>. A transformation is:</p>
<p><span class="math display">\[
G(r,\theta, z) = \langle r\cos(\theta), r\sin(\theta), z\rangle.
\]</span></p>
<p>This has Jacobian determinant <span class="math inline">\(r\)</span>, similar to polar coordinates.</p>
<section id="example-14" class="level5">
<h5 class="anchored" data-anchor-id="example-14">Example</h5>
<p>Returning to the volume of a cone above the <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane under <span class="math inline">\(z = a - b(x^2 + y^2)^{12}\)</span>. This yielded the integral in Cartesian coordinates:</p>
<p><span class="math display">\[
\int_{x=-r}^r \int_{y=-\sqrt{r^2 - x^2}}^{\sqrt{r^2-x^2}} \int_0^{a - b(x^2 + y^2)} 1 dz dy dx,
\]</span></p>
<p>where <span class="math inline">\(r=a/b\)</span>. This is <em>much</em> simpler in Cylindrical coordinates, as the region is described by the rectangle in <span class="math inline">\((r, \theta)\)</span>: <span class="math inline">\([0, \sqrt{b/a}] \times [0, 2\pi]\)</span> and the <span class="math inline">\(z\)</span> range is from <span class="math inline">\(0\)</span> to <span class="math inline">\(a - b r\)</span>.</p>
<p>The volume then is:</p>
<p><span class="math display">\[
\int_{theta=0}^{2\pi} \int_{r=0}^{a/b} \int_{z=0}^{a - br} 1 r dz dr d\theta =
2\pi \int_{r=0}^{a/b} (a-br)r dr = \frac{\pi a^3}{3b^2}.
\]</span></p>
<p>This is in agreement with <span class="math inline">\(\pi r^2 h/3\)</span>.</p>
<hr>
<p>Find the centroid for the cone. First in the <span class="math inline">\(x\)</span> direction, <span class="math inline">\(\iint_R x dV\)</span> is found by:</p>
<div class="cell" data-hold="true" data-execution_count="61">
<div class="sourceCode cell-code" id="cb61"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb61-1"><a href="#cb61-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> r theta z a b</span>
<span id="cb61-2"><a href="#cb61-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y,z) <span class="op">=</span> x</span>
<span id="cb61-3"><a href="#cb61-3" aria-hidden="true" tabindex="-1"></a>x <span class="op">=</span> <span class="fu">r*cos</span>(theta)</span>
<span id="cb61-4"><a href="#cb61-4" aria-hidden="true" tabindex="-1"></a>y <span class="op">=</span> <span class="fu">r*sin</span>(theta)</span>
<span id="cb61-5"><a href="#cb61-5" aria-hidden="true" tabindex="-1"></a>Jac <span class="op">=</span> r</span>
<span id="cb61-6"><a href="#cb61-6" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fu">f</span>(x,y,z) <span class="op">*</span> Jac, (z, <span class="fl">0</span>, a <span class="op">-</span> b<span class="op">*</span>r), (r, <span class="fl">0</span>, a<span class="op">/</span>b), (theta, <span class="fl">0</span>, <span class="fl">2</span>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="61">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
0
\]
</span>
</div>
</div>
<p>That this is <span class="math inline">\(0\)</span> is no surprise. The same will be true for the <span class="math inline">\(y\)</span> direction, as the figure is symmetric about the plane <span class="math inline">\(y=0\)</span> and <span class="math inline">\(x=0\)</span>. However, the <span class="math inline">\(z\)</span> direction is different:</p>
<div class="cell" data-hold="true" data-execution_count="62">
<div class="sourceCode cell-code" id="cb62"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb62-1"><a href="#cb62-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> r theta z a b</span>
<span id="cb62-2"><a href="#cb62-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x,y,z) <span class="op">=</span> z</span>
<span id="cb62-3"><a href="#cb62-3" aria-hidden="true" tabindex="-1"></a>x <span class="op">=</span> <span class="fu">r*cos</span>(theta)</span>
<span id="cb62-4"><a href="#cb62-4" aria-hidden="true" tabindex="-1"></a>y <span class="op">=</span> <span class="fu">r*sin</span>(theta)</span>
<span id="cb62-5"><a href="#cb62-5" aria-hidden="true" tabindex="-1"></a>Jac <span class="op">=</span> r</span>
<span id="cb62-6"><a href="#cb62-6" aria-hidden="true" tabindex="-1"></a>A <span class="op">=</span> <span class="fu">integrate</span>(<span class="fu">f</span>(x,y,z) <span class="op">*</span> Jac, (z, <span class="fl">0</span>, a <span class="op">-</span> b<span class="op">*</span>r), (r, <span class="fl">0</span>, a<span class="op">/</span>b), (theta, <span class="fl">0</span>, <span class="fl">2</span>PI))</span>
<span id="cb62-7"><a href="#cb62-7" aria-hidden="true" tabindex="-1"></a>B <span class="op">=</span> <span class="fu">integrate</span>(<span class="fl">1</span> <span class="op">*</span> Jac, (z, <span class="fl">0</span>, a <span class="op">-</span> b<span class="op">*</span>r), (r, <span class="fl">0</span>, a<span class="op">/</span>b), (theta, <span class="fl">0</span>, <span class="fl">2</span>PI))</span>
<span id="cb62-8"><a href="#cb62-8" aria-hidden="true" tabindex="-1"></a>A, B, A<span class="op">/</span>B</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="62">
<pre><code>(pi*a^4/(12*b^2), pi*a^3/(3*b^2), a/4)</code></pre>
</div>
</div>
<p>The answer depends on the height through <span class="math inline">\(a\)</span>, but <em>not</em> the size of the base, parameterized by <span class="math inline">\(b\)</span>. To finish, the centroid is <span class="math inline">\(\langle 0, 0, a/4\rangle\)</span>.</p>
</section>
<section id="example-15" class="level5">
<h5 class="anchored" data-anchor-id="example-15">Example</h5>
<p>A sphere of radius <span class="math inline">\(2\)</span> is intersected by a cylinder of radius <span class="math inline">\(1\)</span> along the <span class="math inline">\(z\)</span> axis. Find the volume of the intersection.</p>
<p>We have <span class="math inline">\(x^2 + y^2 + z^2 = 4\)</span> or <span class="math inline">\(z^2 = 4 - r^2\)</span> in cylindrical coordinates. The integral then is:</p>
<div class="cell" data-hold="true" data-execution_count="63">
<div class="sourceCode cell-code" id="cb64"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb64-1"><a href="#cb64-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> r<span class="op">::</span><span class="dt">real </span>theta<span class="op">::</span><span class="dt">real </span>z<span class="op">::</span><span class="dt">real</span></span>
<span id="cb64-2"><a href="#cb64-2" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fl">1</span> <span class="op">*</span> r, (z, <span class="fu">-sqrt</span>(<span class="fl">4</span><span class="op">-</span>r<span class="op">^</span><span class="fl">2</span>), <span class="fu">sqrt</span>(<span class="fl">4</span><span class="op">-</span>r<span class="op">^</span><span class="fl">2</span>)), (r, <span class="fl">0</span>, <span class="fl">1</span>), (theta, <span class="fl">0</span>, <span class="fl">2</span>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="63">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
2 \pi \left(\frac{16}{3} - 2 \sqrt{3}\right)
\]
</span>
</div>
</div>
<p>If instead of a fixed radius of <span class="math inline">\(1\)</span> we use <span class="math inline">\(0 \leq a \leq 2\)</span> we have:</p>
<div class="cell" data-hold="true" data-execution_count="64">
<div class="sourceCode cell-code" id="cb65"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb65-1"><a href="#cb65-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> a r theta</span>
<span id="cb65-2"><a href="#cb65-2" aria-hidden="true" tabindex="-1"></a><span class="fu">integrate</span>(<span class="fl">1</span> <span class="op">*</span> r, (z, <span class="fu">-sqrt</span>(<span class="fl">4</span><span class="op">-</span>r<span class="op">^</span><span class="fl">2</span>), <span class="fu">sqrt</span>(<span class="fl">4</span><span class="op">-</span>r<span class="op">^</span><span class="fl">2</span>)), (r, <span class="fl">0</span>, a), (theta,<span class="fl">0</span>, <span class="fl">2</span>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="64">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
2 \pi \left(\frac{2 a^{2} \sqrt{4 - a^{2}}}{3} - \frac{8 \sqrt{4 - a^{2}}}{3} + \frac{16}{3}\right)
\]
</span>
</div>
</div>
</section>
</section>
<section id="spherical-integrals" class="level4">
<h4 class="anchored" data-anchor-id="spherical-integrals">Spherical integrals</h4>
<p>Spherical coordinates describe a point in space by a radius from the origin, <span class="math inline">\(r\)</span> or <span class="math inline">\(\rho\)</span>; a azimuthal angle <span class="math inline">\(\theta\)</span> in <span class="math inline">\([0, 2\pi]\)</span> and an <em>inclination</em> angle <span class="math inline">\(\phi\)</span> (also called polar angle) in <span class="math inline">\([0, \pi]\)</span>. The <span class="math inline">\(z\)</span> axis is the direction of the zenith and gives a reference line to define the inclination angle. The <span class="math inline">\(x\)</span>-<span class="math inline">\(y\)</span> plane is the reference plane, with the <span class="math inline">\(x\)</span> axis giving a reference direction for the azimuth measurement.</p>
<p>The exact formula to relate <span class="math inline">\((\rho, \theta, \phi)\)</span> to <span class="math inline">\((x,y,z)\)</span> is given by</p>
<p><span class="math display">\[
G(\rho, \theta, \phi) = \rho \langle
\sin(\phi)\cos(\theta),
\sin(\phi)\sin(\theta),
\cos(\phi)
\rangle.
\]</span></p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="../integral_vector_calculus/figures/spherical-coordinates.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Figure showing the parameterization by spherical coordinates. (Wikipedia)</figcaption><p></p>
</figure>
</div>
<p>The Jacobian can be computed to be <span class="math inline">\(\rho^2\sin(\phi)\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="66">
<div class="sourceCode cell-code" id="cb66"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb66-1"><a href="#cb66-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> ρ theta phi</span>
<span id="cb66-2"><a href="#cb66-2" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(ρ, theta, phi) <span class="op">=</span> ρ <span class="op">*</span> [<span class="fu">sin</span>(phi)<span class="fu">*cos</span>(theta), <span class="fu">sin</span>(phi)<span class="fu">*sin</span>(theta), <span class="fu">cos</span>(phi)]</span>
<span id="cb66-3"><a href="#cb66-3" aria-hidden="true" tabindex="-1"></a><span class="fu">det</span>(<span class="fu">G</span>(ρ, theta, phi).<span class="fu">jacobian</span>([ρ, theta, phi])) <span class="op">|&gt;</span> simplify <span class="op">|&gt;</span> abs</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="66">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
\left|{ρ^{2} \sin{\left(\phi \right)}}\right|
\]
</span>
</div>
</div>
<section id="example-16" class="level5">
<h5 class="anchored" data-anchor-id="example-16">Example</h5>
<p>Computing the volume of a sphere is a challenge (for SymPy) in Cartesian coordinates, but a breeze in spherical coordinates. Using <span class="math inline">\(r^2\sin(\phi)\)</span> as the multiplying factor, the volume is simply:</p>
<p><span class="math display">\[
\int_{\theta=0}^{2\pi} \int_{\phi=0}^{\pi} \int_{r=0}^R 1 \cdot r^2 \sin(\phi) dr d\phi d\theta =
\int_{\theta=0}^{2\pi} d\theta \int_{\phi=0}^{\pi} \sin(\phi)d\phi \int_{r=0}^R r^2 dr = (2\pi)(2)\frac{R^3}{3} = \frac{4\pi R^3}{3}.
\]</span></p>
</section>
<section id="example-17" class="level5">
<h5 class="anchored" data-anchor-id="example-17">Example</h5>
<p>Compute the volume of the ellipsoid, <span class="math inline">\(R\)</span>, described by <span class="math inline">\((x/a)^2 + (y/v)^2 + (z/c)^2 \leq 1\)</span>.</p>
<p>We first change variables via <span class="math inline">\(G(u,v,w) = \langle ua, vb, wc \rangle\)</span>. This maps the unit sphere, <span class="math inline">\(S\)</span>, given by <span class="math inline">\(u^2 + v^2 + w^2 \leq 1\)</span> into the ellipsoid. Then</p>
<p><span class="math display">\[
\iint_R 1 dV = \iint_S 1 |\det(J_G)| dU
\]</span></p>
<p>But the Jacobian is a constant:</p>
<div class="cell" data-hold="true" data-execution_count="67">
<div class="sourceCode cell-code" id="cb67"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb67-1"><a href="#cb67-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> u v w a b c</span>
<span id="cb67-2"><a href="#cb67-2" aria-hidden="true" tabindex="-1"></a><span class="fu">G</span>(u,v,w) <span class="op">=</span> [u<span class="op">*</span>a, v<span class="op">*</span>b, w<span class="op">*</span>c]</span>
<span id="cb67-3"><a href="#cb67-3" aria-hidden="true" tabindex="-1"></a><span class="fu">det</span>(<span class="fu">G</span>(u,v,w).<span class="fu">jacobian</span>([u,v,w]))</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="67">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
a b c
\]
</span>
</div>
</div>
<p>So the answer is <span class="math inline">\(abc V(S) = 4\pi abc/3\)</span></p>
</section>
</section>
</section>
</section>
<section id="questions" class="level2" data-number="59.6">
<h2 data-number="59.6" class="anchored" data-anchor-id="questions"><span class="header-section-number">59.6</span> Questions</h2>
<section id="question" class="level6">
<h6 class="anchored" data-anchor-id="question">Question</h6>
<p>Suppose <span class="math inline">\(f(x,y) = f_1(x)f_2(y)\)</span> and <span class="math inline">\(R = [a_1, b_1] \times [a_2,b_2]\)</span> is a rectangular region. Is this true?</p>
<p><span class="math display">\[
\iint_R f dA = (\int_{a_1}^{b_1} f_1(x) dx) \cdot (\int_{a_2}^{b_2} f_2(y) dy).
\]</span></p>
<div class="cell" data-hold="true" data-execution_count="68">
<div class="cell-output cell-output-display" data-execution_count="68">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="11970960410578347892" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_11970960410578347892">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_11970960410578347892_1">
<input class="form-check-input" type="radio" name="radio_11970960410578347892" id="radio_11970960410578347892_1" value="1">
<span class="label-body px-1">
No.
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_11970960410578347892_2">
<input class="form-check-input" type="radio" name="radio_11970960410578347892" id="radio_11970960410578347892_2" value="2">
<span class="label-body px-1">
Yes. As an inner integral \(\int_{a^2}^{b_2} f(x,y) dy = f_1(x) \int_{a_2}^{b_2} f_2(y) dy\).
</span>
</label>
</div>
</div>
</div>
<div id="11970960410578347892_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_11970960410578347892"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 2;
var msgBox = document.getElementById('11970960410578347892_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_11970960410578347892")
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_11970960410578347892")
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>Which integrals of the following are <span class="math inline">\(0\)</span> by symmetry? Let <span class="math inline">\(R\)</span> be the unit disc.</p>
<p><span class="math display">\[
a = \iint_R x dA, \quad b = \iint_R (x^2 + y^2) dA, \quad c = \iint_R xy dA
\]</span></p>
<div class="cell" data-hold="true" data-execution_count="69">
<div class="cell-output cell-output-display" data-execution_count="69">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="16753075682065885327" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_16753075682065885327">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_16753075682065885327_1">
<input class="form-check-input" type="radio" name="radio_16753075682065885327" id="radio_16753075682065885327_1" value="1">
<span class="label-body px-1">
Both \(b\) and \(c\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_16753075682065885327_2">
<input class="form-check-input" type="radio" name="radio_16753075682065885327" id="radio_16753075682065885327_2" value="2">
<span class="label-body px-1">
Both \(a\) and \(b\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_16753075682065885327_3">
<input class="form-check-input" type="radio" name="radio_16753075682065885327" id="radio_16753075682065885327_3" value="3">
<span class="label-body px-1">
Both \(a\) and \(c\)
</span>
</label>
</div>
</div>
</div>
<div id="16753075682065885327_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_16753075682065885327"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('16753075682065885327_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_16753075682065885327")
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_16753075682065885327")
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>Let <span class="math inline">\(R\)</span> be the unit disc. Which integrals can be found from common geometric formulas (e.g., known formulas for the sphere, cone, pyramid, ellipse, …)</p>
<p><span class="math display">\[
a = \iint_R (1 - (x^2+y2)) dA, \quad
b = \iint_R (1 - \sqrt{x^2 + y^2}) dA, \quad
c = \iint_R (1 - (x^2 + y^2)^2 dA
\]</span></p>
<div class="cell" data-hold="true" data-execution_count="70">
<div class="cell-output cell-output-display" data-execution_count="70">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="7677493480525289339" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_7677493480525289339">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_7677493480525289339_1">
<input class="form-check-input" type="radio" name="radio_7677493480525289339" id="radio_7677493480525289339_1" value="1">
<span class="label-body px-1">
Both \(a\) and \(b\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_7677493480525289339_2">
<input class="form-check-input" type="radio" name="radio_7677493480525289339" id="radio_7677493480525289339_2" value="2">
<span class="label-body px-1">
Both \(a\) and \(c\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_7677493480525289339_3">
<input class="form-check-input" type="radio" name="radio_7677493480525289339" id="radio_7677493480525289339_3" value="3">
<span class="label-body px-1">
Both \(b\) and \(c\)
</span>
</label>
</div>
</div>
</div>
<div id="7677493480525289339_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_7677493480525289339"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 1;
var msgBox = document.getElementById('7677493480525289339_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_7677493480525289339")
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_7677493480525289339")
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>Let the region <span class="math inline">\(R\)</span> be described by: in the first quadrant and bounded by <span class="math inline">\(x^3 + y^3 = 1\)</span>. What integral below will <strong>not</strong> find the area of <span class="math inline">\(R\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="71">
<div class="cell-output cell-output-display" data-execution_count="71">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="1138760220027521662" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_1138760220027521662">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_1138760220027521662_1">
<input class="form-check-input" type="radio" name="radio_1138760220027521662" id="radio_1138760220027521662_1" value="1">
<span class="label-body px-1">
\(\int_0^1 \int_0^{(1-x^3)^{1/3}} 1\cdot dy dx\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_1138760220027521662_2">
<input class="form-check-input" type="radio" name="radio_1138760220027521662" id="radio_1138760220027521662_2" value="2">
<span class="label-body px-1">
\(\int_0^1 \int_0^{(1-y^3)^{1/3}} 1\cdot dx dy\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_1138760220027521662_3">
<input class="form-check-input" type="radio" name="radio_1138760220027521662" id="radio_1138760220027521662_3" value="3">
<span class="label-body px-1">
\(\int_0^1 \int_0^{(1-y^3)^{1/3}} 1\cdot dy dx\)
</span>
</label>
</div>
</div>
</div>
<div id="1138760220027521662_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_1138760220027521662"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('1138760220027521662_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_1138760220027521662")
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_1138760220027521662")
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>Let <span class="math inline">\(R\)</span> be a triangular region with vertices <span class="math inline">\((0,0), (2,0), (1, b)\)</span> where <span class="math inline">\(b \geq 0\)</span>. What integral below computes the area of :R?</p>
<div class="cell" data-hold="true" data-execution_count="72">
<div class="cell-output cell-output-display" data-execution_count="72">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="12890314262454004693" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_12890314262454004693">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_12890314262454004693_1">
<input class="form-check-input" type="radio" name="radio_12890314262454004693" id="radio_12890314262454004693_1" value="1">
<span class="label-body px-1">
\(\int_0^2\int_0^{bx} dy dx\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_12890314262454004693_2">
<input class="form-check-input" type="radio" name="radio_12890314262454004693" id="radio_12890314262454004693_2" value="2">
<span class="label-body px-1">
\(\int_0^2 \int_0^{2b - bx} dy dx\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_12890314262454004693_3">
<input class="form-check-input" type="radio" name="radio_12890314262454004693" id="radio_12890314262454004693_3" value="3">
<span class="label-body px-1">
\(\int_0^b\int_{y/b}^{2-y/b} dx dy\)
</span>
</label>
</div>
</div>
</div>
<div id="12890314262454004693_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_12890314262454004693"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('12890314262454004693_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_12890314262454004693")
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_12890314262454004693")
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 <span class="math inline">\(f(x) \geq 0\)</span> be an integrable function. The area under <span class="math inline">\(f(x)\)</span> over <span class="math inline">\([a,b]\)</span>, <span class="math inline">\(\int_a^b f(x) dx\)</span>, is equivalent to?</p>
<div class="cell" data-hold="true" data-execution_count="73">
<div class="cell-output cell-output-display" data-execution_count="73">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="7643502073435487085" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_7643502073435487085">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_7643502073435487085_1">
<input class="form-check-input" type="radio" name="radio_7643502073435487085" id="radio_7643502073435487085_1" value="1">
<span class="label-body px-1">
\(\int_a^b \int_0^{f(x)} dx dy\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_7643502073435487085_2">
<input class="form-check-input" type="radio" name="radio_7643502073435487085" id="radio_7643502073435487085_2" value="2">
<span class="label-body px-1">
\(\int_0^{f(x)} \int_a^b dx dy\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_7643502073435487085_3">
<input class="form-check-input" type="radio" name="radio_7643502073435487085" id="radio_7643502073435487085_3" value="3">
<span class="label-body px-1">
\(\int_a^b \int_0^{f(x)} dy dx\)
</span>
</label>
</div>
</div>
</div>
<div id="7643502073435487085_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_7643502073435487085"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('7643502073435487085_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_7643502073435487085")
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_7643502073435487085")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
</section>
<section id="question-6" class="level6">
<h6 class="anchored" data-anchor-id="question-6">Question</h6>
<p>The region <span class="math inline">\(R\)</span> contained within <span class="math inline">\(|x| + |y| = 1\)</span> is square, but not rectangular (in the sense of integration). What transformation of <span class="math inline">\(S = [-1/2,1/2] \times [-1/2,1/2]\)</span> will have <span class="math inline">\(G(S) = R\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="74">
<div class="cell-output cell-output-display" data-execution_count="74">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="9062087378446737388" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_9062087378446737388">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_9062087378446737388_1">
<input class="form-check-input" type="radio" name="radio_9062087378446737388" id="radio_9062087378446737388_1" value="1">
<span class="label-body px-1">
\(G(u,v) = \langle u^2-v^2, u^2+v^2 \rangle\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_9062087378446737388_2">
<input class="form-check-input" type="radio" name="radio_9062087378446737388" id="radio_9062087378446737388_2" value="2">
<span class="label-body px-1">
\(G(u,v) = \langle u-v, u+v \rangle\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_9062087378446737388_3">
<input class="form-check-input" type="radio" name="radio_9062087378446737388" id="radio_9062087378446737388_3" value="3">
<span class="label-body px-1">
\(G(u,v) = \langle u-v, u \rangle\)
</span>
</label>
</div>
</div>
</div>
<div id="9062087378446737388_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_9062087378446737388"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 2;
var msgBox = document.getElementById('9062087378446737388_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_9062087378446737388")
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_9062087378446737388")
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>Let <span class="math inline">\(G(u,v) = \langle \cosh(u)\cos(v), \sinh(u)\sin(v) \rangle\)</span>. Using <code>ForwardDiff</code> find the determinant of the Jacobian at <span class="math inline">\([1,2]\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="75">
<div class="cell-output cell-output-display" data-execution_count="75">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="2552574609621052080" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_2552574609621052080">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="2552574609621052080" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="2552574609621052080_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("2552574609621052080").addEventListener("change", function() {
var correct = (Math.abs(this.value - 2.2079196559736216) <= 0.001);
var msgBox = document.getElementById('2552574609621052080_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_2552574609621052080")
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_2552574609621052080")
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>Let <span class="math inline">\(G(u, v) = \langle \cosh(u)\cos(v), \sinh(u)\sin(v) \rangle\)</span>. Compute the determinant of the Jacobian symbolically:</p>
<div class="cell" data-hold="true" data-execution_count="76">
<div class="cell-output cell-output-display" data-execution_count="76">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="3861120965744933851" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_3861120965744933851">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_3861120965744933851_1">
<input class="form-check-input" type="radio" name="radio_3861120965744933851" id="radio_3861120965744933851_1" value="1">
<span class="label-body px-1">
\(1\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_3861120965744933851_2">
<input class="form-check-input" type="radio" name="radio_3861120965744933851" id="radio_3861120965744933851_2" value="2">
<span class="label-body px-1">
\(\sinh(u)\cosh(v)\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_3861120965744933851_3">
<input class="form-check-input" type="radio" name="radio_3861120965744933851" id="radio_3861120965744933851_3" value="3">
<span class="label-body px-1">
\(\sin^{2}{\left (v \right )} \cosh^{2}{\left (u \right )} + \cos^{2}{\left (v \right )} \sinh^{2}{\left (u \right )}\)
</span>
</label>
</div>
</div>
</div>
<div id="3861120965744933851_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_3861120965744933851"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('3861120965744933851_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_3861120965744933851")
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_3861120965744933851")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
</section>
<section id="question-9" class="level6">
<h6 class="anchored" data-anchor-id="question-9">Question</h6>
<p>Compute the determinant of the Jacobian of the composition of a clockwise rotation by <span class="math inline">\(\theta\)</span>, a reflection through the <span class="math inline">\(x\)</span> axis, and then a translation by <span class="math inline">\(\langle a,b\rangle\)</span>, using the fact that the Jacobian determinant of <em>compositions</em> can be written as product of determinants of the individual Jacobians.</p>
<div class="cell" data-hold="true" data-execution_count="77">
<div class="cell-output cell-output-display" data-execution_count="77">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="15617671486846803443" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_15617671486846803443">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_15617671486846803443_1">
<input class="form-check-input" type="radio" name="radio_15617671486846803443" id="radio_15617671486846803443_1" value="1">
<span class="label-body px-1">
It is \(r^2 \sin(\phi)\), as the rotations use spherical coordinates
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_15617671486846803443_2">
<input class="form-check-input" type="radio" name="radio_15617671486846803443" id="radio_15617671486846803443_2" value="2">
<span class="label-body px-1">
It is \(r\), as the rotation uses polar coordinates
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_15617671486846803443_3">
<input class="form-check-input" type="radio" name="radio_15617671486846803443" id="radio_15617671486846803443_3" value="3">
<span class="label-body px-1">
It is \(1\), as each is area preserving
</span>
</label>
</div>
</div>
</div>
<div id="15617671486846803443_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_15617671486846803443"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('15617671486846803443_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_15617671486846803443")
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_15617671486846803443")
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>A wedge, <span class="math inline">\(R\)</span>, is specified by <span class="math inline">\(0 \leq r \leq a\)</span>, <span class="math inline">\(0 \leq \theta \leq b\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="78">
<div class="cell-output cell-output-display" data-execution_count="78">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
- \frac{a^{3} \cos{\left(b \right)}}{3} + \frac{a^{3}}{3}
\]
</span>
</div>
</div>
<p>What does <code>A</code> compute?</p>
<div class="cell" data-hold="true" data-execution_count="79">
<div class="cell-output cell-output-display" data-execution_count="79">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="14433106279164661146" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_14433106279164661146">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_14433106279164661146_1">
<input class="form-check-input" type="radio" name="radio_14433106279164661146" id="radio_14433106279164661146_1" value="1">
<span class="label-body px-1">
The area of \(R\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_14433106279164661146_2">
<input class="form-check-input" type="radio" name="radio_14433106279164661146" id="radio_14433106279164661146_2" value="2">
<span class="label-body px-1">
The value \(\bar{x}\) of the centroid
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_14433106279164661146_3">
<input class="form-check-input" type="radio" name="radio_14433106279164661146" id="radio_14433106279164661146_3" value="3">
<span class="label-body px-1">
The value \(\bar{y}\) of the centroid
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_14433106279164661146_4">
<input class="form-check-input" type="radio" name="radio_14433106279164661146" id="radio_14433106279164661146_4" value="4">
<span class="label-body px-1">
The moment of inertia of \(R\) about the \(x\) axis
</span>
</label>
</div>
</div>
</div>
<div id="14433106279164661146_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_14433106279164661146"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 1;
var msgBox = document.getElementById('14433106279164661146_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_14433106279164661146")
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_14433106279164661146")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
<p>What does <span class="math inline">\(B/A\)</span> compute?</p>
<div class="cell" data-hold="true" data-execution_count="80">
<div class="cell-output cell-output-display" data-execution_count="80">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="1877741588572937061" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_1877741588572937061">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_1877741588572937061_1">
<input class="form-check-input" type="radio" name="radio_1877741588572937061" id="radio_1877741588572937061_1" value="1">
<span class="label-body px-1">
The area of \(R\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_1877741588572937061_2">
<input class="form-check-input" type="radio" name="radio_1877741588572937061" id="radio_1877741588572937061_2" value="2">
<span class="label-body px-1">
The value \(\bar{x}\) of the centroid
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_1877741588572937061_3">
<input class="form-check-input" type="radio" name="radio_1877741588572937061" id="radio_1877741588572937061_3" value="3">
<span class="label-body px-1">
The value \(\bar{y}\) of the centroid
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_1877741588572937061_4">
<input class="form-check-input" type="radio" name="radio_1877741588572937061" id="radio_1877741588572937061_4" value="4">
<span class="label-body px-1">
The moment of inertia of \(R\) about the \(x\) axis
</span>
</label>
</div>
</div>
</div>
<div id="1877741588572937061_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_1877741588572937061"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 2;
var msgBox = document.getElementById('1877741588572937061_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_1877741588572937061")
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_1877741588572937061")
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>According to <a href="http://www.jstor.org/stable/2689856">Katz</a> in 1899 Cartan formalized the subject of differential forms (elements such as <span class="math inline">\(dx\)</span> or <span class="math inline">\(du\)</span>). Using the rules <span class="math inline">\(dtdt = 0 = dv=dv\)</span> and <span class="math inline">\(dv dt = - dt dv\)</span>, what is the product of <span class="math inline">\(dx=mdt + dv\sqrt{1-m^2}\)</span> and <span class="math inline">\(dy=dt\sqrt{1-m^2}-mdv\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="81">
<div class="cell-output cell-output-display" data-execution_count="81">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="3227784383366619135" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_3227784383366619135">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_3227784383366619135_1">
<input class="form-check-input" type="radio" name="radio_3227784383366619135" id="radio_3227784383366619135_1" value="1">
<span class="label-body px-1">
\(m\sqrt{1-m^2}dt^2+(1-2m^2)dtdv -m\sqrt{1-m^2}dv^2\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_3227784383366619135_2">
<input class="form-check-input" type="radio" name="radio_3227784383366619135" id="radio_3227784383366619135_2" value="2">
<span class="label-body px-1">
\((1-2m^2)dt dv\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_3227784383366619135_3">
<input class="form-check-input" type="radio" name="radio_3227784383366619135" id="radio_3227784383366619135_3" value="3">
<span class="label-body px-1">
\(dtdv\)
</span>
</label>
</div>
</div>
</div>
<div id="3227784383366619135_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_3227784383366619135"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('3227784383366619135_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_3227784383366619135")
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_3227784383366619135")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</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="../differentiable_vector_calculus/plots_plotting.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">58</span>&nbsp; <span class="chapter-title">2D and 3D plots in Julia with Plots</span></span>
</a>
</div>
<div class="nav-page nav-page-next">
<a href="../integral_vector_calculus/line_integrals.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">60</span>&nbsp; <span class="chapter-title">Line and Surface Integrals</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>