Universal Mathematica Manipulator—Poor Man’s Mathematica

Universal Mathematica Manipulator

Newer Version(新しいバージョン)

Wolfram CDF Player is a free of charge software to view documents in Computable Document Format (CDF). Users cannot edit codes using the software. For editing, Mathematica is required. Consequently, the relationship between CDF player and Mathematica is similar to the one between Adobe Reader and Acrobat.

Since CDF Player has almost all Mathematica functions to allow rich user experiences, users should take full advantage of those functions.

Although users cannot edit CDF documents with CDF player, they can still input data. If there were a document with a universal manipulator that receives program codes and outputs the evaluated results of them, then the document can perform as poor man’s Mathematica, or a complimentary alternative for Mathematica.

Users cannot use the ordinary Mathematica expressions as inputs, because, according to Wolfram research, CDF does not support non-numeric input fields [FAQ]. However, any expressions can be represented with numbers (e.g., Gödel number), and CDF supports numbers. Consequently, if there were a converter that converted Mathematica expressions to numbers and vice versa, CDF documents could process Mathematica expressions by using the converter.

Then, I developed such a converter. As a result, a CDF document that can process any Mathematica documents with the converter became reality. Therefore, I call the CDF document “Universal Mathematica Manipulator (UMM).”

Yet, one little problem remains. Users cannot paste on CDF documents unless he/she has Mathematica. As numbers that represent Mathematica expressions are very large, it takes a great deal of trouble to input them digit by digit. Luckily, both Mac OS X and Windows have scripting languages that can simulate key strokes: AppleScript for Mac OS X and VBScript for Windows.

The script in AppleScript is given below. It obtains a number from clipboard and emulates key strokes to input it digit by digit.

tell application "System Events"
     set str to get the clipboard
     keystroke "a" using command down
     keystroke str
end tell

This script is created on AppleScript Editor and saved in User Script Folder (~/Library/Scripts). Make sure that Script menu is shown in the menu bar in AppleScript Editor’s preferences. One downside to the script in AppleScript is to have to hit either “Enter” or “Tab” key to resume the script when it stops. Though, the way to eliminate the extra step is unknown.

Also, the script in VBScript is below. It is better than the one in AppleScript, as we do not need to press the enter key after the number is inputted. Nevertheless, this script has a limitation where it cannot handle an input with 5,000 or longer in length.

Set objIE = CreateObject("InternetExplorer.Application")
text = objIE.document.parentwindow.clipboardData.GetData("text")

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.SendKeys(text & "{Enter}")

In executing the script in VBScript, a warning message of Internet Explorer appears. You can disable the message at your own risk. (Tools > Internet Options > Security tab > Custom level… > Scripting > Allow Programmatic clipboard access > Enable)

This system is tested on Wolfram CDF Player Mac OS X x86 and Microsoft Windows (32-bit). Relatively large codes like a solution for Burrau’s problem of three bodies can be executed.

solution for Burrau's problem of three bodies on UMM

Newer Version(新しいバージョン)


メールアドレスが公開されることはありません。 * が付いている欄は必須項目です