IMSE Week 25 Introduction to Functions - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

IMSE Week 25 Introduction to Functions

Description:

our other examples have made use of more ... drivers and on-the-road drivers ... Joe maps onto 22, or. Joe and 22 form a pair or a maplet. A Function as a Set ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 13
Provided by: Spen161
Category:

less

Transcript and Presenter's Notes

Title: IMSE Week 25 Introduction to Functions


1
IMSE Week 25 Introduction to Functions
  • our Aircraft example only consists of one set,
    the set of people who are on board
  • our other examples have made use of more than one
    set, but each time one set was a subset of
    another, e.g.
  • - users and logged-in users
  • - drivers and on-the-road drivers
  • more interesting systems have more than one set,
    where one is not a subset of another but is
    related in a different way

2
  • suppose we have two sets, the set of persons and
    the set of natural numbers
  • and we also have a relationship between these two
    sets, the relationship of age
  • it may help to visualise this using a diagram

3
Relations v Functions
  • the technical term for such relationships as age
    are relations
  • certain special relations are called functions
    when there is at most one value at the right for
    each value at the left
  • in our example age is a function and not just a
    relation, as no one has more than one numeric age
  • this is clearly shown by our diagram as the lines
    do not diverge (point to more than one number) at
    the right

4
Arrows, Arrows
  • we say that age is a function from person to
    natural number, or in shorthand
  • age PERSON ? N plain arrow
  • we can also write
  • Joe å 22 arrow with a vertical bar at
    the end
  • meaning that
  • Joe maps onto 22, or
  • Joe and 22 form a pair or a maplet

5
A Function as a Set
  • building on this idea, the function age can be
    thought of as a set, consisting of pairs or
    maplets
  • so it makes sense in our previous example to say
  • age Joe å 22, Helen å 22, Paul å 20,
    Linda å 29
  • and that
  • Joe å 22 ? age
  • where all of these five arrows have a vertical
    bar at the end, signifying maplets

6
Total and Partial Functions
  • age was a total function, because every person
    has an age
  • i.e. there is nothing inside the source set (left
    hand square) which is not inside the domain (left
    hand circle) of the function
  • if this is not the case, the function is partial
  • note that this does not apply to the right hand
    side of the diagram - we would still have a total
    function even if there was something inside the
    right hand square (the target set) which is not
    inside the right hand circle (the range of the
    function)
  • strict definitions of the domain and range of our
    function
  • dom age - that subset of the source containing
    values which are related by age to values in the
    target
  • ran age - that subset of the target containing
    values which are related by age to values in the
    source

7
  • Example of a Partial Function
  • an example of a partial function is the function
    driverNum from person to natural number
  • it is partial as some people have no driver number

8
ß Partial Function Arrow
  • to distinguish between total and partial
    functions we use different arrows
  • age is a total function from person to natural
    number
  • age PERSON ? N
  • total function - plain arrow
  • driverNum is a partial function from person to
    natural number
  • driverNum PERSON ß N
  • partial function - arrow with a vertical line
    cutting it in half

9
Modifying Functions
  • functions can be modified in several ways
  • we will look at 3 of them in the context of our
    age function
  • adding mapping pairs which is needed when
  • - a new person is born
  • removing mapping pairs, which is needed when
  • - a person dies
  • overriding mapping pairs, which is needed when
  • - a persons age changes on their birthday

10
  • we can add the maplet Freddie å 0 to our function
    age
  • remembering that we can think of a function as a
    set of pairs or maplets we can write
  • age Freddie å 0, Joe å 22, Helen å 22, Paul
    å 20, Linda å 29
  • or age ? Freddie å 0

11
Removing Mapping Pairs
  • suppose that Joe dies - we can remove him from
    the function by saying
  • age \ Joe å 22
  • this maplet can also be removed by restriction -
    we can write
  • Joe y age
  • which means the function (or set of maplets)
    named age without the maplet containing Joe
  • this gives us an alternative method of referring
    to a maplet by only one element of its pair

12
Overriding
  • suppose Linda is the first person in our example
    to have a birthday
  • we need to alter the second half of the maplet
    Linda å 29
  • i.e. we need to alter a value in the range of the
    function age
  • Linda is in the domain, 29 is in the range, and
    we say that we override the function age when we
    give new values in the range for values in the
    domain
  • we use the following notation to override her age
    (but no one elses)
  • age ? Linda å 30 or
  • age ? Linda å(age Linda 1)
Write a Comment
User Comments (0)
About PowerShow.com