When specifying a Mathematica function, the function does not necessarily have to be a named Mathematica function. The function can also be specified as a nameless pure function. Using pure functions, you can use multiple functions to create a new function on the fly. The syntax of Mathematica pure functions is as follows: • Slots for individual arguments are specified as #1, #2, .... • All arguments can collectively be inserted at one point using ##. Here, a pure function with two arguments is created in a step-by-step way. Method | Notes | =EVAL("Sum[1/x^3,{x,10}]") | this sums the first ten terms in the series | =EVAL("Sum[1/x^3,{x,#1}]","10") | number of terms is now specified as a pure function argument | =EVAL("Sum[1/x^#2,{x,#1}]","10","3") | exponent of x is now specified as a second pure function argument |
Creating a pure function. Note that, as shown, arguments do not have to appear in sequential order inside the function. The index specifies which argument goes where. Once values that may be edited have been specified as arguments, a reference to the cells containing the values can be made. This is discussed in the next section. Notes • If you are familiar with pure functions, you will notice the pure function indicator (&) is not used here. There is no need because, in this context, it is clear that if pound signs are present, a pure function is being specified. • For more information on creating and using pure functions refer to The Mathematica Book. |