April 16, 2014 — Wolfram Blog Team

Professor Malcolm Levitt is Head of Magnetic Resonance at the University of Southampton and a leader in the field of magnetic resonance research. In the early 2000s, he began programming SpinDynamica—a set of Mathematica packages that run spin dynamical calculations—to explore magnetic resonance concepts and develop experiments.

Composite pulse animation

SpinDynamica is an open-source package that Professor Levitt continues to work on as a hobby in his spare time, but the SpinDynamica community also contributes add-ons to bring additional functionality to researchers.

Professor Levitt graciously agreed to answer a few of our questions about his work, Mathematica, and SpinDynamica. He’s hopeful that as word spreads, others will submit add-ons that enhance the core functionality of SpinDynamica.

What is your history in the field of magnetic resonance?

I’ve been researching in magnetic resonance since I was an undergraduate project student in Oxford in the late 1970s. I went on to do a PhD in Oxford, researching in nuclear magnetic resonance (NMR) with Ray Freeman. After that, I went off on a long sequence of postdoctoral positions. I worked with Richard Ernst in Zürich, who later won the Nobel Prize for his work on NMR.

I researched at MIT for about five years, and then became a professor in Stockholm, Sweden, before moving back to the UK in 2001. I now lead a magnetic resonance section at the University of Southampton. Most of my research has involved developing the theory and technology of NMR. It’s an amazingly rich field, since NMR is time-dependent quantum mechanics in action, and allows an instant coupling between a theoretical idea, a numerical simulation, and a real experiment.

There are now many thousands of distinct NMR experiments, involving different sequences of radio frequency pulses and switched magnetic fields, providing information on everything from biomolecular structure to cancer diagnosis to quantum computing. It really is a staggeringly versatile field of research, and I feel very lucky to have stumbled into it and to have made my career in it.

When did you begin working with Mathematica?

I started using Mathematica seriously for magnetic resonance research in the 1990s in Stockholm. During my PhD and in Zürich, I had written a lot of low-level code for controlling an NMR spectrometer, as well as graphical FORTRAN simulations of NMR experiments. Later on, while I was at MIT, I developed a lot of FORTRAN computer code for simulating magnetic resonance experiments, which I tried to make as general as possible. However, I always recognized the limitations and inelegance of the language.

When I first encountered Mathematica I remember a sense of recognition like, “Wow, this is exactly the computer language I would have invented myself if I had known how.” However I do remember at that time Mathematica seemed slow in execution and there would be times of frustration. Nevertheless I stuck with it. Happily, the progress of hardware and continued development of Mathematica made my commitment worthwhile.

What can you tell us about SpinDynamica and how you created it?

I started to use Mathematica seriously for NMR research in Stockholm, partly in combination with a book that I was writing (Spin Dynamics), for which I wanted to generate informative graphics and check the equations. At that time, I did experiment with creating a set of modules for numerical simulations of NMR experiments, as well as generating analytical results, but I did not develop this very far.

Several other numerical simulation packages for NMR came out. Although they were numerically fast for specific classes of problems, I still felt that they were not as general and as elegant as I would like. Furthermore, our group was getting into experiments that required certain types of numerical simulation that were not catered for. So at some point in the early 2000s I set about seriously developing general packages for both symbolic and numerical calculations of magnetic resonance, within the Mathematica environment.

3d trajectories plot

How do you use SpinDynamica in your research?

Mathematica in general, and SpinDynamica in particular, have become completely central to how I develop and test theoretical ideas. So it’s not as if I develop an idea and then test it with SpinDynamica—I actually use SpinDynamica as a tool to develop the idea in the first place. It’s a bit hard to explain, but it works for me. There’s something about Mathematica that seems to match perfectly the way I think and create.

Is there an interesting example or discovery you’ve come across while working with Mathematica and SpinDynamica?

A central topic of research in our group concerns something called long-lived spin states. These are certain quantum states of coupled magnetic nuclei that are very weakly coupled to the environment. They may be used for storing quantum information in nuclear spin systems for long times. (We have demonstrated over 30 minutes, which is an incredibly long time for a quantum effect in a room-temperature liquid.)

In the jargon of magnetic resonance, the equilibration of the nuclear quantum system with the environment is called relaxation. So these special nuclear spin states have very slow relaxation. It is a surprising fact, but true, that although the relaxation theory of NMR has been extensively developed with thousands of research papers since the 1960s and several Nobel prizes along the way, the existence of these states had been overlooked.

It was only when the symmetry properties of the relaxation were examined with Mathematica (using a precursor of SpinDynamica) that the presence of such states was predicted, and then demonstrated experimentally by our group in 2004. Our group is intensively researching the theory of these states and their exploitation in practical NMR experiments and, hopefully, in clinical MRI as well. Amongst other things, we are working with collaborators to develop agents that use long-lived states to detect cancer.

