Exercise 12.2

Exercise 12.2#

Question 1#

Plot \(sin(x)\) and \(cos(x)\) for \(0 < x < 2\pi\) in the same figure, but on separate axes. Arrange these axes vertically and share the x-axes. It should look something like this:

../../../_images/32882113548728fa42247696202e953b70140a94bdbc85aa74bf8ea4e290ec12.png

Question 2#

Ellipses can be defined by the relation:

\[ \frac{x^2}{a^2} + \frac{y^2}{b^2} = 1 \]

where \(a\) is a scaling factor along the \(x\)-axis and \(b\) is a scaling factor along the \(y\)-axis. This can also be expressed using the parametric equations:

\[\begin{align*} x &= a \cos(s)\\ y &= b \cos(s) \end{align*}\]

where \(s\) is a parameter ranging from \(0\) to \(2\pi\).

Write a script that creates a plot with subplots, taking two user inputs: the number of rows and the number of columns for the subplot. On each set of axes plot a full ellipse. Along the rows of the subplots, change the value of \(a\) from 1 to 100 in even increments. Change the value of \(b\) from 1 to 100 in even increments along the columns of the subplots.