7
$\begingroup$

I am going through some of the items in "Modern Differential Geometry of Curves and Surfaces with Mathematica, Third Edition".

An example of the style used by these authors is:

piriform[a_, b_][t_] := {a (1 + Sin[t]), b Cos[t] (1 + Sin[t])}

ParametricPlot[Evaluate[piriform[1, 1][t]], {t, 0, 2 Pi}, AspectRatio -> Automatic]

Can someone please explain why they use piriform[a_, b_][t_] as opposed to piriform[a_, b_, t_]?

Is there some advantage to the authors' form over the latter form?

$\endgroup$
9
$\begingroup$

The form f[a_, b_][t_] allows you to conveniently use f[a, b] as if it were a function. For example, you can Map it over a list:

f[a_, b_][t_] := a^t + b

f[2, 3] /@ {4, 6, 8}
{19, 67, 259}

Please see Define parameterized function for details about this format and alternatives. See also What is the distinction between DownValues, UpValues, SubValues, and OwnValues? for notes about the specific evaluation of SubValues definitions.

Be aware that it is difficult to use Hold attributes for the additional parameters of a function written this way but one can emulate it to a degree. See for example:

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.