{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Date: July 29, 2019\n", "\n", "
  • \n", "Course website and other logistics\n", "
  • \n", "Motivation: Why do this course?\n", " \n", "\n", "
  • \n", "This course is an introductory course and we will be looking at the following topics:\n", " \n", "\n", "As part of the course, we will be not only focussing on the computing part, but we will also be proving relevant theorems that are useful in the context of error estimates and convergence analysis.\n", "\n", "However, before getting into the above let's pause for a moment and look at the following.\n", "\n", "Consider the recurrence $a_{n+1} = 10a_n-9a_{n-1}$, with $a_0 = 2.95$ and $a_1 = 2.95$." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 2.95 , 2.95 , 2.95 , 2.95 ,\n", " 2.95 , 2.95 , 2.95 , 2.95 ,\n", " 2.95 , 2.95 , 2.94999996, 2.94999966,\n", " 2.9499969 , 2.94997213, 2.94974915, 2.94774237,\n", " 2.92968133, 2.76713194, 1.30418746, -11.86231289,\n", " -130.36081598])" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np;\n", "N = 20;\n", "a = np.zeros(N+1);\n", "a[0] = 2.95;\n", "a[1] = 2.95;\n", "for n in range(1,N):\n", " a[n+1] = 10*a[n]-9*a[n-1];\n", "display(a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
  • What is happening above?\n", "
  • Why is it that we are unable to obtain the answer to such a simple problem?\n", "
  • Are we wasting our time doing computations, if we are unable to obtain solution to such simple problems?\n", " \n", "Let's see what happens if I were to change the initial data from $2.95$ to $2.9375$." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375,\n", " 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375,\n", " 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375,\n", " 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375,\n", " 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375,\n", " 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375, 2.9375,\n", " 2.9375, 2.9375, 2.9375])" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np;\n", "N = 50;\n", "a = np.zeros(N+1);\n", "a[0] = 2.9375;\n", "a[1] = 2.9375;\n", "for n in range(1,N):\n", " a[n+1] = 10*a[n]-9*a[n-1];\n", "display(a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Surprisingly, I seem to get the right answer even if I run the recurrence till $50$ terms. What is happening here?\n", "\n", "To answer, the above questions, we first need to look at how numbers get stored on our machine. In mathematics, we have uncountably infinite real numbers. However, our computers are finite machines and hence only a finite set of numbers can be represented. We will look more at this in the next class." ] } ], "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.6.6" } }, "nbformat": 4, "nbformat_minor": 2 }