Week 3 - Functions A

2.101 Introduction

  • Variable
    • In everyday life, many quantities depend on change in variables:
      • Plant's growth depends on sunlight and rainfall.
      • A runner's speed == how long it takes to run a distance.

2.102 The definition of a function

  • Function
    • A function is a rule that relates how one quantity depends on another.
    • It's central to programming and Computer Science.
    • It's a relationship between a set of inputs and a set of outputs, where inputs map to exactly one output.
    • Function is a "well-behaved relation"
      • Given a starting point, we have just one ending point.
    • A function ff from a set of AA to a set of BB is an assignment of exactly one element of BB to each element of AA.
      • If ff is the function from A to B, we write: f:ABf: A \rightarrow B
      • We can read this as f maps A to B:
        • xA:  xf(x)=y   (yB)x \in A: \ \ x \rightarrow f(x) = y \ \ \ (y \in B)
    • Domain of a Function
      • Given the function above, AA is the set of all inputs and called the "domain" of ff.
        • Written as Df=AD_f = A
    • Co-Domain of Function

      • BB is the set containing the outputs and called the co-domain of ff.
        • Written as co-Df=B\text{co-}D_f = B
      • The set of all outputs is called the range of f and is written as RfR_f.
      • yy is called the image of xx.
      • xx is called the pre-image of yy.

        Domain Codomain Range

      • Example: a set mapping characters to a length.

        • f(Sea)3f(\text{Sea}) \rightarrow 3 (contains 3 characters)
        • f(Land)4f(Land) \rightarrow 4 (contains 4 characters)
        • f(on)2f(on) \rightarrow 2
          • 2 is the image of "on"
          • "on" is the pre-image of 2.
      • Conditions under which a relation is not a function:
        • Some inputs do not have an image.
        • Some inputs have more than one image.
      • Exercise 1
        • Given the following function: f:ZZf: Z \rightarrow Z with f(x)=xf(x) = |x|, what is domain, co-domain and range for function ff?
      • Domain: ZZ
      • Co-domain: ZZ
      • Range: Z+Z^{+}
      • Exercise 2
        • Given the following function: g:RRg: R \rightarrow R with g(x)=x2+1g(x) = x^2 + 1
      • Domain: R
      • Co-domain: R
      • Range: {1,5,9...}\{1, 5, 9 ...\}
      • Pre-images(5) = {-2, 2}

2.104 Plotting functions

  • Linear Function

    • Linear function is of form: f(x)=ax+bf(x) = ax + b

      • Where aa and bb are real numbers.
      • Straight-line function that passes through point (0, b).
      • aa is the gradient of the function. Where a>0a > 0 the function is increasing.
        • That is: x1x2x_1 \leq x_2 then f(x1)f(x2)f(x_1) \leq f(x_2).
      • Example of increasing linear function:

      Linear Increasing Function

      • When the gradient is < 0, the function is decreasing.
        • f:RRf: R \rightarrow R
      • f(x)=ax+bf(x) = ax +b
        • If a>0a > 0 then function is increasing.
        • If x1x2x_1 \leq x_2 then f(x1)f(x2)f(x_1) \leq f(x_2)

          Linear Decreasing Function

  • Quadratric Functions

    • Quadratic functions: f(x)=ax2+bx+cf(x) = ax^2 + bx + c

      • Where aa, bb and cc are real numbers and a0a \ne 0.

        Quadratic

      • Domain of function f(x) is set of real numbers.

      • Range of function is set of positive numbers.
      • Exponential Functions
        • If base bb in f(x)=bxf(x) = b^x, b>1b > 1 then function is increasing and represents growth shown in this graph:

    exponential-growth-function

    * Graph also shows that the point $(0,1)$ is a "common point".
    * Domain is equal to set of all real numbers.
    * Range is equal to set of all real positive numbers.
    * X-axis is horizontal asymtot to curve of function.
    
    • If base 0 < b < 1, then function is decreasing:

      Exponential Decay Function

      • Domain and range are the same as previous function.
      • Laws Of Exponential Functions
        • bxby=bx+yb^xb^y = b^{x + y}
        • bxby=bxy\frac{b^x}{b^y} = b^{x-y}
        • (bx)y=bxy(b^x)^y = b^{xy}
        • (ab)x=axbx(ab)^x = a^xb^x
        • (ab)x=axbx(\frac{a}{b})^x = \frac{a^x}{b^x}
        • bx=1bxb^{-x} = \frac{1}{b^x}

