Curve fitting is the process of finding a mathematical curve that comes as close as possible to a set of points. You have some scattered dots — from a drawing, an experiment, a spreadsheet — and you want one clean equation that explains roughly where they all sit. That equation is the "fit."
It sounds technical, but the core idea is something most people have already used without the vocabulary.
You've seen this before, in a spreadsheet
If you've ever put numbers into Google Sheets or Excel, plotted them as a scatter chart, and clicked "add trendline," you've watched curve fitting happen in real time. The software looks at your dots and draws the straight line that sits closest to all of them at once — not touching every point, just running through the middle of the pack in the way that makes the most sense overall.
That's curve fitting in its simplest form: one straight line, fit to a handful of points. Everything else — circles, waves, spirals — is the same basic move with a fancier shape.
What "best" actually means here
Here's the part that trips people up: there's no single line or curve that hits every point exactly, unless you got extremely lucky. So "best fit" doesn't mean perfect — it means least wrong, by some consistent rule.
The most common rule is simple once you see it laid out:
- For every point, measure how far off the curve is at that spot — the gap between where the point actually is and where the curve says it should be.
- Square that gap, for every point. Squaring does two jobs at once: it makes every gap positive (so a point above the curve and a point below it both count as "bad," instead of canceling out), and it punishes big misses much more than small ones.
- Add all those squared gaps together, and look for the curve that makes that total as small as possible.
That's it — that's what "least squares" means, a phrase you'll see attached to almost every curve-fitting method that exists. It's not a different idea from the trendline in your spreadsheet. It's the exact same idea, just spelled out.
Is curve fitting the same thing as "connecting the dots"?
No — connecting the dots draws a line through every point exactly, even if that means a jagged, wandering path. Curve fitting deliberately does not try to hit every point. It looks for one smooth curve that best represents the overall trend, accepting that most individual points will miss by a little.
A shape needs more than a straight line
A line is the simplest curve fit, but most interesting shapes aren't lines. A thrown ball traces a curved arc, not a straight one. A drawn circle obviously isn't a line at all. So curve fitting has a whole menu of shape families beyond "straight line" — parabolas, circles, sine waves, and plenty more — each with its own equation and its own handful of adjustable numbers.
Fitting a parabola works the same way fitting a line does: measure the gaps, square them, add them up, and search for the version of the parabola's equation that makes that total smallest. The math under the hood gets a little more involved, but the goal never changes.
How do you know a fit is actually good?
This is where the "how far off" number from step one becomes genuinely useful on its own — not just as a tool for finding the fit, but as a report card on it afterward. A fit with tiny leftover gaps at every point is a tight fit. A fit with big leftover gaps, even if it's technically the best available option, is telling you something: maybe you picked the wrong shape family, or the points themselves are pretty noisy.
This is exactly what a mathgram's fit score is doing under a friendlier name — it's a summary of those leftover gaps, turned into one number that tells you how much to trust the equation on the card. If you want the full walkthrough of what's on that card, see what is a mathgram.
The catch: you have to already know what shape you're fitting
Here's the limitation that regular curve fitting never quite solves on its own. Fitting a parabola only works if you've already decided, before you start, that a parabola is the right family to try. Feed the same points into a "fit a line" routine and a "fit a circle" routine, and you'll get two completely different answers — both technically "best fits," just best fits within the shape someone already chose.
For a lot of real use, that's fine — you know you're looking at a straight trend, or you know the underlying physics says "parabola." But if you're handed a random hand-drawn squiggle with no label on it, regular curve fitting can't tell you which family to even try. That harder problem — searching over the shapes themselves, not just the numbers inside one shape — is what symbolic regression is for, and it's the part of Graphiti that actually looks at your doodle and decides "this one's a spiral, not a wave."
Where to go from here
Curve fitting is the "tune the numbers" half of the story. The "figure out the shape" half is symbolic regression, covered in symbolic regression, explained for actual humans. For the finished product both of these feed into, see how it works or browse real results in the gallery. And if a specific question about the fit process is nagging at you, it might already be answered in the FAQ.