{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Exploring the functional approach to error propagation" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def g(l,t):\n", " '''Function giving \"little g\" from the measured length and \n", " period of a simple pendulum'''\n", " return 4*np.pi**2*l/t**2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "l = 0.96 # length of pendulum in meters\n", "t = 1.970 # period of pendulum in seconds\n", "delta_t = 0.004 # uncertainty of the period in seconds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Two determinations of uncertainty in $g$ due to uncertainty in $T$: " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "g_best = g(l,t)\n", "g_plus = g(l, t + delta_t)\n", "g_minus = g(l, t - delta_t)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "g_best = 9.765590687774262\n", "uncertainty with plus sign: -0.03953676381878424\n", "uncertainty with minus sign: 0.03977833230749894\n" ] } ], "source": [ "print('g_best = ',g_best)\n", "print('uncertainty with plus sign:', g_plus - g_best)\n", "print('uncertainty with minus sign:', g_minus - g_best)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Since I'm only going to use one significant figure in \n", "in my uncertainty, these two values are equivalent, and my result \n", "is \n", "\n", "$$ g = 9.77 \\pm 0.04\\, \\mbox{m/s$^2$}. $$\n", "\n", "If $\\Delta T$ is large enough that the first order linear approximation\n", "\n", "$$ g(L,T\\pm \\Delta T)\\simeq g(L,T) \\pm \\frac{\\partial g}{\\partial T}\\, \\Delta T $$\n", "\n", "breaks down, then the two uncertainties will not be the same. For example, if \n", "$\\Delta t= 0.3\\,\\mbox{s}$, the two uncertaintiels are not equal:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "g_best = 9.765590687774262\n", "uncertainty with plus sign: -2.41064863569036\n", "uncertainty with minus sign: 3.8237387611780616\n" ] } ], "source": [ "alpha_t = 0.3\n", "g_best = g(l,t)\n", "g_plus = g(l, t + alpha_t)\n", "g_minus = g(l, t - alpha_t)\n", "\n", "print('g_best = ',g_best)\n", "print('uncertainty with plus sign:', g_plus - g_best)\n", "print('uncertainty with minus sign:', g_minus - g_best)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can be a liitle more quantitative about this by considering higher order terms in our \n", "Taylor's series expansions of $g(L,T)$:\n", "\n", "\\begin{eqnarray*}\n", "g(L,T+\\Delta T) &\\simeq& g(L,T) + \\frac{\\partial g}{\\partial T} \\, \\Delta T\n", " + \\frac{1}{2}\\frac{\\partial^2 g}{\\partial T^2} \\Delta T^2\\\\\n", "g(L,T-\\Delta T) &\\simeq& g(L,T) - \\frac{\\partial g}{\\partial T}\\, \\Delta T \n", " + \\frac{1}{2}\\frac{\\partial^2 g}{\\partial T^2}\\, \\Delta T^2.\n", "\\end{eqnarray*}\n", "These expressions will have the same magnitude when the terms quadratic in $\\Delta T$ \n", "are small compared to the linear terms, i.e.,\n", "\n", "$$ \n", "\\frac{1}{2}\\frac{\\partial^2 g}{\\partial T^2} \\Delta T^2 \n", " \\ll \\frac{\\partial g}{\\partial T} \\, \\Delta T. \n", "$$\n", "\n", "Rearranging this gives the condition on $\\Delta T$:\n", "\n", "$$\n", "\\Delta T \\ll 2\\frac{\\frac{\\partial g}{\\partial T}}{\\frac{\\partial^2 g}{\\partial T^2}}\n", "$$\n", "\n", "In this problem we have \n", "\n", "$$ \n", "\\frac{\\partial g}{\\partial T} = -\\frac{8\\pi^2 L}{T^3}\\quad\\mbox{and}{\\quad}\n", " \\frac{\\partial^2 g}{\\partial T^2} = \\frac{24\\pi^2L}{T^4}\n", "$$\n", "\n", "so our condition on the size of $\\Delta T$ becomes\n", "\n", "$$ \n", "\\Delta T \\ll \\frac{2}{3}T. \n", "$$\n", "\n", "This means that in this problem the two uncertainties will be the same when $\\Delta T\\ll 4/3\\, \\mbox{s}$, \n", "or when $\\Delta T$ is, say, less than a tenth of 4/3 ($\\simeq 0.13)$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Version information\n", "`version_information` is from J.R. Johansson (jrjohansson at gmail.com); see Introduction to scientific computing with Python for more information and instructions for package installation.\n", "\n", "`version_information` is installed on the linux network at Bucknell" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "%load_ext version_information" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/json": { "Software versions": [ { "module": "Python", "version": "3.7.7 64bit [GCC 7.3.0]" }, { "module": "IPython", "version": "7.16.1" }, { "module": "OS", "version": "Linux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core" } ] }, "text/html": [ "
SoftwareVersion
Python3.7.7 64bit [GCC 7.3.0]
IPython7.16.1
OSLinux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core
Fri Aug 07 10:10:43 2020 EDT
" ], "text/latex": [ "\\begin{tabular}{|l|l|}\\hline\n", "{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n", "Python & 3.7.7 64bit [GCC 7.3.0] \\\\ \\hline\n", "IPython & 7.16.1 \\\\ \\hline\n", "OS & Linux 3.10.0 1062.9.1.el7.x86\\_64 x86\\_64 with centos 7.7.1908 Core \\\\ \\hline\n", "\\hline \\multicolumn{2}{|l|}{Fri Aug 07 10:10:43 2020 EDT} \\\\ \\hline\n", "\\end{tabular}\n" ], "text/plain": [ "Software versions\n", "Python 3.7.7 64bit [GCC 7.3.0]\n", "IPython 7.16.1\n", "OS Linux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core\n", "Fri Aug 07 10:10:43 2020 EDT" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%version_information" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }