Distance between two functions to create a third function, In this question I am using the euclidean metric to determine the distance between two points.
I want to make a function $f(x)=$ the minimum distance between $y=x$ and $y=e^x$ at each given point x, is there an efficient way of doing this?
Second related question if i knew $e^x$ was the shortest distance between $g(x)$ and  $y = x$ could I figure out closed form solution for $g(x)$
 A: Consider the point $(x_1,g(x_1))$.
At this point
the distance to the line $y=x$
is $d(x_1)=\exp(x_1)$. 

As we can see, for every $x$ 
there are two suitable points,
\begin{align} 
P_1&=(x_1,x_1+\sqrt2\,d(x_1))
\\
\text{and }\quad
P_1&=(x_1,x_1-\sqrt2\,d(x_1))
,
\end{align}
so at least there are two suitable
continuous functions,
\begin{align} 
g_1(x)&=x+\sqrt2\,d(x)
,\\
g_2(x)&=x-\sqrt2\,d(x)
.
\end{align}  
A: Okay so, for your first question, all the points in the form of the line $y=x$ is in the form $(a,a)$ (So this is our best alternative, keep in mind however that the $x$'s in $y=x$ is not the same as the $x$'s in $y=e^x$, as discussed in the comments). As you mentioned, you are using the Euclidean Metric. So we need to find the minimum distance between $(a,a)$ and $(x,e^x)$. We can start at:
$$g(x) = \sqrt{(a-x)^2+(a-e^x)^2}$$
So we would like to find $x$ such that this distance is minimal for a given $a$.
We can take the derivative of $g$, treating $a$ as a constant to find that:
$$g'(x) = \frac{-2e^x(a-e^x)-2(a-x)}{2\sqrt{(a-e^x)^2+(a-x)^2}}$$
So we set $g'(x) = 0$ and then solving for $a$ would give us the closest point of the form $(a,a)$ for a given point $(x,e^x)$. We do the math and we find that:
$$a = \frac{e^{2x}+2x}{e^x+2}$$
Since the $a$ minimizes the distance $g$ we just plug it back in. Therefore, the function that represents the minimum distance for each point in the form $(a,a)$ to the curve $y=e^x$, as you said, "for every $x$" is:
$$g(x) = \sqrt{(\frac{e^{2x}+2x}{e^x+2}-x)^2+(\frac{e^{2x}+2x}{e^x+2}-e^x)^2}$$
Your second question is too unclear, and I'll have to make too many assumptions to answer it
