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