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

2055 lines
129 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 - 29&nbsp; Linearization</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="../derivatives/newtons_method.html" rel="next">
<link href="../derivatives/curve_sketching.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">29</span>&nbsp; <span class="chapter-title">Linearization</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" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="true">Derivatives</a>
<a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="true">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-3" class="collapse list-unstyled sidebar-section depth1 show">
<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 active"><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 collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="false">Integral vector calculus</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-7" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/double_triple_integrals.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">59</span>&nbsp; <span class="chapter-title">Multi-dimensional integrals</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/line_integrals.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">60</span>&nbsp; <span class="chapter-title">Line and Surface Integrals</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/div_grad_curl.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">61</span>&nbsp; <span class="chapter-title">The Gradient, Divergence, and Curl</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/stokes_theorem.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">62</span>&nbsp; <span class="chapter-title">Greens Theorem, Stokes Theorem, and the Divergence Theorem</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../integral_vector_calculus/review.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">63</span>&nbsp; <span class="chapter-title">Quick Review of Vector Calculus</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-8" aria-expanded="false">Alternatives</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-8" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-8" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../alternatives/plotly_plotting.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">64</span>&nbsp; <span class="chapter-title">JavaScript based plotting libraries</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../alternatives/makie_plotting.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">65</span>&nbsp; <span class="chapter-title">Calculus plots with Makie</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-9" aria-expanded="false">Appendices</a>
<a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-9" aria-expanded="false">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-9" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/getting_started_with_julia.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">66</span>&nbsp; <span class="chapter-title">Getting started with Julia</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/julia_interfaces.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">67</span>&nbsp; <span class="chapter-title">Julia interfaces</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/calculus_with_julia.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">68</span>&nbsp; <span class="chapter-title">The <code>CalculusWithJulia</code> package</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/unicode.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">69</span>&nbsp; <span class="chapter-title">Usages of Unicode symbols</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../misc/quick_notes.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">70</span>&nbsp; <span class="chapter-title">Quick introduction to Calculus with Julia</span></a>
</div>
</li>
</ul>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../references.html" class="sidebar-item-text sidebar-link">References</a>
</div>
</li>
</ul>
</div>
</nav>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#numeric-approximations" id="toc-numeric-approximations" class="nav-link active" data-scroll-target="#numeric-approximations"> <span class="header-section-number">29.1</span> Numeric approximations</a>
<ul class="collapse">
<li><a href="#relative-error-or-relative-change" id="toc-relative-error-or-relative-change" class="nav-link" data-scroll-target="#relative-error-or-relative-change"> <span class="header-section-number">29.1.1</span> Relative error or relative change</a></li>
</ul></li>
<li><a href="#differentials" id="toc-differentials" class="nav-link" data-scroll-target="#differentials"> <span class="header-section-number">29.2</span> Differentials</a></li>
<li><a href="#the-error-in-approximation" id="toc-the-error-in-approximation" class="nav-link" data-scroll-target="#the-error-in-approximation"> <span class="header-section-number">29.3</span> The error in approximation</a>
<ul class="collapse">
<li><a href="#why-is-the-remainder-term-as-it-is" id="toc-why-is-the-remainder-term-as-it-is" class="nav-link" data-scroll-target="#why-is-the-remainder-term-as-it-is"> <span class="header-section-number">29.3.1</span> Why is the remainder term as it is?</a></li>
<li><a href="#the-big-and-small-oh" id="toc-the-big-and-small-oh" class="nav-link" data-scroll-target="#the-big-and-small-oh"> <span class="header-section-number">29.3.2</span> The big (and small) “oh”</a></li>
<li><a href="#the-taylorseries-package" id="toc-the-taylorseries-package" class="nav-link" data-scroll-target="#the-taylorseries-package"> <span class="header-section-number">29.3.3</span> The TaylorSeries package</a></li>
</ul></li>
<li><a href="#questions" id="toc-questions" class="nav-link" data-scroll-target="#questions"> <span class="header-section-number">29.4</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/derivatives/linearization.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">29</span>&nbsp; <span class="chapter-title">Linearization</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">SymPy</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">TaylorSeries</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">DualNumbers</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<hr>
<p>The derivative of <span class="math inline">\(f(x)\)</span> has the interpretation as the slope of the tangent line. The tangent line is the line that best approximates the function at the point.</p>
<p>Using the point-slope form of a line, we see that the tangent line to the graph of <span class="math inline">\(f(x)\)</span> at <span class="math inline">\((c,f(c))\)</span> is given by:</p>
<p><span class="math display">\[
y = f(c) + f'(c) \cdot (x - c).
\]</span></p>
<p>This is written as an equation, though we prefer to work with functions within <code>Julia</code>. Here we write such a function as an operator - it takes a function <code>f</code> and returns a function representing the tangent line.</p>
<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">tangent</span>(f, c) <span class="op">=</span> x <span class="op">-&gt;</span> <span class="fu">f</span>(c) <span class="op">+</span> f<span class="op">'</span>(c) <span class="op">*</span> (x <span class="op">-</span> c)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>(Recall, the <code>-&gt;</code> indicates that an anonymous function is being generated.)</p>
<p>This function along with the <code>f'</code> notation for automatic derivatives is defined in the <code>CalculusWithJulia</code> package.</p>
<p>We make some graphs with tangent lines:</p>
<div class="cell" data-hold="true" data-execution_count="5">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> x<span class="op">^</span><span class="fl">2</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(f, <span class="op">-</span><span class="fl">3</span>, <span class="fl">3</span>)</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(<span class="fu">tangent</span>(f, <span class="op">-</span><span class="fl">1</span>))</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(<span class="fu">tangent</span>(f, <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="5">
<p><img src="linearization_files/figure-html/cell-6-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The graph shows that near the point, the line and function are close, but this need not be the case away from the point. We can express this informally as</p>
<p><span class="math display">\[
f(x) \approx f(c) + f'(c) \cdot (x-c)
\]</span></p>
<p>with the understanding this applies for <span class="math inline">\(x\)</span> “close” to <span class="math inline">\(c\)</span>.</p>
<p>Usually for the applications herein, instead of <span class="math inline">\(x\)</span> and <span class="math inline">\(c\)</span> the two points are <span class="math inline">\(x+\Delta_x\)</span> and <span class="math inline">\(x\)</span>. This gives:</p>
<blockquote class="blockquote">
<p><em>Linearization</em>: <span class="math inline">\(\Delta_y = f(x +\Delta_x) - f(x) \approx f'(x) \Delta_x\)</span>, for small <span class="math inline">\(\Delta_x\)</span>.</p>
</blockquote>
<p>This section gives some implications of this fact and quantifies what “close” can mean.</p>
<section id="example" class="level5">
<h5 class="anchored" data-anchor-id="example">Example</h5>
<p>There are several approximations that are well known in physics, due to their widespread usage:</p>
<ul>
<li>That <span class="math inline">\(\sin(x) \approx x\)</span> around <span class="math inline">\(x=0\)</span>:</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="6">
<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">plot</span>(sin, <span class="op">-</span><span class="cn">pi</span><span class="op">/</span><span class="fl">2</span>, <span class="cn">pi</span><span class="op">/</span><span class="fl">2</span>)</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(<span class="fu">tangent</span>(sin, <span class="fl">0</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="6">
<p><img src="linearization_files/figure-html/cell-7-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Symbolically:</p>
<div class="cell" data-hold="true" data-execution_count="7">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>c <span class="op">=</span> <span class="fl">0</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> <span class="fu">sin</span>(x)</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(c) <span class="op">+</span> <span class="fu">diff</span>(<span class="fu">f</span>(x),x)(c) <span class="op">*</span> (x <span class="op">-</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="7">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
x
\]
</span>
</div>
</div>
<ul>
<li>That <span class="math inline">\(\log(1 + x) \approx x\)</span> around <span class="math inline">\(x=0\)</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) <span class="op">=</span> <span class="fu">log</span>(<span class="fl">1</span> <span class="op">+</span> x)</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(f, <span class="op">-</span><span class="fl">1</span><span class="op">/</span><span class="fl">2</span>, <span class="fl">1</span><span class="op">/</span><span class="fl">2</span>)</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(<span class="fu">tangent</span>(f, <span class="fl">0</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="8">
<p><img src="linearization_files/figure-html/cell-9-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Symbolically:</p>
<div class="cell" data-hold="true" data-execution_count="9">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>c <span class="op">=</span> <span class="fl">0</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> <span class="fu">log</span>(<span class="fl">1</span> <span class="op">+</span> x)</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(c) <span class="op">+</span> <span class="fu">diff</span>(<span class="fu">f</span>(x),x)(c) <span class="op">*</span> (x <span class="op">-</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="9">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
x
\]
</span>
</div>
</div>
<p>(The <code>log1p</code> function implements a more accurate version of this function when numeric values are needed.)</p>
<ul>
<li>That <span class="math inline">\(1/(1-x) \approx x\)</span> around <span class="math inline">\(x=0\)</span>:</li>
</ul>
<div class="cell" data-hold="true" data-execution_count="10">
<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">f</span>(x) <span class="op">=</span> <span class="fl">1</span><span class="op">/</span>(<span class="fl">1</span><span class="op">-</span>x)</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(f, <span class="op">-</span><span class="fl">1</span><span class="op">/</span><span class="fl">2</span>, <span class="fl">1</span><span class="op">/</span><span class="fl">2</span>)</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(<span class="fu">tangent</span>(f, <span class="fl">0</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">
<p><img src="linearization_files/figure-html/cell-11-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Symbolically:</p>
<div class="cell" data-hold="true" data-execution_count="11">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>c <span class="op">=</span> <span class="fl">0</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> <span class="fl">1</span> <span class="op">/</span> (<span class="fl">1</span> <span class="op">-</span> x)</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(c) <span class="op">+</span> <span class="fu">diff</span>(<span class="fu">f</span>(x),x)(c) <span class="op">*</span> (x <span class="op">-</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="11">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
x + 1.0
\]
</span>
</div>
</div>
<ul>
<li>That <span class="math inline">\((1+x)^n \approx 1 + nx\)</span> around <span class="math inline">\(x = 0\)</span>. For example, with <span class="math inline">\(n=5\)</span></li>
</ul>
<div class="cell" data-hold="true" data-execution_count="12">
<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>n <span class="op">=</span> <span class="fl">5</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> (<span class="fl">1</span><span class="op">+</span>x)<span class="op">^</span>n <span class="co"># f'(0) = n = n(1+x)^(n-1) at x=0</span></span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(f, <span class="op">-</span><span class="fl">1</span><span class="op">/</span><span class="fl">2</span>, <span class="fl">1</span><span class="op">/</span><span class="fl">2</span>)</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(<span class="fu">tangent</span>(f, <span class="fl">0</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="12">
<p><img src="linearization_files/figure-html/cell-13-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Symbolically:</p>
<div class="cell" data-hold="true" data-execution_count="13">
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@syms</span> x, n<span class="op">::</span><span class="dt">real</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>c <span class="op">=</span> <span class="fl">0</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> (<span class="fl">1</span> <span class="op">+</span> x)<span class="op">^</span>n</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(c) <span class="op">+</span> <span class="fu">diff</span>(<span class="fu">f</span>(x),x)(x<span class="op">=&gt;</span>c) <span class="op">*</span> (x <span class="op">-</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="13">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
n x + 1
\]
</span>
</div>
</div>
<hr>
<p>In each of these cases, a more complicated non-linear function is well approximated in a region of interest by a simple linear function.</p>
</section>
<section id="numeric-approximations" class="level2" data-number="29.1">
<h2 data-number="29.1" class="anchored" data-anchor-id="numeric-approximations"><span class="header-section-number">29.1</span> Numeric approximations</h2>
<div class="cell" data-hold="true" data-execution_count="14">
<div class="cell-output cell-output-display" data-execution_count="14">
<p><img src="linearization_files/figure-html/cell-15-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The plot shows the tangent line with slope <span class="math inline">\(dy/dx\)</span> and the actual change in <span class="math inline">\(y\)</span>, <span class="math inline">\(\Delta y\)</span>, for some specified <span class="math inline">\(\Delta x\)</span>. The small gap above the sine curve is the error were the value of the sine approximated using the drawn tangent line. We can see that approximating the value of <span class="math inline">\(\Delta y = \sin(c+\Delta x) - \sin(c)\)</span> with the often easier to compute <span class="math inline">\((dy/dx) \cdot \Delta x = f'(c)\Delta x\)</span> - for small enough values of <span class="math inline">\(\Delta x\)</span> - is not going to be too far off provided <span class="math inline">\(\Delta x\)</span> is not too large.</p>
<p>This approximation is known as linearization. It can be used both in theoretical computations and in pratical applications. To see how effective it is, we look at some examples.</p>
<section id="example-1" class="level5">
<h5 class="anchored" data-anchor-id="example-1">Example</h5>
<p>If <span class="math inline">\(f(x) = \sin(x)\)</span>, <span class="math inline">\(c=0\)</span> and <span class="math inline">\(\Delta x= 0.1\)</span> then the values for the actual change in the function values and the value of <span class="math inline">\(\Delta y\)</span> are:</p>
<div class="cell" data-execution_count="15">
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(x) <span class="op">=</span> <span class="fu">sin</span>(x)</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>c, deltax <span class="op">=</span> <span class="fl">0</span>, <span class="fl">0.1</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="fu">f</span>(c <span class="op">+</span> deltax) <span class="op">-</span> <span class="fu">f</span>(c), f<span class="op">'</span>(c) <span class="op">*</span> deltax</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="15">
<pre><code>(0.09983341664682815, 0.1)</code></pre>
</div>
</div>
<p>The values are pretty close. But what is <span class="math inline">\(0.1\)</span> radians? Lets use degrees. Suppose we have <span class="math inline">\(\Delta x = 10^\circ\)</span>:</p>
<div class="cell" data-execution_count="16">
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>deltax⁰ <span class="op">=</span> <span class="fl">10</span><span class="op">*</span><span class="cn">pi</span><span class="op">/</span><span class="fl">180</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>actual <span class="op">=</span> <span class="fu">f</span>(c <span class="op">+</span> deltax⁰) <span class="op">-</span> <span class="fu">f</span>(c)</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a>approx <span class="op">=</span> f<span class="op">'</span>(c) <span class="op">*</span> deltax⁰</span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a>actual, approx</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="16">
<pre><code>(0.17364817766693033, 0.17453292519943295)</code></pre>
</div>
</div>
<p>They agree until the third decimal value. The <em>percentage error</em> is just <span class="math inline">\(1/2\)</span> a percent:</p>
<div class="cell" data-execution_count="17">
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>(approx <span class="op">-</span> actual) <span class="op">/</span> actual <span class="op">*</span> <span class="fl">100</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="17">
<pre><code>0.5095057975210231</code></pre>
</div>
</div>
</section>
<section id="relative-error-or-relative-change" class="level3" data-number="29.1.1">
<h3 data-number="29.1.1" class="anchored" data-anchor-id="relative-error-or-relative-change"><span class="header-section-number">29.1.1</span> Relative error or relative change</h3>
<p>The relative error is defined by</p>
<p><span class="math display">\[
\big| \frac{\text{actual} - \text{approximate}}{\text{actual}} \big|.
\]</span></p>
<p>However, typically with linearization, we talk about the <em>relative change</em>, not relative error, as the denominator is easier to compute. This is</p>
<p><span class="math display">\[
\frac{f(x + \Delta_x) - f(x)}{f(x)} = \frac{\Delta_y}{f(x)} \approx
\frac{f'(x) \cdot \Delta_x}{f(x)}
\]</span></p>
<p>The <em>percentage change</em> multiplies by <span class="math inline">\(100\)</span>.</p>
<section id="example-2" class="level5">
<h5 class="anchored" data-anchor-id="example-2">Example</h5>
<p>What is the relative change in surface area of a sphere if the radius changes from <span class="math inline">\(r\)</span> to <span class="math inline">\(r + dr\)</span>?</p>
<p>We have <span class="math inline">\(S = 4\pi r^2\)</span> so the approximate relative change, <span class="math inline">\(dy/S\)</span> is given, using the derivative <span class="math inline">\(dS/dr = 8\pi r\)</span>, by</p>
<p><span class="math display">\[
\frac{8\pi\cdot r\cdot dr}{4\pi r^2} = 2r\cdot dr.
\]</span></p>
</section>
<section id="example-3" class="level5">
<h5 class="anchored" data-anchor-id="example-3">Example</h5>
<p>We are traveling <span class="math inline">\(60\)</span> miles. At <span class="math inline">\(60\)</span> miles an hour, we will take <span class="math inline">\(60\)</span> minutes (or one hour). How long will it take at <span class="math inline">\(70\)</span> miles an hour? (Assume you cant divide, but, instead, can only multiply!)</p>
<p>Well the answer is <span class="math inline">\(60/70\)</span> hours or <span class="math inline">\(60/70 \cdot 60\)</span> minutes. But we cant divide, so we turn this into a multiplication problem via some algebra:</p>
<p><span class="math display">\[
\frac{60}{70} = \frac{60}{60 + 10} = \frac{1}{1 + 10/60} = \frac{1}{1 + 1/6}.
\]</span></p>
<p>Okay, so far no calculator was needed. We wrote <span class="math inline">\(70 = 60 + 10\)</span>, as we know that <span class="math inline">\(60/60\)</span> is just <span class="math inline">\(1\)</span>. This almost gets us there. If we really dont want to divide, we can get an answer by using the tangent line approximation for <span class="math inline">\(1/(1+x)\)</span> around <span class="math inline">\(x=0\)</span>. This is <span class="math inline">\(1/(1+x) \approx 1 - x\)</span>. (You can check by finding that <span class="math inline">\(f'(0) = -1\)</span>.) Thus, our answer is approximately <span class="math inline">\(5/6\)</span> of an hour or 50 minutes.</p>
<p>How much in error are we?</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="fu">abs</span>(<span class="fl">50</span> <span class="op">-</span> <span class="fl">60</span><span class="op">/</span><span class="fl">70</span><span class="op">*</span><span class="fl">60</span>) <span class="op">/</span> (<span class="fl">60</span><span class="op">/</span><span class="fl">70</span><span class="op">*</span><span class="fl">60</span>) <span class="op">*</span> <span class="fl">100</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>2.7777777777777684</code></pre>
</div>
</div>
<p>Thats about <span class="math inline">\(3\)</span> percent. Not bad considering we could have done all the above in our head while driving without taking our eyes off the road to use the calculator on our phone for a division.</p>
</section>
<section id="example-4" class="level5">
<h5 class="anchored" data-anchor-id="example-4">Example</h5>
<p>A <span class="math inline">\(10\)</span>cm by <span class="math inline">\(10\)</span>cm by <span class="math inline">\(10\)</span>cm cube will contain <span class="math inline">\(1\)</span> liter (<span class="math inline">\(1000\)</span>cm<span class="math inline">\(^3\)</span>). In manufacturing such a cube, the side lengths are actually <span class="math inline">\(10.1\)</span> cm. What will be the volume in liters? Compute this with a linear approximation to <span class="math inline">\((10.1)^3\)</span>.</p>
<p>Here <span class="math inline">\(f(x) = x^3\)</span> and we are asked to approximate <span class="math inline">\(f(10.1)\)</span>. Letting <span class="math inline">\(c=10\)</span>, we have:</p>
<p><span class="math display">\[
f(c + \Delta) \approx f(c) + f'(c) \cdot \Delta = 1000 + f'(c) \cdot (0.1)
\]</span></p>
<p>Computing the derivative can be done easily, we get for our answer:</p>
<div class="cell" 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="fu">fp</span>(x) <span class="op">=</span> <span class="fl">3</span><span class="op">*</span>x<span class="op">^</span><span class="fl">2</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>c₀, Delta <span class="op">=</span> <span class="fl">10</span>, <span class="fl">0.1</span></span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a>approx₀ <span class="op">=</span> <span class="fl">1000</span> <span class="op">+</span> <span class="fu">fp</span>(c₀) <span class="op">*</span> Delta</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="19">
<pre><code>1030.0</code></pre>
</div>
</div>
<p>This is a relative error as a percent of:</p>
<div class="cell" data-execution_count="20">
<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>actual₀ <span class="op">=</span> <span class="fl">10.1</span><span class="op">^</span><span class="fl">3</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a>(actual₀ <span class="op">-</span> approx₀)<span class="op">/</span>actual₀ <span class="op">*</span> <span class="fl">100</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">
<pre><code>0.029214763452615394</code></pre>
</div>
</div>
<p>The manufacturer may be interested instead in comparing the volume of the actual object to the <span class="math inline">\(1\)</span> liter target. They might use the approximate value for this comparison, which would yield:</p>
<div class="cell" data-execution_count="21">
<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="fl">1000</span> <span class="op">-</span> approx₀)<span class="op">/</span>approx₀ <span class="op">*</span> <span class="fl">100</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="21">
<pre><code>-2.912621359223301</code></pre>
</div>
</div>
<p>This is off by about <span class="math inline">\(3\)</span> percent. Not so bad for some applications, devastating for others.</p>
</section>
<section id="example-eratosthenes-and-the-circumference-of-the-earth" class="level5">
<h5 class="anchored" data-anchor-id="example-eratosthenes-and-the-circumference-of-the-earth">Example: Eratosthenes and the circumference of the earth</h5>
<p><a href="https://en.wikipedia.org/wiki/Eratosthenes">Eratosthenes</a> is said to have been the first person to estimate the radius (or by relation the circumference) of the earth. The basic idea is based on the difference of shadows cast by the sun. Suppose Eratosthenes sized the circumference as <span class="math inline">\(252,000\)</span> <em>stadia</em>. Taking <span class="math inline">\(1\)</span>`stadia as<code>160</code>meters and the actual radius of the earth as<code>6378.137</code>kilometers, we can convert to see that Eratosthenes estimated the radius as<code>6417</code>.</p>
<p>If Eratosthenes were to have estimated the volume of a spherical earth, what would be his approximate percentage change between his estimate and the actual?</p>
<p>Using <span class="math inline">\(V = 4/3 \pi r^3\)</span> we get <span class="math inline">\(V' = 4\pi r^2\)</span>:</p>
<div class="cell" data-execution_count="22">
<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">6417</span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>rₐ <span class="op">=</span> <span class="fl">6378.137</span></span>
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>Δᵣ <span class="op">=</span> rₑ <span class="op">-</span> rₐ</span>
<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a><span class="fu">Vₛ</span>(r) <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 class="op">*</span> r<span class="op">^</span><span class="fl">3</span></span>
<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a>Δᵥ <span class="op">=</span> Vₛ<span class="op">'</span>(rₑ) <span class="op">*</span> Δᵣ</span>
<span id="cb26-6"><a href="#cb26-6" aria-hidden="true" tabindex="-1"></a>Δᵥ <span class="op">/</span> <span class="fu">Vₛ</span>(rₑ) <span class="op">*</span> <span class="fl">100</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="22">
<pre><code>1.8168770453483072</code></pre>
</div>
</div>
</section>
<section id="example-a-simple-pendulum" class="level5">
<h5 class="anchored" data-anchor-id="example-a-simple-pendulum">Example: a simple pendulum</h5>
<p>A <em>simple</em> pendulum is comprised of a massless “bob” on a rigid “rod” of length <span class="math inline">\(l\)</span>. The rod swings back and forth making an angle <span class="math inline">\(\theta\)</span> with the perpendicular. At rest <span class="math inline">\(\theta=0\)</span>, here we have <span class="math inline">\(\theta\)</span> swinging with <span class="math inline">\(\lvert\theta\rvert \leq \theta_0\)</span> for some <span class="math inline">\(\theta_0\)</span>.</p>
<p>According to <a href="http://tinyurl.com/yz5sz7e">Wikipedia</a> - and many introductory physics book - while swinging, the angle <span class="math inline">\(\theta\)</span> varies with time following this equation:</p>
<p><span class="math display">\[
\theta''(t) + \frac{g}{l} \sin(\theta(t)) = 0.
\]</span></p>
<p>That is, the second derivative of <span class="math inline">\(\theta\)</span> is proportional to the sine of <span class="math inline">\(\theta\)</span> where the proportionality constant involves <span class="math inline">\(g\)</span> from gravity and the length of the “rod.”</p>
<p>This would be much easier if the second derivative were proportional to the angle <span class="math inline">\(\theta\)</span> and not its sine.</p>
<p><a href="http://en.wikipedia.org/wiki/Christiaan_Huygens">Huygens</a> used the approximation of <span class="math inline">\(\sin(x) \approx x\)</span>, noted above, to say that when the angle is not too big, we have the pendulums swing obeying <span class="math inline">\(\theta''(t) = -g/l \cdot t\)</span>. Without getting too involved in why, we can verify by taking two derivatives that <span class="math inline">\(\theta_0\sin(\sqrt{g/l}\cdot t)\)</span> will be a solution to this modified equation.</p>
<p>With this solution, the motion is periodic with constant amplitude (assuming frictionless behaviour), as the sine function is. More surprisingly, the period is found from <span class="math inline">\(T = 2\pi/(\sqrt{g/l}) = 2\pi \sqrt{l/g}\)</span>. It depends on <span class="math inline">\(l\)</span> - longer “rods” take more time to swing back and forth - but does not depend on the how wide the pendulum is swinging between (provided <span class="math inline">\(\theta_0\)</span> is not so big the approximation of <span class="math inline">\(\sin(x) \approx x\)</span> fails). This latter fact may be surprising, though not to Galileo who discovered it.</p>
</section>
</section>
</section>
<section id="differentials" class="level2" data-number="29.2">
<h2 data-number="29.2" class="anchored" data-anchor-id="differentials"><span class="header-section-number">29.2</span> Differentials</h2>
<p>The Leibniz notation for a derivative is <span class="math inline">\(dy/dx\)</span> indicating the change in <span class="math inline">\(y\)</span> as <span class="math inline">\(x\)</span> changes. It proves convenient to decouple this using <em>differentials</em> <span class="math inline">\(dx\)</span> and <span class="math inline">\(dy\)</span>. What do these notations mean? They measure change along the tangent line in same way <span class="math inline">\(\Delta_x\)</span> and <span class="math inline">\(\Delta_y\)</span> measure change for the function. The differential <span class="math inline">\(dy\)</span> depends on both <span class="math inline">\(x\)</span> and <span class="math inline">\(dx\)</span>, it being defined by <span class="math inline">\(dy=f'(x)dx\)</span>. As tangent lines locally represent a function, <span class="math inline">\(dy\)</span> and <span class="math inline">\(dx\)</span> are often associated with an <em>infinitesimal</em> difference.</p>
<p>Taking <span class="math inline">\(dx = \Delta_x\)</span>, as in the previous graphic, we can compare <span class="math inline">\(dy\)</span> the change along the tangent line given by <span class="math inline">\(dy/dx \cdot dx\)</span> and <span class="math inline">\(\Delta_y\)</span> the change along the function given by <span class="math inline">\(f(x + \Delta_x) - f(x)\)</span>. The linear approximation, <span class="math inline">\(f(x + \Delta_x) - f(x)\approx f'(x)dx\)</span>, says that</p>
<p><span class="math display">\[
\Delta_y \approx dy; \quad \text{ when } \Delta_x = dx
\]</span></p>
</section>
<section id="the-error-in-approximation" class="level2" data-number="29.3">
<h2 data-number="29.3" class="anchored" data-anchor-id="the-error-in-approximation"><span class="header-section-number">29.3</span> The error in approximation</h2>
<p>How good is the approximation? Graphically we can see it is pretty good for the graphs we choose, but are there graphs out there for which the approximation is not so good? Of course. However, we can say this (the <a href="http://en.wikipedia.org/wiki/Taylor%27s_theorem">Lagrange</a> form of a more general Taylor remainder theorem):</p>
<blockquote class="blockquote">
<p>Let <span class="math inline">\(f(x)\)</span> be twice differentiable on <span class="math inline">\(I=(a,b)\)</span>, <span class="math inline">\(f\)</span> is continuous on <span class="math inline">\([a,b]\)</span>, and <span class="math inline">\(a &lt; c &lt; b\)</span>. Then for any <span class="math inline">\(x\)</span> in <span class="math inline">\(I\)</span>, there exists some value <span class="math inline">\(\xi\)</span> between <span class="math inline">\(c\)</span> and <span class="math inline">\(x\)</span> such that <span class="math inline">\(f(x) = f(c) + f'(c)(x-c) + (f''(\xi)/2)\cdot(x-c)^2\)</span>.</p>
</blockquote>
<p>That is, the error is basically a constant depending on the concavity of <span class="math inline">\(f\)</span> times a quadratic function centered at <span class="math inline">\(c\)</span>.</p>
<p>For <span class="math inline">\(\sin(x)\)</span> at <span class="math inline">\(c=0\)</span> we get <span class="math inline">\(\lvert\sin(x) - x\rvert = \lvert-\sin(\xi)\cdot x^2/2\rvert\)</span>. Since <span class="math inline">\(\lvert\sin(\xi)\rvert \leq 1\)</span>, we must have this bound: <span class="math inline">\(\lvert\sin(x) - x\rvert \leq x^2/2\)</span>.</p>
<p>Can we verify? Lets do so graphically:</p>
<div class="cell" data-hold="true" data-execution_count="23">
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="fu">h</span>(x) <span class="op">=</span> <span class="fu">abs</span>(<span class="fu">sin</span>(x) <span class="op">-</span> x)</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="op">^</span><span class="fl">2</span><span class="op">/</span><span class="fl">2</span></span>
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(h, <span class="op">-</span><span class="fl">2</span>, <span class="fl">2</span>, label<span class="op">=</span><span class="st">"h"</span>)</span>
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(g, <span class="op">-</span><span class="fl">2</span>, <span class="fl">2</span>, label<span class="op">=</span><span class="st">"f"</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="linearization_files/figure-html/cell-24-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The graph shows a tight bound near <span class="math inline">\(0\)</span> and then a bound over this viewing window.</p>
<p>Similarly, for <span class="math inline">\(f(x) = \log(1 + x)\)</span> we have the following at <span class="math inline">\(c=0\)</span>:</p>
<p><span class="math display">\[
f'(x) = 1/(1+x), \quad f''(x) = -1/(1+x)^2.
\]</span></p>
<p>So, as <span class="math inline">\(f(c)=0\)</span> and <span class="math inline">\(f'(c) = 1\)</span>, we have</p>
<p><span class="math display">\[
\lvert f(x) - x\rvert \leq \lvert f''(\xi)\rvert \cdot \frac{x^2}{2}
\]</span></p>
<p>We see that <span class="math inline">\(\lvert f''(x)\rvert\)</span> is decreasing for <span class="math inline">\(x &gt; -1\)</span>. So if <span class="math inline">\(-1 &lt; x &lt; c\)</span> we have</p>
<p><span class="math display">\[
\lvert f(x) - x\rvert \leq \lvert f''(x)\rvert \cdot \frac{x^2}{2} = \frac{x^2}{2(1+x)^2}.
\]</span></p>
<p>And for <span class="math inline">\(c=0 &lt; x\)</span>, we have</p>
<p><span class="math display">\[
\lvert f(x) - x\rvert \leq \lvert f''(0)\rvert \cdot \frac{x^2}{2} = x^2/2.
\]</span></p>
<p>Plotting we verify the bound on <span class="math inline">\(|\log(1+x)-x|\)</span>:</p>
<div class="cell" data-hold="true" data-execution_count="24">
<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">h</span>(x) <span class="op">=</span> <span class="fu">abs</span>(<span class="fu">log</span>(<span class="fl">1</span><span class="op">+</span>x) <span class="op">-</span> x)</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> x <span class="op">&lt;</span> <span class="fl">0</span> ? x<span class="op">^</span><span class="fl">2</span><span class="op">/</span>(<span class="fl">2</span><span class="fu">*</span>(<span class="fl">1</span><span class="op">+</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 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">plot</span>(h, <span class="op">-</span><span class="fl">0.5</span>, <span class="fl">2</span>, label<span class="op">=</span><span class="st">"h"</span>)</span>
<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(g, <span class="op">-</span><span class="fl">0.5</span>, <span class="fl">2</span>, label<span class="op">=</span><span class="st">"g"</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">
<p><img src="linearization_files/figure-html/cell-25-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Again, we see the very close bound near <span class="math inline">\(0\)</span>, which widens at the edges of the viewing window.</p>
<section id="why-is-the-remainder-term-as-it-is" class="level3" data-number="29.3.1">
<h3 data-number="29.3.1" class="anchored" data-anchor-id="why-is-the-remainder-term-as-it-is"><span class="header-section-number">29.3.1</span> Why is the remainder term as it is?</h3>
<p>To see formally why the remainder is as it is, we recall the mean value theorem in the extended form of Cauchy. Suppose <span class="math inline">\(c=0\)</span>, <span class="math inline">\(x &gt; 0\)</span>, and let <span class="math inline">\(h(x) = f(x) - (f(0) + f'(0) x)\)</span> and <span class="math inline">\(g(x) = x^2\)</span>. Then we have that there exists a <span class="math inline">\(e\)</span> with <span class="math inline">\(0 &lt; e &lt; x\)</span> such that</p>
<p><span class="math display">\[
\text{error} = h(x) - h(0) = (g(x) - g(0)) \frac{h'(e)}{g'(e)} = x^2 \cdot \frac{1}{2} \cdot \frac{f'(e) - f'(0)}{e} =
x^2 \cdot \frac{1}{2} \cdot f''(\xi).
\]</span></p>
<p>The value of <span class="math inline">\(\xi\)</span>, from the mean value theorem applied to <span class="math inline">\(f'(x)\)</span>, satisfies <span class="math inline">\(0 &lt; \xi &lt; e &lt; x\)</span>, so is in <span class="math inline">\([0,x].\)</span></p>
</section>
<section id="the-big-and-small-oh" class="level3" data-number="29.3.2">
<h3 data-number="29.3.2" class="anchored" data-anchor-id="the-big-and-small-oh"><span class="header-section-number">29.3.2</span> The big (and small) “oh”</h3>
<p><code>SymPy</code> can find the tangent line expression as a special case of its <code>series</code> function (which implements <a href="../taylor_series_polynomials.html">Taylor series</a>). The <code>series</code> function needs an expression to approximate; a variable specified, as there may be parameters in the expression; a value <span class="math inline">\(c\)</span> for <em>where</em> the expansion is taken, with default <span class="math inline">\(0\)</span>; and a number of terms, for this example <span class="math inline">\(2\)</span> for a constant and linear term. (There is also an optional <code>dir</code> argument for one-sided expansions.)</p>
<p>Here we see the answer provided for <span class="math inline">\(e^{\sin(x)}\)</span>:</p>
<div class="cell" data-execution_count="25">
<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="pp">@syms</span> x</span>
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a><span class="fu">series</span>(<span class="fu">exp</span>(<span class="fu">sin</span>(x)), x, <span class="fl">0</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="25">
<span class="math-left-align" style="padding-left: 4px; width:0; float:left;">
\[
1 + x + O\left(x^{2}\right)
\]
</span>
</div>
</div>
<p>The expression <span class="math inline">\(1 + x\)</span> comes from the fact that <code>exp(sin(0))</code> is <span class="math inline">\(1\)</span>, and the derivative <code>exp(sin(0)) * cos(0)</code> is <em>also</em> <span class="math inline">\(1\)</span>. But what is the <span class="math inline">\(\mathcal{O}(x^2)\)</span>?</p>
<p>We know the answer is <em>precisely</em> <span class="math inline">\(f''(\xi)/2 \cdot x^2\)</span> for some <span class="math inline">\(\xi\)</span>, but were we only concerned about the scale as <span class="math inline">\(x\)</span> goes to zero that when <span class="math inline">\(f''\)</span> is continuous that the error when divided by <span class="math inline">\(x^2\)</span> goes to some finite value (<span class="math inline">\(f''(0)/2\)</span>). More generally, if the error divided by <span class="math inline">\(x^2\)</span> is <em>bounded</em> as <span class="math inline">\(x\)</span> goes to <span class="math inline">\(0\)</span>, then we say the error is “big oh” of <span class="math inline">\(x^2\)</span>.</p>
<p>The <a href="http://en.wikipedia.org/wiki/Big_O_notation">big</a> “oh” notation, <span class="math inline">\(f(x) = \mathcal{O}(g(x))\)</span>, says that the ratio <span class="math inline">\(f(x)/g(x)\)</span> is bounded as <span class="math inline">\(x\)</span> goes to <span class="math inline">\(0\)</span> (or some other value <span class="math inline">\(c\)</span>, depending on the context). A little “oh” (e.g., <span class="math inline">\(f(x) = \mathcal{o}(g(x))\)</span>) would mean that the limit <span class="math inline">\(f(x)/g(x)\)</span> would be <span class="math inline">\(0\)</span>, as <span class="math inline">\(x\rightarrow 0\)</span>, a much stronger assertion.</p>
<p>Big “oh” and little “oh” give us a sense of how good an approximation is without being bogged down in the details of the exact value. As such they are useful guides in focusing on what is primary and what is secondary. Applying this to our case, we have this rough form of the tangent line approximation valid for functions having a continuous second derivative at <span class="math inline">\(c\)</span>:</p>
<p><span class="math display">\[
f(x) = f(c) + f'(c)(x-c) + \mathcal{O}((x-c)^2).
\]</span></p>
<section id="example-the-algebra-of-tangent-line-approximations" class="level5">
<h5 class="anchored" data-anchor-id="example-the-algebra-of-tangent-line-approximations">Example: the algebra of tangent line approximations</h5>
<p>Suppose <span class="math inline">\(f(x)\)</span> and <span class="math inline">\(g(x)\)</span> are represented by their tangent lines about <span class="math inline">\(c\)</span>, respectively:</p>
<p><span class="math display">\[
\begin{align*}
f(x) &amp;= f(c) + f'(c)(x-c) + \mathcal{O}((x-c)^2), \\
g(x) &amp;= g(c) + g'(c)(x-c) + \mathcal{O}((x-c)^2).
\end{align*}
\]</span></p>
<p>Consider the sum, after rearranging we have:</p>
<p><span class="math display">\[
\begin{align*}
f(x) + g(x) &amp;= \left(f(c) + f'(c)(x-c) + \mathcal{O}((x-c)^2)\right) + \left(g(c) + g'(c)(x-c) + \mathcal{O}((x-c)^2)\right)\\
&amp;= \left(f(c) + g(c)\right) + \left(f'(c)+g'(c)\right)(x-c) + \mathcal{O}((x-c)^2).
\end{align*}
\]</span></p>
<p>The two big “Oh” terms become just one as the sum of a constant times <span class="math inline">\((x-c)^2\)</span> plus a constant time <span class="math inline">\((x-c)^2\)</span> is just some other constant times <span class="math inline">\((x-c)^2\)</span>. What we can read off from this is the term multiplying <span class="math inline">\((x-c)\)</span> is just the derivative of <span class="math inline">\(f(x) + g(x)\)</span> (from the sum rule), so this too is a tangent line approximation.</p>
<p>Is it a coincidence that a basic algebraic operation with tangent lines approximations produces a tangent line approximation? Lets try multiplication:</p>
<p><span class="math display">\[
\begin{align*}
f(x) \cdot g(x) &amp;= [f(c) + f'(c)(x-c) + \mathcal{O}((x-c)^2)] \cdot [g(c) + g'(c)(x-c) + \mathcal{O}((x-c)^2)]\\
&amp;=[(f(c) + f'(c)(x-c)] \cdot [g(c) + g'(c)(x-c)] + (f(c) + f'(c)(x-c) \cdot \mathcal{O}((x-c)^2)) + g(c) + g'(c)(x-c) \cdot \mathcal{O}((x-c)^2)) + [\mathcal{O}((x-c)^2))]^2\\
&amp;= [(f(c) + f'(c)(x-c)] \cdot [g(c) + g'(c)(x-c)] + \mathcal{O}((x-c)^2)\\
&amp;= f(c) \cdot g(c) + [f'(c)\cdot g(c) + f(c)\cdot g'(c)] \cdot (x-c) + [f'(c)\cdot g'(c) \cdot (x-c)^2 + \mathcal{O}((x-c)^2)] \\
&amp;= f(c) \cdot g(c) + [f'(c)\cdot g(c) + f(c)\cdot g'(c)] \cdot (x-c) + \mathcal{O}((x-c)^2)
\end{align*}
\]</span></p>
<p>The big “oh” notation just sweeps up many things including any products of it <em>and</em> the term <span class="math inline">\(f'(c)\cdot g'(c) \cdot (x-c)^2\)</span>. Again, we see from the product rule that this is just a tangent line approximation for <span class="math inline">\(f(x) \cdot g(x)\)</span>.</p>
<p>The basic mathematical operations involving tangent lines can be computed just using the tangent lines when the desired accuracy is at the tangent line level. This is even true for composition, though there the outer and inner functions may have different “<span class="math inline">\(c\)</span>”s.</p>
<p>Knowing this can simplify the task of finding tangent line approximations of compound expressions.</p>
<p>For example, suppose we know that at <span class="math inline">\(c=0\)</span> we have these formula where <span class="math inline">\(a \approx b\)</span> is a shorthand for the more formal <span class="math inline">\(a=b + \mathcal{O}(x^2)\)</span>:</p>
<p><span class="math display">\[
\sin(x) \approx x, \quad e^x \approx 1 + x, \quad \text{and}\quad 1/(1+x) \approx 1 - x.
\]</span></p>
<p>Then we can immediately see these tangent line approximations about <span class="math inline">\(x=0\)</span>:</p>
<p><span class="math display">\[
e^x \cdot \sin(x) \approx (1+x) \cdot x = x + x^2 \approx x,
\]</span></p>
<p>and</p>
<p><span class="math display">\[
\frac{\sin(x)}{e^x} \approx \frac{x}{1 + x} \approx x \cdot(1-x) = x-x^2 \approx x.
\]</span></p>
<p>Since <span class="math inline">\(\sin(0) = 0\)</span>, we can use these to find the tangent line approximation of</p>
<p><span class="math display">\[
e^{\sin(x)} \approx e^x \approx 1 + x.
\]</span></p>
<p>Note that <span class="math inline">\(\sin(\exp(x))\)</span> is approximately <span class="math inline">\(\sin(1+x)\)</span> but not approximately <span class="math inline">\(1+x\)</span>, as the expansion for <span class="math inline">\(\sin\)</span> about <span class="math inline">\(1\)</span> is not simply <span class="math inline">\(x\)</span>.</p>
</section>
</section>
<section id="the-taylorseries-package" class="level3" data-number="29.3.3">
<h3 data-number="29.3.3" class="anchored" data-anchor-id="the-taylorseries-package"><span class="header-section-number">29.3.3</span> The TaylorSeries package</h3>
<p>The <code>TaylorSeries</code> packages will do these calculations in a manner similar to how <code>SymPy</code> transforms a function and a symbolic variable into a symbolic expression.</p>
<p>For example, we have</p>
<div class="cell" data-execution_count="26">
<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>t <span class="op">=</span> <span class="fu">Taylor1</span>(<span class="dt">Float64</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="26">
<pre><code> 1.0 t + 𝒪(t²)</code></pre>
</div>
</div>
<p>The number type and the order is specified to the constructor. Linearization is order <span class="math inline">\(1\)</span>, other orders will be discussed later. This variable can now be composed with mathematical functions and the linearization of the function will be returned:</p>
<div class="cell" data-execution_count="27">
<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">sin</span>(t), <span class="fu">exp</span>(t), <span class="fl">1</span><span class="op">/</span>(<span class="fl">1</span><span class="op">+</span>t)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="27">
<pre><code>( 1.0 t + 𝒪(t²), 1.0 + 1.0 t + 𝒪(t²), 1.0 - 1.0 t + 𝒪(t²))</code></pre>
</div>
</div>
<div class="cell" data-execution_count="28">
<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">sin</span>(t)<span class="op">/</span><span class="fu">exp</span>(t), <span class="fu">exp</span>(<span class="fu">sin</span>(t))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="28">
<pre><code>( 1.0 t + 𝒪(t²), 1.0 + 1.0 t + 𝒪(t²))</code></pre>
</div>
</div>
<section id="example-automatic-differentiation" class="level5">
<h5 class="anchored" data-anchor-id="example-automatic-differentiation">Example: Automatic differentiation</h5>
<p>Automatic differentiation (forward mode) essentially uses this technique. A “dual” is introduced which has terms <span class="math inline">\(a +b\epsilon\)</span> where <span class="math inline">\(\epsilon^2 = 0\)</span>. The <span class="math inline">\(\epsilon\)</span> is like <span class="math inline">\(x\)</span> in a linear expansion, so the <code>a</code> coefficient encodes the value and the <code>b</code> coefficient reflects the derivative at the value. Numbers are treated like a variable, so their “b coefficient” is a <code>1</code>. Here then is how <code>0</code> is encoded:</p>
<div class="cell" data-execution_count="29">
<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">Dual</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="29">
<pre><code>0 + 1ɛ</code></pre>
</div>
</div>
<p>Then what is <span class="math inline">\(\(x)\)</span>? It should reflect both <span class="math inline">\((\sin(0), \cos(0))\)</span> the latter being the derivative of <span class="math inline">\(\sin\)</span>. We can see this is <em>almost</em> what is computed behind the scenes through:</p>
<div class="cell" data-hold="true" data-execution_count="30">
<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>x <span class="op">=</span> <span class="fu">Dual</span>(<span class="fl">0</span>, <span class="fl">1</span>)</span>
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a><span class="pp">@code_lowered</span> <span class="fu">sin</span>(x)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="30">
<div class="ansi-escaped-output">
<pre>CodeInfo(
<span class="ansi-bright-black-fg">1 ─</span> x = DualNumbers.value(z)
<span class="ansi-bright-black-fg"></span> xp = DualNumbers.epsilon(z)
<span class="ansi-bright-black-fg"></span> %3 = DualNumbers.sin(x)
<span class="ansi-bright-black-fg"></span> %4 = xp
<span class="ansi-bright-black-fg"></span> %5 = DualNumbers.cos(x)
<span class="ansi-bright-black-fg"></span> %6 = %4 * %5
<span class="ansi-bright-black-fg"></span> %7 = DualNumbers.Dual(%3, %6)
<span class="ansi-bright-black-fg">└──</span> return %7
)</pre>
</div>
</div>
</div>
<p>This output of <code>@code_lowered</code> can be confusing, but this simple case neednt be. Working from the end we see an assignment to a variable named <code>%7</code> of <code>Dual(%3, %6)</code>. The value of <code>%3</code> is <code>sin(x)</code> where <code>x</code> is the value <code>0</code> above. The value of <code>%6</code> is <code>cos(x)</code> <em>times</em> the value <code>1</code> above (the <code>xp</code>), which reflects the <em>chain</em> rule being used. (The derivative of <code>sin(u)</code> is <code>cos(u)*du</code>.) So this dual number encodes both the function value at <code>0</code> and the derivative of the function at <code>0</code>.)</p>
<p>Similarly, we can see what happens to <code>log(x)</code> at <code>1</code> (encoded by <code>Dual(1,1)</code>):</p>
<div class="cell" data-hold="true" data-execution_count="31">
<div class="sourceCode cell-code" id="cb40"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a>x <span class="op">=</span> <span class="fu">Dual</span>(<span class="fl">1</span>, <span class="fl">1</span>)</span>
<span id="cb40-2"><a href="#cb40-2" aria-hidden="true" tabindex="-1"></a><span class="pp">@code_lowered</span> <span class="fu">log</span>(x)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="31">
<div class="ansi-escaped-output">
<pre>CodeInfo(
<span class="ansi-bright-black-fg">1 ─</span> x = DualNumbers.value(z)
<span class="ansi-bright-black-fg"></span> xp = DualNumbers.epsilon(z)
<span class="ansi-bright-black-fg"></span> %3 = DualNumbers.log(x)
<span class="ansi-bright-black-fg"></span> %4 = xp
<span class="ansi-bright-black-fg"></span> %5 = 1 / x
<span class="ansi-bright-black-fg"></span> %6 = %4 * %5
<span class="ansi-bright-black-fg"></span> %7 = DualNumbers.Dual(%3, %6)
<span class="ansi-bright-black-fg">└──</span> return %7
)</pre>
</div>
</div>
</div>
<p>We can see the derivative again reflects the chain rule, it being given by <code>1/x * xp</code> where <code>xp</code> acts like <code>dx</code> (from assignments <code>%5</code> and <code>%4</code>). Comparing the two outputs, we see only the assignment to <code>%4</code> differs, it reflecting the derivative of the function.</p>
</section>
</section>
</section>
<section id="questions" class="level2" data-number="29.4">
<h2 data-number="29.4" class="anchored" data-anchor-id="questions"><span class="header-section-number">29.4</span> Questions</h2>
<section id="question" class="level6">
<h6 class="anchored" data-anchor-id="question">Question</h6>
<p>What is the right linear approximation for <span class="math inline">\(\sqrt{1 + x}\)</span> near <span class="math inline">\(0\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="32">
<div class="cell-output cell-output-display" data-execution_count="32">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="17466537924534489082" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_17466537924534489082">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_17466537924534489082_1">
<input class="form-check-input" type="radio" name="radio_17466537924534489082" id="radio_17466537924534489082_1" value="1">
<span class="label-body px-1">
\(1 + (1/2) \cdot x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17466537924534489082_2">
<input class="form-check-input" type="radio" name="radio_17466537924534489082" id="radio_17466537924534489082_2" value="2">
<span class="label-body px-1">
\(1 - (1/2) \cdot x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17466537924534489082_3">
<input class="form-check-input" type="radio" name="radio_17466537924534489082" id="radio_17466537924534489082_3" value="3">
<span class="label-body px-1">
\(1 + x^{1/2}\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17466537924534489082_4">
<input class="form-check-input" type="radio" name="radio_17466537924534489082" id="radio_17466537924534489082_4" value="4">
<span class="label-body px-1">
\(1 + 1/2\)
</span>
</label>
</div>
</div>
</div>
<div id="17466537924534489082_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_17466537924534489082"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 1;
var msgBox = document.getElementById('17466537924534489082_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_17466537924534489082")
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_17466537924534489082")
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>What is the right linear approximation for <span class="math inline">\((1 + x)^k\)</span> near <span class="math inline">\(0\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="33">
<div class="cell-output cell-output-display" data-execution_count="33">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="17507395460573168060" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_17507395460573168060">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_17507395460573168060_1">
<input class="form-check-input" type="radio" name="radio_17507395460573168060" id="radio_17507395460573168060_1" value="1">
<span class="label-body px-1">
\(1 + x^k\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17507395460573168060_2">
<input class="form-check-input" type="radio" name="radio_17507395460573168060" id="radio_17507395460573168060_2" value="2">
<span class="label-body px-1">
\(1 + k\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17507395460573168060_3">
<input class="form-check-input" type="radio" name="radio_17507395460573168060" id="radio_17507395460573168060_3" value="3">
<span class="label-body px-1">
\(1 - k \cdot x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17507395460573168060_4">
<input class="form-check-input" type="radio" name="radio_17507395460573168060" id="radio_17507395460573168060_4" value="4">
<span class="label-body px-1">
\(1 + k \cdot x\)
</span>
</label>
</div>
</div>
</div>
<div id="17507395460573168060_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_17507395460573168060"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 4;
var msgBox = document.getElementById('17507395460573168060_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_17507395460573168060")
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_17507395460573168060")
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>What is the right linear approximation for <span class="math inline">\(\cos(\sin(x))\)</span> near <span class="math inline">\(0\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="34">
<div class="cell-output cell-output-display" data-execution_count="34">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="17388172503463809428" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_17388172503463809428">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_17388172503463809428_1">
<input class="form-check-input" type="radio" name="radio_17388172503463809428" id="radio_17388172503463809428_1" value="1">
<span class="label-body px-1">
\(1 + x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17388172503463809428_2">
<input class="form-check-input" type="radio" name="radio_17388172503463809428" id="radio_17388172503463809428_2" value="2">
<span class="label-body px-1">
\(1 - x^2/2\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17388172503463809428_3">
<input class="form-check-input" type="radio" name="radio_17388172503463809428" id="radio_17388172503463809428_3" value="3">
<span class="label-body px-1">
\(1\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_17388172503463809428_4">
<input class="form-check-input" type="radio" name="radio_17388172503463809428" id="radio_17388172503463809428_4" value="4">
<span class="label-body px-1">
\(x\)
</span>
</label>
</div>
</div>
</div>
<div id="17388172503463809428_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_17388172503463809428"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 3;
var msgBox = document.getElementById('17388172503463809428_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_17388172503463809428")
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_17388172503463809428")
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>What is the right linear approximation for <span class="math inline">\(\tan(x)\)</span> near <span class="math inline">\(0\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="35">
<div class="cell-output cell-output-display" data-execution_count="35">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="16609923048795162895" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_16609923048795162895">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_16609923048795162895_1">
<input class="form-check-input" type="radio" name="radio_16609923048795162895" id="radio_16609923048795162895_1" value="1">
<span class="label-body px-1">
\(1 - x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_16609923048795162895_2">
<input class="form-check-input" type="radio" name="radio_16609923048795162895" id="radio_16609923048795162895_2" value="2">
<span class="label-body px-1">
\(x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_16609923048795162895_3">
<input class="form-check-input" type="radio" name="radio_16609923048795162895" id="radio_16609923048795162895_3" value="3">
<span class="label-body px-1">
\(1\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_16609923048795162895_4">
<input class="form-check-input" type="radio" name="radio_16609923048795162895" id="radio_16609923048795162895_4" value="4">
<span class="label-body px-1">
\(1 + x\)
</span>
</label>
</div>
</div>
</div>
<div id="16609923048795162895_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_16609923048795162895"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 2;
var msgBox = document.getElementById('16609923048795162895_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_16609923048795162895")
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_16609923048795162895")
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>What is the right linear approximation of <span class="math inline">\(\sqrt{25 + x}\)</span> near <span class="math inline">\(x=0\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="36">
<div class="cell-output cell-output-display" data-execution_count="36">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="5858734404270288908" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_5858734404270288908">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_5858734404270288908_1">
<input class="form-check-input" type="radio" name="radio_5858734404270288908" id="radio_5858734404270288908_1" value="1">
<span class="label-body px-1">
\(1 - (1/2) \cdot x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_5858734404270288908_2">
<input class="form-check-input" type="radio" name="radio_5858734404270288908" id="radio_5858734404270288908_2" value="2">
<span class="label-body px-1">
\(5 \cdot (1 + (1/2) \cdot (x/25))\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_5858734404270288908_3">
<input class="form-check-input" type="radio" name="radio_5858734404270288908" id="radio_5858734404270288908_3" value="3">
<span class="label-body px-1">
\(1 + x\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_5858734404270288908_4">
<input class="form-check-input" type="radio" name="radio_5858734404270288908" id="radio_5858734404270288908_4" value="4">
<span class="label-body px-1">
\(25\)
</span>
</label>
</div>
</div>
</div>
<div id="5858734404270288908_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_5858734404270288908"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 2;
var msgBox = document.getElementById('5858734404270288908_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_5858734404270288908")
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_5858734404270288908")
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) = \sqrt{x}\)</span>. Find the actual error in approximating <span class="math inline">\(f(26)\)</span> by the value of the tangent line at <span class="math inline">\((25, f(25))\)</span> at <span class="math inline">\(x=26\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="37">
<div class="cell-output cell-output-display" data-execution_count="37">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="17812931405383772427" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_17812931405383772427">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="17812931405383772427" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="17812931405383772427_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("17812931405383772427").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.0009804864072151531) <= 0.001);
var msgBox = document.getElementById('17812931405383772427_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_17812931405383772427")
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_17812931405383772427")
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>An estimate of some quantity was <span class="math inline">\(12.34\)</span> the actual value was <span class="math inline">\(12\)</span>. What was the <em>percentage error</em>?</p>
<div class="cell" data-hold="true" data-execution_count="38">
<div class="cell-output cell-output-display" data-execution_count="38">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="6311614915903402577" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_6311614915903402577">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="6311614915903402577" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="6311614915903402577_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("6311614915903402577").addEventListener("change", function() {
var correct = (Math.abs(this.value - 2.833333333333332) <= 0.001);
var msgBox = document.getElementById('6311614915903402577_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_6311614915903402577")
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_6311614915903402577")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
</section>
<section id="question-7" class="level6">
<h6 class="anchored" data-anchor-id="question-7">Question</h6>
<p>Find the percentage error in estimating <span class="math inline">\(\sin(5^\circ)\)</span> by <span class="math inline">\(5 \pi/180\)</span>.</p>
<div class="cell" data-hold="true" data-execution_count="39">
<div class="cell-output cell-output-display" data-execution_count="39">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="2254795534943209696" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_2254795534943209696">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="2254795534943209696" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="2254795534943209696_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("2254795534943209696").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.12703678331200158) <= 0.001);
var msgBox = document.getElementById('2254795534943209696_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_2254795534943209696")
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_2254795534943209696")
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>The side length of a square is measured roughly to be <span class="math inline">\(2.0\)</span> cm. The actual length <span class="math inline">\(2.2\)</span> cm. What is the difference in area (in absolute values) as <em>estimated</em> by a tangent line approximation.</p>
<div class="cell" data-hold="true" data-execution_count="40">
<div class="cell-output cell-output-display" data-execution_count="40">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="15037203957059983690" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_15037203957059983690">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="15037203957059983690" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="15037203957059983690_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("15037203957059983690").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.7999999999999998) <= 0.001);
var msgBox = document.getElementById('15037203957059983690_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_15037203957059983690")
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_15037203957059983690")
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>The <a href="https://en.wikipedia.org/wiki/Birthday_problem">Birthday problem</a> computes the probability that in a group of <span class="math inline">\(n\)</span> people, under some assumptions, that no two share a birthday. Without trying to spoil the problem, we focus on the calculus specific part of the problem below:</p>
<p><span class="math display">\[
\begin{align*}
p
&amp;= \frac{365 \cdot 364 \cdot \cdots (365-n+1)}{365^n} \\
&amp;= \frac{365(1 - 0/365) \cdot 365(1 - 1/365) \cdot 365(1-2/365) \cdot \cdots \cdot 365(1-(n-1)/365)}{365^n}\\
&amp;= (1 - \frac{0}{365})\cdot(1 -\frac{1}{365})\cdot \cdots \cdot (1-\frac{n-1}{365}).
\end{align*}
\]</span></p>
<p>Taking logarithms, we have <span class="math inline">\(\log(p)\)</span> is</p>
<p><span class="math display">\[
\log(1 - \frac{0}{365}) + \log(1 -\frac{1}{365})+ \cdots + \log(1-\frac{n-1}{365}).
\]</span></p>
<p>Now, use the tangent line approximation for <span class="math inline">\(\log(1 - x)\)</span> and the sum formula for <span class="math inline">\(0 + 1 + 2 + \dots + (n-1)\)</span> to simplify the value of <span class="math inline">\(\log(p)\)</span>:</p>
<div class="cell" data-hold="true" data-execution_count="41">
<div class="cell-output cell-output-display" data-execution_count="41">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="12045164786041990837" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_12045164786041990837">
<div style="padding-top: 5px">
<div class="form-check">
<label class="form-check-label" for="radio_12045164786041990837_1">
<input class="form-check-input" type="radio" name="radio_12045164786041990837" id="radio_12045164786041990837_1" value="1">
<span class="label-body px-1">
\(-n(n-1)/2/365\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_12045164786041990837_2">
<input class="form-check-input" type="radio" name="radio_12045164786041990837" id="radio_12045164786041990837_2" value="2">
<span class="label-body px-1">
\(-n(n-1)/2\cdot 365\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_12045164786041990837_3">
<input class="form-check-input" type="radio" name="radio_12045164786041990837" id="radio_12045164786041990837_3" value="3">
<span class="label-body px-1">
\(-n^2/(2\cdot 365)\)
</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label" for="radio_12045164786041990837_4">
<input class="form-check-input" type="radio" name="radio_12045164786041990837" id="radio_12045164786041990837_4" value="4">
<span class="label-body px-1">
\(-n^2 / 2 \cdot 365\)
</span>
</label>
</div>
</div>
</div>
<div id="12045164786041990837_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.querySelectorAll('input[name="radio_12045164786041990837"]').forEach(function(rb) {
rb.addEventListener("change", function() {
var correct = rb.value == 1;
var msgBox = document.getElementById('12045164786041990837_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_12045164786041990837")
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_12045164786041990837")
if (explanation != null) {
explanation.style.display = "block";
}
}
})});
</script>
</div>
</div>
<p>If <span class="math inline">\(n = 10\)</span>, what is the approximation for <span class="math inline">\(p\)</span> (not <span class="math inline">\(\log(p)\)</span>)?</p>
<div class="cell" data-hold="true" data-execution_count="42">
<div class="cell-output cell-output-display" data-execution_count="42">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="7304358481197848893" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_7304358481197848893">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="7304358481197848893" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="7304358481197848893_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("7304358481197848893").addEventListener("change", function() {
var correct = (Math.abs(this.value - 0.8840093219278197) <= 0.001);
var msgBox = document.getElementById('7304358481197848893_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_7304358481197848893")
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_7304358481197848893")
if (explanation != null) {
explanation.style.display = "block";
}
}
});
</script>
</div>
</div>
<p>If <span class="math inline">\(n=100\)</span>, what is the approximation for <span class="math inline">\(p\)</span> (not <span class="math inline">\(\log(p)\)</span>?</p>
<div class="cell" data-hold="true" data-execution_count="43">
<div class="cell-output cell-output-display" data-execution_count="43">
<form class="mx-2 my-3 mw-100" name="WeaveQuestion" data-id="2176047214208863571" data-controltype="">
<div class="form-group ">
<div class="controls">
<div class="form" id="controls_2176047214208863571">
<div style="padding-top: 5px">
<br>
<div class="input-group">
<input id="2176047214208863571" type="number" class="form-control" placeholder="Numeric answer">
</div>
</div>
</div>
<div id="2176047214208863571_message" style="padding-bottom: 15px"></div>
</div>
</div>
</form>
<script text="text/javascript">
document.getElementById("2176047214208863571").addEventListener("change", function() {
var correct = (Math.abs(this.value - 1.2889999979257225e-6) <= 0.01);
var msgBox = document.getElementById('2176047214208863571_message');
if(correct) {
msgBox.innerHTML = "<div class='pluto-output admonition note alert alert-success'><span> 👍&nbsp; Correct </span></div>";
var explanation = document.getElementById("explanation_2176047214208863571")
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_2176047214208863571")
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="../derivatives/curve_sketching.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">28</span>&nbsp; <span class="chapter-title">Curve Sketching</span></span>
</a>
</div>
<div class="nav-page nav-page-next">
<a href="../derivatives/newtons_method.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">30</span>&nbsp; <span class="chapter-title">Newtons method</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>