Plotting with Matplotlib

The bisection method | View | Download | |

The Bessel function $J_2(x)$ | View | Download | |

Tour of matplotlib | View | Download | |

Parametric and implicit plots | View | Download | |

Prime numbers | View | Download | |

Statistics plots | View | Download | |

Stirling's approximation for $n!$ | View | Download |

- The axes should be labelled $x$ and $y$ respectively.
- There should be a legend labelling the two graphs as "f(x)" and "g(x)" respectively.
- The two graphs should be thicker than the default thickness.
- The two graphs should be in different colours.
- The plot should have a title: "Two functions".
- Each graph should have at least 500 points.

`plt.show()`

to display the plot. You should `plot_lissajous(n, m)`

to plot the Lissajous curve $(x, y)=(\sin(n t),\cos(m t))$ for $0\leq t\leq 2\pi$.
- Your should use the
`figsize`

option to make the plot have size $5\times 5$. - Your plot should show the region where $-2\leq x,y\leq 2$ (i.e. $-2\leq x\leq 2$ and $-2\leq y\leq 2$).
- You should show the curve on its own without any axes, title or other extraneous elements.
- The curve should be shown as a dashed line, brick red in colour (hex code
`aa4a44`

) - You should generate at least 500 points on the curve.

`plt.show()`

) in the online test on Moodle.
`bisect(f, a, b)`

which searches for a root of $f(x)$ in the interval $[a,b]$ (by a
rather mediocre method). It returns a list `cs`

of approximate roots.
Write a function `show_bisect(f, a, b)`

which calls `bisect(f, a, b)`

and then
generates a plot as follows:
- Plot $f(x)$ for $a\leq x\leq b$ in blue.
- Draw the horizontal line $y=0$ in black.
- For each $c$ in the list of approximate roots, draw a dotted line from $(c,0)$ to the corresponding point on the graph. Make the line red if $f(c)\gt 0$ and green if $f(c)\lt 0$.

`bisect(f, a, b)`

. I do not suggest that
you change the basic method, but various other things could be done better.
(None of this task is on the online test.)