User Tools

Site Tools


gibson:teaching:fall-2012:math445:pf1

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

1. Produce a plot of //sin(x)// versus //x// in blue and //cos(x)// versus //x// in red for 100 evenly spaced points between 0 and 2pi. Label the axes. 2. Given matrix A, set //v// to the //j//th column of //A//. 3. Given matrix A, set //v// to the //i//th row of //A//. 4. Suppose matrix //A// has //M// rows and //N// cols. Set //B// to //A// with its columns in reversed order. 5. Solve system of equations <code> 2y - x = 1 3y + 2z = 5 -3x + z = -2 </code> 6. Produce a vector of 100 random floating-point numbers between 0 and 10. 7. Produce a vector of 100 random integers between 0 and 10. 8. Produce a random permutation of the integers between 1 and 10. 9. Produce a random permutation of the vector v = [3 3 4 5 7]; 10. Produce all permutations of the vector v = [3 3 4 5 7]; 11. Produce a quiver plot of the vector field $v = [v_x, v_y]$ where $v_x = \sin(x) \cos(y)$, $v_y = x y$, and //x// and //y// range from -pi to pi. Label the axes. 12. Produce a contour plot of $f(x,y) = \sin(x^2+y^2)/\sqrt{x^2 + y^2}$ where //x// and //y// range from -10 to 10. Label the axes. 13. Produce a 3d surface plot of the function from problem 12 over the same range, and with a color bar. Label the axes. 14. Write down the connectivity matrix //C// for the links in this small network of websites. <network-of-links figure here> 15. Write Matlab code that converts the connectivity matrix //C// to a transition matrix //T// that governs the transition of probabilities under random surfing. 16. Given //T//, write Matlab code that computes the vector //x// of probabilities //x(j)// that you'll end up at website //j// after a long night of random websurfing. 17. Write an equation for y as a function of x (log-linear, etc) for the following data plot <data plot goes here> 18. How would you graph the function $y(x) = x^c$, in a way that highlights this functional relationship? 19. How would you graph the function $y(x) = c^x$, in a way that highlights this functional relationship? 20. Write an anonymous function that returns the square of its input. 21. Write an anonymous function that, for an input vector $x = [x_1, ~x_2]$ returns the output vector $f(x) = [4 x_1 x_2, ~\sin(x_1) cos(x_2)]$ 22. Convert the following 2nd order ODE to a 1st order system of ODE in two variables. $dx^2/dt^2 + 3\; dx/dt + \sin(x) = 0$ 22. Show how to integrate the system of ODEs from problem 22 from t = 0 to 10 using the initial condition x(0) = 0, dx/dt(0) = 1. Write the ODE system in Matlab using an anonymous function. 23. Compute the terminal velocity of a ping-pong ball dropped from a great height, using this system of equations <latex> dy/dt = v_y </latex> <latex> d v_y/dt = -g - \mu v_y^2 </latex> where $g = 9.81, ~\mu =0.35$, $y$ represents the vertical position, and $v_y$ represents the vertical velocity. Represent the two free variables with the vector $x = [y, v_y]$ and reexpress the two equations above as an ODE system $\dx/dt = [\dx_1/dt, dx_2/dt] = f(x)$. Write an anonymous function in Matlab that computes $\dx/dt = f(x)$ given a vector $x$, and then use //ode45// to integrate the system from $t=0$ to $t=100$ from the initial conditions $x(0) = [y(0), ~v_y(0)] = [0, 0]$. 24. Plot the position of the ping-pong ball as a function of time. Label the axes. 25. Write a function that performs matrix-vector multiplication for a **sparse** matrix //A//, that accesses only nonzero elements of //A//. For an // M x N // matrix //A// and an //N//-dimensional vector //x//, the matrix-vector product $y = Ax$ is defined by <latex> y_i = sum_{j=1} A_{ij} x_j </latex> for each component $y_i$ of the //M// dimensional vector $y$. But don't that formula directly! Instead start your code with <code> K = nnz(A); [i,j,a] = find(A); </code> and write the matrix-vector multiplication as a loop over the $K$ nonzero elements of $A$.

gibson/teaching/fall-2012/math445/pf1.1354734971.txt.gz · Last modified: 2012/12/05 11:16 by gibson