Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Linear Function Calculator (Find y = mx + b from Two Points or a Slope and a Point, Rate of Change and Intercepts)

Choose a mode and enter the coordinates of two points (or the slope and the coordinates of one point). If you also enter an x, the value of y for that x is calculated too.

Decimals, negative numbers and fractions such as 3/4 can be used. The fields you do not need switch automatically with the mode.
Result and graph
Enter the coordinates (or the slope) in the fields on the left and press "Calculate". The result and a graph will appear here.

What you can do on this page

  • Find the equation \(y = mx + b\) of the line through two points \((x_1,\ y_1)\) and \((x_2,\ y_2)\) on the spot, just by entering the coordinates
  • You can also choose a mode that finds the equation from the slope \(m\) and one point on the line
  • The slope (rate of change) is shown with the steps of \(m = \dfrac{\Delta y}{\Delta x}\). Answers are shown as fractions in lowest terms (exact values)
  • It also finds where the line crosses the x-axis and the y-axis and the value of \(y\) for an \(x\) you choose, and draws a graph of the line
  • If the two points have the same x-coordinate, so the line is not a linear function, it tells you that the line is the vertical line "x = constant" and explains why
  • A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
Coordinates and slopes can be decimals, negative numbers or fractions such as 3/4.

What is this calculation used for?

Predicting costs on a pricing plan (phone, electricity, taxi)

A price made of "a base fee plus a charge for each unit you use" is exactly the linear function \(y = mx + b\): the y-intercept \(b\) is the base fee and the slope \(m\) is the price per unit. For example, a taxi that charges $3.50 to start plus $2.50 per mile costs \(y = 2.5x + 3.5\), so a 4-mile ride costs \(2.5 \times 4 + 3.5 = 13.50\) dollars.
Working out the unit price and the base fee from two monthly bills (two points of usage and amount) is exactly "finding the equation from two points".

