# Finding equation of surface from known data

I have the raw data of $$X$$, $$Y$$, $$Z$$, where $$X$$ and $$Y$$ are inputs and $$Z$$ is the output. Plotting the surface gives the red curve:

The surface seems to be a simple function involving trigonometric functions. For example, plotting the equation $$\cos(X)^2 + \cos(Y)^2$$ gives the blue surface and it looks similar to the red graph (but the RMS error is very large). I have tried introducing variables ($$a_1\cos(X)^2 + a_2\cos(Y)^2$$, where $$a_1$$ and $$a_2$$ vary from $$0$$ to $$1$$) but the RMS error is still large.

How can I find the equation which gives the red surface?

• Perhaps consider NURBS or B-Spline based surfaces?
– NNN
Feb 21 at 6:04
• If you cannot come up with other ideas (e.g., some quadratic function) and do not have prior knowledge (e.g., from physics, data generating process), I'd suggest symbolic regression. There are Python and Julia packages available that implement this. Feb 21 at 8:18
• Most curves/surfaces do not correspond to close-form formulas. What makes you think that such a formula exists? Feb 21 at 13:20
• Are you familiar with least-squares regression? Given some candidate functions e.g., polynomials. you can find the linear combination that yields the least error over your dataset. Least squares with degree $\leq 2$ polynomials look like they should yeild a decent fit. Feb 21 at 15:52
• @cos_theta, I will try that out. Feb 22 at 2:39