Curve Function Extractor
Draw one or more freehand curves on a canvas (with optional stroke smoothing), or upload an image containing hand-drawn or printed curves. The tool fits each curve with a piecewise polynomial or parametric function, then shows every curve as a card with its formula, degree, and domain. If more than 10 curves are found, only the 10 most significant (by arc length and size) are shown. Hover a card to highlight the matching stroke on the canvas. Everything runs locally in your browser.
Reviewed by Alessia Bogoni, Data Analyst & Researcher · Last updated September 29, 2026
How it works
- 1
Draw one or more freehand curves on the canvas, or switch to Upload and drop an image containing curves.
- 2
Click "Extract functions"; the tool fits each curve with least-squares polynomials (or a parametric curve for loops).
- 3
Each curve appears as a card showing its formula, broken into pieces where needed, with the domain each piece applies to.
- 4
Hover any card to highlight that curve's exact stroke on the canvas, and copy the formula with one click.
Real least-squares fitting, not a lookup table
Every formula shown here comes from an actual least-squares polynomial fit solved with Gaussian elimination, the same math used in scientific curve fitting, rather than a canned shape matched against a template. The degree (linear, quadratic, or cubic) is chosen automatically per segment, picking the simplest formula that still explains the shape well.
Piecewise and parametric, because real doodles aren't functions
A hand-drawn wave, hill, or loop usually isn't a valid function of x: a single x can map to multiple y values. This tool handles that case directly. Strokes are split at direction changes into pieces that are each safely fit as y = f(x) or x = f(y), and shapes that don't split cleanly (closed loops, tight scribbles) get a parametric x(t)/y(t) fit instead of a misleading forced formula.
From a photo of a graph to editable math
Upload mode brings the same fitting engine to printed or photographed curves, whether that's a textbook graph, a whiteboard sketch, or a plotted chart, by tracing the ink into a skeleton path before fitting. You're not limited to curves you draw yourself.
Frequently asked questions
How does it turn a hand-drawn line into a formula?
Each stroke is resampled and smoothed, split into pieces that are monotonic in x (or y for near-vertical sections), and each piece is fit with a least-squares polynomial (degree 1 to 3, picking the lowest degree that fits well). Closed loops or very short strokes are instead fit parametrically as x(t) and y(t) over arc length, since they aren't valid functions of x.
Why do some curves show more than one formula?
A single stroke that curves back on itself in x, or has a sharp peak or valley, can't be described by one simple polynomial, so it's split into consecutive pieces, each with its own formula and the x (or y) range it applies to.
What happens with more than 10 curves?
Only the 10 most significant curves are shown, ranked mainly by arc length (how much curve is actually there) with bounding-box size as a secondary factor, so tiny stray marks don't crowd out real curves.
How does image upload mode find the curves?
The image is converted to grayscale, automatically thresholded into black/white (Otsu's method, with a manual override slider), thinned down to single-pixel-wide skeleton lines, then each connected line is traced into an ordered path and fitted the same way as a hand-drawn stroke.
Is my drawing or photo uploaded anywhere?
No, drawing, image processing, and curve fitting all happen in your browser; nothing is sent to a server.
Does it handle loops, circles, or curves that cross themselves?
Closed loops are detected and fit as a parametric curve (x and y each as a function of a parameter t from 0 to 1) instead of a single y = f(x), so shapes like circles or spirals get a sensible formula. Self-crossing curves in uploaded images are a known limitation: the tracer follows one path through the crossing rather than splitting it.