Mathematica 7: A Review

A powerful tool that supports image processing, OpenGL, multi-core architectures, and more


December 01, 2008
URL:http://www.drdobbs.com/web-development/mathematica-7-a-review/212201141

Mike Riley is a Dr. Dobb's contributing editor. He can be contacted at [email protected].


When I was a freshman in high school, my older -- and much smarter -- brother Frank was in all the math AP classes. For the holidays, Frank successfully convinced my parents to buy him a Texas Instruments TI-59 calculator. At that time, the TI-59 was the most advanced and expensive portable calculator on the market. It had more buttons than I had ever seen before on a hand-held device, but its coolest feature was that it was programmable. By running custom magnetic strips through the built-in card reader, programs could be easily reloaded into the calculator. The buttons, the strips, the 10-digit display and the speed at which this little machine could almost instantaneously calculate factorials just blew me away. The TI-59 sparked my interest in both mathematics and programming in a way no other technology had in the past. While I had seen Apple IIs and TRS-80s at the store, those computers were priced in the stratosphere, especially for a 14-year old kid in the late '70s.

Fast forward to the holidays of 2008, where my own kids use technologies light-years more powerful than that now quaint programmable calculator. My 14-year old daughter has a multi-core Linux PC in her bedroom that she uses for work and play, while her brother who is two years older casually uses an Apple TV to browse the expanding universe of YouTube videos. And just before the Thanksgiving holiday this year, a parcel arrived from Wolfram Research that recaptured the enthusiasm and excitement I experienced with the TI-59 almost 30 years ago. Mathematica 7 is Wolfram's most advanced, sophisticated, and feature-packed release yet, and has so much algorithmic power and flexibility packed into its bits that you could spend a lifetime mastering the millions of computational permutations it is capable of.

Mathematica 7 ships with over 500 new features beyond its predecessor (Mathematica 6) that was released over a year ago. Rather than list all 500+ additions, I focus on the highlights oriented toward the programming and engineering audience that dominates Dr. Dobb's readership. Each version of Mathematica delivers a plethora of new capabilities with a few that stand far above the addition of a new function or graph type. In Mathematica 6, the killer feature was the Manipulate function which brought to life the once static results of numeric and graphic output. Manipulate lets you add dynamic variables to a statement which would render the output with sliders, buttons and drop-down lists that could be used to quickly visualize changes to variable input. The other huge step forward in that version was Wolfram's release of its Mathematica Player, which allowed compiled notebooks to be freely distributed and interacted with using the Mathematica Player client. And because this client runs on the same platforms (Windows, Mac OSX, and Linux) that Mathematica does, cross-platform code execution is a worry-free reality.

[Click image to view at full size]
Figure 1: Mathematica 7's new 3-D Spline support delivers OpenGL-driven data visualization.

Mathematica 7 also has its share of killer features, but if I had to pick two areas, they would be image manipulation and parallel computation. Over 15 new graphic primitives have been added, ranging from BezierCurves to SplineKnots. An number of chart types, including Bar, Bubble, Histogram, Pie, and Sector, and their 3D counterparts, have been added. Numerous 2D and 3D functions have been added or enhanced to visualize Contour, Stream and Vector Density Plots as well as various visualization directives and options such as Transparent, PolarAxes, and ContourLabels.

[Click image to view at full size]
Figure 2: The new VectorPlot function can be used for such requirements as visualizing fluid dynamics.

But the coolest data visualization features are Mathematica 7's new image processing and analysis functions. These let you treat images just like any other data type and manipulate them accordingly. The new functions like ImageCompose, ImagePartition, MorphologicalComponents, and TopHatTransform go far beyond the other Photoshop or GIMP-like image functions also included in Mathematica, such as Blur, ImageResize, ImageReflect, ImageRotate, Sharpen and the various filters like Charcoal, OilPainting and SaltPepperNoise that can be applied to image data via the ImageEffect function. Using these new image analysis and transformation functions, you could leverage Mathematica's power to create powerful image manipulation workflows within minutes. Everything from medical imagery to satellite topology photos could be interrogated, manipulated and rapidly evaluated for various research and commercial purposes.

[Click image to view at full size]
Figure 3: The new image manipulation features allow images to be treated as any other data type.

The other new feature set that greatly appeals to computational enthusiasts is the bevy of new parallel computing additions. Previously sold as a separate add-on, Mathematica 7 seamlessly integrates these multi-kernel functions to take full advantage of multi-core systems. By default, it supports 4 kernels (4 cores) out of the box. For those developers fortunate and wealthy enough to afford a dual quad-core (or more) system, an additional license configuration will need to be purchased from Wolfram to take advantage of the additional cores. One of the more frustrating things I encounter when using various tools on my quad-core workstation is the complete lack of awareness programs have of my computer's multi-core architecture, especially when those programs are computationally intensive. Wolfram recognized this rapidly expanding trend and took advantage of the extra horsepower via its new Parallelize, ParallelTry and ParallelEvaluate functions which provide automatic and concurrent expression evaluation. Parallel performance can be tweaked and queued using the ParallelMap, ParallelCombine, ParallelSubmit, WaitAll and WaitNext functions. These and many other parallel computing functions ensure that developers have tremendously granular control over what will be sent through the parallel pipeline and exactly how that data will be processed. Mathematica 7 is the first program I've used on my 64-bit Linux-driven quad-core rig that showcases the power a multi-core workstation can deliver. It's one of the first features I demonstrate for my technical peers and the response from them is always the same -- That's cool!

