The following mathematical expression:
In Maple, symbol
:= is used for an assignment. In order to
define a function Maple uses notation that is somewhat closer to the
mathematical original with a
:= notation is a shorthand for calling a function
define whose purpose is to define functions:
Maple, similarly, has a special form, unapply, which has the same
effect as the combination of
In Mathematica functions
are defined more like in Maxima. Here is
F[x_]. The underscore tells Mathematica that
xin the expression on the right is to be understood as a formal parameter, as in .
We can also use the delayed
Set, denoted by
while defining a function,
although, in this case, it wouldn't make much difference, because
x^2 + 1/2 cannot be evaluated any further.
As in Maxima and in Maple, there is a system utility in Mathematica too,
called Function, which can be used to define a function. Here
is an example of how it works.
?gtrick. By placing the question mark in front of a symbol, you can always ask Mathematica how it understands the symbol. We have used it already before when we asked Mathematica about delayed expressions. In this case function
gis not stored in the same way as function
f, even though they have the same effect on their arguments. It is stored as a lambda-expression instead. If you are familiar with Lisp or lambda calculus, you will find it quite natural to think about functions this way.
The definitions of a function in Maxima, Maple and Mathematica
suffer from imprecision. In real mathematics we would usually
specify precisely a set that x belongs to, as well as a set
that the values of F belong to, e.g.,
We will see later on that there are ways to restrict x to certain ranges in this context.