I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't encountered yet. Where (books, websites, etc.) do I look for examples of good (best?) practices of Mathematica programming?

link|improve this question

57% accept rate
feedback

10 Answers

up vote 59 down vote
+100

Here's the full list that I started here A collection of Mathematica learning resources and updated here http://stackoverflow.com/a/8673695/884752. As this site is dedicated to Mathematica it makes more sense to maintain it here.

This represents a huge amount of information, don't hesitate to share it and suggest other interesting links!


Here's a collection of resources I started to collect for a friend who wanted to learn Mathematica. As it grew bigger It thought it would interest other people. Of course it's not exhaustive so feel free to reply with related links.

Introduction

Basic advices for people new to Mathematica

Functional style

Avoid iterative programming using loops like For, use instead functional programming functions Map, MapThread, FoldList ... and pure functions. This makes the code cleaner and faster.

Transpose and Dimensions

  • Something not easy to guess alone at the beginning: if you have x={1,2} and y={3,4}, doing Transpose[{x,y}] or {x,y}ESC tr ESC in the Front End will produce {{1,3},{2,4}} (format compatible with ListPlot). This helps understand why:

    http://documents.wolfram.com/flash/animations/Transpose.html

  • You can also use the second argument of Transpose to reorder the indices of a multidimensional list.

  • Don't forget to regularly control the output of the lists you generate using Dimensions.

Programming easily

  • Getting help: Execute ?Map for example for a short description of a function, or press F1 on a function name for more details and examples about it. You can solve many problems by adapting examples to your needs.

  • Auto-completion: Start the name of a function and press Ctrl+k to get a list of functions which names start with what has already been entered. Once the name of the function is written completely press Ctrl+Shift+k to get a list of its arguments.

  • Use palettes in the Palettes menu especially when you're beginning.

  • In Mathematica 8 use the natural input capability of Wolfram Alpha, for example type "= graph 2 x +1 between 0 and 3" without the quotes and see the command associated with the result.

The backbone of Mathematica: Rules (more advanced)

Tutorials

Tips and tricks

General tricks

Tips for writing fast code

Packed arrays

Compile

Advanced evaluation of expressions

Manipulate

FAQ

Wolfram Websites

Mathematica one liner competition

Wolfram technology conferences

2011

2010

2009

2007

2006

2005

2004

2003

2001

1999

1997

1994

1992

Blogs

Personal websites

Calculus

Forums

MathGroup

StackX

Books

Getting ideas from Lisp

Links to some packages

