Problems can be too big...
Actually want an answer...
Numerics compliment analytical methods
In [1]:
%matplotlib inline
import numpy
import matplotlib.pyplot as plt
def A(P, r, n):
return P / r * ((1 + r)**n - 1)
n = numpy.linspace(0, 20, 100)
target = 5000
plt.hold(True)
for r in [0.02, 0.05, 0.08, 0.1, 0.12]:
plt.plot(n, A(100, r, n))
plt.plot(n, numpy.ones(n.shape) * target, 'k--')
plt.legend(["r = 0.02", "r = 0.05", "r = 0.08", "r = 0.1", "r = 0.12", "Target"], loc=2)
plt.xlabel("Years")
plt.ylabel("Annuity Value (Dollars)")
plt.show()
In [2]:
x = numpy.linspace(0, 4 * numpy.pi)
plt.plot(x, 2.0 * numpy.sin(x))
plt.title("River Sine")
plt.xlabel("x")
plt.ylabel("y")
plt.axis([0, 4*numpy.pi, -2, 2])
plt.show()
We need to calculate the function $f(x)$'s arc-length from $[0, 4 \pi]$
$$L = \int_0^{4 \pi} \sqrt{1 + |f'(x)|^2} dx$$In general need numerical quadrature.
Lotka-Volterra Predator-Prey model
$$\frac{d R}{dt} = R \cdot (a - b \cdot F)$$$$\frac{d F}{dt} = F \cdot (c \cdot R + d)$$
In [3]:
data = numpy.loadtxt("./data/sunspot.dat")
data.shape
plt.plot(data[:, 0], data[:, 1])
plt.xlabel("Year")
plt.ylabel("Number")
plt.title("Number of Sunspots")
plt.show()
All notebooks are found on github.
Highly recommend obtaining a github account if you do not already have one. Will allow you start to become comfortable with git.
Clone the repository
$> git clone git://github.com/mandli/intro-numerical-methods
Pull in new changes
$> git pull
Push new changes (you do not have permission to do this
$> git push
Also note that you can watch what changes were made and submit issues to the github project page if you find mistakes (PLEASE DO THIS!).
The easiest way to install all the components you will need for the class is to use Continuum Analytics' Anaconda distribution. We will be using python 2.7.x for all in class demos and homework so I strongly suggest you do not get the Python 3.4 version.
Alternatives to using Anaconda also exist in the form of Enthought's Canopy distribution which provides all the tools you will need as well along with an IDE (development environment).
Instead of running things locally on your machine there are a number of cloud services that you are welcome to use in order to get everything running easily.