Previous Up Next

2.15.1  Difference between function and expression

A function f is defined for example by :
f(x):=x^2-1 or by f:=x->x^2-1
that is to say, for all x, f(x) is equal to the expression x2−1. In that case, to have the value of f for x=2, input :f(2).
But if the input is g:=x^2-1, then g is a variable where the expression x2−1 is stored. In that case, to have the value of g for x=2, input : subst(g,x=2) (g is an expression depending on x).

When a command expects a function as argument, this argument should be either the definition of the function (e.g. x->x^2-1) or a variable name assigned to a function (e.g. f previously defined by e.g. f(x):=x^2-1).
When a command expects an expression as argument, this argument should be either the definition of the expression (for example x^2-1), or a variable name assigned to an expression (e.g. g previously defined, for example, by g:=x^2-1), or the evaluation of a function. e.g. f(x) if f is a previously defined function, for example, by f(x):=x^2-1).


Previous Up Next