20  Visualizing functions

In these exercises, you are given functions \(f : \mathbb{R}^n \to \mathbb{R}^m\) and asked to visualize them.

Exercises: paths and their curves

Exercise 20.1 Let \(f : \mathbb{R}\to \mathbb{R}^2\) be a path defined by \[f(t) = [r(t)\cos(4t), r(t)\sin(4t)], \quad r(t) = \exp(-t).\] Sketch the curve traced by the path for \(0 \leq t \leq 2\pi\). You can check your sketch against, say, a Python plot.

Exercise 20.2 Let \(f : (0,+\infty) \to \mathbb{R}^2\) be a path defined by \[f(t) = [\ln(t), t].\] Sketch the curve traced by the path. You can check your sketch against, say, a Python plot.

Exercise 20.3 (A heart-shaped curve) Consider the parametrically defined curve

\[ x(t)=16\sin^3t,\qquad y(t)=13\cos t-5\cos(2t)-2\cos(3t)-\cos(4t), \]

where \(0\leq t\leq 2\pi\).

  1. Evaluate \((x(t),y(t))\) for \(t=0,\pi/2,\pi,3\pi/2,\) and \(2\pi\).

  2. Use these points, together with the symmetry of the curve, to make a rough sketch by hand.

  3. Plot the curve using Python. Use equal scaling on the two coordinate axes.

Exercises: level curves

Exercise 20.4 Let \(f(x,y) = x^2 + y^2\). Sketch the level curves \(\{(x,y) \mid f(x,y) = n\}\), for \(n = 1\) and \(n=2\), \(n=3\), and \(n=4\).

Exercise 20.5 Let \(f(x,y) = x + y + 2\). Sketch the level curves where \(f(x,y)=0\), \(2\) and \(4\). Can you sketch the graph of \(f\)?

Exercise 20.6 Let \(f(x,y) = x^2 - y^2\). The graph is called the hyperbolic paraboloid, or a saddle. Sketch the graph. Sketch the level curves \(\{(x,y) \mid f(x,y) = n\}\), for \(n = 0\) and \(n=-1\), \(n=1\). Make sure that you get all “pieces”.

Exercise 20.7 Write a Python program for sketching the level curves in the hyperbolic-paraboloid exercise above, but use more closely spaced constants. There are tools in Matplotlib that are handy.

Exercise 20.8 Adapt your program to draw level curves of \((x,y)\mapsto (x^2 + 3y^2)e^{1-x^2-y^2}\).

Exercises: sections and level surfaces

Consider the hydrogen-atom eigenfunctions in atomic units. They are indexed by \(n\geq1\), \(0\leq\ell<n\), and \(-\ell\leq m\leq\ell\). Their separated form is

\[ \psi_{n\ell m}(r,\theta,\phi)=R_{n\ell}(r)Y_{\ell m}(\theta,\phi), \]

with

\[ R_{n\ell}(r)=N_{n\ell}\rho^\ell L_{n-\ell-1}^{2\ell+1}(\rho)e^{-\rho/2}, \qquad \rho=\frac{2r}{n}. \]

Here \(N_{n\ell}\) is a normalization constant. Coordinate conversion uses

\[ r=\sqrt{x^2+y^2+z^2},\quad x=r\sin\theta\cos\phi,\quad y=r\sin\theta\sin\phi,\quad z=r\cos\theta. \]

In particular, the 1\(s\) and 2\(p_z\) functions are given by \[\psi_{1s}(x,y,z) = \frac{1}{\sqrt{\pi}} e^{-r(x,y,z)},\] \[\psi_{2p_z}(x,y,z) = \frac{1}{4\sqrt{2\pi}} z e^{-r(x,y,z)/2}.\]

Exercise 20.9 Write a Python program to draw the level surfaces of hydrogen orbitals, \(\{ (x,y,z)\mid \psi(x,y,z) = c \}\). Choose interesting values of \(c\). It can be interesting to color code surfaces of opposite positive and negative \(c\).

Exercise 20.10 Write a program to visualize sections of the orbital graphs. For example, fix \(y=y_\text{const}\) and plot \((x,z)\mapsto\psi(x,y_\text{const},z)\).