Polynomial Curve Fit and Interpolation Calculator: Least Squares Line, Parabola, Cubic and Lagrange

Fit a curve to your data, or draw one exactly through it.

Calculated from standard textbook formulas, with every step shown. The formulas are fixed, so the working does not need checking: what matters is the numbers you type in. Use these calculators only if you are competent to choose the inputs (loads, material strength, dimensions, supports) and check your units and assumptions. For learning and checking your own working: design and sign-off are for a qualified engineer. Drafting Central does not store the numbers you type.

How this calculator works

Type the points, one per line, as x then y.

Choose the fit or the interpolation, and the degree.

Enter the x value to find y at.

Formulas used

  • y = c_0 + c_1x + c_2x^2 + \cdots
  • R^2 = 1 - \frac{SS_E}{SS_T}
  • P(x) = \sum y_i\prod_{j\ne i}\frac{x - x_j}{x_i - x_j}

Worked example

With the default numbers in the calculator above:

  1. The fitted polynomial: y = 1.99 x + 0.05
  2. Coefficient of x^1: 1.99
  3. Coefficient of x^0: 0.05
  4. R squared: 0.997305
  5. Standard error of the fit: 0.18886
  6. Predicted y at the x value: 5.025

Change the numbers in the calculator to see the full working, every step, for your own case.

A second worked example

A different case, with these numbers: Degree of the polynomial (fit only) 2.

  1. The fitted polynomial: y = 0.021429 x^2 + 1.8614 x + 0.2
  2. Coefficient of x^2: 0.0214286
  3. Coefficient of x^1: 1.86143
  4. Coefficient of x^0: 0.2
  5. R squared: 0.997467
  6. Standard error of the fit: 0.22424
  7. Predicted y at the x value: 4.9875

Common questions

What is least squares fitting?

It finds the curve that makes the sum of the squares of the vertical distances to the points as small as possible.

What does R squared mean?

The share of the variation in y that the curve explains. 1 means a perfect fit.

Why not always use a high degree?

A high degree fits the noise as well as the trend and swings wildly between and beyond the points.

Related calculators

Got a question about this? Ask an engineering question and get a plain-language answer with references.

Further reading: Any numerical methods or statistics text (polynomial regression and Lagrange interpolation).

Need a calculator we do not have?

Tell us what you would like to calculate. We read every request and build the most asked-for ones.

We store your request (and your email if you give it) to decide what to build. We do not store the numbers you type into calculators.

Embed this calculator on your own page

Copy this code into your page. The calculator runs inside the frame and links back to Drafting Central.

Need this drawn, designed or checked?

Drafting Central is a mechanical engineering and drafting business working with customers across Australia and around the world. A calculator gives you the numbers; we can turn them into drawings and designs.

Need help with a real project?

Talk to Drafting Central →

← All engineering calculators