Advanced maths

Nonlinear least squares curve fitting calculator with parameter bounds

Fit an entered model expression to x,y observations using a bounded local nonlinear least-squares search.

Your numbers

Rows separated by semicolons; values by commas.
Rows separated by semicolons; values by commas.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Fit an entered model expression to x,y observations using a bounded local nonlinear least-squares search. Parameters, initial values and finite bounds are visible, and the result reports residuals rather than hiding the dependence on starting values. The page distinguishes a converged local fit from a global optimum or an uncertainty analysis.

THE FORMULAmin_theta Σ(f(x_i,theta)−y_i)² within entered box.

A worked example

For the points (0,1),(1,3),(2,5),(3,7), the model a+b*x fits with a=1 and b=2, giving zero SSE. Nonlinear parameter expressions use the same form, but a converged local result should be checked across starting points and against the residual pattern.

Good to know

≤4parameters/100points, strictly interior initial values and finite box bounds. Supported expression parser; logistic transform/local Nelder-Mead, no global optimum, coefficient intervals or active-bound fit certificate.

Use explicit parameter names and multiplication

The model expression can use x and parameters a,b,c,d, with supported arithmetic and one-input functions. Enter multiplication explicitly, such as a*exp(b*x), rather than relying on implicit multiplication. The expression parser does not evaluate JavaScript, property access or arbitrary function calls.

The initial parameter list determines how many parameters are fitted, up to four, and each needs a matching lower/upper row. Do not use an undeclared parameter expecting it to be optimized automatically. Observations are x,y pairs, and the sample count must exceed the number of fitted parameters.

Bounded least squares recovers the exact line in the exampleModel: a+b xa=1, b=2SSE=0; local solver
For the points (0,1),(1,3),(2,5),(3,7), the model a+b*x fits with a=1 and b=2, giving zero SSE. Nonlinear parameter expressions use the same form, but a converged local result should be checked across starting points and against the residual pattern. Diagram is schematic; labels specify the numerical values.

The D optimal experimental design calculator from candidate rows selects measurement rows before responses are fitted. Nonlinear least squares estimates model parameters from responses already observed, with a local search that should be checked across starts.

Define the squared-residual objective

For each observation, residual is fitted model value minus observed y. Squaring and summing gives SSE, which the search minimizes. The sign convention matters when inspecting systematic residual patterns even though squaring would give the same objective under the opposite sign.

Least squares emphasizes large absolute residuals. It does not automatically provide robustness to outliers or account for unequal measurement variances. If y values have different uncertainty levels, an unweighted fit can be inappropriate even when its numerical objective is minimized accurately.

Understand the finite-box transformation

Each parameter is transformed from an unconstrained search coordinate through a logistic map into its finite lower/upper interval. Initial values must be strictly inside those bounds. The search therefore stays inside the box rather than evaluating invalid parameter values outside it.

A true optimum on a bound is a special case the current interior method does not certify. Fits approaching the numerical transformation boundary are rejected. Do not interpret a near-boundary error as proof that no acceptable model exists; it may call for an active-bound solver or a better-justified parameter interval.

Verify a straight-line benchmark

The default points are (0,1),(1,3),(2,5),(3,7), and model a+b*x has exact solution a=1,b=2 with zero SSE. This simple case supplies an independent arithmetic benchmark even though the same interface can fit expressions nonlinear in their parameters.

For a nonlinear model such as a*exp(b*x), a single linear-system solve is insufficient because the parameters enter nonlinearly. The page’s general local search handles the objective directly. That broader capability does not make its optimization guarantee equivalent to the closed-form uniqueness of the straight-line benchmark.

Interpret the local-search result honestly

The method uses Nelder–Mead from one entered starting point and requires convergence to a finite objective. Different starts can reach different local minima or equivalent parameterizations. A low SSE found once is an upper bound on the best attainable SSE, not a proof that every other parameter set is worse.

Try scientifically plausible alternative starts and inspect whether fitted curves and residual patterns remain stable. Repeating starts only to select a desired parameter sign is not a sound validation method. The form does not automate a global multistart certificate or perform an exhaustive parameter-box search.

Read residuals before interpreting coefficients

Residuals can reveal curvature, changing variance or an outlier that a single SSE hides. A small total can coexist with a systematic error pattern when response scale is small or observations cover only a narrow x interval. Coefficients can also be poorly identified even when the fitted curve is stable over that interval.

No standard errors, confidence intervals or parameter-correlation matrix is computed. Printed coefficient precision is numerical output, not inferential certainty. Extrapolating far outside the observed x range can amplify small coefficient differences, especially for exponential and rational expressions.

Keep model choice separate from fitting

The expression is a supplied hypothesis. The calculator does not discover a mechanistic law, select among arbitrary functional families or prove causality. Domain restrictions, such as positive logarithm arguments, must hold at evaluated observations and candidate parameters; invalid evaluations do not become valid by plotting only selected points.

Use consistent units and finite bounds justified by the model. A scale change can alter search conditioning even when an equivalent physical model exists. Record the expression, starts, bounds and residual convention with the result so that another analyst can distinguish a reproducible local fit from an unqualified claim about the underlying process.

A few questions, answered

Can this guarantee the global best fit?

No. It is a single-start bounded local search and can converge to a local optimum.

Why must initial values be strictly inside bounds?

The logistic transformation uses interior coordinates and does not certify an optimum exactly on a bound.

Are coefficient confidence intervals returned?

No. The output is a numerical fit with residuals, not a full inferential analysis.

Is a small SSE enough to validate the model?

No. Inspect residual patterns, identifiability and out-of-sample behavior as well as the study assumptions.

Find your calculator

Start typing to explore the library.