# 3.29 FAQ-257 How can I perform regression with multiple linear terms and obtain an analytical solution?

Last Update: 10/13/2016

You can get an analytical solution of an equation if the equation has multiple linear terms. Instead of using the NLFit tool to get an iterative solution, you can treat the linear terms as different independent variables (such as $x_1, x_2, x_3 \,$, etc.) and use the Multiple Linear Regression tool to the get the analytical solution. The key is to create several new columns in the worksheet and fill data into them according to the linear terms of the function and then to perform multiple linear regression on the new data.

Suppose you want to get the analytical solution to the following function:

$y=a*x+b*x^2+c*e^x \,$

The function can be viewed as:

$y=a*x_1+b*x_2+c*x_3 \,$

where $x_2=x^2 \,$ and $x_3=e^x\,$.

We need to add two new columns and fill them with data according to the two terms $x^2 \,$, $e^x \,$ respectively. Then regression with multiple linear terms should be performed to get an analytical solution. The detailed steps are as follows:

1. Start with a new workbook and import the file \Samples\Curve Fitting\ Exponential Growth.dat.
2. Highlight column B and right click on it. Then choose Insert twice to insert two columns before column B.
3. Now we set the designation of the new columns to X. Highlight them. Right-click on them and then choose Set As: X from the short-cut menu.
4. Highlight the 2nd column and right-click on it. Choose Set Column Values from the short-cut menu. In the Set Values dialog, enter col(A)^2 as the formula. Click Apply to fill data.
5. Don't close the Set Values dialog. Click on the heading for the 3rd column. This enables you to set values for this column. This time, enter exp(col(A)) as the formula. Click OK.
6. Highlight all the columns and select Analysis: Fitting: Multiple Linear Regression to open the Multiple Regression dialog. In the Fit Control groups, select the Fix Intercept check box and make sure the number in the Fix Intercept at edit box is 0. Click Ok to perform the fitting.
7. The fitting results should be as follows:
It indicates that the solutions are: a = -0.08256, b = 0.18566, c = 1.18432.

Keywords:regression, fitting, multiple linear regression, analytical solution, iterative solution