Mathematica Basics--Functions II

Introduction

In this notebook we will look at how you as the user can create your own recursive functions in Mathematica.

Review: Certain ideas in mathematics are best expressed recursively. One situation that frequently uses the idea of recursion is that of constructing sequences. Obviously not all sequences require recursion in their definition, but some of the more interesting ones do.

One way of looking at the idea of sequences it to consider them to be functions which take the set of natural numbers as their domain. For example, the non-recursive sequence:

1, 4, 9, 16, 25, 36, 49, 64,...

can be thought of as shorthand (or should that be longhand?) for the function:

f(n) = n2, n=1, 2, 3, 4, 5, 6, 7, 8,...

And the famous Fibonacci sequence:

1, 1, 2, 3, 5, 8, 13, 21, 34,...

can be thought of as the recursive function:

fib(n) = fib(n-1) + fib(n-2)

fib(1) = fib(2) = 1

the latter two equations are referred to as the initial values of the sequence or function.

Evaluating Commands

Remember, as we said in the introduction to the first notebook, in order to tell Mathematica that you want it to actually evaluate what you have typed, hit the ENTER key over on the extreme right side of your keyboard on the numeric keypad. Again, don't confuse this with the RETURN key, which merely starts a new line of text.



You can now switch to the actual Mathematica practice notebook by clicking on the button at left. It will take a while to start up! Don't forget to come back here when you're done by using the Applications menu! (You can also use this menu just to come back here to reread the instructions.) See you in a few minutes.

Welcome back! Hopefully everything went well. You may now go to the Table of Contents for the Mathematica Basics Labs, or simply quit.




Mathematica Basics by Christopher A. Barker
©1998 Christopher A. Barker, 5151 Pacific Ave., Stockton, CA 95207, USA
e-mail: barker@inreach.com; WWW: http://barker.sjdccd.cc.ca.us/home.html