TITLE: How to make an approximation of path with polynom P(x,y)=0?
QUESTION [5 upvotes]: Hi. Imagine that a user draws on the canvas any path. I want to approximate this path with a path $P(x,y)=0$ where $P(x,y)$ - is unknown polynom. May be somebody can suggest an appropriate algorithm?
1) I tried to use the method of least squares to find this polynom. Just choosed on the path a lot of points $(x_i,y_i)$ . And minimized unknown $\sum\limits_i P(x_i,y_i)^2$ among all polinoms of degree n. This problem of minimization is a problem of finding an eigen vector of huge matrix that grows as $n^2\times n^2$. Already for $n=7$ this matrix has a size $36\times36$ it's hard work for PC   to find the solution. And for $n=7$ it doesn't give appropriate result.
2) Spline doesn't work for me. Because spline - is a union of curves $P_i(x,y)=0$. To each spline  of course we can correspond $P(x,y)=\prod\limits_i P_i(x,y) $. But this union  $P(x,y)=0$ will have a lot of bifurcation points on the curve. And for my project it is very bad

REPLY [2 votes]: Your reference to eigenvalues suggests that you are minimizing $\sum_i P(x_i, y_i)^2$ subject to a constraint like $\sum_{a,b} P_{ab}^2=1$, where $P(x,y) = \sum_{a,b} P_{ab} x^a y^b$. Why not instead minimize $\sum_i P(x_i, y_i)^2$ subject to a linear constraint like $P_{00}=1$? 
This is a standard approach when fitting a conic through a cloud of points (see, for example, Paul L. Rosin, A note on the least squares fitting of ellipses, Pattern Recognition Letters, Volume 14, Issue 10, October 1993, Pages 799–808) and I don't see why it wouldn't be a good idea for higher degree.
This puts your problem in the form "minimize $\vec{x}^T A \vec{x}$, subject to $\vec{b} \cdot \vec{x}=1$", to which the solution is $\vec{x} = \frac{A^{-1} \vec{b}}{\vec{b}^T A^{-1} \vec{b}}$; no eigenvalues needed. 
I suspect Misha's comment will be more useful than this answer, though.
I also second everyone who said that $36 \times 36$ is not large. It looks like this thread might be able to help you find a better linear algebra library.