ForHosting KIT · Developer Utilities

Polynomial regression calculator

This polynomial regression calculator fits a curve of a chosen degree to paired numerical observations using deterministic least squares.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Supply an x array, a matching y array, and the degree of the polynomial you want. The result gives coefficients in ascending power order, beginning with the constant term, so it can be copied directly into analysis code or evaluated with Horner-style arithmetic. The calculation uses Householder QR decomposition for better numerical behavior than directly solving the normal equations.

Prepare paired observations and choose a degree

Enter the independent values in x and the corresponding observed values in y. Position matters: the first y value belongs to the first x value, the second belongs to the second, and so on. Both arrays must therefore have exactly the same length, and every entry must be a finite number. Then choose a non-negative integer degree. Degree zero fits a constant, degree one fits a straight line, degree two fits a quadratic, and each higher degree adds another power of x. You need at least degree plus one points because that many coefficients must be determined. More points are usually preferable: they make the task a genuine least-squares fit rather than exact interpolation and can reduce the influence of measurement noise. Avoid selecting a high degree merely because it follows the supplied observations more closely. An unnecessarily flexible polynomial can oscillate between points and make poor predictions beyond the sampled range. Start with the simplest degree justified by the shape of the data and by the purpose of the model.

Read and use the returned coefficients

The coefficients are returned in ascending power order. If the result is <code>[c0, c1, c2]</code>, the fitted equation is <code>y = c0 + c1*x + c2*x^2</code>. This convention makes the constant term easy to identify and keeps every array position tied to its exponent. The response also repeats the accepted degree and number of paired points, identifies the coefficient order, and names the least-squares method. The coefficients minimize the sum of squared vertical residuals: for every supplied x value, the fitted polynomial produces a prediction, the prediction is subtracted from the observed y value, and the squared differences are added. Least squares balances all observations rather than guaranteeing that the curve passes through any particular one. Small decimal artifacts can arise from floating-point arithmetic, so results are normalized to a stable precision before they are returned. When consuming the output, retain the documented order and evaluate the polynomial consistently; reversing the list would describe an entirely different curve.

Understand numerical limits and fitting failures

The calculator uses Householder QR decomposition, a standard way to solve least-squares systems without explicitly forming the normal equations. That choice generally behaves better when polynomial columns have different scales, but polynomial fitting can still be numerically demanding. Very large x magnitudes, a wide spread of scales, or a degree near the configured maximum may amplify rounding error. In demanding scientific work, consider centering and scaling x before fitting, then preserve that transformation with the model. The calculator rejects a request when there are fewer points than degree plus one. It also rejects rank-deficient data, such as asking for a positive-degree polynomial when the x values do not contain enough distinct information to determine every coefficient. These failures are preferable to returning infinities, NaN values, or an arbitrary solution. A successful fit describes association within the supplied observations; it does not establish causation, validate extrapolation, or prove that a polynomial is the correct data-generating process. Inspect residual behavior and domain knowledge before relying on the curve for consequential predictions.

Fit a calibration curve

Estimate a quadratic or cubic relationship between known reference inputs and measured instrument responses.

Model a curved trend

Summarize a smooth nonlinear pattern in paired observations with coefficients that can be reused in code.

Check coursework calculations

Compare hand-computed polynomial least-squares coefficients with a deterministic QR-based result.

What does it cost?

The API price is $0.002 per request. The browser calculator can run the same deterministic core locally.

In what order are coefficients returned?

Ascending powers: the first value is the constant term, the second multiplies x, the third multiplies x squared, and so on.

How many points do I need?

At least degree plus one paired points are required. Using additional observations is generally better for fitting noisy data.

Why can a fit be singular even with enough points?

The x values may not contain enough distinct information to determine every requested power, for example when all x values are identical.

Does the curve pass through every point?

Not necessarily. Least squares minimizes the total squared vertical residuals; exact passage through every point occurs only for compatible data.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/polynomial-regression

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/polynomial-regression \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"x":[-2,-1,0,1,2],"y":[9,2,1,6,17],"degree":2}'
{
  "x": [
    -2,
    -1,
    0,
    1,
    2
  ],
  "y": [
    9,
    2,
    1,
    6,
    17
  ],
  "degree": 2
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.polynomial_regression",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →