Line Of Best Fit Calculator

Calculate the line of best fit (linear regression) for a set of data points. Enter x and y values to get the slope, intercept, and R-squared value.

isCalculator Editorial Team Published by:
Reviewed by: Review Board
Last Updated:

Was this calculator helpful?

How to use this tool?

How to Use the Line of Best Fit Calculator

  1. Enter X values in the first field as comma-separated numbers (e.g., 1,2,3,4,5).
  2. Enter Y values in the second field with the same format and same number of values as X (e.g., 2,4,5,4,5).
  3. Click Calculate. The calculator will display:
    • Equation: The line of best fit in the form y = mx + b (slope and intercept rounded to 4 decimals).
    • R²: The coefficient of determination (0 to 1), indicating how well the line fits the data.
  4. If you see an error, check that:
    • Both fields contain numbers separated by commas.
    • X and Y have the same count of values.
    • You have at least two data points.
    • X values are not all identical.

Tip: Use decimal points (e.g., 1.5, 2.3) for non-integer values. No units are required—just raw numbers.

Previous Results

Generate Charts
Result Inputs Date

Frequently Asked Questions

The line of best fit is a straight line that best represents the data on a scatter plot. It is calculated using linear regression to minimize the sum of squared errors.

Enter your x and y values as comma-separated numbers (e.g., 1,2,3 for x and 2,4,5 for y). Then click Calculate to get the slope, intercept, and R-squared value.

R-squared (R²) is a statistical measure that represents the proportion of the variance for the dependent variable that's explained by the independent variable. Values range from 0 to 1, with higher values indicating a better fit.

Reviewed by Experts

Eurico José Kiala

Eurico José Kiala

Mathematician

Teacher

LinkedIn
João Lino

João Lino

Mathematician

LinkedIn
Quick Convert
Length Converter
0
Weight/Mass Converter
0
Area Converter
0
Volume Converter
0
Speed Converter
0
Temperature Converter
0
Pressure Converter
0
Energy Converter
0
Power Converter
0
Force Converter
0
Time Converter
0
Angle Converter
0
Fuel Consumption Converter
0
Data Storage Converter
0
Base Numbers Converter
0
Dry Volume Converter
0
Currency Converter
0
Text Case Converter
0