Userdefined functions are a very handy way to simplify routine calculations, such as the distance formula. The distance between the points (h_{1}, k_{1}) and (h_{2}, k_{2}) is : .
A straightforward way to define a function on the TI89 is to use the "Define" command, followed by a list of parameters the function uses, followed by the function's result. See below.
After starting a new problem, press <F4> and select "1: Define". 

You want to pick a meaningful name for your function, but one that's not too long to type. Although it seems like a good idea, singleletter names can be a problem since NewProb automatically erases them. Actually, long function names aren't a problem, because you can always pick the function name from the <2nd><VARLINK> menu. I picked "dist" for the name of the function  type <2nd><alpha>"dist"<alpha>"(" <alpha> "h1," <alpha> "k1," <alpha> "h2," <alpha> "k2)=" 

Now, type the function result, as shown. Then press <ENTER>. 

Example 1 on p. A11 of the Larsen text is shown at right. ("Find the distance between the points (2,1) and (3,4).") You type <2nd><alpha>"dist"<alpha>"(2,1,3,4)"<ENTER>. To get the approximate result on the last line, press <Diamond><ENTER> instead of just <ENTER>. 

A solution is shown at right for Example 3 on p. A12 of the Larsen text. ("Find x such that the distance between (x,3) and (2,1) is 5.") The first step uses the "dist" function to write an equation for "the distance between (x,3) and (2,1) is 5", and the second step uses the solve() function to solve the resulting equation for x. Note that you don't have to type the equation into the solve() function  just use the blue arrow keys to highlight it in the history area and press <ENTER>. It will be copied onto the edit line. 

Here is a second solution for Example 3 which skips the intermediate step. You can use whichever method seems more natural to you. 

The midpoint of the segment connecting the points (h_{1}, k_{1}) and (h_{2}, k_{2}) is . You can create a userdefined function on the TI89 to calculate this as follows:
I thought "mid" would be a good name for this function, but unfortunately, the TI89 already has a builtin function with that name. I chose the name "mpt" for my function. Type <F4><Enter> to select "Define", then type <2nd><alpha>"mpt"<alpha> followed by the parameter list and "=" as shown. 

The right side of the function is shown at right. Note that you have to use square brackets (<2nd>",") in order for the function to return point coordinates (actually a matrix...). Press <ENTER> when done. 

A solution to the problem below Example 3 on p. A12 of the Larsen text (find "the midpoint of the segment joining the points (5,3) and (9,3)") is shown at right. 
