<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction and Motivation
Step1:  Boat race
Given a river (say a sinusoid) find the total length actually rowed over a given interval
$$f(x) = A \sin x$$
Step2:  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.
Non-Linear population growth
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)$$
Where are the steady states?
How do we solve the initial value problem?
How do we understand the non-linear dynamics?
How do we evaluate whether this is a good model?
Interpolation and Data Fitting
Finding trends in real data represented without a closed form (analytical form).
Sunspot counts
<ASSISTANT_TASK:>
Python Code:
%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()
Explanation: Introduction and Motivation: Modeling and methods for scientific computing
Why are we here?
Cannot solve everything
$$x^5 + 3x^2+ 2x + 3 = 0$$
$$f(x,y,z,t) = 0$$
Problems can be too big...
Actually want an answer...
Numerics compliment analytical methods
Why should I care?
The Retirement Problem
$$A = \frac{P}{r} \left((1+r)^n - 1 \right)$$
$P$ is the incremental payment
$r$ is the interest rate per payment period
$n$ is the number of payments
$A$ is the total amount after n payments
Note that these can all be functions of $r$, $n$, and time
End of explanation
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()
Explanation: Boat race
Given a river (say a sinusoid) find the total length actually rowed over a given interval
$$f(x) = A \sin x$$
End of explanation
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()
Explanation: 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.
Non-Linear population growth
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)$$
Where are the steady states?
How do we solve the initial value problem?
How do we understand the non-linear dynamics?
How do we evaluate whether this is a good model?
Interpolation and Data Fitting
Finding trends in real data represented without a closed form (analytical form).
Sunspot counts
End of explanation
<END_TASK>