# [Beowulf] Teaching Scientific Computation (looking for the perfect text)

Robert G. Brown rgb at phy.duke.edu
Tue Nov 20 14:51:58 PST 2007

On Tue, 20 Nov 2007, Joe Landman wrote:

> C has a nasty way of doing exactly what you tell it to do, which oddly
> enough, might not be completely aligned with what you want it to do.

This is a wonderful statement, and is one reason that -- difficult as it
is initially -- C is a lovely language to START people on.  It is at
once totally unforgiving and totally unconstrained.  It "can" do
anything at all from write almost all of an operating system beyond a
few fragments of assembler to do serious numerical or GUI coding.  But
it does, generally, do exactly what you tell it to do.  So you'd better
learn to tell it to do the right thing!

> GSL is nice, though at last look it wasn't parallel/threaded.

It doesn't have a good tensor object, either, although I did write one
and tried to contribute it. It would have required a rewrite of their
vector and matrix structs, though, to be fully consistent.

I still have it if anyone ever DOES need a GSL-style tensor object.  I
think I quit at 9th or 10th rank -- large enough to handle candidate
field theories, at least some of them.

>> So, I'm thinking about reworking the class to favor C, and fearing 3 weeks
>> of pointer and addressing hell.  For those of you who teach
>
> Its actually not that painful.  I was able to walk through it in one session,
> explaining what the symbols mean, how to read them, and then showing them in
> use for a heat diffusion problem in 2D (breaking up a large array into
> panels).

Indeed, if you combine pointers with a "here's how the computer REALLY
works, kids" lecture so that you help them visualize memory and maybe
give them a simplified overview of "assembloid" -- a ten instruction
assember that does nothing but load, store,
add/subtract/multiply/divide, compare (x3), and branch that helps them
understand what compilers are actually doing in there, it will doubtless
help them with both why pointers are astoundingly useful and how/when to
use them.

> Sum reductions look the same in all languages.  And they can be done
> incorrectly in all languages :(

Which is the one reason that they DO need at least the first couple of
chapters of real numerical methods somewhere in there.  Fortran
encourages you to think that there is a standard FORmula TRANslation for
any equation based algorithm, and of course in once sense there is.  If
you fail to ever learn the risks of summing e.g. alternativing series
with terms that mostly cancel, one day you are bound to e.g. sum up your
own spherical bessel functions from the ascending recursion relation and
wonder why all your answers end up wrong... especially when it WORKS for
the first three or four values of \ell.

rgb

--
Robert G. Brown
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone(cell): 1-919-280-8443
Web: http://www.phy.duke.edu/~rgb
Lulu Bookstore: http://stores.lulu.com/store.php?fAcctID=877977