High School Modules > Algebra by Gregory A. Moore
Functions & Relations
The definition of a function, and the connection with relations, domains and ranges, numeric and algebraic views of functions.
[Directions : Execute the Code Resource section first. Although there will be no output immediately, these definitions are used later in this worksheet.]
0. Code
| > | restart; with(plots): |
Warning, the name changecoords has been redefined
| > | Domain := proc( SET ) local domain, k; domain := {}; for k from 1 to nops(SET) do domain := domain union {SET[k][1]}; od: domain; end proc: |
| > | Range := proc( SET ) local range, k; range := {}; for k from 1 to nops(SET) do range := range union {SET[k][2]}; od: range; end proc: |
1. Relations, Domains & Ranges
A relation is any pairing of values. A function is a special type of relation where each of the first type of item only has one of the second type.
| > | fruity_colors := { [apple,red],[banana,yellow],[kiwi,green], [cherry,red],[lemon,yellow],[pear,green]}; |
The first element of each pair is a fruit, and the second element is the color of the fruit. The set of all fruits is the domain of the relation, and the set of all colors is the range.
| > | Domain(fruity_colors); |
| > | Range(fruity_colors); |
Lets look at some other examples.
| > | Baseball_teams := { [Los_Angeles, Dodgers], [New_York, Yankees], [Toronto, Blue_Jays], [San_Francisco,Giants], [Atlanta,Braves] }; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
| > | Typcal_foods := { [America, hotdog], [Mexico, Taco], [Japan, Sushi], [India,Naan],[Middle_East,felafel], [Vietnam,Pho] }; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
We can also have relations of numbers of course.
| > | Number_set := { seq([k, k^2], k = 1..9) }; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
| > | Number_set := { seq([(k-2)^2, (k-4)^2], k = 1..7) }; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
2. Functions & Relations
A relation is any pairing of values. A function is a special type of relation where each of the first type of item only has one of the second type. The set of fruity colors is function because each fruit has only one color - even though some fruit may have the same color as other fruit.
| > | fruity_colors := { [apple,red],[banana,yellow],[kiwi,green], [cherry,red],[lemon,yellow],[pear,green]}; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
In this next case, some of the values of the domain have more than one value of the range. Thus this is NOT a function.
| > | country_and_cities := { [Canada, Toronto], [Canada, Montreal], [USA, New_York], [ USA, Los_Angeles], [Mexico, Guadalajara], [Japan, Osaka], [ Japan, Tokyo], [Russia, Moscow], [India, Bombay], [India, Delhi]}; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
Look closely at these number sets. In the first set, each x value has only one y value. But this is not true in the second example. A function is a relation for which each member of the domain only is only associated with one member of the range. Thus the first set is a function, while the second one is not.
| > | Number_set := { seq([k, k^2], k = 1..9) }; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
| > | Number_set := { seq([(k-3)^2, (k-5)^2], k = 1..7) }; `\n the domain `= Domain(%); `\n the range ` = Range(%%); |
3. Functions as Tables
Functions can also be expressed as tables of values. The values of x from the domain are on the left, and values of y from the range are at right.
| > | restart: |
| > | f:= x -> 100-x^2: array( [[ k,f(k) ] $ k = 0..8] ); |
| > | f:= x -> 2*floor(x/2): array( [[ k,f(k) ] $ k = 0..8] ); |
| > | f:= x -> 2^x + 1; array( [[ k, f(k)] $ k = 1..8] ); |
The values don't necessarily have to be integers.
| > | f:= x -> : array( [[ k,f(k) ] $ k = 0..8] ); |
Error, `:` unexpected
| > | f:= x -> evalf(sin(Pi/(x+3))): array( [[ k, f(k)] $ k = 1..8] ); |
4. Functions as Formulas
Most of the functions that we will see for now can be expressed as a formula of some sort. In these cases, there is an input, x, and and output f(x). For value of x, there is a corresponding value f(x).
| > | f := x -> 3*x^2 -10*x + 21; `f(0)` = f(0); `f(1)` = f(1); `f(-1)` = f(-1); `f(10)` = f(10); `f(100)` = f(100); `f(10000)` = f(10000); |
Functions come in all shapes and sizes.
| > | f := x -> (x^2 + 11)/(3*x^2 - 9); `f(0)` = f(0); `f(1)` = f(1); `f(-1)` = f(-1); `f(10)` = f(10); `f(100)` = f(100); `f(10000)` = f(10000); |
| > | f := x -> x - 3/(x^2 + 3); `f(0)` = f(0); `f(1)` = f(1); `f(-1)` = f(-1); `f(10)` = f(10); `f(100)` = f(100); `f(10000)` = f(10000); |
Functions can also represent science formulas as well as abstract mathematical functions
| > | Centigrade := F -> (5/9)*(F-32); Centigrade(0); Centigrade( 212); |
| > | Feet2Inches := inches -> inches * 12; Feet2Inches(1); Feet2Inches(2.5); Feet2Inches(6); |
| > | Grams2Kg := grams -> grams*1000; Grams2Kg(3000); Grams2Kg(10); |
Notice that functions can also be evaluated with constants.
| > | f := x -> (x+3)/(x-5); f(6); f(15); f(Q); f(any_value); |
| > | f := x -> 100*x^3 + 2000*x + 3000; f(6); f(15); f(Q); f(any_value); |
© 2002 Waterloo Maple Inc