Exercise 12.1

Exercise 12.1#

Question 1#

NumPy has a number of Mathematical functions and Constants. Use these to plot the following:

(1) \(sin(x)\) for \(0 < x < 2\pi\)

../../../_images/a54243023a05efb1ce4fe5652be3205fc0249b07e5f505633f97bb0703d8e4d2.png

(2) \(|x - 2|\) for \(0 < x < 3\)

../../../_images/ddafc4dda5c9a57dffe778b76d29cc0d7fd29e8593db3169b88fa72dc7433c64.png

Make sure to label the \(x\) and \(y\) axis.

Question 2#

Plot a unit circle. Remember that the circle can be parameterized as:

(3)#\[\begin{align} x(s) &= \cos(2 \pi s)\\ y(s) &= \sin(2 \pi s) \end{align}\]

for \(0 < s < 1\).

../../../_images/cae2eafe1daa853368c6fffff7c7f98032a116d9613f28f2c79949a8f83ede48.png

Hint: You can use the set_aspect() method of the axis object to prevent the circle from distorting.

Question 3#

Plot a spiral, parameterized by:

(4)#\[\begin{align} x(s) &= s \cos(2 \pi s)\\ y(s) &= s \sin(2 \pi s) \end{align}\]

for \(0 < s < 1\).

../../../_images/dff5613eec9df5303440347f4c0f9b044e9dab0f49957669bb46f83e6bc73510.png