This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
Wolfram Research, Inc.

Building Systems with MathematicaThe World of Mathematica

Mathematica as a Software Component

Mathematica has a modular architecture that makes it easy to use as a highly powerful software component.

Here is some input and output in the standard notebook front end to Mathematica.

You can also access the Mathematica kernel directly from a raw terminal.

Integrate[Sqrt[Log[x]], x]

MathLink provides a general program-level interface between Mathematica and external programs.

Here is C code for sending an expression from an external program to Mathematica.

/* Integrate[Sqrt[Log[x]], x] */

MLPutFunction( stdlink, "EvaluatePacket ", 1);
MLPutFunction( stdlink, "Integrate", 2);
MLPutFunction( stdlink, "Sqrt", 1);
MLPutFunction( stdlink, "Log", 1);
MLPutSymbol( stdlink, "x", 1);
MLPutSymbol( stdlink, "x");
MLEndPacket( stdlink);

Click here to load the kernel and set the working directory to one that contains prebuilt examples for your computer system.

This installs a compiled external C program that does bitwise operations on integers.

This executes the external code for the BitAnd function.

This uninstalls the external program.

You can use MathLink to access the Mathematica kernel from many kinds of programs.

Here is the Microsoft Word front end to Mathematica.

Here is a web site that calls Mathematica.

Here, Microsoft Excel is linked to Mathematica.

Under Microsoft Windows, you can click this button to start a simple example of a Visual Basic front end to Mathematica.

MathLink can also be used to access other programs from within the Mathematica kernel.

MathLink allows you to set up templates to specify how external programs should be called. This defines a link to a C subroutine library.

:Begin:
:Function: anneal
:Pattern: TSPTour[r:{{_, _}..}]
:Arguments: {First[Transpose[r]], Last[Transpose[r]],
Length[r], Range[Length[r]]}
:ArgumentTypes: {RealList, RealList, Integer, IntegerList}
:ReturnType: Manual
:End:

Here is a 3D graphic generated within Mathematica.

This image was generated by sending a description of the graphic from Mathematica, via a MathLink connection, to an external photorealistic renderer.





You can use MathLink to control the Mathematica front end from within the kernel.

This tells the front end to bring up the color selector dialog box.

You can use MathLink to communicate between Mathematica kernels — on one computer or several.

On most computer systems (typically excluding Macintosh) this launches a subsidiary Mathematica kernel on your computer.

This reads data from the subsidiary Mathematica kernel.

This writes a command to the subsidiary kernel.

This reads back the $SessionID from the subsidiary kernel.

The $SessionID in your main kernel will be different.

This closes down the subsidiary kernel.

Building Systems with MathematicaThe World of Mathematica