High School Modules > Algebra by Gregory A. Moore
The Algebra of Functions
Combining functions by sums, products, differences, quotients, and compostion.
[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
| > | FuncOps := proc( f, g, a, b ) local N, M, P, i,j,k, A, p ; A := array( [seq( [ seq( ` `, j = 1..7 ) ], i = a..b+1 ) ]); A[1,1] := `x`; A[1,2] := `f(x)`; A[1,3] := `g(x)`; A[1,4] := `f(x)+g(x)`; A[1,5] := `f(x)-g(x)`; A[1,6] := `f(x)*g(x)`; A[1,7] := `f(x)/g(x)`; for i from a to b do A[i+1, 1] := i; od; for i from a to b do A[i+1, 2] := f(i); od; for i from a to b do A[i+1, 3] := g(i); od; for i from a to b do A[i+1, 4] := f(i)+g(i); od; for i from a to b do A[i+1, 5] := f(i)-g(i); od; for i from a to b do A[i+1, 6] := f(i)*g(i); od; for i from a to b do if( g(i) = 0) then A[i+1, 7] := `undef`; else A[i+1, 7] := f(i)/g(i); fi; od; print(A); end proc: |
| > | FuncComp := proc( f, g, a, b ) local N, M, P, i,j,k, A, p ; A := array( [seq( [ seq( ` `, j = 1..3 ) ], i = a..b+1 ) ]); A[1,1] := `x`; A[1,2] := `g(x)`; A[1,3] := `f(g(x))`; for i from a to b do A[i+1, 1] := i; od; for i from a to b do A[i+1, 2] := g(i); od; for i from a to b do A[i+1, 3] := f(g(i)); od; print(A); end proc: |
1. Arithmetic Operations on Functions - Algebraically
The four basic arithmetic operations of adding, subtracting, multiplying, and dividing, can be performed on functions in the same way one would perform these operations on numbers or expressons. Its pretty straight forward. When adding and subtracting you combine like terms.
| > | f := x -> 3*x + 2; g := x -> 8*x - 7; `f(x) + g(x)` = f(x) + g(x); `f(x) - g(x)` = f(x) - g(x); `f(x) * g(x)` = f(x) * g(x); `f(x) / g(x)` = f(x) / g(x); |
| > | f := x -> x; g := x -> 1/x; `f(x) + g(x)` = f(x) + g(x); `f(x) - g(x)` = f(x) - g(x); `f(x) * g(x)` = f(x) * g(x); `f(x) / g(x)` = f(x) / g(x); |
| > | f := x -> x^2 - 6*x + 13; g := x -> x^2 + 9*x - 22; `f(x) + g(x)` = f(x) + g(x); `f(x) - g(x)` = f(x) - g(x); `f(x) * g(x)` = f(x) * g(x); `f(x) / g(x)` = f(x) / g(x); |
2. Arithmetic Operations on Functions - Numerically
Lets look at how these operations affect the the numerical values.
| > | f := x -> 2*x ; g := x -> 3*x; FuncOps(f, g, 1, 5); |
| > | f := x -> 2*x + 3 ; g := x -> -4*x + 20; FuncOps(f, g, 1, 5); |
| > | f := x -> x ; g := x -> 1/x; FuncOps(f, g, 1, 6); |
| > | f := x -> x^2 + 3*x + 2 ; g := x -> x^2 -5*x + 7; FuncOps(f, g, 1, 6); |
| > | f := x -> abs(x-3) ; g := x -> abs(x-5); FuncOps(f, g, 1, 7); |
3. Arithmetic Operations on Functions - Graphically
Just for fun, lets look at how these operations affect the graphs.
Example 1
Here are two functions. We will graph the functions along with their sums, differences, product, and quotient.
| > | f := x -> 20; g := x -> x; |
| > | r := y = -30..30: A := plot( { f(x), g(x) }, x = -5..5, r, color = black, thickness = 1): Bp := plot( f(x)+g(x), x = -5..5, r, color = blue, thickness = 2): Bm := plot( {f(x)-g(x), g(x)-f(x)}, x = -5..5, r, color = green, thickness = 2): Cp := plot( f(x)*g(x), x = -5..5, r, color = red, thickness = 2): Cm := plot( f(x)/g(x), x = -5..5, r, color = gold, thickness = 2, discont = true): |
The origial functions are in black and thin. The sum is blued, and differences, f-g and g-f are green.
| > | plots[display](A,Bp,Bm); |
The origial functions are in black and thin. The product is red, and quotient is gold.
| > | plots[display](A,Cp,Cm); |
Example 2
Here are two functions. We will graph the functions along with their sums, differences, product, and quotient.
| > | f := x -> 3*x; g := x -> 2*x; |
| > | r := y = -20..20: A := plot( { f(x), g(x) }, x = -5..5, r, color = black, thickness = 1): Bp := plot( f(x)+g(x), x = -5..5, r, color = blue, thickness = 2): Bm := plot( {f(x)-g(x), g(x)-f(x)}, x = -5..5, r, color = green, thickness = 2): Cp := plot( f(x)*g(x), x = -5..5, r, color = red, thickness = 2): Cm := plot( f(x)/g(x), x = -5..5, r, color = gold, thickness = 2, discont = true): |
The origial functions are in black and thin. The sum is blued, and differences, f-g and g-f are green.
| > | plots[display](A,Bp,Bm); |
The origial functions are in black and thin. The product is red, and quotient is gold.
| > | plots[display](A,Cp,Cm); |
Example 3
Here are two functions. We will graph the functions along with their sums, differences, product, and quotient.
| > | f := x -> x; g := x -> floor(x); |
| > | r := y = -10..10: A := plot( { f(x), g(x) }, x = -5..5, r, color = black, thickness = 1): Bp := plot( f(x)+g(x), x = -5..5, r, color = blue, thickness = 2): Bm := plot( {f(x)-g(x), g(x)-f(x)}, x = -5..5, r, color = green, thickness = 2): Cp := plot( f(x)*g(x), x = -5..5, r, color = red, thickness = 2): Cm := plot( f(x)/g(x), x = -5..5, r, color = gold, thickness = 2, discont = true): |
The origial functions are in black and thin. The sum is blued, and differences, f-g and g-f, are green.
| > | plots[display](A,Bp,Bm); |
The origial functions are in black and thin. The product is red, and quotient is gold.
| > | plots[display](A,Cp,Cm); |
Example 4
Here are two functions. We will graph the functions along with their sums, differences, product, and quotient.
| > | f := x -> 11*x^2 - 6*x + 13; g := x -> 8*x^2 + 19*x - 41; |
| > | r := y = -60..80: A := plot( { f(x), g(x) }, x = -5..5, r, color = black, thickness = 1): Bp := plot( f(x)+g(x), x = -5..5, r, color = blue, thickness = 2): Bm := plot( {f(x)-g(x), g(x)-f(x)}, x = -5..5, r, color = green, thickness = 2): Cp := plot( f(x)*g(x), x = -5..5, r, color = red, thickness = 2): Cm := plot( f(x)/g(x), x = -5..5, r, color = gold, thickness = 2, discont = true): |
The origial functions are in black and thin. The sum is blued, and differences, f-g and g-f are green.
| > | plots[display](A,Bp,Bm); |
The origial functions are in black and thin. The product is red, and quotient is gold.
| > | plots[display](A,Cp,Cm); |
4. Composite Functions - Numeric & Algebraic Approach
The Idea of Composite Functions
To compose functions means to evaluate one function, and then take that output as the input for the next function. In a sense, the functions are applied serially. This is not an arithmetic operation. In the operations of addition, subtraction, multiplication, and division we looked above, the values of each function were computed and then the operation performed. In this case, its as though one function is embedded into the other.
| > | f := x -> 2*x + 1; g := x -> 3*x - 7; |
| > | g(1); |
| > | f(%); |
| > | `f(g(1))` = f(g(1)); |
We find f(g(10)) by computing g(10) = 23, and then computing f(23). Lets try some more examples.
| > | f := x -> 2*x + 1; g := x -> 3*x - 7; g( 0 ); `g(0)` = %; `f(g(0))` = f(%%); |
| > | f := x -> 13*x + 7; g := x -> 1/(x+2); g( 4 ); `g(4)` = %; `f(g(4))` = f(%%); |
The Idea of Composite Functions - Tables
To compose functions means to evaluate one function, and then take that output as the input for the other. In a sense, the functions are applied serially. This is not an arithmetic operation. In the operations of addition, subtraction, multiplication, and division
| > | f:= x->3*x; g:= x-> 2*x; FuncComp( f,g, 1,10); |
| > | f:= x-> 4*x - 7; g:= x-> 3*x + 2; FuncComp( f,g, 1,10); |
| > | f:= x-> 10*x; g:= x-> x^2 ; FuncComp( f,g, 1,8); |
| > |
Simplifying Composite Functions
When composing functions, its often necessary to do a little algebra to simplify the result.
| > | f := x -> (x+1)^2 ; g := x -> 4 + 7/x; f(g(x)): % = expand(%); |
| > | f := x -> x^2 + 2 ; g := x -> 5*x + 11; f(g(x)): % = expand(%); |
Self-Composite Functions
When you compose two functions, there is nothing stopping you from composing a function with itself!
| > | f := x -> 20*x - 33; f(f(x)); |
| > | g := x -> (x+1)/(x+2); g(g(x)); simplify( expand(%)); |
5. Composition is NOT Commuative (in general)
Addition and multiplication of functions is commutative - which means that a different order gives the same results.
| > | f := x -> 5*x + 11 ; g := x -> (x-2)/(x+7); `(f+g)(1)`=f(1) + g(1), `(g+f)(1)`=g(1) + f(1); `(f*g)(1)`=f(1) * g(1), `(g*f)(1)`=g(1) * f(1); |
However, composition of functions is usually NOT commutative. If you change the order of composition from f(g(x)) to g(f(x)), you usually get different values. Lets try out some numbers.
| > | `f(g(1))` = f(g(1)); `g(f(1))` = g(f(1)); |
| > | `(f+g)(3)`=f(3) + g(3), `(g+f)(3)`=g(3) + f(3); `(f*g)(3)`=f(3) * g(3), `(g*f)(3)`=g(3) * f(3); `f(g(3))` = f(g(3)), `g(f(3))` = g(f(3)); |
| > | `(f+g)(0)`=f(0) + g(0), `(g+f)(3)`=g(0) + f(0); `(f*g)(0)`=f(0) * g(0), `(g*f)(3)`=g(0) * f(0); `f(g(0))` = f(g(0)), `g(f(0))` = g(f(0)); |
Compare these two tables - same two functions, same domain. But the final results are different!
| > | f:= x-> 10*x; g:= x-> x^2 ; FuncComp( f,g, 1,8); FuncComp( g,f, 1,8); |
| > | f:= x-> x^2; g:= x-> x + 10 ; FuncComp( f,g, 1,8); FuncComp( g,f, 1,8); |
| > | f:= x-> 10; g:= x-> x^2 ; FuncComp( f,g, 1,8); FuncComp( g,f, 1,8); |
We can see this algebraically also.
| > | f := x -> 5*x + 11 ; g := x -> (x-2)/(x+7); f(g(x)): `f(g(x))` = %; simplify( expand( %%) ); g(f(x)): `g(f(x))` = %; simplify( expand( %%) ); |
| > | f := x -> x^2 + 10*x - 7 ; g := x -> x^2 -10*x + 7; f(g(x)): `f(g(x))` = %; simplify( expand( %%) ); g(f(x)): `g(f(x))` = %; simplify( expand( %%) ); |
| > | f := x -> x^3 + x ; g := x -> 1/(x+10); f(g(x)): `f(g(x))` = %; simplify( expand( %%) ); g(f(x)): `g(f(x))` = %; simplify( expand( %%) ); |
6. Composite Functions - Repeated Composition [Optional]
An interesting thing sometimes happens when you evaluate a function, then take the output and evaluate it again with the same function, over and over.
| > | f := x -> x/3 + 7; |
| > | f(0); (f@f)(0); (f@@3)(0); |
Look at what happens at 20 iterations of f(x) at x = 0. The values appear to approach a particular value.
| > | for k from 1 to 20 do evalf( (f@@k)(0) ); od; |
| > | f := x -> (x^2) - x + 2/3; for k from 1 to 12 do evalf( (f@@k)(0) ); od; |
In other cases, the values bounce back and forth, or converge to two different values.
| > | f := x -> (x^2) - 1; for k from 1 to 10 do evalf( (f@@k)(0) ); od; |
| > | f := x -> (x^2) - 9/10; for k from 1 to 12 do evalf( (f@@k)(0) ); od; |
© 2002 Waterloo Maple Inc