ThisCalculator

Everyday

Desmos Polynomial Regression Calculator Guide

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Desmos does not have a single button labeled “polynomial regression calculator,” but its graphing calculator includes a built-in regression feature that fits a polynomial of any degree to your data. You enter your x and y values as a table, then type a command like y1 ~ ax1^2 + bx1 + c to get the coefficients, the R² value, and a plotted curve. This article explains exactly how to use that feature, what the output means, and how to avoid the most common mistakes.

Formula

Polynomial regression fits a curve of the form:

y = anxn + an-1xn-1 + … + a1x + a0

where n is the degree you choose (1 for linear, 2 for quadratic, 3 for cubic, etc.). The calculator finds the coefficients an…a0 that minimize the sum of squared vertical distances between the data points and the curve (ordinary least squares). The R² value (coefficient of determination) tells you how much of the variation in y is explained by the model, with 1 being a perfect fit.

Worked Example

Using the default values: x = 1,2,3,4,5 and y = 2,4,6,8,10, with degree 2.

  1. For a quadratic fit, the model is y = ax² + bx + c.
  2. The least-squares solution gives a ≈ 0, b ≈ 2, c ≈ 0.
  3. So the fitted equation is y = 2x, which exactly matches the data.
  4. R² = 1.0000, indicating a perfect fit.

The calculator block above returns coefficients “0, 2, 0” (highest degree first) and R² = 1.0000.

How to Perform Polynomial Regression in Desmos

Desmos’s graphing calculator (desmos.com/calculator) makes this straightforward:

  • Click the “+” button and choose “Table” to enter your x and y values.
  • Type a regression command in a new expression line. For a quadratic: y1 ~ ax1^2 + bx1 + c. For a cubic: y1 ~ ax1^3 + bx1^2 + cx1 + d.
  • Desmos will display the fitted parameters (a, b, c, …) and the R² value directly under the command.
  • The curve appears automatically on the graph. You can adjust the window to see it clearly.

If your table is named differently (e.g., x2, y2), replace x1 and y1 accordingly. Desmos also supports non-polynomial regressions like exponential, logarithmic, and sinusoidal by changing the expression.

Choosing the Right Degree

The degree of the polynomial controls how flexible the curve is:

  • Degree 1 (linear): a straight line. Best for data with a constant rate of change.
  • Degree 2 (quadratic): one bend. Good for data with a single maximum or minimum.
  • Degree 3 (cubic): up to two bends. Useful for data with an inflection point.
  • Higher degrees (4, 5, …): more bends, but risk overfitting—the curve may follow noise rather than the underlying trend.

Start with degree 1 and increase only if the R² improves meaningfully and the curve makes sense for your data. A degree equal to the number of points minus one will always fit perfectly but is usually meaningless for prediction.

Common Mistakes and How to Avoid Them

  • Using the wrong variable names: If your table is x1/y1, use x1 and y1 in the regression command. Typing x or y alone will not work.
  • Forgetting to include all terms: For a quadratic, you must include x^2, x, and the constant. Omitting a term changes the model.
  • Overfitting: A high-degree polynomial may pass through every point but predict poorly outside the data range. Always check the R² and the curve’s shape.
  • Ignoring units: If x and y have units, the coefficients carry derived units. For example, if x is in seconds and y in meters, the linear coefficient has units m/s.
  • Extrapolating too far: Polynomials can swing wildly beyond the data range. Use the fit only within or near the observed x values.

Comparing Desmos with Other Tools

Desmos is free and runs in the browser, making it ideal for quick classroom or personal use. Excel and Google Sheets also offer polynomial trendlines (via chart options), but they require a few more clicks and do not show the equation as interactively. Dedicated statistical software like R or Python (with NumPy’s polyfit) gives more detailed diagnostics but has a steeper learning curve. Desmos’s advantage is its simplicity and immediate visual feedback—you see the curve update as you type.

Limitations of the Desmos Regression Feature

Desmos’s regression uses least squares and assumes your model is linear in the parameters (which polynomials are). It does not provide confidence intervals, p-values, or residual plots by default, though you can compute residuals manually. For large datasets (thousands of points), Desmos may slow down. Also, the calculator does not automatically suggest the best degree—you must decide based on your domain knowledge and the R² value.

Frequently Asked Questions

How do I copy the regression equation from Desmos?

Click on the expression line containing the regression command. The fitted equation appears in a box below; you can select and copy the text, or click the “Edit” icon to see the full equation with coefficients.

Can Desmos do polynomial regression on a log scale?

Yes. You can apply a log transformation to your data by creating a new table column (e.g., lny = ln(y1)) and then fitting a polynomial to the transformed values. Alternatively, use a logarithmic regression model directly.

Why does my R² show as 1 even though the curve looks wrong?

An R² of 1 can occur if you have as many parameters as data points (perfect fit) or if the data is exactly linear/quadratic. Check the residual plot or the coefficients—if they seem extreme, you may be overfitting.

Can I force the polynomial to pass through the origin?

Yes. Omit the constant term in your regression command. For a quadratic through the origin, use y1 ~ ax1^2 + bx1. Desmos will then fit the curve with no intercept.

Does Desmos work offline for regression?

The Desmos graphing calculator requires an internet connection in the browser, but the mobile app allows offline use once downloaded. The regression feature works offline in the app.

What is the difference between R² and adjusted R²?

R² always increases when you add more terms, even if they are not useful. Adjusted R² penalizes extra parameters, giving a more honest measure of fit quality. Desmos only shows R², so you may need to compute adjusted R² manually if you compare models with different degrees.

Related

Formula used
in x | x values (comma separated) | - | 1,2,3,4,5 | 0
in y | y values (comma separated) | - | 2,4,6,8,10 | 0
in deg | Polynomial degree | - | 2 | 1
out coef | Coefficients (highest first) | - | polyfit(x,y,deg) | 4
out r2 | R-squared | - | rsq(x,y,deg) | 4

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.