Let $A$ be the two-dimensional array $$ \mathbf{A} = \left\lbrack\begin{array}{ccc} 0 & 12 & -1\cr -1 & -1 & -1\cr 11 & 5 & 5 \end{array}\right\rbrack $$ Implement and apply the function
$$ f(x) = x^3 + xe^x + 1 $$to each element in $A$. Then calculate the result of the array expression $A^3 + Ae^A + 1$, and demonstrate that the end result of the two methods are the same.
The viscosity of water, $\mu$, varies with the temperature $T$ (in Kelvin) according to
$$ \mu = A\times 10^{B/(T-C)} $$where $A$ = $2.414 \times 10^{−5}$ Pa s, $B$ = 247.8 K, and $C$ = 140 K. Plot $\mu(T)$ for $T$ between 0 and 100 degrees Celsius. Label the $x$ axis with "temperature (C)" and the $y$ axis with "viscosity (Pa s)". Note that $T$ in the formula for $\mu$ must be in Kelvin.
The wave speed $c$ of water surface waves depends on the length $\lambda$ of the waves. The following formula relates $c$ to $\lambda$:
$$ c(\lambda) = \sqrt{\frac{g\lambda}{2\pi}\left(1 + s\frac{4\pi^2}{\rho g \lambda^2}\right)\tanh\left(\frac{2\pi h}{\lambda}\right)} $$where $g$ is the acceleration of gravity, $s$ is the air-water surface tension ($7.9 \times 10^{-2}$ N/m), $\rho$ is the density of water (can be taken as 1000 kg/m$^3$ ), and $h$ is the water depth. Let us fix $h$ at 50 m. First make a plot of $c(\lambda)$ for small $\lambda$ (1 mm to 10 cm). Then make a plot $c(\lambda)$ for larger $\lambda$ (1 m to 2 km).
Suppose we have measured the oscillation period $T$ of a simple pendulum with a mass $m$ at the end of a massless rod of length $L$. We have varied $L$ and recorded the corresponding $T$ value. The measurements are found in a file data/pendulum.dat, containing two columns. The first column contains $L$ values and the second column has the corresponding $T$ values. Load the $L$ and $T$ values into two arrays. Plot $L$ versus $T$ using circles for the data points.
To elongate a spring a distance x, one needs to pull the spring with a force $kx$. The parameter $k$ is known as the spring constant. The corresponding potential energy in the spring is $\frac{1}{2}kx$. Make a class for springs. Let the constructor __init__ store $k$ as a class attribute, and implement the methods force(x) and energy(x) for evaluating the force and the potential energy, respectively.