**This is an old revision of the document!** ----
====== Math 445 final exam topics ====== ---- ====Vectors and matrices==== You should know how to create vectors and matrices, how to access and set their elements, and how to perform mathematical operations with them. For example, if asked "Write Matlab code that would assign the 3rd and 7th columns of the matrix ''A'' into a matrix variable ''B''," you should know that the answer is <code matlab> B = A(:, [3 7]) </code> Note that correctness and conciseness both count! The above answer is better and will get a better grade than ''B = [A(:,3), A(:,7)]'', because it is more readable, less error-prone, and generalizes more easily. Relevant Matlab vocabulary: * ''zeros'' * creating vectors and matrices with lists of elements in square brackets * creating vectors with colon syntax and ''linspace'' * ''* \ + - ='' ---- ====Linear algebra versus elementwise operations=== You should know the difference between linear algebra and elementwise operations on matrices and vectors. For example, given two 2 x 2 matrices ''A'' and ''B'', you should be able to compute ''A * B'' and ''A .* B'' by hand. You should also know in what circumstances it's appropriate to use linear algebra operations or elementwise operations. ---- ==== Solving systems of equations ==== You should be able to translate a story problem into a system of linear equations and then write Matlab code to solve the system of equations. For example, suppose you have twenty coins worth %%$%%1.35 and they're all nickels and dimes. Translate this problem into a system of equations and write the Matlab code that would solve the equations numerically. \begin{eqnarray*} n + d &= 20 \\ 5 n + 10 d &= 135 \end{eqnarray*} <code matlab> A = [1 1 ; 5 10]; b = [20 ; 135]; x = A\b; n = x(1) d = x(2) </code> or even just <code matlab> [1 1 ; 5 10] \ [20 ; 135] </code> ---- ==== Plotting ==== You should know * how to make $xy$-plots of given functions $y=f(x)$ using **linspace**, elementwise operations on vectors, **plot**, **semilogx**, **semilogy**, and **loglog**. * how to make 2D contour plots with **linspace**, **meshgrid**, elementwise matrix operations, and **contour** or **contourf** * how to make 3D surface plots with **linspace**, **meshgrid**, elementwise matrix operations, and **surf** * how to load data from a file and plot it * how to label axes, title a plot, color the lines, show markers on data points, display a coordinate grid, show a colorbar, etc. ---- ==== Log-linear relations ==== You should know how to infer a functional relation $y=f(x)$ given a logarithmic or linear plot , and which of **plot**, **semilogx**, **semilogy**, and **loglog** is best for a given relation $y=f(x)$. ---- ==== Evaluating expressions ==== You should know how to write concise Matlab code to evaluate mathematical expressions. In particular, you should know how to evaluate expressions involving sums and products. For example, write two lines of Matlab code that would evaluate the sum \begin{eqnarray*} \sum_{n=1}^{10} \frac{n}{(n+1)^2} \end{eqnarray*} Answer: <code matlab> n = 1:10; sum(n./(n+2).^2) </code> ---- ==== Functions ==== You should be able to write simple Matlab functions to perform specified computations. For example, if asked to write a Matlab function that, given a value of $N$, evaluates \begin{eqnarray*} \sum_{n=1}^{N} \frac{n}{(n+1)^2} \end{eqnarray*} you should respond with <code matlab> function s = f(N) n=1:N; s = sum(n./(n+2).^2) end </code> ---- ====for loops==== You should know how to use ''for'' loops to perform repeated computations. For example, if asked to write a function that computes the above sum using a ''for'' loop (instead of using the ''sum'' function), you would write <code matlab> function s = f(N) s = 0; for n = 1:N s = s + n/(n+2)^2 end end </code> ---- ...to be continued... * **fprintf**: how to do basic formatted output with **fprintf**. * scripts: how to write scripts to perform a given sequence of commands. * hamster dynamics / Google Page Rank: how to translate a graph of nodes and links to a transition matrix and then calculate the steady-state distribution.