Free preview

95 lessons

Mathematical Foundations for ML

Free preview

Mathematical Foundations for ML · 95 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

The equation of a straight line

The slope-intercept form

Explanation

There are infinitely many straight lines which all share the same slope, so how do we identify a specific one? We fix one point on the line: only one line with that slope passes through it.

The most convenient point to fix is where the line crosses the yy-axis. Every point on the yy-axis has xx-coordinate 00, so we write this point as (0,c)(0, c), where cc is the height of the crossing.

In the diagram below, the slider sets the slope shared by all the faint lines, and the point on the yy-axis picks out one of them.

12345−1−2−3−4−512345−1−2−3−4−5
x
y
(0,1)
Move the slider to change the slope m: every faint line has that slope. Drag the red point along the y-axis to pick out the line crossing at (0,c). The larger |m|, the steeper the line.
y=2x+1, with slope m=2 and y-intercept (0,1)
Slope-intercept form

Definition

A straight line written as

y=mx+cy = mx + c

is in slope-intercept form. The number mm is the slope of the line, and cc is its yy-intercept: putting x=0x = 0 gives y=cy = c, so the line crosses the yy-axis at (0,c)(0, c).

Reading mm and cc off an equation tells us which line it describes. In y=3x−2y = 3x - 2 we have m=3m = 3 and c=−2c = -2, so the line rises and crosses the yy-axis at (0,−2)(0, -2).

When there is no constant term, as in y=4xy = 4x, we have c=0c = 0, so the line passes through the origin.

Example

Four straight lines are drawn on the axes below. Which of them is y=−12x+3y = -\dfrac{1}{2}x + 3?

12345−1−2−3−4−512345−1−2−3−4−5
x
y
A
B
C
D

Solution

In y=−12x+3y = -\dfrac{1}{2}x + 3 we have c=3c = 3, so the line we want crosses the yy-axis at (0,3)(0, 3). Lines AA, BB and CC all pass through that point, while DD crosses at (0,−2)(0, -2), so DD is ruled out.

Next we use the slope. Here m=−12m = -\dfrac{1}{2}, which is negative, so the line falls from left to right. Line BB rises, so BB is ruled out too.

That leaves AA and CC, and we separate them by the size of their slope. Starting from (0,3)(0, 3), line AA drops 11 unit for every 22 units across, so its slope is −12-\dfrac{1}{2}. Line CC drops 22 units for every 11 unit across, giving a much steeper −2-2.

The line is AA.

Practice questions

4 questions

Four straight lines are drawn on the axes below. Which one is y=2x−3y = 2x - 3?

12345−1−2−3−4−512345−1−2−3−4−5
x
y
A
B
C
D

Select the correct answer:

+ 3 more questions

Finding the equation of a drawn line

Explanation

Writing the equation of a drawn line means finding the two numbers in y=mx+cy = mx + c from the picture. The diagram below marks where each one comes from: the point (0,c)(0, c) where the line crosses the yy-axis gives cc, and the rise and run from (0,c)(0, c) to a second point on the line give the slope mm.

12345−1−2−3−4−512345−1−2−3−4−5
x
y
(0,c)
run
rise
Finding the equation of a drawn line

Procedure

  1. Read cc from the point (0,c)(0, c) where the line crosses the yy-axis.
  2. Take the yy-axis crossing (0,c)(0, c) as (x1,y1)(x_1, y_1) and another point on the line with whole-number coordinates as (x2,y2)(x_2, y_2), and compute m=y2−y1x2−x1m = \dfrac{y_2 - y_1}{x_2 - x_1}.
  3. Write mm and cc into y=mx+cy = mx + c.

Example

Write the equation of the straight line drawn below.

12345−1−2−3−4−512345−1−2−3−4−5
x
y
(0,−1)
(1,1)

Solution

  1. The line crosses the yy-axis at (0,−1)(0, -1), so c=−1c = -1.

  2. We take the yy-axis crossing as (x1,y1)=(0,−1)(x_1, y_1) = (0, -1) and the point (1,1)(1, 1), where the line passes exactly through a grid point, as (x2,y2)(x_2, y_2). The green legs show the run and rise between them:

    m=y2−y1x2−x1=1−(−1)1−0=21=2\begin{align*} m &= \dfrac{y_2 - y_1}{x_2 - x_1} \\ &= \dfrac{1 - (-1)}{1 - 0} \\ &= \dfrac{2}{1} \\ &= 2 \end{align*}
  3. Writing m=2m = 2 and c=−1c = -1 into y=mx+cy = mx + c gives the equation

    y=2x−1y = 2x - 1

Practice questions

4 questions

What is the equation of the straight line drawn below?

12345−1−2−3−4−512345−1−2−3−4−5
x
y

Select the correct answer:

+ 3 more questions

The horizontal or vertical line through a point

Explanation

A horizontal line stays at one height, so every point on it has the same yy-coordinate. The horizontal line through (2,1)(2, 1) contains (−3,1)(-3, 1), (0,1)(0, 1), (4,1)(4, 1) and every other point with yy-coordinate 11, whatever its xx-coordinate. Its equation is y=1y = 1.

A vertical line stays at one position across, so every point on it has the same xx-coordinate. The vertical line through (2,1)(2, 1) is x=2x = 2.

12345−1−2−3−4−512345−1−2−3−4−5
x
y
Drag the point. The horizontal line through it keeps the y-coordinate of the point, and the vertical line keeps its x-coordinate.
Point (2,1): horizontal line y=1, vertical line x=2
Horizontal and vertical lines through a point

Definition

A horizontal line has an equation y=cy = c, and a vertical line has an equation x=kx = k, for numbers cc and kk. Through the point (a,b)(a, b):

  • The horizontal line is y=by = b, since each of its points keeps the yy-coordinate bb.
  • The vertical line is x=ax = a, since each of its points keeps the xx-coordinate aa.

A horizontal line fits the slope-intercept form with m=0m = 0, since y=cy = c is y=0x+cy = 0x + c. A vertical line does not: the equation x=kx = k contains no yy, so it cannot be rearranged into y=mx+cy = mx + c.

Example

Write the equations of the horizontal line and the vertical line through (−4,3)(-4, 3). Both lines are drawn below.

12345−1−2−3−4−512345−1−2−3−4−5
x
y
(−4,3)

Solution

Here the point is (a,b)=(−4,3)(a, b) = (-4, 3).

  • For the blue horizontal line we keep the point's yy-coordinate, 33, and leave xx free. Its equation is y=3y = 3.
  • For the red vertical line we keep the point's xx-coordinate, −4-4, and leave yy free. Its equation is x=−4x = -4.

We check against the point: (−4,3)(-4, 3) has yy-coordinate 33, so it satisfies y=3y = 3, and it has xx-coordinate −4-4, so it satisfies x=−4x = -4.

Practice questions

4 questions

Four straight lines are drawn on the axes below. Which one is y=2y = 2?

12345−1−2−3−4−512345−1−2−3−4−5
x
y
A
B
C
D

Select the correct answer:

+ 3 more questions