The One-Line Maze Program in MATLAB

A classic one-line program for the Commodore 64 microcomputer is

10 PRINT CHR$(205.5+RND(1)); GOTO 10

This is essentially what was printed in the section “Random Graphics” of the Commodore 64 User’s Guide (1982). The program prints a random maze that gradually builds up on-screen. The following video demonstrates it

I recently came across a 309-page book by Montfort et al. (MIT Press, 2013) dedicated to discussing this program from every conceivable angle. The book, which can be freely downloaded in PDF form, has as its title the program itself and was written by a team of ten authors with backgrounds in digital media, art, literature, and computer science. I found the book an interesting read, not least for the memories it brought back of my days programming the Commodore PET and Commodore 64 machines in the early 1980s (discussed in this post about the Commodore PET and this post about the Commodore 64). I suspect that never has so much been written about a single line of code!

Various translations of the program into other languages have been done, but I could not find a MATLAB version. Here, then, is my MATLAB offering, which takes advantage of the MATLAB char function’s ability to produce Unicode characters:

while 1, fprintf('%s\n',char(rand(1,80)+9585.5)); pause(.2), end

The pause command is not necessary but helps to slow the printing down, and the argument of pause may need adjusting for your computer.

Are there other interesting MATLAB one-liners? This one is from Mike Croucher:

x=[-2:.001:2]; plot(x,(sqrt(cos(x)).*cos(200*x)+sqrt(abs(x))-0.7).*(4-x.*x).^0.01)

And here is one to compute the Mandelbrot set, condensed from the code mandel in MATLAB Guide:

[x,y]=ndgrid(-1.5:5e-3:1.5); c=x+1i*y; z=c; for k=1:50, z=z.^2+c; end, contourf(x,y,abs(z)<1e6)

If you know any other good one-liners please put them in the comment box below.

Posted in software | Tagged , | 1 Comment

Celebrating Charlie Van Loan

Charlie Van Loan, Joseph C. Ford Professor of Engineering in the Department of Computer Science at Cornell University, retires in summer 2016.

van_loan_linocut.jpg

Charles Van Loan. The Entertainer. By Henk van der Vorst (linocut 2010)

Charlie has been a huge inspiration to me and many others, not least through his book Matrix Computations, with Gene Golub, now in its fourth edition. I wrote about the book on the occasion of the publication of the fourth edition (2013) in this previous post.

Following his PhD at the University of Michigan, Charlie visited the Department of Mathematics at the University of Manchester in 1974–1975 as a Science Research Council Research Fellow. He wrote the department’s first Numerical Analysis Report as well as three more of the first ten reports, as explained in this post.

A 55-minute video interview with Charlie by his colleague Kavita Bala, recorded in 2015, is available at the Cornell University eCommons. In it, Charlie talks about his PhD, with Cleve Moler as advisor, life as a young Cornell faculty member, the “GVL” book, computer science education, and many other things.

van_loan_interview.jpg

A two-part minisymposium is being held in Charlie’s honor at the SIAM Annual Meeting in Boston, July 11-14, 2016, organized by David Bindel (Cornell University) and Ilse Ipsen (North Carolina State University). I will be speaking in the second part about Charlie’s work on the matrix exponential. The details are below. If you will be at the meeting come and join us. I hope to provides links to the slides after the event.

SIAM Annual Meeting 2016.
Numerical Linear and Multilinear Algebra: Celebrating Charlie Van Loan.
Wednesday, July 13

Part I: MS73, MS89: 10:30 AM – 12:30 PM. BCEC Room 254B. Abstracts

  • 10:30-10:55 Parallel Tucker-Based Compression for Regular Grid Data, Tamara G. Kolda, Sandia National Laboratories, USA
  • 11:00-11:25 Cancer Diagnostics and Prognostics from Comparative Spectral Decompositions of Patient-Matched Genomic Profiles, Orly Alter, University of Utah, USA
  • 11:30-11:55 Exploiting Structure in the Simulation of Super Carbon Nanotubes, Christian H. Bischof, Technische Universität Darmstadt, Germany
  • 12:00-12:25 A Revisit to the GEMM-Based Level 3 BLAS and Its Impact on High Performance Matrix Computations abstract Bo T. Kågström, Umeå University, Sweden

