# Science on Android

I have covered a lot of different scientific packages that are available under Linux in this space, but the focus has been on Linux running on desktop machines. This has been rather short-sighted, however, as lots of other platforms have Linux available and shouldn't be neglected. So in this article, I start looking at the type of science you can do on the Android platform. For my next several articles, I plan to include occasional Android applications that you may find useful.

The first application I want to explore is Maxima for Android. Maxima has been under development since the 1960s at MIT, and it continues to this day under an open-source license. It is a full computer algebra system, written in Common Lisp. Luckily, Embeddable Common Lisp has been ported to Android, so this provides the Lisp engine needed to run the Maxima engine.

Installing Maxima on your Android device is a two-step process. The first step is to install the base application from the Google Play store. Once it is installed and you run it for the first time, the application will unpack the bulk of the application. Because this section is so large, the app will ask you where to unpack it, so you can put it on some other media if you don't have a lot of room in internal storage.

When you initially start Maxima, you get a display of the licensing information and the version number, and then you are presented with an input prompt labeled as "(%i1)". Depending on the device you are using and the age of your eyes, you may have a hard time seeing the output displayed on the screen. If so, you can zoom in and out with a two-finger pinch or zoom, just like in other Android applications. Your other option is actually to change the font size. You can use the command textSize:XX, where XX is the size you want to use for the font in pixels. The suggested range is 10–50 pixels.

Figure 1. When you start Maxima, you get the standard license and version information.

At the bottom of the screen, you will find a text entry box outlined in orange. This is where you enter the Maxima commands you want to run. Once you have entered your command and press Enter, it is displayed in the main window, along with the results. The MathJax library handles the pretty-print display of this mathematical information. The history mechanism used in order to re-use previous commands is very intuitive. When you tap a previous command, it is copied and pasted into the text input command box, ready for you to make any necessary edits before executing it again.

The Android version of Maxima includes a full set of documentation that is available by tapping on the menu icon and selecting the "Manual" option. A lot of examples are available in each section of the manual that you may want to try. Assuming that this would be a common thing people would want to do, you simply can tap the example you want to work with, which will copy the example into the command text input box. This way you can find an example that is close to what you want to try to do and easily copy it into the command box. You then can edit it and make any required changes before running it. This really can speed up any research work you are trying to do with Maxima.

There is also a function named example(). If you call example without any parameters, it will generate a list of all of the subjects that have examples provided. You then can look at the examples for a specific subject by calling example with the named subject. For instance, you can learn about arrays with the command example(arrays). This will pull up and run a series of examples on how to use arrays within Maxima.

The other useful function for speeding up research is the ability to load files of Maxima commands. Maxima for Android automatically looks in the main Download directory when you try to load files. Also, files with the ".txt" filename ending are found and loaded without having to include the file ending. This means if you have a file named "my_script.txt" in the Download directory, you can load it with the command load(my_script). If you use Dropbox and synchronize the Download directory, you easily can move files back and forth between your Android device and your desktop.

One major area that is not completely implemented yet is the graphical system for plots and graphs. However, new features are being added with each new version. The graphical functions actually are provided by gnuplot. The functions currently implemented are plot2d, plot3d, implicit_plot, contour_plot, draw, draw2d and draw3d. These commands pop open a new window to display the results of the plot command.

Because everything is full screen on Android, you need to tap on the back icon to get back to the main Maxima window. If you want to see the plot again, you can tap on the menu and select the "Graph" option. This will re-open the last plotting window.

Another major issue is the lapack library. Trying to load it will cause an error, so you won't have access to the optimized linear algebra functions provided through lapack.

When you are doing complicated research, you may need to stop part way through the process and pick it up again at a later time. This is handled by the concept of a session. Tapping the menu icon, you can select the "Session" option. This will pop open a sub-menu where you can choose either to "Save", "Restore" or "Playback" your session. You have just one saved session state at a time, however, so it is really useful only when you need to stop in the middle of a workflow.

If you are working on a larger project where you are using the same libraries for an extended period of time, you can set initialization code that gets run whenever Maxima starts. This code needs to be stored in the file /data/local/tmp/maxima-init.mac. Any arbitrary Maxima code can be placed here, so you can initialize a pretty complicated environment if you like.

Now you can carry Maxima around in your pocket, ready to work out all of those troublesome problems that come up in everyday life. So, you won't have any excuse for not solving the equations you need in order to plot out your space travel, all on the train ride to work. Just promise to be good, and don't try to use it on your next physics exam.

______________________

Joey Bernard has a background in both physics and computer science. This serves him well in his day job as a computational research consultant at the University of New Brunswick. He also teaches computational physics and parallel programming.