
Example 8: Defining a user function
The
DEF
function allows you to define your own functions, which are then available for use. In the example
below it has been used to define Fermat’s prime function
f x
2
2
x
+
1
. Note that the sequence of keys is:
( )
=
ENTER ALPHA F (
SHIFT = 2
2
+ 1 ENTER
The CAS will then echo the function back to you and, if you press
VARS
to go to the
VARS
view, you will find that it is now a defined variable.
Use the
button at the bottom of the screen to see the definition of
the variable. Press
ON
to exit the view.
Although we used
X
as our variable here, there is no reason for this.
We could just as easily have defined it as
f K
=
2
2
K
+
1
.
( )
You can now call this function by simply typing, for example,
F(5)
.
350