Homework due on Wednesday September 13.

Problem 1

Plot the following three functions on the same plot. Distinguish the graphs in some way and make sure which is which is easily understood: f1(x) = x sin(x), f2(x) = x^2 sin(x), and f3(x) = x^3 sin(x). Plot them over [-.1,.1], [-1,1], and [-3,3]. (Give me the printouts of the plots; I don't need to see the commands you used to generate them.)
hint: do "help axis" and see if that makes your life easier. Also, for fun, play around with "help subplot".

Problem 2

Repeat the above with f1(x) = x^2, f2(x) = |x|, f3(x) = sgn(x). (Give me the printouts of the plots; I don't need to see the commands you used to generate them.)
hint: do "help abs". Also, sgn(x) = 1 if x > 0 and sgn(x) = -1 if x < 0.

Problem 3

Plot the function which is x^2 for x > 0 and x for x <=0. (Give me the printout of the plot; I don't need to see the commands you used to generate them.)

Problem 4

Create a vector of length 50 of random numbers. Plot it. (Give me the printout of the plot; I don't need to see the commands you used to generate them.)
hint: do "help rand".

Now, let's do some statistics. I want the following quantities: n, f(n) = mean(x), g(n) = |mean(x)-.5|. First take n = 10, take x to be a random vector of length n, find its mean (hint: do "help mean"), and find the magnitude of the difference of the mean and 1/2.
Do this for n = 10^1,10^2,10^3,10^4,10^5,10^6, and 10^7. At each step, save the information as follows: for n=10^1, after you've defined x, do "N(1) = n; f(1) = mean(x); g(1) = abs(mean(x)-.5);" for n=10^2, do "N(2) = n; f(2) = mean(x); g(2) = abs(mean(x)-.5);" etc etc.
You now have three vectors of length 7. First, present them as a table. Then, plot f versus N. Plot g versus N. What does the plot of g look like? Test your theory by plotting log(g) versus log(N). How can you confirm your theory from the plot?