Understanding how a spring stretches (science, Hooke's law)

A spring stretches in proportion to the weight hung on it (Hooke's law), so the total length of the spring, "natural length + stretch", is a linear function. For example, a spring with a natural length of 10 cm that stretches 2 cm for each weight has length \(y = 2x + 10\) (\(x\) is the number of weights).
If you fix the equation from two measurements in an experiment (two points), you can predict the length for weights you have not tried yet. It is a classic example that links middle school science and math.

Estimating the temperature from the altitude (hiking and weather)

As a rough average, air gets about 3.5°F cooler for every 1,000 ft you climb (this is called the lapse rate). If you know the temperature at the bottom, a linear function gives a rough estimate of the temperature at the top. For example, if it is 77°F at the trailhead, the temperature at \(x\) thousand feet higher is about \(y = 77 - 3.5x\), so at a summit 6,000 ft higher it is about 56°F.
The real temperature also depends on the weather and humidity, so this is not an exact formula, but it is a practical approximation for deciding what to wear on a hike.

Predicting sales and costs (business, break-even)

Business costs often take the form "fixed costs such as rent + a variable cost for each item made", which is also a linear function: the y-intercept is the fixed cost and the slope is the variable cost per item.
Comparing the cost line with the sales line shows "how many you need to sell to make a profit" (the break-even point). It is a widely used first step in a business plan.

Converting temperature units (Celsius and Fahrenheit)

Fahrenheit (°F), used in the US, and Celsius (°C), used in most other countries, are related exactly by the linear function \(F = 1.8C + 32\). With slope 1.8 and y-intercept 32, it is a familiar example of an exactly linear relationship.
For example, 20°C is \(1.8 \times 20 + 32 = 68\) °F. You can use this formula directly to read a weather forecast abroad or an oven temperature in a recipe from another country.

Formulas and graphs

Equation of a linear function \(y = mx + b\) (slope-intercept form)
Graph
Standard notation (the usual math form)
\(y\) \(=\) \(m\) \(\times\) \(x\) \(+\) \(b\)
In words (symbols replaced with words)
④ y-coordinate of a point on the line \(y\) \(=\) ② slope \(m\) (rate of change) \(\times\) ① x-coordinate \(x\) \(+\) ③ y-intercept \(b\)
The formula in words
① Take the x-coordinate \(x\)
② multiply it by the slope \(m\) (how much y increases each time x increases by 1)
③ add the y-intercept \(b\) (the value of y when x = 0)
④ and you get the y-coordinate of the point on the line \(y\)
Quick example
For the linear function \(y = 2x + 1\), with slope 2 and y-intercept 1, the value of \(y\) when \(x = 3\) is
y-coordinate \(y\) \(=\) slope (2) \(\times\) x-coordinate (3) \(+\) y-intercept (1)
\(y = 2 \times 3 + 1 = 7\)
Key idea
A linear function is a function of the form \(y = mx + b\), and its graph is a straight line. The word "linear" tells you that \(x\) appears only to the first power (no \(x^2\) or \(x^3\)). The slope \(m\) tells you "how much y changes each time x increases by 1", and the y-intercept \(b\) is "the starting height (y when x = 0)". For example, a pricing plan of "a base fee of \(b\) dollars plus a rate of \(m\) dollars for each unit \(x\) you use" has exactly this form. Direct variation \(y = kx\), taught in Grade 7, is the special linear function whose y-intercept is 0 (its line passes through the origin).
Finding the slope \(m\) (rate of change) from two points
Graph
Standard notation (the usual math form)
\(m\) \(=\) \(y_2 - y_1\) \(\div\) \(x_2 - x_1\)
In words (symbols replaced with words)
③ slope \(m\) (rate of change) \(=\) ① change in y (rise) \(\Delta y = y_2 - y_1\) \(\div\) ② change in x (run) \(\Delta x = x_2 - x_1\)
The formula in words
① Take the change in y, \(\Delta y\) (how far it went up or down)
② divide it by the change in x, \(\Delta x\) (how far it went across)
③ and you get the slope \(m\) (rate of change)
Quick example
The slope (rate of change) of the line through the two points (1, 3) and (4, 9) is
slope \(m\) \(=\) change in y (9 − 3 = 6) \(\div\) change in x (4 − 1 = 3)
\(m = \dfrac{9 - 3}{4 - 1} = \dfrac{6}{3} = 2\)
Key idea
The rate of change, taught with linear functions in Grade 8, is \(\dfrac{\text{change in } y}{\text{change in } x}\), often called "rise over run". For a linear function this value is the same wherever you measure it, and it is exactly the slope \(m\) (for a curve, it depends on where you measure). Subtract in the same order on the top and the bottom. If you subtract point 1 from point 2, do it in that order in both. If you mix the order, the sign comes out reversed. When the two points have the same x-coordinate (\(\Delta x = 0\)), you would be dividing by 0, so the slope is undefined. The line through the two points is then a vertical line parallel to the y-axis, "x = constant", which is not the graph of a linear function (this calculator detects this case and explains it).
Finding the y-intercept \(b\) from the slope and one point
Standard notation (the usual math form)
\(b\) \(=\) \(y_1\) \(-\) \(m\) \(\times\) \(x_1\)
In words (symbols replaced with words)
④ y-intercept \(b\) \(=\) ③ y-coordinate of the point \(y_1\) \(-\) ① slope \(m\) \(\times\) ② x-coordinate of the point \(x_1\)
The formula in words
① Multiply the slope \(m\)
② by the x-coordinate of the point \(x_1\) (this is how much y grows on the way from x = 0 to the point)
③ and subtract it from the y-coordinate of the point \(y_1\)
④ to get the y-intercept \(b\)
Quick example
The y-intercept of the line with slope 2 through the point (3, 7) is
y-intercept \(b\) \(=\) y-coordinate (7) \(-\) slope (2) \(\times\) x-coordinate (3)
\(b = 7 - 2 \times 3 = 1\)
\(y = 2x + 1\)
Key idea
Saying that the point \((x_1,\ y_1)\) is on the line tells you that substituting it into the equation, \(y_1 = m x_1 + b\), is true. Solving this for \(b\) gives \(b = y_1 - m x_1\). (This is the same as starting from point-slope form, \(y - y_1 = m(x - x_1)\), and rewriting it in slope-intercept form.) When you find the equation from two points, you first find the slope \(m\) as the rate of change, and then you only need to substitute either point into this formula. So in both modes, the last step comes down to this formula.
Where the line crosses the x-axis and the y-axis (the intercepts)
Graph
Standard notation (the usual math form)
\(x\) \(=\) \(-\) \(b\) \(\div\) \(m\)
In words (symbols replaced with words)
③ x-intercept (where it crosses the x-axis) \(=\) \(-\) ① y-intercept \(b\) \(\div\) ② slope \(m\)
The formula in words
① Take the y-intercept \(b\) with its sign reversed
② divide it by the slope \(m\)
③ and you get the x-intercept (where it crosses the x-axis) (it crosses the y-axis at \((0,\ b)\))
Quick example
To find where \(y = 2x + 1\) crosses the x-axis, substitute \(y = 0\):
x-intercept \(=\) \(-\) y-intercept (1) \(\div\) slope (2)
\(0 = 2x + 1\)
\(x = -\dfrac{1}{2}\)
Key idea
The line crosses the x-axis "where \(y = 0\)", so solving \(0 = mx + b\) for \(x\) gives the x-intercept \(x = -\dfrac{b}{m}\). This is an important way to see linear functions: the solution of the equation \(mx + b = 0\) matches the point where the graph crosses the x-axis. The line crosses the y-axis "where \(x = 0\)", and substituting gives \(y = b\). So the y-intercept \(b\) is exactly "the height where the graph crosses the y-axis". When the slope is 0 (the horizontal line \(y = b\)), the line is parallel to the x-axis and never crosses it (if \(b = 0\), the line is the x-axis itself).
To find the equation \(y = mx + b\) of a line from two points, find the slope \(m = \dfrac{\Delta y}{\Delta x}\) (the rate of change) first, then the y-intercept \(b = y_1 - m x_1\). From the slope and one point, you only need the y-intercept. The y-intercept \(b\) is the height where the line crosses the y-axis, and \(-\dfrac{b}{m}\) is the x-coordinate where it crosses the x-axis.

Symbols and terms

Symbols

\(y = mx + b\) y equals m x plus b The slope-intercept form of a linear function: \(m\) is the slope and \(b\) is the y-intercept. This is the standard form in US schools. (Some countries write it \(y = ax + b\).)
\(m\) m The slope (rate of change): how much y increases each time x increases by 1. Nobody knows for sure why the letter m is used for slope.
\(b\) b The y-intercept: the value of y when x = 0, which is the height where the graph crosses the y-axis.
\(x_1,\ y_1\) x sub 1, y sub 1 The coordinates of point 1. The small number at the lower right is called a subscript; it is a label for "which point" (it is not multiplication or an exponent).
\(\Delta\) delta The capital Greek letter delta, the Greek D, as in "difference". It stands for "change". \(\Delta x\) is the change in x and \(\Delta y\) is the change in y.
\(\left(-\dfrac{b}{m},\ 0\right)\) negative b over m, zero The point where the line crosses the x-axis. Its y-coordinate is 0, and its x-coordinate is \(-\dfrac{b}{m}\), the solution of the equation \(mx + b = 0\).
\((0,\ b)\) zero, b The point where the line crosses the y-axis. Its x-coordinate is 0, and its y-coordinate is the y-intercept \(b\) itself.

Terms

linear function A function of the form \(y = mx + b\). Its graph is a straight line. The word "linear" tells you that x appears only to the first power. Taught in Grade 8.
function A rule that gives back exactly one number for each number you put in. Think of it as a machine: put in \(x\) and out comes \(y\). For example, put 3 into the machine \(y = 2x + 1\) and 7 comes out.
slope A number that tells "how much the line goes up or down for every 1 it goes across" (rise over run). A positive slope rises from left to right, a negative slope falls, and a slope of 0 gives a horizontal line.
rate of change The change in y divided by the change in x, \(\dfrac{\Delta y}{\Delta x}\). For a linear function it is the same wherever you measure it, and it equals the slope \(m\).
y-intercept The y-coordinate of the point where the graph crosses the y-axis (the value of y when x = 0). In the linear function \(y = mx + b\), it is \(b\). (The x-intercept is where the graph crosses the x-axis.)
direct variation A relationship of the form \(y = kx\) (a proportional relationship). When x doubles or triples, y doubles or triples too. It is the special linear function whose y-intercept \(b\) is 0 (its line passes through the origin). Taught in Grade 7.
coordinates A pair of numbers \((x,\ y)\) that gives the position of a point. The horizontal position is the x-coordinate and the vertical position is the y-coordinate.
coordinate plane A plane made by crossing a horizontal number line (the x-axis) and a vertical number line (the y-axis) at a right angle. It is the grid you draw graphs on.
origin The point \((0,\ 0)\) where the x-axis and the y-axis cross. It is written \(O\), from "origin".
crossing point The point where two lines cross. On this page, you find the points where a line crosses the x-axis and the y-axis.
change in y How much a value increased, found as "after − before" (the change in x is found the same way). If the value went down, the change is negative.
constant A fixed number that does not change. In an equation such as "x = 2", the 2 is a constant, and the equation stands for the vertical line whose x-coordinate is always 2.
constant function A function whose y-value is always the same, whatever x is. Its equation has the form \(y = b\), and its graph is a horizontal line parallel to the x-axis. It is \(y = mx + b\) with \(m = 0\); some textbooks count it as a linear function and some do not.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back over these topics is the quickest way forward.

Positive and negative numbers (Grades 6–7)
  • Being able to subtract with negative numbers (example: \(3 - (-1) = 4\))
  • Knowing the sign rules for multiplying and dividing negative and positive numbers (example: \((-3) \times 2 = -6\))
The coordinate plane (Grades 5–6)
  • Being able to write the position of a point as a pair \((x,\ y)\) (example: the point \((2,\ 3)\) is "2 to the right and 3 up")
  • Knowing where the x-axis, the y-axis and the origin are
Proportional relationships (Grade 7)
  • Knowing that the graph of direct variation \(y = kx\) is a line through the origin
  • Knowing that the constant \(k\) tells "how much y increases when x increases by 1"
Expressions and equations (Grades 6–8)
  • Being able to substitute numbers into an expression such as \(y_1 = m x_1 + b\)
  • Being able to solve a linear equation such as \(0 = 2x - 6\) (used to find where the line crosses the x-axis)
Working with fractions (Grades 5–7)
  • Being able to simplify fractions such as \(\dfrac{6}{3} = 2\)
  • Being comfortable leaving answers as fractions (and able to turn \(\dfrac{3}{2}\) into 1.5)

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to find the equation of a line from two points
Point 1 x-coordinate x1 1
Point 1 y-coordinate y1 3
Point 2 x-coordinate x2 4
Point 2 y-coordinate y2 9
Slope m (rate of change) =(B4-B2)/(B3-B1)
y-intercept b =B2-B5*B1
x-intercept (x where it crosses the x-axis) =-B6/B5
Table to find the equation of a line from the slope and one point
Slope m 2
x-coordinate of the point x1 3
y-coordinate of the point y1 7
y-intercept b =B3-B1*B2
x to find y for 5
Value of y for that x =B1*B5+B4
Table to find where the line crosses the x-axis and the y-axis
Slope m 2
y-intercept b 1
x-intercept (x where it crosses the x-axis) =-B2/B1
y where it crosses the y-axis =B2
After pasting, the upper rows (coordinates and slope) are your inputs and the lower rows are calculated automatically.
The first table finds the equation from the two points (1, 3) and (4, 9): the slope m is 2, the y-intercept b is 1 (the equation of the line is y = 2x + 1), and the x-intercept is −0.5. "/" is division and "*" is multiplication.
The second table works from the slope 2 and the point (3, 7): the y-intercept b is 1, and y is 11 when x = 5.
The third table finds only where the line crosses the axes, from its equation (slope and y-intercept). If the two points have the same x-coordinate, the divisor is 0 and an error (#DIV/0!) appears. This matches the fact that the slope is undefined (the line is not a linear function).

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to find the equation of a line from two points
Point 1 x-coordinate x1 1
Point 1 y-coordinate y1 3
Point 2 x-coordinate x2 4
Point 2 y-coordinate y2 9
Slope m (rate of change) =(B4-B2)/(B3-B1)
y-intercept b =B2-B5*B1
x-intercept (x where it crosses the x-axis) =-B6/B5
Table to find the equation of a line from the slope and one point
Slope m 2
x-coordinate of the point x1 3
y-coordinate of the point y1 7
y-intercept b =B3-B1*B2
x to find y for 5
Value of y for that x =B1*B5+B4
Table to find where the line crosses the x-axis and the y-axis
Slope m 2
y-intercept b 1
x-intercept (x where it crosses the x-axis) =-B2/B1
y where it crosses the y-axis =B2
The same formulas as in Excel work as is. Copy the whole table, paste it into cell A1, and replace the coordinates and slope with your own numbers.

How to calculate it in Python

from fractions import Fraction

# Coordinates of the two points (a fraction such as 3/4 can be written Fraction(3, 4))
x1, y1 = Fraction(1), Fraction(3)
x2, y2 = Fraction(4), Fraction(9)

slope = (y2 - y1) / (x2 - x1)   # slope m (rate of change) = Δy ÷ Δx
intercept = y1 - slope * x1     # y-intercept b = y1 − m×x1

print(f"Slope m = {slope}")
print(f"y-intercept b = {intercept}")
print(f"Equation of the line: y = {slope}x + {intercept}")
if slope != 0:
    print(f"Crosses the x-axis at: ({-intercept / slope}, 0)")
print(f"Crosses the y-axis at: (0, {intercept})")

x_value = Fraction(5)           # the x to find y for
print(f"When x = {x_value}, y = {slope * x_value + intercept}")
With the fractions module from the standard library, you can calculate with exact fractions and no decimal rounding errors. This example finds the equation from the two points (1, 3) and (4, 9). Running it prints the slope 2 and the y-intercept 1 (y = 2x + 1), the x-axis crossing point (-1/2, 0), and y = 11 when x = 5. Change the coordinates and run it.

How to write it in LaTeX and other math languages (copy and paste)

Equation of a linear function \(y = mx + b\) (slope-intercept form)
y = mx + b
y = mx + b
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>y</mi>
    <mo>=</mo>
    <mi>m</mi><mi>x</mi>
    <mo>+</mo>
    <mi>b</mi>
  </mrow>
</math>
y = m x + b
y == m x + b
y := m*x + b;
y = m*x + b;
y = mx + b
Finding the slope \(m\) (rate of change) from two points
m = (y₂ − y₁) ÷ (x₂ − x₁)
m = \frac{y_2 - y_1}{x_2 - x_1}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>m</mi>
    <mo>=</mo>
    <mfrac>
      <mrow><msub><mi>y</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>y</mi><mn>1</mn></msub></mrow>
      <mrow><msub><mi>x</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>x</mi><mn>1</mn></msub></mrow>
    </mfrac>
  </mrow>
</math>
m = (y_2 - y_1)/(x_2 - x_1)
(y2 - y1)/(x2 - x1)
m := (y2 - y1)/(x2 - x1);
m = (y2 - y1)/(x2 - x1);
m = (y_2 - y_1)/(x_2 - x_1)
Finding the y-intercept \(b\) from the slope and one point
b = y₁ − mx₁
b = y_1 - m x_1
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>b</mi>
    <mo>=</mo>
    <msub><mi>y</mi><mn>1</mn></msub>
    <mo>&#x2212;</mo>
    <mi>m</mi>
    <msub><mi>x</mi><mn>1</mn></msub>
  </mrow>
</math>
b = y_1 - m x_1
y1 - m x1
b := y1 - m*x1;
b = y1 - m*x1;
b = y_1 - m x_1
Where the line crosses the x-axis and the y-axis (the intercepts)
x = −b ÷ m
x = -\frac{b}{m}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>x</mi>
    <mo>=</mo>
    <mo>&#x2212;</mo>
    <mfrac><mi>b</mi><mi>m</mi></mfrac>
  </mrow>
</math>
x = -b/m
-b/m
x := -b/m;
x = -b/m;
x = −b/m

How to have ChatGPT  do the calculation

You are a math calculation assistant for linear functions. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing).

Find the equation y = mx + b of the line through the two points (1, 3) and (4, 9).
Show each of the following:
1. The slope m (rate of change), with the steps of Δy/Δx
2. The y-intercept b
3. The equation of the line y = mx + b
4. The coordinates of the points where the line crosses the x-axis and the y-axis
5. The value of y when x = 5

In Python, use the fractions module from the standard library to calculate exactly, and show the formulas you used and the numbers from the execution result. If an answer is a fraction, give it in lowest terms.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.