CompSciHW5

Homework 5 - Due Friday, March 4, 2016 1) Use numpy and pyplot to plot the following functions:   (remember to start by choosing an appropriate range for x) a) f(x) = sin(x) cos(2x) b) g(x) = x (if x is in 0,1), 2-x (if x is in 1,2), 0 otherwise c) h(x) = exp(-x*x/(2*sigma)), for sigma = 1, 2, and 3 d) w(x) = g(x) - 4*g(x-2.0) e) u(x, y) = sin(x)*cos(3*y) - cos(2*x)*sin(y) [Hint: use pylab.imshow]

2) Name the type of the following functions:  (remember that *a means a list is input and **a means a dictionary) a) def joinwith(space, *a): return space.join(a) b) def map_on_n(f, n):       return [f(i) for i in range(n)] c) def get_elem(k="default", **d): return d[k] + 2.0 d) def chaos(*a, **b):       return random.random*random.random e) def sliceof(st, stop, step, *a): return a[st:stop:step]