[Click image to view at full size]
Figure 4: Mathematica 7 takes full advantage of multi-core computing architectures.

New Features

Another slick addition in the previous Mathematica release was its Wolfram managed web service data look-ups, called "Curated Data". Calling these in-line functions poll Wolfram's servers have which compiled and formatted this lookup data from a variety of scientific and statistical resources. That version introduced such data sources as the AstronomicalData, ChemicalData, and FinancialData among other things which allowed users to poll datasets subscribed to and optimized by Wolfram for its Mathematica customers to consume. Now in version 7, these Curated Data sets have been expanded to include GenomeData and GenomeLookup for human gene sequence information, ProteinData for protein model structures and functions and even GeodesyData for geodetic coordinate systems data.

[Click image to view at full size]
Figure 5: DNA data from the human genome can now be directly called upon within Mathematica.

[Click image to view at full size]
Figure 6: Protein molecule models can also be called upon and further manipulatedwithin Mathematica.

Existing data collections for such functions as the AstronomicalData, DictionaryLookup, and WeatherData have been expanded with additional data properties, entities and objects. Combining these functions together make for some truly stunning, relatively real-time data visualization revelations that would have previously required days or weeks of programming to do what can now be done in Mathematica under a minute.

[Click image to view at full size]
Figure 7: Create an impressive mean temperature graphic in Mathematica using two linesof code.

While it does annoy me that Wolfram has locked down this web service to its own company servers, I can rationalize this decision to a certain degree assuming that Wolfram is scrubbing the data and keeping it as up-to-date as possible. I suspect Wolfram would also argue that by curating the data, they ensure the stability and reliability of the data being consumed from the Internet rather than dealing with SOAP soup that other web service-consuming applications have to contend with. Nevertheless, I still would prefer a SOAP and/or RESTful interface function to let me make that decision of data source consumption and accept whatever instability risks it might bring. For now, I will have to continue to curate my own data sources by scraping the web, populating a PostgreSQL database and using Mathematica's JDBC-compatible SQL database connectivity support (part of Mathematica's DatabaseLink toolkit) to pull the custom data into the application instead.

As Mathematica continues to expand beyond its single user interactive session roots into the realm of workflow automation, it has also added new functions to interact with messaging and the host operating system. The SendMail function adds email notification, great for being alerted when a complex, parallelized computation is completed or even something more sophisticated like being emailed a data-rich PDF complete with stunning 3D charts, manipulated images and beautifully rendered mathematical formulas to an internal company mailing list.

[Click image to view at full size]
Figure 8: The Internet Connectivity tab in the preferences dialog box can be used to set default mail server settings for the new SendMail function.

The new SystemOpen feature, similar to the existing Run function, provides a less verbose interface to easily open files or URLs from within a Mathematica notebook or operation. SystemOpen is accompanied by several other file determination and naming functions including AbsoluteFileName, FileExistsQ, FindFile, FileNameJoin and others. Combining the new parallel, image processing, email notification and external application execution commands can transform Mathematica into a serious data processing and messaging hub in a sophisticated workflow scenario. Combine this with Wolfram's gridMathematica and upcoming CloudMathematica add-ons for high-performance and distributed computing needs, Mathematica truly becomes a central controller for a mathematically intensive corporate application or research project.

I would be remiss if I didn't also mention that this new release sports hundreds of new mathematical algorithms and functions for mathematicians and educators. These include new discrete calculus algorithms, number theory functions (many of which I had never heard of before, like DirichletCharacter, MangoldtLambda and RiemannR), extended boolean computation, special functions like HurwitzLerchPhi and InverseHaversine, new Q-Functions like QhypergeometricPFQ, new utility functions like DiracComb and HeavisidePi and so much more. And perhaps the one enhancement that will further promote third-party and vertical market opportunities, Mathematica's Palette menu lets the Mathematica UI environment be enhanced and extended with custom palettes. One of the finest examples of this practice is action is the bundled Classroom Assistant, written by Eric Schulz, a mathematics professor at Walla Walla Community College. The Classroom Assistant palette makes the most frequently accessed calculations, commands and formatting ideal for presentation on an LCD projector or Smartboard. For more details, check out my audio interview with Eric at the recent 2008 International Mathematica User's Conference.

[Click image to view at full size]
Figure 9: The Classroom Assistant palette exposes popular presentation formatting and math functions.

Programming Models