Part II: MS92, 4:00 PM – 6:00 PM. BCEC Room 254B. Abstracts

  • 4:00-4:25 Charlie Van Loan and the Matrix Exponential, Nicholas J. Higham, University of Manchester, United Kingdom
  • 4:30-4:55 Nineteen Dubious Ways to Compute the Zeros of a Polynomial, Cleve Moler, The MathWorks, Inc., USA
  • 5:00-5:25 The Efficient Computation of Dense Derivative Matrices in MATLAB Using ADMAT and Why Sparse Linear Solvers Can Help, Thomas F. Coleman, University of Waterloo, Canada
  • 5:30-5:55 On Rank-One Perturbations of a Rotation, Robert Schreiber, Hewlett-Packard Laboratories, USA
Posted in people | Tagged , | 1 Comment

Acronymous Thoughts

According to the Concise Oxford English Dictionary (COD, 11th ed., 2004), “An acronym is a word formed from the initial letters of other words”. Here are some well-known examples.

  • AIDS: acquired immune deficiency syndrome,
  • laser: light amplification by stimulated emission of radiation,
  • radar: radio detection and ranging,
  • scuba: self-contained underwater breathing apparatus,
  • snafu: situation normal all fouled up,
  • sonar: sound navigation and ranging,
  • UNESCO: United Nations Educational, Scientific, and Cultural Organization,
  • WYSIWYG: what you see is what you get.

There is even a recursive acronym, GNU, standing for “GNU’s not Unix”.

ID-10096639.jpg

Image courtesy of smarnad at FreeDigitalPhotos.net.

On close inspection, the OED definition is imprecise in two respects. First, can we take more than one letter from each word? The definition doesn’t say, but the examples radar and sonar make it clear that we can. Second, do we have to take the initial letters from the words in their original order. This is clearly the accepted meaning. Merriam Webster’s Collegiate Dictionary (10th ed., 1993) provides a more precise definition that covers both points, by saying “formed from the initial letter or letters of each of the successive parts or major parts of a compound term”.

In common with many fields, applied mathematics has a lot of acronyms. It also has a good number of the most elegant of acronyms: those that take exactly one letter from each word, such as

  • BLAS: basic linear algebra subprograms,
  • DCT: discrete cosine transform,
  • FSAL: first same as last,
  • MIMO: multi-input multi-output,
  • NaN: not a number,
  • PDE: partial differential equation,
  • SIRK: singly-implicit Runge-Kutta,
  • SVD: singular value decomposition.

New acronyms are regularly formed in research papers. Non-native speakers are advised to be careful in doing so, as their constructions may have unsuspected meanings. The authors of this article in Chemical Communcations managed to get two exceptionally inappropriate acronyms into print, and one wonders how these escaped the referees and editor.

Another question left open by the definitions mentioned above is whether an acronym has to be pronounceable. The big Oxford English Dictionary (3rd ed., 2015) lists two meanings, which allow an acronym to be pronounceable or unpronounceable. The New York Times Manual of Style and Usage (5th ed., 2015) says “unless pronounced as a word, an abbreviation is not an acronym”, while the Style Guide of The Economist (11th ed., 2015) also requires pronounceability, as do various other references.

Apart from SIAM (Society for Industrial and Applied Mathematics), not many mathematics societies have pronounceable acronyms. In the “pronounced by letter” camp we have, for example,

  • AMS: American Mathematical Society
  • AWM: Association for Women in Mathematics
  • EMS: European Mathematical Society
  • IMA: Institute of Mathematics and its Applications
  • IMU: International Mathematical Union
  • LMS: London Mathematical Society
  • MAA: Mathematical Association of America
  • MPS: Mathematical Programming Society

SIAM’s founders chose well when they named the society in 1952! Indeed the letters S, I, A, M have proved popular, forming in a different order the acronyms of the more recent bodies SMAI (La Société de Mathématiques Appliquées et Industrielles) and AIMS (the African Institute for Mathematical Sciences).

A situation where (near) acronyms are particularly prevalent is in research proposals, where a catchy acronym in the title is often felt to be an advantage. I suspect that in many cases the title is chosen to fit the acronym. Indeed there is now a word to describe this practice. In 2015 the OED added the word backronym (first occurrence in 1983), which refers to “a contrived explanation of an existing word’s origin, positing it as an acronym”. One backronym is “SOS”; see Wikipedia and this article by John Cook for more examples.

The Acronym Finder website does a good job of finding the meaning of an acronym, often returning multiple results. For SIAM it produces 17 definitions, of which the “top hit” is the expected one—and at least one is rather unexpected!

Posted in writing | Tagged , | 1 Comment

Publication Peculiarities: More Examples

