Scientific computing - selected example solutions to midterm problems

Your improvements and suggestions are welcome. Write me an e-mail if you find a better solution or a part of it.

Midterm 2014

p2014-markov.m

After download, change the name of the file to markov.m

  1. span style="color: #228B22;">% solves QMQ^-1 v = l*v for lambda - dominating eigenvalue
  2.  
  3. % it is equivalent to MQ^-1v = l*Q^-1 v or My = l * y with v = Q*y
  4. % if, of course, Q is nonsingular;
  5. % note that usually Q will be singular so our reformulation makes the problem well posed even for singular Q
  6. % check if Q is singular... (if someone insists, because this takes both time and memory!)
  7. % extract diagonal only
  8. % note that computing the norm of an eigenvector is a NONSENSE!

p2014-threebody.m

After download, change the name of the file to threebody.m

  1. span style="color: #228B22;">% these are squares of dist
  2. % compute omega at rectangular gridpoints (x,y) (e.g. returned by meshgrid)
  3. % for FD approx only
  4. % exact formula: takes effort to derive
  5. % quick and dirty approximation
  6. % for FD approx only
  7. % plot
  8. % restiricting to 1-D problem:
  9. %g can be inaccurate: fsolve exit code: %d\n', x(1), info));
Last modified: 11.06.2014, 09:32:36.
© Piotr Krzyżanowski