Functional, Linear, Object-Oriented (via Wolfram's Eclipse IDE-based Workbench) Procedural, Rule-Based and Symbolic are just some of the ways programmers can write applications leveraging Mathematica's symbolic structure. Not only is this highly flexible model great for exploring different programming approaches to solve computationally challenging problems, it also adapts to whatever model is optimal for the task at hand. After exploring the functional programming aspects of Mathematica, my own appreciation for different approaches was enhanced and I didn't feel shackled to solving problems using the belabored OO approach. In fact, Mathematica has achieved its amazing calculation speed and efficiency by not adopting the pack mentality of following the latest methodology craze but rather continued to refine its own computational engine constructions. It's no wonder that most of the attendees I interviewed at the recent Mathematica Conference were converts from other programming languages sold on the flexibility and power that Mathematica's programming models had to offer.

Documentation

Because Mathematica's documentation is constructed as a Mathematica notebook, all the code elements and demonstrates are live and fully executable. This aids tremendously in the learning of what functions can do as well as provide copious examples to copy and paste as a framework to start from. Mathematica 7's documentation has been further revamped to provide outstanding organization to what could be over 10,000 pages of printed material. The interface provides several different organizational approaches to accessing the information, from an attractive Documentation Center summary page, a Function Navigator hierarchy to a Virtual Book for those who prefer to meticulously read everything sequentially to a clean Google-style search bar for impatient programmers like me. The documentation is available both locally and mirrored on the web. Wolfram's website further extends the demonstrations embedded in the help system with the Wolfram Demonstrations Project, a web site showcasing numerous mathematical models categorized by genre's ranging from Physical Sciences to Engineering & Technology. Not only does this resource promote Mathematica's abilities but also further assists Mathematica users with code that can be incorporated into their own projects.

[Click image to view at full size]
Figure 10: Mathematica's Documentation Center is a fully interactive online help system.

Glitches

Brand new software releases are rarely perfect, and Mathematica 7 is no exception. For this review, I evaluated the 64-bit Linux edition of the program and encountered a few annoying bugs and non-working functions. After resolving my initial license key issues with Wolfram's tech support staff (the application is tightly locked down by machine ID), palettes and certain windows had the annoying tendency of popping up underneath my Linux desktop application bar. Apparently someone in QA failed to check that condition or assign it a high enough priority to fix in time for the program's release. Hitting the ALT-F7 to move the misaligned window and expose its title bar. Another annoying omission is the fact that the new Speak function simply does not work on the Linux platform. This was one of the first functions I tried since I was curious to see if Mathematica actually embedded its own voice synthesizer or simply relied on whatever default was installed on the host operating system. The latter turned out to be the case, but only on the Windows and Mac OSX versions. Regardless of whether a voice synthesis package like Cepstral or Festival was installed, the Speak function simply did not work. After following up with Wolfram, they confirmed that this finding was indeed the case and that there were no immediate plans to enable this function on Linux. While I constructed my own LinuxSpeak function (LinuxSpeak[phrase_] := Run["swift", phrase]) to correct this oversight and work with the Cepstral text-to-speech sound set, the dream of a talking cross-platform mathematically-oriented application was shelved for now. I also encountered one unexpected crash to the desktop while running a particularly hairy nested function set. I suspect it was due to exhausting RAM or an overflowed stack but even after searching for a crash dump log which I never did locate, I still don't know what precisely caused the fault. Fortunately that occurred only once in the whole time I used the program over the many days I put it through its paces.

Wish List

While 500+ new features, many of which are major additions, delivers tremendous value to both new Mathematica users and those looking to upgrade, there are so many more that Wolfram can build upon in future editions. One of the biggest areas I would like Wolfram to consider is collaboration. When I met with the many talented scientists, researchers and engineers at the Mathematica Conference, I saw a group of passionate, dedicated, enthusiastic individuals willing to share their knowledge and best practices. I thought, "Wouldn't it be great if I could have permissive access to these highly intelligent minds while working on my own Mathematica programs?" Including a screen sharing, IM-like client that categorized accessible individuals by industry or subject expertise wouldn't be too difficult and would give Wolfram a seriously valuable database of active users. Chat rooms could be monitored/managed by Wolfram tech support and developers and screen-casted collaborative notebooks within the actual Mathematica environment could show off new approaches or features and saved locally for further development and exploration. In line with the collaboration request, Mathematica would need to keep track of collaborative changes by supporting either its own version control system or providing hooks into popular source control systems like Git and Subversion. While these can be used today outside of the Mathematica environment, building such utility into the program's File menu would be a relatively easy feature to add and help promote version control and distributed teams.

Less ambitious requests would be for simple enhancements to the Mathematica notebook structure to include such features as unlimited Undo/Redo, automatic scrap collection, clean-up and more intelligent reformatting of notebook elements would all be welcome additions.

Conclusion

Mathematica 7 has re-ignited my interest in mathematics much the way my brother's TI-59 did years ago. Just as I was blown away by the cutting edge calculation power and programmability of that computational system at the time, so too am I thrilled by the sheer mathematical universe, programming flexibility and multi-core goodness that Mathematica delivers. Existing Mathematica users have little reason not to upgrade to this latest release while programmers and computer systems engineers who have yet to experience how easy and powerful this remarkable platform is should unhesitatingly request the 15-day trial from Wolfram's website and take it for a test drive. Strap in and enjoy the ride!

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.