lect_19 - Recursive definition Margaret M. Fleck 5 March...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Recursive definition Margaret M. Fleck 5 March 2010 In this lecture, we see how to define functions and sets recursively, a math- ematical technique that closely parallels recursive function calls in computer programs. 1 Announcements Exams were returned in lecture today. If you missed lecture, well also bring them to discussion sections next week and afterwards you can get them at office hours. 2 Recursive definitions Youve all seen recursive procedures in programming languages. Recursive function definitions in mathematics are basically similar. A recursive definition defines an object in terms of smaller objects of the same type. Because this process has to end at some point, we need to include explicit definitions for the smallest objects. So a recursive definition always has two parts: Base case or cases Recursive formula/step 1 Recursive definitions are sometimes called inductive definitions or (espe- cially for numerical functions) recurrence relations. For example, recall that the factorial function n ! is defined by n ! = n ( n- 1) . . . 2 1. We can define the factorial function n ! recursively: 0! = 1 n ! = n ( n- 1)! The recursive definition gets rid of the annoyingly informal . . . and, therefore, tends to be easier to manipulate in formal proofs or in computer programs. Notice that the base and inductive parts of these definitions arent ex- plicitly labelled. This is very common for recursive definitions. Youre just expected to figure out those labels for yourself. Heres another recursive definition of a familiar function: g (1) = 1 g ( n ) = g ( n- 1) + n This is just another way of defining the summation n i =1 n . This par- ticular recursive function happens to have a nice closed form: n ( n +1) 2 . Some recursively-defined functions have a nice closed form and some dont, and its hard to tell which by casual inspection of the recursive definition....
View Full Document

This note was uploaded on 09/21/2011 for the course CS 173 taught by Professor Erickson during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 7

lect_19 - Recursive definition Margaret M. Fleck 5 March...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online