Here are some additions to previous posts in my Publication Peculiarities series.

As another meta-title, to add to those in Publication Peculiarities: Papers, I offer

D. S. Collens, Remark on remarks on Algorithm 48: Logarithm of a complex number, Comm. ACM, 7(8), 485, 1964

I have several new acknowledgements to add to those in Publication Peculiarities: Acknowledgements.

First is this thanks to the U.S. Immigration Service.

“B.J.H. would also like to thank the U.S. Immigration Service under the Bush administration, whose visa background security check forced her to spend two months (following an international conference) in a third country, free of routine obligations—it was during this time that the hypothesis presented herein was initially conjectured.”

from

Biyu He and Marcus Raichle, The fMRI Signal, Slow Cortical Potential and Consciousness, Trends in Cognitive Sciences, 13, 302-309, 2009

Paul Martin pointed out the acknowledgement

“We would like to thank Professor Patrick Browne for showing us, over a beer in McGonagall’s pub in Dundee, that a 50p coin is a set of constant width and hence the areas of the shadow projections of an obstacle do not uniquely determine the shape of an obstacle.”

in

D. Colton and B. D. Sleeman, Uniqueness Theorems for the Inverse Problem of Acoustic Scattering, IMA J. Appl. Math., 31, 253-259, 1983

Federico Poloni notes the

Unacknowledgements

This work is ostensibly supported by the the Italian Ministry of University and Research under the FIRB program, project RBIN047MH9-000. The Ministry however has not paid its dues and it is not known whether it will ever do.

in the paper

F. Chierichetti, S. Lattanzi and A. Panconesi, Rumour Spreading and Graph Conductance, 1657-1663, in Proceedings of the Twenty-first Annual {ACM–SIAM} Symposium on Discrete Algorithms, SIAM, 2010

Niall Madden pointed out

“Finally I would like to thank my daughter Lily for keeping me awake.”

in this arXiv paper.

Finally, a footnote on the first page of the paper

Andrew Hendry, Catherine Peichel, Blake Matthews, Janette Boughman and Patrik Nosil, Stickleback Research: The Now and the Next, Evolutionary Ecology Research, 15, 111-141, 2013

reads “Each author wishes the others had contributed more”.

Posted in publication peculiarities | 2 Comments

Mathematics and Digital Photography

A few months ago I wrote a post Mathematics in Color, in which I discussed some mathematical aspects of color and showed how a simple change of basis from RGB color space to LAB color space can enable dramatic color changes to be done very easily.

Over the last decade most recent developments in digital imaging software such as Adobe Lightroom and Adobe Photoshop have been based on advanced mathematics, yet many of the most powerful and useful transformations that one can make to an image are based on elementary mathematics and have been possible since the early versions of the products. For example, with every click of the healing brush—which might, for example, be used to remove a stray piece of litter in a landscape or a skin imperfection in a portrait—Photoshop solves a partial differential equation. Yet global operations such as changes to colour and contrast can be done with commands (and in particular, masks) that amount to simple addition and multiplication operations.

I’ve just launched a new blog on photography and digital imaging in which one theme will be exploiting elementary mathematics in digital imaging. The first post shows how the much-used Clarity tool in Lightroom and Photoshop can be applied in a more effective way by taking what amounts to a componentwise linear combination of the images before and after Clarity has been applied.

Head over to the post Refined Use of the Clarity Tool in Photoshop to find out more.

151022-1904-14-2639-cropped.jpg

Original (cropped) image.


151022-1904-14-2639-clarity100-cropped.jpg

With Clarity applied in blended fashion. Compare the water, clouds, and trees with the original.

Posted in miscellaneous | Tagged | Leave a comment

Iterating MATLAB Commands

Some MATLAB commands can be “applied to themselves”. A good example is help help, which provides help on the help function. For what other functions fun is fun fun a legal statement that produces something interesting? Here are some examples (by no means an exhaustive list).

char char
demo demo
diary diary
doc doc
diff diff
double double
edit edit
error error
iskeyword iskeyword
length length
magic magic
max max
size size
sort sort
spy spy
unique unique
upper upper
warning warning
which which

Can you see why these are legal and guess what the effect of these calls will be? Search for “command-function duality” in the MATLAB help for some clues.

Are there any legal triple invocations? Yes, for example

and and and
char char char
isa isa isa
max max max

Indeed char can be iterated as many times as you like, but and and isa can be iterated three times but not twice.

If you think of additional interesting examples, please add them to the comments below.

Posted in software | Tagged | 2 Comments

