Tuesday, March 26, 2013

Improved Finite Difference Formula: Irregular Grid

Computing finite difference formulae on irregular grids is an O(2n^2) operation thanks algorithms developed by Bengt Fornberg. The Fortran code for the algorithm was supplied in his paper: Fornberg, Siam Rev., 40, pp 685-691, 1998.

A decent Matlab implementation is available here on the webpage of Randall J. LeVeque. The following picture may help with the nomenclature of the input arguments. The abscissa are provided as a vector xbar.

There is another matlab program available on the Scholarpedia article on this topic.

Sunday, March 24, 2013

"On the folly of" ... universities

Egged on by a recommendation from this podcast, I sought out the apparently classic paper by Steven Kerr entitled "On the folly of rewarding A, while hoping for B" (pdf here). For some time now, I have been fascinated by how the structure of incentives determines behavior and outcomes. This paper was, therefore, preaching to the choir.

Nevertheless, Kerr made important observations three decades ago about incentive structures at universities, that have become more salient and pervasive since.
Society hopes that teachers will not neglect their teaching responsibilities but rewards them almost entirely for research and publications. This is most true at large and prestigious universities. Cliches such as "good research and good teaching go together" not withstanding, professors often find that they must choose between teaching and research-oriented activities when allocating their time. Rewards for good teaching usually are limited to outstanding teacher awards, which are given to only a small percentage of good teachers and which usually bestow little money and fleeting prestige. Punishments for poor teaching are also rare.

Rewards for research and publications, on the other hand, and punishments for failure to accomplish these are commonly administered by universities at which teachers are employed. Furthermore, publication-oriented resumes usually will be well-received at other universities, whereas teaching credentials, harder to document and quantify, are much less transferable. Consequently, it is rational for university teachers to concentrate on research, even if to the detriment of teaching and at the expense of their students.

Tuesday, March 19, 2013

Beamer, pause, and space after equations

"\pause" is a very commonly used command in Beamer presentations to prevent displaying all of the slide at once.

In general, it works quite well as this minimal example shows:

Here the pause command was used between the equation and the line "This is the eigenvalue problem".

No problem, right (no pun intended)!

Using an itemize environment can cause some funny extra-space to be inserted between an equation and the next line:

Notice the extra space between the equation and the next item.

A relatively easy fix is to insert a blank line between the equation and the next item.

The code used to generate the three cases is below.

Tuesday, March 12, 2013

Matlab: The Four Subspaces and the Fundamental Theorem of Linear Algebra

Understanding the four fundamental subspaces of a matrix is central to looking at soul of a general matrix. Here is a short essay by Gilbert Strang which outlines them.

It is very easy to write a Matlab or GNU Octave program that demonstrates the different parts of the theorem for a general matrix. Here is one  (fundaspace.m).

It takes as input any matrix, and demonstrates the dimension, bases and orthogonality of the four spaces. When called without any arguments it demonstrates the following example.

octave> fundaspace()


    1    2    3    4
    5    6    7    8
    9   10   11   12

Number of Rows, m = 3
Number of Cols, n = 4

Rank, r = 2


Column Space Basis
    1    2
    5    6
    9   10

Left Null Space Basis

Row Space Basis
   1   5
   2   6
   3   7
   4   8

Null Space Basis
   0.044995  -0.545871
   0.346875   0.761366
  -0.828735   0.114882
   0.436865  -0.330377


dim(ColSpace) + dim(Left NullSpace) = m, (2 + 1 = 3)
dim(RowSpace) + dim(NullSpace) = n, (2 + 2 = 4)


ColSpace' * Left NullSpace


RowSpace' * NullSpace

  -8.3267e-17   5.5511e-16
   2.7756e-17   5.5511e-16

Thursday, March 7, 2013

Molecular Weight Distribution: The generalized exponential distribution

A generalized exponential (GEX) distribution described and plotted in a previous blog post, is often used to empirically approximate a wide variety of distribution. Unlike the lognormal distribution, which has two parameters, the GEX distribution has 3 parameters, which understandably permits greater flexibility.

The weight- and number- distributions are given by
\[ W(M) = \frac{m  t^{\frac{k+1}{m}}}{\Gamma \left(\frac{k+1}{m}\right)} M^k e^{-t M^m}\]
\[ N(M) = \frac{m  t^{k/m}}{\Gamma \left(\frac{k}{m}\right)} M^{k-1}e^{-t M^m} \]
The weight- and number-average molecular weights are:

\[M_w =  \int_0^\infty M W(M) dM = t^{-1/m} \frac{\Gamma\left( \frac{2 + k}{m} \right)}{\Gamma\left( \frac{1 + k}{m} \right)}\]
\[M_n =  \int_0^\infty M N(M) dM = t^{-1/m} \frac{\Gamma\left( \frac{1 + k}{m} \right)}{\Gamma\left( \frac{k}{m} \right)} \]

Sunday, March 3, 2013

Seidman on EconTalk

A very interesting/lively conversation between host Russ Roberts and Louis Michael Seidman at EconTalk on why the constitution should be ignored in framing public policy. You can see some of Seidman's views presented in his NYT opinion: "Let's give up on the constitution."

It's amazing how much one can learn from a civil conversation expressing opposing viewpoints on a controversial topic.

Note: Although this podcast has been available for about a month now, I just got around to listening to it last week.

Friday, March 1, 2013

Links: Proof-reading and Copy-editing bloopers

The blog associated with one of my favorite podcasts (Way With Words) has a link to a funny video of actual newspaper headlines that could have used better proof-reading.

Here is a lot more devoted nit-picking (marketing?).