I am developing a game using SDFs and ray marching. High school starts next year so I don't really know any calculus (not even pre calc) or linear algebra.
Here's the problem:
A surface is defined by this function (removed constants, not sure if it changes anything): $$S(x,y) = e^{-(x^2+y^2)}$$ graph of S
A vector A is on the surface if it satisfies $S(A_x,A_y) = A_z$ .This is the distance function (with constants removed): $$\mathrm{dist}(a,b) = \sqrt{(a_x - b_x)^2 + (a_y - b_y)^2 + (a_z - b_z)^2}$$
Given any vector A, how can I find a vector B on the surface, such that $\mathrm{dist}(A, B)$ is minimum, or at least approximate it?
The distance between a point $A(x_a,y_a,z_a)$ and the surface is $$d(x,y)=\sqrt{(x-x_a)^2+(y-y_a)^2+\left(e^{-x^2-y^2}-z_a\right)^2}$$ to minimize this function we should solve the system $$\begin{cases} (x-x_a)-2 x e^{-x^2-y^2} \left(e^{-x^2-y^2}-z_a\right)=0\\ (y-y_a)-2 y e^{-x^2-y^2} \left(e^{-x^2-y^2}-z_a\right)=0\\ \end{cases} $$ which is not solvable with elementary formulas.
One should implement a subprogram that solves the system above numerically.
For instance I tried to solve approximately when $A(2,5,3)$ and got
$x = 0.36, \;y= 0.86$
The real problem is finding the values where to start the approximation.
Linearizing the problem I found that a good start is
$$x_0= \frac{x_a}{2 z_a-1},y_0= \frac{y_a}{2 z_a-1}$$