Quotes on Applied Mathematics

ID-100213508.jpg

Image courtesy of Stuart Miles at FreeDigitalPhotos.net.

In the 1000 or so pages of The Princeton Companion to Applied Mathematics the 165 authors offer insight, wisdom, and humour. Here is a selection of quotes from the book.

  • Gil Strang (page 939)

“Our subject is extremely large!”

  • David Tong (page 374)

“Classical mechanics is an ambitious subject. Its purpose is to predict the future and reconstruct the past, to determine the history of every particle in the universe.”

  • Heather Mendick (page 949)

“Jurassic Park, which … contains perhaps the only screen example of a `cool’ mathematician.”

  • Sergio Verdu (page 545)

“Authored in 1948 by Claude Shannon (1916–2001), `A mathematical theory of communication’ is the Magna Carta of the information age and information theory’s big bang.”

  • Ya-xiang Yuan (page 953)

“China … has a long tradition of mathematicians being well respected, and famous mathematicians are often put into high-ranking positions in government.”

  • Ian Stewart (page 912)

“Always wanted to write a book? Then do so. Just be aware of what you are letting yourself in for.”

Posted in Princeton Companion | Leave a comment

Five Books on Applied Mathematics

five-books-njh.jpg

The website Five Books consists of interviews with experts about their five favourite books in their subject. I was recently interviewed about my favourite popular applied mathematics books.

After making my original choice of books (ones that I use in my research) I realized that it was pitched at too high a level for a general audience. Identifying my revised choice was not easy, as I wanted to select books that contain a significant applied mathematics content, yet most books at the popular level are focused on pure mathematics.

I thought it would be good to include a book about equations. There are several such books, including It Must be Beautiful: Great Equations of Modern Science (2003) and The Great Equations: Breakthroughs in Science from Pythagoras to Heisenberg (2009). I chose Ian Stewart’s Seventeen Equations that Changed the World (2012), which has a strong applied mathematics slant.

After we did the interview, I saw an interview with Ian Stewart in Chalkdust magazine (a mathematics magazine produced by students at UCL), in which he said that the Seventeen Equations book is his favourite of all the books he’s written!

If you are wondering how to write a popular mathematics book, Ian gives some of the secrets in his article “How to Write a General Interest Mathematics Book” in The Princeton Companion to Applied Mathematics.

The complete set of Five Books interviews about mathematics is here.

Posted in books | Leave a comment

Programming the Commodore PET

My first programming languages were Fortran, learned in my mathematics degree, and Basic, which was the language built into the ROM (read only memory) of the Commodore PET. The PET—one of the early microcomputers, first produced in 1977—stored programs on cassette tapes, using its integral cassette deck. In those days you could buy programs on tape, at what today would seem very high prices, but people mostly wrote their own programs or typed them in from a magazine.

Many computer magazines existed that published (and paid for) programs written by hobbyists. Readers would happily type in a page or two of code in order to try the programs out. The two most popular categories of programs were games and utilities. I recently came across a file in which I’d kept a page from the January 1982 issue of Your Computer magazine containing one of my first published programs. The whole page is here in PDF form.

screenprint82.jpg

The purpose of the Screenprint program is to print the contents of the PET’s screen to an attached Commodore printer—something there was no built-in way to do. The pictures underneath the listing are screen dumps of the output from another program I wrote called Whirly Art.

Some explanation of the code is needed.

  • In Commodore Basic (a variant of Microsoft Basic) , line numbers are essential and are the target for a goto statement, which jumps to the specified line. Notice that the line numbers here are spaced about 10 apart: this is to allow for insertion of intermediate lines as the code is developed. There was no standard way to renumber the lines of a program, but I think I later acquired an add-on ROM that could do this.
  • There are no spaces within any non-comment line of code. Today this would be terrible coding practice, but each space took one byte of storage and in those days storage was at a premium. This bit of code was intended to be appended to another program, so it was important that it occupy as little memory as possible. The Basic interpreter was able to recognize keywords IF, THEN, FOR, etc., even when they were not surrounded by spaces.
  • The PEEK command reads a byte from RAM (random access memory) and the POKE commands writes a byte to RAM. CHR$(A) is a string character with ASCII value A.

I was surprised to find that scans of many issues of Your Computer are available on the Internet Archive. Indeed that archive contains a huge range of material on all topics, including a selection of books about the Commodore PET, some of which are in my loft but which I have not looked at for years.

Posted in software | Tagged | Leave a comment