What impact do you think SpinDynamica could have on future magnetic resonance research?

That is hard to predict. There are several simulation packages in the community, many of which require less user intelligence, and which have a much faster execution for specific problems, than SpinDynamica. SpinDynamica is immensely powerful, but it does require that users have a good theoretical understanding in order to use it.

That weakness could be addressed by including additional packages for simulating common experimental situations without major theoretical understanding. The problem is that, at the moment, SpinDynamica remains a hobby project that is developed almost exclusively by me in my spare time. So although it is a superb tool for our particular branch of research, which demands a high theoretical level, there are many aspects that are rather undeveloped, including some important functionality that I have simply never had time to develop.

Nevertheless, I think the core functionality of SpinDynamica is powerful and stable, and I hope that the community will take it and build on it. That is slowly starting to happen. I have taught several graduate-level courses using SpinDynamica to explain the quantum-mechanical concepts of magnetic resonance, so there is take-up by a small but growing group of scientists. I think the impact will become much greater when I find time to write up a proper scientific paper on the architecture and functionality of SpinDynamica. Unfortunately my schedule makes that unlikely to happen soon.


April 10, 2014 — Wolfram Blog Team

It probably comes as no surprise that Wolfram has been asked to participate in a number of hackathons recently, including the upcoming HackIllinois. There’s a natural fit between our pioneering, agile approach to technology development and the growing hackathon phenomenon, in which coders come together for a short but intensive time—either individually or in teams—to create new and unique software or hardware applications.

HackIllinois

Last month while at SXSW 2014, Wolfram helped provide support for Slashathon, the first-ever music-focused hackathon. Hosted by Slash from Guns N’ Roses, the winning hack will be used to help release Slash’s new album. Wolfram provided mentoring for the competition in the form of onsite coding experts and technology access.

Also last month, Wolfram supported both hackBCA and HackPrinceton in New Jersey for high school and college students, respectively. In addition to having Wolfram programming experts available as mentors, Stephen Wolfram attended both of these events, where he spoke about the Wolfram Language and what the Wolfram technology stack is making possible.

Stephen Wolfram gives talk about Wolfram Language

At hackBCA, several projects made use of the Wolfram|Alpha API and the emerging Wolfram Cloud platform. We also saw some neat uses of Wolfram technologies at HackPrinceton. The Wolf Cocoa team developed a solution for making OS X apps by creating Wolfram Language bindings to the Objective-C runtime. Another group, Pokebble, used the Wolfram|Alpha API to enable users to play Pokémon on the wearable Pebble smart watch. And the third place overall software project winner, α-TeX, used the Wolfram Cloud to enable users to embed computed results into LATEX.

Graphic command

This weekend Wolfram is again going where the coders are. Which isn’t far, as HackIllinois—the first-ever student-run hackathon at the University of Illinois at Urbana-Champaign—will be happening right down the road from Wolfram’s headquarters. Over 1,000 college students from across the country will be converging on the UIUC campus to imagine, learn, and launch their latest ideas as mobile apps, web apps, or other software and hardware projects.

As an event sponsor, Wolfram will be on hand to give a tech talk and demo our technologies, and to provide other event support. We’re excited to see what the winning teams can produce in only 36 hours!

Whether for educational purposes or fully commercial applications, we’re glad to see hackathons catching on as a way to develop the next generation of cutting-edge programmers. Maybe we’ll see you or your students at future hackathons. In the meantime, happy coding!


November 14, 2012 — Jon McLoone, International Business & Strategic Development

I stumbled upon a nice project called Rosetta Code. Their stated aim is “to present solutions to the same task in as many different languages as possible, to demonstrate how languages are similar and different, and to aid a person with a grounding in one approach to a problem in learning another.”

After amusing myself by contributing a few solutions (Flood filling, Mean angle, and Sum digits of an integer being some of mine), I realized that the data hidden in the site provided an opportunity to quantify a claim that I have often made over the years—that Mathematica code tends to be shorter than equivalent code in other languages. This is due to both its high-level nature and built-in computational knowledge.

Here is what I found.

Large tasks - Line count ratio

Mathematica code is typically less than a third of the length of the same tasks written in other languages, and often much better.

Read More »


April 18, 2012 — Vitaliy Kaurov, Technical Communication & Strategy

A number of you have written us asking about interface design, Dynamic structures, and general starting tips for creating Wolfram Computable Document Format (CDF) files. I will present three examples of CDF files that will provide some insight into good practices. You should also read the recent Mathematica Q&A Series blog post about delivering CDF to your websites and blogs with the help of the CDF Web Deployment Wizard. This enables users to showcase their Mathematica projects online and share them with the global community. Let’s have a look at some features that make CDF great, rising well above other platforms. For a more extensive list, please see the CDF comparison table.

