====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gibson:teaching:fall-2012:math445:pf1 [2012/12/05 10:57] gibson |
gibson:teaching:fall-2012:math445:pf1 [2012/12/05 13:23] (current) gibson |
||
---|---|---|---|
Line 8: | Line 8: | ||
4. Suppose matrix //A// has //M// rows and //N// cols. Set //B// to //A// with its columns in reversed order. | 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 | + | 5. Solve the system of equations |
<code> | <code> | ||
Line 26: | Line 26: | ||
10. Produce all permutations 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 | + | 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. | |
- | $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}$ | 12. Produce a contour plot of $f(x,y) = \sin(x^2+y^2)/\sqrt{x^2 + y^2}$ | ||
Line 40: | Line 33: | ||
- | 13. Produce a 3d surface plot of the same function with a color bar. | + | 13. Produce a 3d surface plot of the function from problem 12 over the same range, and with a color bar. |
Label the axes. | Label the axes. | ||
Line 47: | Line 40: | ||
network of websites. | network of websites. | ||
- | <network-of-links figure here> | + | {{:gibson:teaching:fall-2012:math445:network2.png?direct&300}} |
15. Write Matlab code that converts the connectivity matrix //C// to a | 15. Write Matlab code that converts the connectivity matrix //C// to a | ||
Line 55: | Line 47: | ||
- | 16. Given //T//, write Matlab code that computes the vector //x// of | + | 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 | + | probabilities $x_j$ that you'll end up at website $j$ after a |
long night of random websurfing. | long night of random websurfing. | ||
- | 17. Write an equation for y as a function of x (log-linear, etc) for | + | 17. Write an equation for //y// as a function of //x// for |
- | the following data plot | + | the following data plot. Bonus: express exponential functions |
+ | as powers of //e// rather than powers of 10. Use $e^{2.3}\approx 10$ | ||
+ | to convert between the two. | ||
+ | |||
+ | {{:gibson:teaching:fall-2012:math445:fig1.png?direct&300}} | ||
- | <data plot goes here> | ||
18. How would you graph the function $y(x) = x^c$, in a way that highlights | 18. How would you graph the function $y(x) = x^c$, in a way that highlights | ||
- | this functional relationship? | + | this functional relationship? I.e. given vectors $x$ and $y$ satisfying |
+ | $y_i = x_i^c$, what Matlab command should you use to plot $y$ versus $x$? | ||
Line 77: | Line 73: | ||
21. Write an anonymous function that, for an input vector $x = [x_1, ~x_2]$ | 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)]$ | + | 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 | 22. Convert the following 2nd order ODE to a 1st order system of ODE in | ||
two variables. | two variables. | ||
- | $dx^2/dt^2 + 3 dx/dt + \sin(x) = 0$ | + | $dx^2/dt^2 + 3\; dx/dt + \sin(x) = 0$ |
- | 22. Show how to integrate the system of ODEs from problem 19 from | + | 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. | + | 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. | Write the ODE system in Matlab using an anonymous function. | ||
Line 95: | Line 91: | ||
<latex> dy/dt = v_y </latex> | <latex> dy/dt = v_y </latex> | ||
- | <latex> d v_y/dt = -g - \mu v_y^2 </latex> | + | <latex> d v_y/dt = -g - \mu v_y |v_y| </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 of the form | ||
+ | |||
+ | $dx/dt = f(x)$ | ||
- | where $y$ represents the vertical position of the ping-pong ball and | + | Note that both sides of this equation are vectors: $dx/dt = [dx_1/dt, ~dx_2/dt]$ and |
- | $v_y$ represents its vertical veloctiy. Use the initial conditions | + | $f(x) = [f_1(x_1, x_2), ~f_2(x_1, x_2)]$. Your job is to find the functions $f_1$ and $f_2$. |
- | $y(0) = 0, v_y(0) = 0$. Write the ODE system in Matlab using an | + | |
- | anonymous function. | + | |
+ | Write an anonymous function in Matlab that computes $dx/dt = f(x)$ for an input vector $x$, | ||
+ | and then use //ode45// to integrate this 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 pingpong ball as a function of time. | + | 24. Plot the position of the ping-pong ball as a function of time. |
Label the axes. | Label the axes. | ||
Line 113: | Line 117: | ||
<latex> | <latex> | ||
- | y_i = sum_{j=1} A_{ij} x_j | + | y_i = \sum_{j=1}^N A_{ij} x_j |
</latex> | </latex> | ||
- | for each component $y_i$ of the //M// dimensional vector $y$. But don't that | + | for each component $y_i$ of the //M// dimensional vector $y$. But don't code that |
- | formula directly! Instead start your code with | + | formula directly! Instead start your function with |
<code> | <code> | ||
Line 124: | Line 128: | ||
</code> | </code> | ||
- | and write the matrix-vector multiplication as a loop over the $K$ nonzero elements | + | and write the matrix-vector multiplication as a loop over the K nonzero elements |
- | of $A$. | + | of A. |