# Least-squares fit of explicit parabolic sheet to data points

For a given set of data points

$$\{(x_i, y_i, z_i)\}$$

there exists some

$$f_{ABC}(x,y)=Ax^2+Bxy+Cy^2$$

that minimizes

$$\sum_i(f_{ABC}(x_i,y_i)-z_i)^2$$

$$A$$, $$B$$, and $$C$$ can be found quickly by directly solving/minimizing

$$(\begin{bmatrix}x_1^2&x_1y_1&y_2^2\\x_1^2&x_2y_2&y_2^2\\x_1^2&x_3y_3&y_3^2\\\vdots&\vdots&\vdots\end{bmatrix}\begin{bmatrix}A\\B\\C\end{bmatrix}-\begin{bmatrix}z_1\\z_2\\z_3\\\vdots\end{bmatrix})^2$$

However, suppose we want to reduce the model's degrees of freedom from 3 to 2 by constraining $$f_{ABC}$$ to be a parabolic sheet. I think this would mean that $$\begin{bmatrix}A&B&C\end{bmatrix}$$ has to be of the form $$\begin{bmatrix}U^2&2UV&V^2\end{bmatrix}$$ so that $$f_{ABC}(x,y)=(Ux+Vy)^2$$.

It seems this is no longer solvable directly as a linear system.

What would be a performant/fast way to solve this constrained version of the problem?

## Background

The above question is a simpler version of my actual problem, which is to fit an explicit bicubic surface patch $$g(x,y)=Ax^2+Bxy+Cy^2+D+Ex^3+Fy^3+Gx^2y+Hxy^2+Ix+Jy$$ that is constrained to be quadratic (instead of cubic) along some (any) direction.

## Thoughts

Thinking further, my best idea currently is to

1. Directly fit an unconstrained quadratic surface i.e. find a solution in the span of $$\begin{bmatrix}x_i^2&x_iy_i&y_i^2&1&x_i&y_i\end{bmatrix}$$. Call this the "quadratic solution".
2. Orthogonalize the remaining basis vectors $$\begin{bmatrix}x_i^3&y_i^3&x_i^2y_i&x_iy_i^2\end{bmatrix}$$ w.r.t. the quadratic solution.
3. Somehow solve a constrained minimization within this reduced basis that is orthogonal to the quadratic solution, though I don't really know how to go about this.

I think the eventual cubic terms should be of the form $$Ex^3+Fy^3+Gx^2y+Hxy^2=(Ux+Vy)^3$$ so the constraint is $$\begin{bmatrix}E&F&G&H\end{bmatrix}=\begin{bmatrix}U^3&3U^2V&3UV^2&V^3\end{bmatrix}$$

How to do this constrained optimization?