I've coded in C/Scheme for 10 years. I have a BS CS.

I've recently become very interested in pattern-matching (lisp's match macro), and term rewriting systems, which brought me to Mathematica.

I would like to read a book on Mathematica that will show me lots of cool term-rewriting as a programming style techniques.


What should I read?

  • 2
    $\begingroup$ Gray's "Mastering Mathematica" has a nice chapter on rule-based programming followed by a discussion of substitution and Lambda calculus, so you may want to check that out. $\endgroup$ Commented Jun 28, 2012 at 20:04
  • 6
    $\begingroup$ To the closers: please think before you cast the close votes. This question is IMO well formulated, rather narrowly focused, and constructive. Please save us all the reopening effort. $\endgroup$ Commented Jun 28, 2012 at 20:49
  • 3
    $\begingroup$ I agree with @Leonid. I would not vote to close this and will vote to reopen if closed. $\endgroup$
    – rm -rf
    Commented Jun 28, 2012 at 21:01
  • 1
    $\begingroup$ @Leonid I do not see the point of having huge resource lists if we are going to have also questions on parts of them. I don't think this should be closed (rather, I think the other question and answers are impossible to use, but that's another matter) $\endgroup$
    – acl
    Commented Jun 28, 2012 at 21:54
  • 2
    $\begingroup$ @Leonid I should add here that I do appreciate the effort gone into compiling the other, long answer. I just wish it could be somehow made more usable (of course if parts of it resided in answers to other questions Faysal would have a hard time maintaining and adding it). I am not sure what the best solution is. I'll stop because, as is well-known, This Is Not A Discussion Forum :) $\endgroup$
    – acl
    Commented Jun 28, 2012 at 22:10

2 Answers 2


OK, I will start with a few suggestions. I think, that what you really need is to understand Mathematica evaluator. Once you get this understanding, programming in Mathematica will become vastly easier for you, and you will be ready for the advanced examples showing the power of rules. So, here are the steps I'd take:

  • Read the book of David Wagner, "Power programming with Mathematica, the kernel" (1996, Computing McGraw-Hill). This is the best book I know to explain the essence of Mathematica evaluation process, and it is full of nice examples. Although it is currently out of print, you can get a free, licensed PDF copy of the book here.

  • While Wagner explains many things about evaluation process, some more details can be found in the WRI Technical Report by David Withoff titled "Mathematica internals" (thanks @Faysal for reminding me about it). It is a short and very interesting read, and even though it was published in 1992, it is mostly accurate to these days (which speaks well of Mathematica design consistency).

  • Get and read as many books by Roman Maeder as you can :-). There are four I know of, and I would read them in this order:

    If you thoroughly read these, you will get more than enough background. They are not an easy read, but easily the best and most elegant exposition of Mathematica from the rule-based perspective, with plenty of non-trivial examples. I think his books are still unmatched, even though published way back. You should have no problems reading them after Wagner's book.

  • After that, you can hunt for rule-based code in many places. There are many nice examples in the books of Michael Trott, and also "Mastering Mathematica" by John Gray, as was mentioned in comments. There are also lots of good and non-trivial rule-based code in the past MathGroup posts, StackOverflow discussions ([mathematica] tag) and here on Mathematica SE. I will try to collect links to some which I find representative and post them here in this answer.

But, to summarize: first, understand the evaluation sequence and evaluation control (Wagner's book is IMO the best source for that, and I will add some links to evaluation-related SO and SE threads here soon). After that, the rest will follow. With your Scheme background, it will be much easier, since the recursive part of Mathematica evaluator is similar to what you know from Lisp / Scheme, so you will have to only grok the rule-based part (which is very substantial, and makes Mathematica evaluator really different).

  • 1
    $\begingroup$ Have you forgotten your own book? mathprogramming-intro.org It's a gem and you know it :-) $\endgroup$ Commented Jun 28, 2012 at 21:21
  • $\begingroup$ @ndroock1 Thanks :). I did not focus on rule-based part, in fact I under-represented it. Neither did I focus on or explain the evaluation process. Both are covered in the new one I am working on, but who knows when it is ready (particularly with the current level of activity here which keeps me busy). Since the question was not about a collection of books on Mathematica programming, I did not include it then. $\endgroup$ Commented Jun 28, 2012 at 21:28
  • $\begingroup$ Wagner's book is available neither on amazon nor abebooks. How do I acquire a copy of said book? $\endgroup$
    – user1602
    Commented Jun 29, 2012 at 0:36
  • 2
    $\begingroup$ Ask your university or city library. $\endgroup$ Commented Jun 29, 2012 at 7:00
  • 2
    $\begingroup$ About the evaluation process a brief description is given here library.wolfram.com/infocenter/Demos/4683 $\endgroup$
    – faysou
    Commented Jun 30, 2012 at 21:26

If you are relatively new to Mathematica, I would definitely pick up a copy of "Programming with Mathematica: An Introduction" by Paul Wellin. This will give you an excellent starting point and solid foundation before you progress to more advanced material. I am still working my way through Paul's book, but it has been well worth it and has really opened my eyes to the power of Mathematica.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.