Reply on using aliases for command arguments

*To*: Mathematica user's group <MathGroup at yoda.physics.unc.edu>*Subject*: Reply on using aliases for command arguments*From*: Robby Villegas <Villegas at knox.bitnet>*Date*: Tuesday, February 25 1992

Dave Kirkby <davek at mph.sm.ucl.ac.uk> asked how to perform many integrations over the same interval(s) without having to type the interval(s) in each call to Integrate. Dave, your definition of s as a string didn't work because Integrate, like most Mathematica functions, doesn't take strings as arguments, it takes normal expressions. When you want to use a command or function repeatedly with several arguments common to all uses, you can store the arguments as a _sequence_ which can be spliced into the command with ease: s = Sequence[{x, 0, a}, {y, 0, b}] (If you're using version 1 of Mathematica, you could simply enclose the two arguments in parentheses: s = ( {x, 0, a}, {y, 0, b} ). ) Now whenever you want to use Integrate with these arguments, just use s in the position where you would have placed "{x, 0, a}, {y, 0, b}" : Integrate[x y, s] You could use a Sequence definition for just about any Mathematica function or command, but some take their input literally instead of evaluating it first. For instance, most of the plotting commands (Plot, Plot3D, ParametricPlot3D, etc) hold their arguments unevaluated, so if your intervals above were being used for plotting instead of integrating, you would need to hang an Evaluate on your alias 's': ParametricPlot3D[f[x, y], Evaluate[s] ] Look for HoldFirst, HoldRest, or HoldAll in the list returned by Attributes[cmmd] to decide if you'll need the Evaluate around your alias 's' when it is used inside a command 'cmmd'. In fact, if you use Integrate with fixed limits a lot, you might also want NIntegrate, and NIntegrate is a HoldAll function, so in contrast to Integrate, you would need the Evaluate. A different method would be to define a function of a short name which contains the fixed limits of integration in its formula: int[f_] := Integrate[f, {x, 0, a}, {y, 0, b}] Here, any expression you give as input to the function 'int' will be fed as is to the formula, so no Evaluate trickiness is involved, no matter what command is being used. Robby Villegas Knox College (Villegas at Knox.Bitnet)