Lecture 8 Powerpoint

advertisement
Mathematics for Computing
Lecture 8:
Functions
Dr Andrew Purkiss-Trew
Cancer Research UK
e-mail: a.purkiss@mail.cryst.bbk.ac.uk
Functions
Functions
What is a function?
Range and other rules
Composite functions
Inverse of function
Formula
Functions relate two sets of numbers:
y  4x  2
3
2
y  x  3x  7 x  6
y  mx  c
2
Each x gives a value of y
so in the first function, x = 2, gives y = 18.
In the second function, x = 1, gives y = -1.
General form
General form
f ( x)  x
2
use f,g or h to represent function.
Functions and Sets
Definition: For sets X and Y, A function from
X to Y is a rule that assigns each element of X
to a single element of Y
f : X Y
X is the domain, Y is the codomain
If x is any element of X. Then each element
of Y assigned to x is called the image of x
and written f (x)
Example
f : R  R, f (x)  x
f (5)  25
f ( 4)  16
f ( 3)  3
x
f
2
x2
Range
If f:XY is a function then the range is
{yY: y= f(x) for some or all xX}
Example
f : R  R, f ( x)  x
2
The range of f is {y:y0}
Another example
A = {1,3,5}, B={2,4,6,8}
f:A B, f(1)=2, f(3)=6, f(5)=2
The range of f = {2,6}
1
2
4
6
8
3
5
A
B
More definitions
Onto
A function is onto if its range is equal to its
codomain.
One-to-one
A function is one-to-one if no two distinct
elements of the domain have the same
image.
Examples of definitions
Not one-to-one
Not onto
One-to-one
Not onto
One-to-one
Onto
Not one-to-one
Onto
Not a function
Composite functions
Composite function link two functions
together
x
f
f(x)
g
g(f(x))
Let A,B and C be arbitrary sets:
f:AB and g:BC
Input is {x:xA} and output g(f(x))C
Composite Functions 2
Formal definition
Let f:AB and g:BC. The composite
function of f and g is
g o f :AC, (g o f)(x) = g(f(x))
Composite Function Example
f:RR, f(x) = x2 and g:RR, g(x) = 2x + 1
f o g : RR, (f o g)(x) = f(g(x))
= f(2x+1)
=(2x+1)2
g o f : RR, (g o f)(x) = g(f(x))
= g(x2)
=2x2+1
Identity and Inverse
Identity
I:AA, i(x)=x
Inverse of a function is the function that
‘reverses’ the effect of the function. It is
represented by f –1 for the function f
Inverse 2
Let f:AB and g:BA be functions
If g o f : AA is the identity function on A
and if f o g : BB is the identity function
on B, then f is the inverse of g (and g is the
inverse of f )
Download