Publication Peculiarities: More Author Lists

In an earlier post in my series of posts on publication peculiarities, I wrote about author lists. Here are some more offerings on the same topic.

Number of Authors

A contender for the world record for the paper with the greatest number of authors is the 5,154-author paper

G. Aad, B. Abbott, J. Abdallah, O. Abdinov et al., Combined measurement of the Higgs boson mass in pp Collisions at \sqrt{s}=7 and 8 TeV with the ATLAS and CMS experiments. Phys. Rev. Lett., 114, 191803, 2015.

It comprises 8.5 pages of text and 24.5 pages of author list and author addresses.

Names that Relate to the Paper Title

New Scientist magazine used the term nominative determinism for the tendency for authors to gravitate to fields of research related to their surname. (See this article for more background on the term.)

A. G. Cock, Genetical Studies on Growth and Form in the Fowl, Genetical Research 4, 167-192, 1963.

A. J. Splatt and D. Weedon, The Urethral Syndrome: Experience with the Richardson Urethroplasty, British Journal of Urology 49, 173-176, 1977.

Zhian Sun and Keith Shine, Studies of the Radiative Properties of Ice and Mixed-Phase Clouds, Q. J. R. Meteorol. Soc. 120, 111-137, 1994.

Relations

It’s not hard to find examples of husband-wife co-authors. Other relations are less common.

Brothers:

Nicholas J. Higham and Desmond J. Higham, Large Growth Factors in Gaussian Elimination with Pivoting, SIAM J. Matrix Anal. Appl., 10, 155-164, 1989.

Father (second author) and son (first author):

Alex Olshevsky and Vadim Olshevsky, Kharitonov’s Theorem and Bezoutians, Linear Algebra Appl., 399 (1), 285-297, 2005.

Michael Stewart and G. W. Stewart, On Hyperbolic Triangularization: Stability and Pivoting, SIAM J. Matrix Anal. Appl., 19, 847-860, 1998

Mother (Alicja) and daughter (Agata):

Alicja Smoktunowicz, Agata Smoktunowicz, and Ewa Pawelec, The three-term recursion for Chebyshev polynomials is mixed forward-backward stable, Numerical Algorithm, 69(4), 785–794, 2015.

Grandfather (Walter) and grandson (Daniel):

Walter Ledermann, Carol Alexander and Daniel Ledermann, Random Orthogonal Matrix Simulation, Linear Algebra Appl. 434, 1444-1467, 2011

Rhyming Names

G. E. P. Box and D. R. Cox, An Analysis of Transformations, Journal of the Royal Statistical Society. Series B (Methodological) 26, 211-252, 1964.

Pronounced the same but spelled differently:

Peter D. Burns and Roy S. Berns, Error Propagation Analysis in Color Measurement and Imaging, Color Research & Application 22, 280-289, 1997

The latter paper also has the distinction of having a DOI that I cannot get to parse correctly in this post: 10.1002/(SICI)1520-6378(199708)22:4<280::AID-COL9>3.0.CO;2-L

Names that are Colours

R. A. Brown and C. H. Green, Threats to Health or Safety: Perceived Risk and Willingness-To-Pay, Social Science & Medicine. Part C: Medical Economics 15, 67-75, 1981.

Esther Black and Craig White, Fear of Recurrence, Sense of Coherence and Posttraumatic Stress Disorder in Haematological Cancer Survivors, Psycho-Oncology 14, 510-515, 2005

Opposites

The next article includes the unusual combination of Wright and Wrong.

S. Levi, C. T. Dollery, S. R. Bloom, J. Calam, T. M. Cox, H. J. F. Hodgson, M. S. Losowsky, M. B. Pepys, N. A. Wright, and O. M. Wrong, Campylobacter Pylori, Duodenal Ulcer Disease, and Gastrin, BMJ 299, 1093-1094, 1989.

Ones That Got Away

Many years ago Ron Mitchell, of the University of Dundee, told me that there was a report or paper by Collar and Tie, the first author presumably being the engineer Arthur Roderick Collar. I have not being able to locate this publication.

Fictitious Authors

There are a number of examples of fictitious authors with amusing names being included on papers. I will not try to document any here, but point to The true story of Stronzo Bestiale (and others scientific jokes) for some examples.

Acknowledgements

Thanks to Des Higham for pointing out Box and Cox, Brown and Green, and Cock, which are taken from Learning LaTeX (page 40) by D. F. Griffiths and D. J. Higham.

Posted in publication peculiarities | Leave a comment