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/3b96fb052b5d4e2a3b016a3f69ab08e769892b9f9c4f11883ad650e80348e442.png

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

../../../_images/79837e62f89ef520724e59a841f6021cf02a958b5235f272eb7b1fbb8ad3eaf7.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/b435a9547193d4bef01f105bea546936ebc0224e62468a9715b952cb748fe4cc.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/ebda10ae27935b9de44f3bf67689a5966a6631f398d0690bddfd72cc8a142a0c.png