Q:

How to find a function on a 3-dimentional space base on a set of points?

So I have been working on stereographic projections and stuff. I want to input a set of points on the plane z = -1 and find the function on the sphere that it was projecting from. Right now I have successfully found the points on the sphere  So is there a way to input some points in the 3-dimentional space and output a function? Just like in the 2-dimentional space, if we were finding a line equation we would use y=mx+c.

A:

The transformation formulas for stereographic projection using North Pole $N(0,0,1)$
$$P(x,y,-1) \rightarrow P'(X,Y,Z)$$
from the horizontal plane with equation $z=-1$ to the unit sphere are :
$$\begin{cases}X=\dfrac{4x}{x^2 + y^2 + 4}\\ Y=\dfrac{4y}{x^2 + y^2 + 4}\\Z=1 - \dfrac{8}{x^2 + y^2 + 4}\end{cases} \ \ (F)$$
They originate from the following relationship (classical stereographic projection, which amounts to what is called an "inversion" in classical geometry):
$$\overrightarrow{NP'}=\lambda \overrightarrow{NP} \ \ \text{with} \ \ \lambda=\dfrac{4}{\|NP\|^2}$$
The inverse formulas are in two parts, because knowing $(X,Y)$ is not enough to be able to retrieve $(x,y)$: one has to know in which hemisphere is situated point $P'(X,Y,Z=\pm\sqrt{1-X^2-Y^2})$:
Northern hemisphere (case $x^2+y^2\geq4$): $\ \begin{cases}x=\dfrac{2X(1+\sqrt{1-X^2-Y^2})}{X^2 + Y^2}\\y=\dfrac{2Y(1+\sqrt{1-X^2-Y^2})}{X^2 + Y^2}\end{cases} \ \ $(N) 
Southern hemisphere (case $x^2+y^2\leq 4$): $\ \begin{cases}x=\dfrac{2X(1-\sqrt{1-X^2-Y^2})}{X^2 + Y^2}\\ y=\dfrac{2Y(1-\sqrt{1-X^2-Y^2})}{X^2 + Y^2}\end{cases} \ \ $(S)
Remark: Formulas are simpler with polar coordinates.
Here is an example, with an interesting artifact. I have used formulas (F) for 10,000 (uniformly distributed) points $(x,y)$ with $-20\leq x,y\leq 20$. The resulting stereographic image is far from being uniformly distributed on the sphere, which is not surprising, and besides, there is a flower-like "exclusion zone"; up to the reader to understand why... 
Edit : How for example, 
1) a straight line with equation $y=mx+p$ is transformed ? The simplest approach consist in saying that it is the set of points of the form:
$$\begin{cases}x&=&x\\y&=&mx+p\\z&=&-1\end{cases} \ \ \text{which, plugged in (F) give} \ \ \begin{cases}X=\dfrac{4x}{x^2 + (mx+p)^2 + 4}\\ Y=\dfrac{4y}{x^2 + (mx+p)^2 + 4}\\Z=1 - \dfrac{8}{x^2 + (mx+p)^2 + 4}\end{cases}$$
2) a circle with the following parametric equations is transformed ?
$$\begin{cases}x&=&r \cos \theta\\y&=&r \sin \theta\\z&=&-1\end{cases} \ \ \text{ is transformed into} \ \ \begin{cases}X=\dfrac{4r}{r^2 + 4}\cos \theta\\ Y=\dfrac{4r}{r^2 + 4}\sin\theta\\Z=1 - \dfrac{8}{r^2 + 4}\end{cases}$$
which means a circle with radius $\dfrac{4r}{r^2 + 4}$ at a certain height, as can be awaited.

