| home | contents | previous | next page | send comment | send link | add bookmark |

10.1. Terminology and notation

The name of a function and associated independent variables are conventionally declared using the form:

name( var1, var2, ...)
In this context, the parentheses enclose the identifiers of the independent variables. A function definition usually places the name and the associated independent variable list on the left hand side of an equality symbol. The right hand side gives an algebraic expression that defines the function. For example:
f(x) = x2 + 3x + 2
Given a function definition as above, the evaluation of a function for a particular argument is performed by substitution. For example, to indicate that f(x) is to be evaluated for x = 2, we replace x with the number 2 in the function declaration and write:
f(2) 
The number 2 is the argument of the function. This indicates that the function is to be evaluated as:
f(2) = 22 + 3×2 + 2 = 12

Multivariate functions

When a function has more than one independent variable, the order of the variables in the function declaration is important in evaluation of the function. Consider the example:

g(x, y) = 2x + 3y
In this, we indicate that g(x, y) is to be evaluated for x = 5 and y = 7 by writing g(5, 7) where the order of the arguments corresponds to the order of the independent variables. So, we evaluate the function as follows:
g(5, 7) = 2(5) + 3(7) = 31
The arguments to a function may be algebraic expressions. In the example, g(x, y), we may write:
g(2t, t2)
As an example, if t = 3.3, the following evaluation is implied:
g(2t, t2) = 2(2t) + 3(t2) 
          = 2(2×3.3) + 3(3.32) = 2×6.6 + 3×10.89 
          = 45.87

Using functions in computer programs

In the Zeno computer programming language, a function to implement this example could be written as:

function g(x, y: real) : real

    return 2*x + 3*y

end function
Such a function may be used in a Zeno program as follows:
t := 3.3
z := g(2*t, t^2)


| home | contents | previous | next page | send comment | send link | add bookmark |

Copyright © 2005, Stephen R. Schmitt