This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / The Mathematica Book / Practical Introduction / Files and External Operations  /

1.11.9 Splicing Mathematica Output into External Files

If you want to make use of Mathematica output in an external file such as a program or document, you will often find it useful to "splice" the output automatically into the file.


Splicing Mathematica output into files.

The basic idea is to set up the definitions you need in a particular Mathematica session, then run Splice to use the definitions you have made to produce the appropriate output to insert into the external files.


#include "mdefs.h"

double f(x)
double x;
{
double y;

y = <* Integrate[Sin[x]^5, x] *> ;

return(2*y - 1) ;
}


A simple C program containing a Mathematica formula.


#include "mdefs.h"

double f(x)
double x;
{
double y;

y = -5*Cos(x)/8 + 5*Cos(3*x)/48 - Cos(5*x)/80 ;

return(2*y - 1) ;
}


The C program after processing with Splice.