lecture 4: Formal definition of a function, simple examples of functions (linear, quadratic), how to draw them and how to figure out their domain and range.

What is a function?

1. Motivational Real-World Example

Vending Machine Analogy:
A vending machine takes in a selection code (e.g., A1, B2) and gives you a unique snack. If you press A1, you always get the same item. It doesn't give two snacks, and it doesn't give you different items each time.
That’s the essence of a function: Each input leads to exactly one output.


2. Formal Definition

function is a rule that assigns each element from a set called the domain to exactly one element in another set called the range.

Notation:
f:ABf:A\to B, where f(x)Bf(x) \in B for each xAx \in A.
(AA is the domain and BB is the range.)


3. Domain and Range

Two functions can have the same domain and range but be completely different rules.
(e.g., f(x)=xf(x)=x vs. g(x)=xg(x)=−x).

Co-domain vs. Range

So, the range is a subset of the co-domain.

Example:
f(x)=x2f(x)=x^2


4. Why Do We Care?

5. Examples

Examples of mappings that are not functions:

Questions:


Linear Functions

1. Example

If you earn 10 Riyals for every hour worked: y=10xy=10x is a linear function.

2. General Form

f(x)=mx+bf(x)=mx+b


3. Graph

Example:
Graph of f(x)=2x+1f(x)=2x+1:

Graph of f(x)=2x+1

Quadratic Functions

1. Why Use Quadratics?

Used to model things like:


2. General Form

f(x)=ax2+bx+cf(x)=ax^2+bx+c

3. Domain and Range

Example:
Graph of f(x)=x22x+1f(x)=x^2−2x+1

Graph of f(x)=x^2-2x+1

4. Vertex

The vertex of a quadratic function is the point where the function changes direction.

The x-coordinate of the vertex of a quadratic function f(x)=ax2+bx+cf(x)=ax^2+bx+c is given by the formula:

x=b2ax=-\frac{b}{2a}

The y-coordinate of the vertex is then found by plugging the x-coordinate back into the function.

Example:
f(x)=x22x+1f(x)=x^2-2x+1


Function evaluation

If given a formula, function evaluated at a point is the value of the function at that point.

Examples:

By the same logic, we can evaluate functions at points represented by expressions.

Examples:


Regular Exercises

1. Water Tank Domain and Range

A water tank is being drained. The function h(t)h(t) gives the amount of water (in liters) left in the tank after tt minutes.
The tank starts full at 100 liters, and drains at 5 liters per minute, until empty.

Solution
a) The tank starts full at 100 liters and drains at a rate of 5 liters per minute. Once it’s empty, the amount of water stays at 0.

A piecewise function to represent this is:

h(t)={1005tif 0t200if t>20h(t) = \begin{cases} 100 - 5t & \text{if } 0 \leq t \leq 20 \\ 0 & \text{if } t > 20 \end{cases}

b) The domain is all non-negative real numbers since time can continue indefinitely:

Domain: [0,)\text{Domain: } [0, \infty)

c) The range is all the possible values of h(t)h(t). The tank drains from 100 liters to 0 and stays at 0:

Range: [0,100]\text{Range: } [0, 100]

d) Yes, the function continues forever. After 20 minutes, the tank is empty and the water level remains at 0 for all t>20t > 20.

2. Photo Frame

You have a square photo print with side length xx centimeters. You want to add a frame of constant width 22 centimeters all around it.

Hint: Write the area of the frame as a function of xx, and then solve for xx.

Solution
Let the photo side length be xx cm. The frame adds 2 cm all around, so the total side length with frame is:

x+2+2=x+4x + 2 + 2 = x + 4

The area of the photo alone is:

x2x^2

The area of the photo plus frame is:

(x+4)2(x + 4)^2

The area of the frame alone is the difference:

Frame area=(x+4)2x2\text{Frame area} = (x + 4)^2 - x^2

Given frame area = 100 cm², write the equation:

(x+4)2x2=100(x + 4)^2 - x^2 = 100

Expand:

x2+8x+16x2=100    8x+16=100x^2 + 8x + 16 - x^2 = 100 \implies 8x + 16 = 100

Solve for xx:

8x=84    x=10.58x = 84 \implies x = 10.5

So, the photo side length should be 10.5 cm.

3. Quadratic Function Construction

Construct a quadratic function f(x)f(x) that satisfies the following:

Solution
The vertex form of a quadratic is:

f(x)=a(xh)2+kf(x) = a(x - h)^2 + k

where vertex is at (h,k)(h,k). Here, vertex (2,3)(2,-3) gives:

f(x)=a(x2)23f(x) = a(x - 2)^2 - 3

Use f(0)=5f(0) = 5 to find aa:

5=a(02)23    5=4a35 = a(0 - 2)^2 - 3 \implies 5 = 4a - 3

4a=8    a=24a = 8 \implies a = 2

Therefore, the function is:

f(x)=2(x2)23f(x) = 2(x - 2)^2 - 3

4. Reverse Engineering a Function

You are given that:

Solution
a) Look at the values:

f(0)=2f(1)=5f(2)=8f(3)=11\begin{aligned} f(0) &= 2 \\ f(1) &= 5 \\ f(2) &= 8 \\ f(3) &= 11 \end{aligned}

Notice that each time xx increases by 1, f(x)f(x) increases by 3. So the function increases linearly with slope 3.
A possible formula is:

f(x)=3x+2f(x) = 3x + 2

b) The function is linear because the output changes by a constant amount (3) for every increase of 1 in xx.

c) Could more than one rule produce these values?
Technically, yes — more than one function could match these four points but behave differently elsewhere.

For example, consider the absolute value function:

f(x)=3x1+2f(x) = 3|x - 1| + 2

Let's check the values:

f(0)=301+2=3(1)+2=5f(1)=311+2=0+2=2f(2)=321+2=3(1)+2=5f(3)=331+2=3(2)+2=8\begin{aligned} f(0) &= 3|0 - 1| + 2 = 3(1) + 2 = 5 \\ f(1) &= 3|1 - 1| + 2 = 0 + 2 = 2 \\ f(2) &= 3|2 - 1| + 2 = 3(1) + 2 = 5 \\ f(3) &= 3|3 - 1| + 2 = 3(2) + 2 = 8 \end{aligned}

These outputs do not match the original f(x)f(x) values, proving this is a different rule. However, with careful design, a nonlinear function could be made to match specific points.

This example shows that just a few input-output pairs aren’t enough to uniquely determine a function, especially if you're not assuming linearity. Different rules can fit the same values at some xx but behave differently elsewhere.


Extra Advanced Exercises

1. Fencing a Rectangular Area

You are given 40 meters of fencing and want to enclose a rectangular area against a wall (so you only need to fence three sides). Let xx be the width of the fenced rectangle.

2. Composing Functions

You’re told that:

h(x)=2x+3h(x)=\sqrt{2x+3}

And someone tells you it came from composing two functions ff and gg, so that
h(x)=f(g(x))h(x)=f(g(x))