Free preview

83 lessons

Mathematical Foundations for ML

Free preview

Mathematical Foundations for ML · 83 lessons

Build the maths foundations that make ML click

No surprise gaps

Actually remember it

Skip what you know

One subscription. All learning paths included.

Our content is best on a larger screen

What is a function

Input-output relationship

Explanation

A function from a set AA to a set BB is a rule that assigns to each element of AA exactly one element of BB. We write f:ABf: A \to B and call AA the domain and BB the codomain.

Function

Definition

A function f:ABf: A \to B assigns to each element of AA exactly one element of BB. If aAa \in A, we write f(a)f(a) for the element of BB assigned to aa.

The word "rule" here is deliberately broad - a function does not have to be defined by an equation. A table, a graph, or a verbal description can all define functions, as long as each input is assigned exactly one output. Any such rule is called a mapping, and the terms "function" and "mapping" are used interchangeably.

This is the only requirement. In particular:

  • The same input cannot produce different outputs. If a rule assigns both 22 and 2-2 to the same input, it is not a function.
  • Different inputs may share the same output. The definition requires each input to have exactly one output, but does not require each output to come from exactly one input.
  • Every input must have an output. A function cannot leave an input unassigned.

Example

Does the rule f(x)=x2f(x) = x^2 for xRx \in \mathbb{R} define a function?

Solution

For any xRx \in \mathbb{R}, squaring gives exactly one real number. Each input is assigned a single output, so ff is a function.

Different inputs can share the same output: f(3)=f(3)=9f(-3) = f(3) = 9. This is allowed - the definition requires each input to have one output, not that each output comes from one input.

Practice questions

4 questions

Let A={1,2,3}A = \{1, 2, 3\} and B={4,5,6,7}B = \{4, 5, 6, 7\}. A rule assigns:

15,24,351 \mapsto 5, \quad 2 \mapsto 4, \quad 3 \mapsto 5

Does this rule define a function f:ABf: A \to B?

Select the correct answer:

+ 3 more questions

Functions from graphs

Explanation

When a function is defined by a formula, its graph is the set of all input-output pairs (x,f(x))(x, f(x)) plotted as points in the plane. We can use this to determine whether a graph represents a function without knowing the formula - by checking whether each xx-value corresponds to at most one yy-value.

Vertical line test

Definition

A graph represents a function if and only if every vertical line crosses the graph at most once. If any vertical line crosses the graph at two or more points, the same input produces different outputs, and the graph does not represent a function.

Use the visualisation below to see this in action. Drag the red diamond on the xx-axis across the plane and use the buttons to cycle through different curves.

12345−1−2−312345−1−2−3−4−5−4−5

Straight line: y=x1 Function

Every vertical line crosses a non-vertical straight line exactly once. This graph represents a function.

Example

The following points are plotted on a coordinate plane. Determine whether each set represents a function.

Set A: {(1,3),  (2,5),  (3,2),  (4,5)}\{(1, 3),\; (2, 5),\; (3, 2),\; (4, 5)\}

Set B: {(1,3),  (2,5),  (2,1),  (4,5)}\{(1, 3),\; (2, 5),\; (2, -1),\; (4, 5)\}

Solution

Set A

We apply the vertical line test by checking whether any xx-coordinate appears more than once.

The xx-coordinates are 11, 22, 33, 44 - all distinct. A vertical line at each of these values crosses exactly one point.

1234512345

Every vertical line passes through at most one point. Set A is a function.


Set B

The xx-coordinates are 11, 22, 22, 44. The value x=2x = 2 appears twice, with different yy-values: (2,5)(2, 5) and (2,1)(2, -1).

1234512345−1

The vertical line at x=2x = 2 crosses two points. The input 22 has two different outputs (55 and 1-1), so the vertical line test fails.

Set B is not a function.

Practice questions

4 questions

A circle is drawn on the coordinate plane, centred at the origin. Does this graph represent a function?

Select the correct answer:

+ 3 more questions