2.106 Injective and surjective functions

  • Injective Function

    • A function is considered injective or one-to-one if and only if:

      • any 2 distinct inputs will lead to 2 distinct outputs.
      • In other words:
        • for all a,bA, if ab then f(a)f(b)a, b \in A, \text{ if } a \ne b \text{ then } f(a) \ne f(b)
        • same as saying: a,bA, if f(a)=f(b) then a=ba, b \in A, \text{ if } f(a) = f(b) \text{ then } a = b
      • Example on the left is an injective function, as every element of AA has a unique image in B.
      • Example on the right is not injective. 2 or 4 in A have the same image 0. 1 and 3 have the same image 1.

      Injective Function

    • You can show a function is not injective by finding two different inputs aa and bb with the same Function Image.

    • An example with a linear function:
      • To show function f:R>Rf: R -> R with f(x)=2x+3f(x) = 2x + 3 is an injective function, we must show that  if f(a)=f(b) then a=b\text{ if } f(a) = f(b) \text{ then } a = b
        • f(a)=f(b)f(a) = f(b) => 2a+3=2b+32a + 3 = 2b + 3 => 2a=2b2a = 2b => a=ba = b => f is injective.
      • Proof 2:
        • Let a,bRa, b \in R, show that  if ab then f(a)f(b)\text{ if } a \ne b \text{ then } f(a) \ne f(b)
          • aba \ne b => 2a2b2a \ne 2b => 2a+32b+32a + 3 \ne 2b+3 => f(a)f(b)f(a) \ne f(b) => f is injective
    • An example quadratic function that is not injection.
      • Show function f:R>Rf: R -> R with f(x)=x2f(x) = x^2 is not an injective function
      • Example with 2 counter examples that have the same image.
        • One example is 5 and -5 have the same image.
          • f(5)=(5)2=(5)2=f(5)f(5) = (5)^2 = (-5)^2 = f(-5)
            • Since: 55-5 \ne 5 it's not injective.
            • If we change domain to R+R^{+}, the function becomes injective.
        • Proof 1:
          • Let a,bR+a, b \in R^{+} show that if f(a)=f(b)f(a) = f(b) then a=ba = b.
            • Let a,bR+a, b \in R^{+} show that if f(a)=f(b)f(a) = f(b) then a=ba = b
        • Proof 2:
          • Let a,bR+a, b \in R^{+} show that if aba \ne b then f(a)f(b)f(a) \ne f(b)
          • ab=>a2b2a \ne b => a^2 \ne b^2 as a,bR+=>f(a)f(b)=>fa, b \in R+ => f(a) \ne f(b) => f is injective.
    • Surjective Function
    • A function is said to be a surjective (onto) function if and only if every element of the co-domain of ff, BB, has at least one pre-image in the domain of f,Af, A.
      • In other words, every element in the output domain has some input that will return it.
    • for all yBy \in B there exists xAx \in A such that y=f(x)y = f(x)

      • Equivalent to saying range and co-domain of surjective function are the same.
        •  CODf=Rf\text{ CO}-D_f = R_f
      • Examples:

        Surjective Example

    • An example Linear Function

      • Show that the function f:R>Rf: R -> R with f(x)=2x+3f(x) = 2x+3 is a surjective (onto) function.
      • Need to show that for any element yRy \in R, there exists xRx \in \mathbb{R} such that f(x)=yf(x) = y
    • Proof:
      • f(x)=yf(x) = y => 2x+3=y2x + 3 = y => 2x=y32x = y - 3 => x=y32Rx = \frac{y-3}{2} \in R
      • Hence, for all yRy \in R, there exists x=y32Rx = \frac{y-3}{2} \in R such that f(x)=yf(x) = y
    • An example quadratic function that is not surjective
      • Show that function f:R>Rf: R-> R with f(x)=x2f(x) = x^2 not a surjective (onto) functions
      • Proof: * Let yRy \in R, show that there exists xRx \in R such that f(x)=yf(x) = y * Rf( set images )=[0,+[R(coDf)=RR_f (\text{ set images }) = [0, + \infty [\ne R(co-D_f) = R * We know the range of RfRf is positive integers only: all negative images have no pre-images.
    • Examples:
    • Injective, not surjective injective-not-surjective
      • Injective because each element in the domain has a unique image.
      • Not surjective because the element 2 in the co-domain has no pre-image.
    • Surjective but not injective surjective-not-injective
      • Not injective because a and d are different but have the same image.
    • Injective and surjective injective-and-surjective
      • Each element has a unique image.
      • Each element in co-domain has at least one pre-image.
    • Neither injective nor surjective not-injective-or-surjective
      • Not injective because a and c have the same image.
      • Not surjective because the 4 element of co-domain has no pre-image.
    • Not a valid function not-valid-function
    • Input a has 2 outputs. In a function, an input can only have a single output.

2.109 Functions (Peer-graded Assignment)

Part 1

  • *$f_1 : \mathbb{R} \rightarrow \mathbb{R}$ where f(x)=x2+1f(x) = x^{2} + 1
    • Claim: This function is not injective.
    • Proof:
      • Let a=2a = 2, b=2b = -2
      • f(2)=(2)2+1=5f(2) = (2)^2 + 1 = 5
      • f(2)=(2)2+1=5f(-2) = (-2)^2 + 1 = 5
      • f(2)=f(2)f(2) = f(-2) therefore the function is not injective.
    • Claim: This function is not surjective.
    • Proof:
      • f(x)=yf(x) = y
      • x2+1=yx^2 + 1 = y
      • x2=y1x^2 = y - 1
      • x=(y1)x = \sqrt{(y - 1)}
      • R(y1)=[1,+[R \sqrt{(y - 1)} = [1, + \infty [
      • [1,+[ R[1, + \infty [ \ \ne \mathbb{R} therefore, this function is not surjective.
  • *$f_2 : \mathbb{R} \rightarrow [1, + \infty [ \text{ where } f(x) = x^{2} + 1$
    • Claim: This function is not injective.
    • Proof:
      • Let a=2a = 2, b=2b = -2
      • f(2)=(2)2+1=5f(2) = (2)^2 + 1 = 5
      • f(2)=(2)2+1=5f(-2) = (-2)^2 + 1 = 5
      • f(2)=f(2)f(2) = f(-2) therefore the function is not injective.
    • Claim: This function is surjective.
    • Proof:
      • f(x)=yf(x) = y
      • x2+1=yx^2 + 1 = y
      • x2=y1x^2 = y - 1
      • x=(y1)x = \sqrt{(y - 1)}
      • R(y1)=[1,+[R _{\sqrt{(y - 1)}} = [1, + \infty [ therefore, this function is surjective.
  • f3:RR where f(x)=x3f_3: \mathbb{R} \rightarrow \mathbb{R} \text{ where } f(x) = x^3
    • Claim: This function is injective.
    • Proof:
      • f(a)=f(b)f(a) = f(b)
      • f(a)=a3f(a) = a^3
      • f(b)=b3f(b) = b^3
      • a3=b3a^3 = b^3
      • (a3)1/3=(b3)1/3(a^3)^{1/3} = (b^3)^{1/3}
      • a=ba = b for all a,bRa, b \in \mathbb{R} there the function is injective.
    • Claim: This function is surjective
    • Proof:
      • f(x)=yf(x) = y
      • x3=yx^3 = y
      • x=y3x = \sqrt[3]{y}
      • y3R\sqrt[3]{y} \in \mathbb{R} therefore, the function is surjective.
  • f4:RR where f(x)=2x+3f_4 : \mathbb{R} \rightarrow \mathbb{R} \text{ where } f(x) = 2x + 3
    • Claim: This function is injective.
    • Proof:
      • f(a)=f(b)f(a) = f(b)
      • 2a+3=2b+32a + 3 = 2b + 3
      • 2a=2b2a = 2b
      • a=ba = b therefore f is injective.
    • Claim: This function is surjective.
    • Proof:
      • f(x)=yf(x) = y
      • 2x+3=y2x + 3 = y
      • 2x=y32x = y - 3
      • x=y32Rx = \frac{y-3}{2} \in \mathbb{R} therefore the function is surjective.
  • f5:ZZ where f(x)=2x+3f_5: \mathbb{Z} \rightarrow \mathbb{Z} \text{ where } f(x) = 2x + 3
    • Claim: This function is injective.
    • Proof:
      • f(a)=f(b)f(a) = f(b)
      • 2a+3=2b+32a + 3 = 2b + 3
      • 2a=2b2a = 2b
      • a=ba = b therefore ff is injective.
    • Claim: This function is not surjective
    • Proof:
      • f(a)=2a+3f(a) = 2a + 3
      • f(x)=yf(x) = y
      • 2x+3=y2x + 3 = y
      • 2x=y32x = y - 3
      • x=y32Zx = \frac{y-3}{2} \notin \mathbb{Z} for all xx therefore this function is not surjective.

Part 2

Let f:R]1,+[f : \mathbb{R} \rightarrow ]1, +\infty[ with f(x)=ex+1f(x) = e^{x} + 1

  1. Show that f(x)f(x) is bijection.

    • Claim: f(x)f(x) is a bijective as it is both injective and surjective.
    • Proof of injective:
      • f(a)=f(b)f(a) = f(b)
      • f(a)=ea+1f(a) = e^a + 1
      • f(b)=eb+1f(b) = e^b + 1
      • ea=ebe^a = e^b
      • a=ba = b therefore the function is injective.
    • Proof of surjective:
      • R ex=[1,+[R \ {e^x} = [1, +\infty[
      • Co-D ex=[1,+[\text{Co-D } e_x = [1, +\infty[
      • R ex=Co-D exR \ {e^x} = \text{Co-D } e_x therefore the function is surjective.
  2. Find the inverse function f1f^{-1}.

    • f(x)=yf(x) = y
    • ex+1=ye^x + 1 = y
    • ex=y1e^x = y - 1
    • x=loge(y1)x = \log_e(y - 1)
    • f1(x)=loge(x1)f^{-1}(x) = log_e(x - 1)
  3. Plot the curve of ff and f1f^{-1} in the same graph. plot-f-and-f-inverse

  4. What can you say about these two curves?

The curves are symmetric with respect to the line y=xy = x.