#!/usr/bin/env python
# coding: utf-8
# Date: July 29, 2019
#
#
# Course website and other logistics
#
# Motivation: Why do this course?
#
# -
# You can make ₹'s, €'s $'s etc; Turning Math into Cash
#
-
# There are tons of open problems, when solved also turns out to be of practical relevance; The Smart Money’s on Numerical Analysts
#
-
# Makes you powerful; Provides you tools to advance any field; Almost every field these days have a sub-field prefixed with computational;
#
# -
# Biology -> Computational Biology,
#
-
# Fluid Dynamics -> Computational Fluid Dynamics,
#
-
# Number Theory -> Computational Number Theory,
#
-
# Machine learning -> Computational Learning Theory,
#
#
#
#
# This course is an introductory course and we will be looking at the following topics:
#
# -
# Interpolation
#
-
# Root finding
#
-
# Numerical Integration
#
-
# Numerical differentiation
#
-
# Numerical solution of ordinary differential equations
#
-
# Monte-Carlo methods
#
#
# 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.
#
# However, before getting into the above let's pause for a moment and look at the following.
#
# Consider the recurrence $a_{n+1} = 10a_n-9a_{n-1}$, with $a_0 = 2.95$ and $a_1 = 2.95$.
# In[1]:
import numpy as np;
N = 20;
a = np.zeros(N+1);
a[0] = 2.95;
a[1] = 2.95;
for n in range(1,N):
a[n+1] = 10*a[n]-9*a[n-1];
display(a)
# What is happening above?
# Why is it that we are unable to obtain the answer to such a simple problem?
# Are we wasting our time doing computations, if we are unable to obtain solution to such simple problems?
#
# Let's see what happens if I were to change the initial data from $2.95$ to $2.9375$.
# In[2]:
import numpy as np;
N = 50;
a = np.zeros(N+1);
a[0] = 2.9375;
a[1] = 2.9375;
for n in range(1,N):
a[n+1] = 10*a[n]-9*a[n-1];
display(a)
# Surprisingly, I seem to get the right answer even if I run the recurrence till $50$ terms. What is happening here?
#
# 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.