DEV Community

Rachit Joshi
Rachit Joshi

Posted on

How to Find the Slope of a Line: Formula, Types, and Examples

INTRODUCTION

If you have ever looked at a graph and wondered how to describe whether a line is going upward, downward, or staying flat, slope is the mathematical concept you need.

Slope tells us about the direction and steepness of a line. It is an important concept in coordinate geometry and is also useful when working with equations, graphs, data, and mathematical models.

What Is Slope?

The slope of a line describes how much the line changes vertically compared with how much it changes horizontally.

It is commonly represented by m.

In simple terms:

Slope = Change in Y / Change in X

The vertical change is often called the rise, while the horizontal change is called the run.

Slope Formula

When two points on a line are known:

(x₁, y₁) and (x₂, y₂)

the slope can be calculated using:

m = (y₂ − y₁) / (x₂ − x₁)

Here:

m = slope
x₁, y₁ = coordinates of the first point
x₂, y₂ = coordinates of the second point
y₂ − y₁ = change in vertical direction
x₂ − x₁ = change in horizontal direction

The key idea is simple: find the rise, find the run, and divide rise by run.

Example: Finding Slope From Two Points

Suppose we have two points:

(2, 1) and (6, 3)

Using the formula:

m = (3 − 1) / (6 − 2)

m = 2 / 4

m = 1/2

So, the slope is:

m = 0.5

Because the slope is positive, the line rises as we move from left to right.

Four Types of Slope

There are four common types of slope:

Positive slope
Negative slope
Zero slope
Undefined slope

Understanding these four types makes it much easier to interpret graphs.

1. Positive Slope

A line has a positive slope when it moves upward from left to right.

For example:

m = 2

As the x-value increases, the y-value also increases.

You can think of it as a line going uphill from left to right.

2. Negative Slope

A line has a negative slope when it moves downward from left to right.

For example:

m = −2

As x increases, y decreases.

Visually, the line travels downward as you move from left to right.

3. Zero Slope

A horizontal line has a zero slope.

For example:

m = 0

The y-coordinate remains constant even though the x-coordinate changes.

A simple example is:

y = 5

This represents a horizontal line.

*4. Undefined Slope
*

A vertical line has an undefined slope.

Why?

Because the x-values remain the same, making:

x₂ − x₁ = 0

Since division by zero is undefined, the slope of a vertical line is undefined.

For example, a line passing through:

(2, 4) and (2, −2)

has an undefined slope.

Why Is Slope Important?

Slope isn't just a formula used in mathematics class. It helps us understand how one quantity changes in relation to another.

For example, slope can help describe:

The direction of a line on a graph
The rate of change between two variables
Trends in data
Linear equations
Relationships between coordinates
Changes represented in charts and graphs

The same basic idea—change in one quantity compared with change in another—appears in many areas of mathematics and science.

Final Thoughts

Learning how to find the slope is an important step toward understanding coordinate geometry and linear equations. Once you understand the simple relationship between rise and run, you can quickly determine how a line behaves on a graph.

For more beginner-friendly explanations of mathematics, programming, and computer-science concepts, TPointTech provides a broad collection of tutorials and examples that can help you build your fundamentals step by step.

Top comments (0)