How to do Curve Fitting in Excel (With Examples)

Curve fitting in excel is the process of finding the optimal curve that best fits a given set of data points. This process can be done by creating a scatter plot of the data and then using trendlines or regression equations to find the best fit. Examples include using linear regression to find the best fit straight line, or more complex equations such as polynomial or exponential regression for more complex data sets. Additionally, the Excel Solver tool can be used to fine-tune the fit to the data points for the best possible result.


Often you may want to find the equation that best fits some curve for a dataset in Excel.

Fortunately this is fairly easy to do using the Trendline function in Excel.

This tutorial provides a step-by-step example of how to fit an equation to a curve in Excel.

Step 1: Create the Data

First, let’s create a fake dataset to work with:

Step 2: Create a Scatterplot

Next, let’s create a scatterplot to visualize the dataset.

First, highlight cells A2:B16 as follows:

Next, click the Insert tab along the top ribbon, and then click the first plot option under Scatter:

This produces the following scatterplot:

Step 3: Add a Trendline

Next, click anywhere on the scatterplot. Then click the + sign in the top right corner. In the dropdown menu, click the arrow next to Trendline and then click More Options:

In the window that appears to the right, click the button next to Polynomial. Then check the boxes next to Display Equation on chart and Display R-squared value on chart.

This produces the following curve on the scatterplot:

Curve fitting in Excel

The equation of the curve is as follows:

y = 0.3302x2 – 3.6682x + 21.653

The tells us the percentage of the variation in the that can be explained by the predictor variables. The R-squared for this particular curve is 0.5874.

Step 4: Choose the Best Trendline

We can also increase the order of the Polynomial that we use to see if a more flexible curve does a better job of fitting the dataset.

For example, we could choose to set the Polynomial Order to be 4: 

This results in the following curve:

Curve fitting in Excel example

The equation of the curve is as follows:

y = -0.0192x4 + 0.7081x3 – 8.3649x2 + 35.823x – 26.516

The R-squared for this particular curve is 0.9707.

This R-squared is considerably higher than that of the previous curve, which indicates that it fits the dataset much more closely.

We can also use this equation of the curve to predict the value of the response variable based on the predictor variable. For example if x = 4 then we would predict that y = 23.34:

y = -0.0192(4)4 + 0.7081(4)3 – 8.3649(4)2 + 35.823(4) – 26.516 = 23.34


You can find more Excel tutorials on .

x