We will start with a short program that numerically solves the challenging problem of constrained global optimization by finding the minimum on a limited surface region. Think of finding the lowest point of an area of a mountain range. Dragging the 2D slider on the interface below automatically changes the surface geometry, and the CDF engine quickly recomputes the new minimum. This is reflected in the updated positions of the red dot. Drag and rotate the 3D graphics with the mouse to get a different view. Hold Ctrl while dragging to zoom (Command on a Mac) or hold Shift and drag to pan.

Code that numerically solves the challenging problem of constrained global optimization by finding the minimum on a limited surface region

Read More »


March 25, 2010 — Adam Berry, Senior Kernel Developer

It happens to everyone—you spend forever digging around in your filesystem for the dataset you need to finish your work. But you can’t remember the name or enough about the contents to be able to search for it. Searching is wasted time, time that would be far better spent on productive tasks.

What users like myself really need is for our tools to reflect the way we actually work, and that’s where project-based workflows in tools like Wolfram Workbench come in.

When working with Mathematica, we need notebooks—some will contain rough work and some will be presentation material. We may also need some data and other forms of output, such as HTML for final delivery. So let’s walk through setting up a project, and some of the features that can enhance your workflow and improve your productivity.

Read More »


February 25, 2010 — Wolfram Blog Team

Wolfram|Alpha‘s mission—to make all systematic knowledge immediately computable by anyone—is a major software engineering effort. With millions of lines of code and hundreds of team members, a sophisticated code-base manager is essential in making the project possible. Enter Wolfram Workbench.

Wolfram Workbench 2, the recently released version of Wolfram’s state-of-the-art software engineering and deployment tool, is used at all levels of the Wolfram|Alpha project, from data curation and quality assurance to documentation and framework development. With its leading code-editing, navigation, and project-management tools, Workbench is a scalable solution that is necessary for building and growing Wolfram|Alpha.

In this video, two Wolfram|Alpha developers describe Workbench‘s invaluable role in the project.

Read More »


February 17, 2010 — Wolfram Blog Team

Wolfram Workbench 2 is out today. New in Version 2 is the ability to create and integrate documentation for your Mathematica applications, as well as a host of improvements to code editing, navigation, and more.

Workbench is an Eclipse-based integrated development environment (IDE) with a powerful suite of tools to help you quickly create innovative, next-generation applications from concept to completion. You can work with any Eclipse-supported language, making Workbench a very efficient organizational tool. It’s a powerful tool for small projects as well as large scale applications. How do we know? It is one of our key tools in the development of Mathematica, Wolfram|Alpha, and other Wolfram technologies.

Read More »


March 19, 2009 — Werner Schuster, Kernel Developer

Inside and outside of Wolfram Research, teams are working on large Mathematica projects. Working with large code bases requires powerful tools; it is even better if these tools are integrated. With Wolfram Workbench, we brought an integrated development environment (IDE) to our users.

What does “integrated” mean? Well, let’s look at just one example of how Workbench integrates Mathematica‘s central language features, pattern matching, editors, and source management tools.

Let’s start with a specific problem: with our Mathematica 6.0 release, we overhauled many of our libraries and APIs (our recent Version 7.0 release builds on the improvements in Version 6.0). Some groups of functions were deprecated or their APIs changed. We had collected a long list of these changes… but how would users apply them to their source code? Go through them one by one and line by line in their code? Definitely not.

Read More »


November 12, 2007 — Nilay Gandhi, Corporate Communications

Last month, we hosted our annual technology conference here at our headquarters in Champaign, Illinois, where hundreds of Mathematica users from around the world came to show us what they’ve been working on and to see what we’ve been up to.

A lot of the conference presentations are now available on our website, so you can take a look at them even if you didn’t have a chance to attend this year.

Read More »


June 15, 2007 — Kovas Boguta, Special Projects Group

In this blog and elsewhere, you’ll often see the statement that some advanced Mathematica feature is just another application of symbolic programming. It’s the kind of idea that seems too powerful to explain in a single blog post, yet simple enough that I am tempted to try. So, here goes.

Symbolic programming is based on the concept of recasting core features of human language into a computationally active form.

What does it mean to have a human-language-oriented programming language?

Our cognitive model of computation is typically a three-stage process: 1) describing the computation, 2) executing that description, and 3) outputting the results.

The “language” part of most programming languages begins and ends with stage one. Linguistic structures are erected to describe the program. But the execution of the program is typically oriented around an entirely different system of types and objects; and likewise, the program’s output structure tends to resemble nothing particularly language-like.

Symbolic programming uses linguistic structures as the foundation of all aspects of computation. From a computation’s description, to how the computation executes, to how humans interface with the results, the exact same basic tree structure is used throughout.

This is a powerful unification, making possible many useful computations that in other systems range from cumbersome to practically impossible. We’ll see examples along the way, but let me first describe what these linguistic structures actually are.

Read More »