327
E.g. 6 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
()
2
21
fx
+ . Note that the sequence of keys is:
▼ ENTER ALPHA F ( XTθ ▲
▲ SHIFT = 2 X
y
2 X
y
XTθ ▲ ▲ ▲
+ 1 ENTER
The CAS will then echo
the function back to you
and, if you go to the
VARS view, you will find
that it is now a defined
variable.
Although we used X as our variable here, there
is no reason for this. We could just as easily
have defined it as
()
2
21
K
fK=+.
You can now call this function by
simply typing, for example, F(5).
We can now test to see if
this is a prime number by
using the ISPRIME?
function from the MATH
menu. This is found in the Integer
section as shown right.
It returns a value of 0 (false) indicating that it is not
a prime number.
Using the FACTOR function
from the menu
shows that its factors are
641 and 6700417.