To return lists of values to multiple cells, Mathematica functions can be entered as an array formula. Some functions in Mathematica naturally return lists, others can be mapped over lists. Here are some examples. Example | Result | =EVAL("Range","10") | {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} | =EVAL("Map","Factorial",A1:A10) | a list containing the factorial of each number in A1:A10 |
Formulas that can be entered as an array. To enter a formula as an array: Once entered, array formulas appear surrounded by { } in the formula bar. All cells in an array formula range share a single formula, each element of the array returned to a separate cell. The MathematicaLink add-in provides two tools to help make using array formulas easier:
The Array toggle command on the Mathematica Context Menu. Notes • If you manually edit an array formula but forget to select all cells in the array beforehand, an error message will appear when you try to re-enter the formula. If this happens, press Esc to cancel any changes you made. Then, select all cells in the array before making the changes again. • Array formulas can significantly reduce calculation times if the same operation is being performed on a large number of cells. If you have filled a range with the same formula by dragging the formula across the range, it may be much faster to perform these calculations using an array formula. There is a transaction time associated with each call to Mathematica. If a single array formula is used to return values for 100 cells, recalculation could be up to 100 times faster than calling 100 individual formulas. |