Packages for preparing publication-quality scientific figures

  • LevelScheme by Mark Caprio (latest version: 3.52, Sep 2011, for Mathematica 6 and higher)
  • Presentations and other packages by David Park (latest version: 25 Aug 2011)
  • A WorkLife Framework by Scientific Arts LLC (extendable and customizable toolset that broadens Mathematica's scope across many aspects of daily work)
  • FeynArts by Thomas Hahn (latest version: 3.7, 27 Mar 2012, package for generation and visualization of Feynman diagrams and amplitudes)
  • Writing and Publishing a Book with Mathematica by Paul R. Wellin (2005, available from the Wolfram Library Archive)

Useful non-free tools for development, deployment, distribution, linking, etc.

  • Workbench by WRI, current version: 2 (official Mathematica IDE based on Eclipse, great for projects involving several packages and generating integrated documentation)
  • webMathematica by WRI, current version: 3 ("Deploy high-powered applications as interactive websites")
  • gridMathematica by WRI, current version: 8 ("Easily control CPUs and GPUs to solve large problems fast")
  • Mathematica Applications and Add-Ons (all add-ons marketed via WRI, related to Mathematica)
  • Mathematica Link for Excel by Episoft, Inc., current version: 3.5 (link Microsoft Excel with Mathematica)
link|improve this answer
Thanks for the bounty! – Faysal Aberkane Apr 22 at 12:40
feedback

Since you're at the level to self-identify as a pretty good Mathematica programmer, I'm sure you're past (or are aware of) the obvious answers such as Stephen Wolfram's Mathematica book and Sal Mangano's Mathematica cookbook.

You can read Leonid Shifrin's book Mathematica programming: an advanced introduction for some interesting corner cases and examples in different programming paradigms. I've found that even if the topic/goals of the chapter are known to me, I learn something from the code examples.

Another really good book for inspiration on visual examples and demonstrations is Stan Wagon's Mathematica in Action and you can also see some of his examples on his demonstration page. I'm fairly certain you know about him and the book, given your question on Reuleaux rollers.

Of course, there're the Mathematica Guidebooks by Michael Trott, but I've found it way too big to actually sit down and learn something in a focused manner. What I normally do is to flip through randomly and stop somewhere (perhaps an interesting graphic, if it's the graphics volume) and try to look through his code samples.

Recently, I've been learning a lot from some of the entries to WRI's annual one-liner contest. The goal is to write the most impressive function/demonstration in 140 characters or less (i.e., you can tweet it). This competition attracts some of the finest users of Mathematica and it really takes me a while to break down some of the entries to figure out what's going on. You can see this year's entries here and search for the previous years'.

link|improve this answer
feedback

Besides the documentation, which I find very helpful, I also like the following resources:

  • The Wolfram Demonstrations Project is a fantastic resource, where you can draw up previously successful programs and learn some best practices. Their utility has varied, but I've certainly learned a lot by seeing great code in practice.
  • In a similar vein, I also follow the 'Wolfram Blog'. It's not all universally relevant for my own interests, but following it on Twitter is a good way to dip in here and there.
  • Finally, as a new user, I also draw on the Mathematica Cookbook for some nifty examples.

As noted above, however, I normally use the documentation and look through examples of uses, as that's my best way of learning.

link|improve this answer
3  
I find code on demonstrations web pages hard to read actually. There is almost no comments in most of the demos there, so it is hard to understand the algorithms, and the code formatting makes it very hard to read. Mathematica needs a pretty print type formatting for the code. This way one can download a demo, or any other code, and reformat the code so it is more easy to read. I like the code to be spread out a little, with some white space between things so I can more easily understand it. – Nasser M. Abbasi Jan 18 at 11:56
+1 for the cookbook but I agree with @Nasser on the readability of the demonstrations (plus, doing everything in one giant code block as demonstrations seem to organize things is probably not going to scale very well for anything nontrivial) – acl Jan 19 at 13:26
feedback

For neat tips and tricks, there is a daily tip posted to the MathematicaTip twitter page.

link|improve this answer
1  
This is a pretty good resource. It has lots of small, easy to digest snippets. – Mike Bantegui Jan 18 at 4:44
feedback

I highly recommend examining the included packages under your Mathematica installation directory:

\AddOns\ExtraPackages

\AddOns\LegacyPackages

\AddOns\Packages

\AddOns\Applications

link|improve this answer
feedback

The Mathematica GuideBook by Michael Trott always gives me lots of inspirations. Beside of it (and other places been mentioned above), I like exploring the SystemFiles folder. Some interesting tricks (especially about interface and FrontEnd) are hiding there.

link|improve this answer
The SystemFiles suggestion is a good one. Do you have any particular examples to share? – Verbeia Jan 18 at 2:28
@Verbeia Some undocumented things can be learned from the system files. such as "SyntaxColoringReasons" for CurrentValue which can be seen in WhyTheColoring.nb (Dynamic[CurrentValue[InputNotebook[], "SyntaxColoringReasons"]]), system fonts classification which can be seen in UnicodeFontMapping.tr, some inappropriate converting when import GBK encoded Chinese text can be corrected by manipulating CP936.m, etc. – Silvia Jan 18 at 11:49
feedback

Nobody's mentioned the packages that come with Mathematica. There's a heap of great coding examples in there, especially the later packages.

link|improve this answer
feedback

The 'Mathematica GuideBook' series by Michael Trott has tons of good examples that go much further than typical 'toy-examples'. I found it a very valuable and thorough ressource for learning the ins and outs of the Mathematica language.

link|improve this answer
feedback

A poster on MathGroup gave a list of resources back in October that is pretty useful. It's a large list so its easier to link to it than reproduce it here.

link|improve this answer
feedback

Not strictly a Mathematica blog but Rip’s Applied Mathematics Blog is a very nice resource for advanced Mathematica problem solving. Rip makes regular weekly posts on whatever interests him that week and they usually include some neat implementation in Mathematica.

link|improve this answer
I fixed your link. The form you used is not valid here. Also, I am not yet voting for this as I haven't checked out the site and the quality of the coding. – Mr.Wizard Apr 22 at 9:43
Thanks Mr.Wizard! – R Hall Apr 22 at 12:04
1  
+1, though not much about Mathematica. – Artes Apr 22 at 13:49
If bewildered one should look into examples rip94550.wordpress.com/2012/04/16/… – Artes Apr 24 at 12:03
Thanks this blog is very interesting. – Faysal Aberkane May 1 at 14:17
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.