Defining Functions

You can define your own functions. In general, the syntax for defining a function is:
myfunction(parameter1, parameter2, ...) = expression
Functions can depend on one or more variables. Function names are not case sensitive. This means, for example, that the function Y(x) will be the same as y(x).

You can see which functions are currently in memory in the Memorylist. If the Memorylist isn't visible, then select Memorylist from the menu View or press <F9> to make it visible.

You can delete a defined function by selecting the function in the Memorylist and pressing <DEL>, or by typing the command Clear(myfunction) in the workarea. See System functions for more information about Clear.


Examples

' Define a function.
Y(x) = 2 * x ^ 2
       Y(x) is defined

' Now use the defined function.
Y(3)
       Ans = 18

Y(2/5)
       Ans = 0.32

0.5 * Y(3 + 4)
       Ans = 49

' Functions can depend on more than one variable.
Surface(width, height) = width * height
       Surface(width,height) is defined

Surface(5, 3)
       Ans = 15

Surface(5, 3 + 2)
       Ans = 25

' End the line with a semicolon to hide the answer.
Hyp(s1, s2) = Sqrt(s1 ^ 2 + s2 ^ 2);

Hyp(3, 4)
       Ans = 5

'Delete a function
Clear(Y)
       Done

'Test if the function doesn't exist anymore
Y(3.5+2)
       Error: Unknown function Y( )
Back to top

See Also

Memorylist, Defining Variables, System functions