Once you have established a link, you are ready to perform Mathematica calculations inside Excel. One way of doing this is using the EVAL worksheet function. This worksheet function allows you to call any Mathematica function from within an Excel formula. Try entering the simple Mathematica function, Prime, in an empty worksheet cell. This is done as shown. Formula | Result | =EVAL("Prime",100) | 541 |
The value returned is the hundredth prime number. Now, try creating an interactive prime number calculator by specifying a cell reference as an argument. Formula | Result | =EVAL("Prime",A1) | #N/A |
Unless you have already entered a value in cell A1, the function returns unevaluated and displays an error code. The #N/A error code indicates that one or more inputs to the formula are not available. Type any integer you choose in cell A1, and a prime number will be calculated for you. Here are some other examples. Formula | Result | =EVAL("Factorial",10) | 3628800 | =EVAL("Det",A1:C3) | determinate of matrix in cells A1:C3 | =EVAL("Expand","(x+1)^5") | 1 + 5 * x + 10 * x ^ 2 + 10 * x ^ 3 + 5 * x ^ 4 + x ^ 5 | =EVAL("Plot","Sin[x]","{x,-Pi,Pi}") | ExcelGraphic[1] |
The last of these displays a Mathematica graphic. To display Mathematica graphics, the kernel will launch a copy of the Mathematica front end in server mode.
The Mathematica front end as a graphics server. Mathematica contains thousands of functions. If you know precisely which Mathematica function you wish to use and the arguments it takes, you can type it directly into your spreadsheet, as shown. If you are unsure of the name of a Mathematica function or how to use it, or want to explore the functions Mathematica has to offer, click Functions on the Mathematica Toolbar. This will launch the Mathematica Function Wizard. The first step of the wizard is designed to help you find, and learn about, Mathematica functions.
The Mathematica Function Wizard—Step 1. The next step is designed to help you interactively specify arguments to the function.
The Mathematica Function Wizard—Step 2. An optional third step is available to select and specify options for functions such as Plot that have a defined set of options.
The Mathematica Function Wizard—Step 3. Notes • Unlike Excel, Mathematica uses case-sensitive syntax. Therefore, be sure to capitalize Mathematica function names like Prime. • You cannot interact with a Mathematica front end that is in server mode. If you would like to work in the Mathematica front end, you can launch another standard instance of the front end. |