I have defined an expression, such as

a = x


I would like to convert this into a function, such as

f[x_]:=x


However, in my case, the expression on the right-hand-side of a is rather complicated, so I do not want to manually write the expression on the right-hand-side of the function definition. I would like to write something like

f[x_]:=a


I know that this will not work. Is there a way to evaluate a in the function definition to ensure that I have actually defined a function in the end?


Question: Force exerted on potential wall
Answer: Your answer gets derailed at the point where you try to apply the two classical equations 
$$p=mv\textrm{ and }F=\frac{dp}{dt}$$
to this (very) quantum problem. To see why this is fundamentally flawed, notice that the plane-wave situation you consider (not exactly a plane wave, though: it's two counter-propagating plane waves) is a stationary state, so that all time derivatives are zero.

You then make a couple of slips that get you badly off track. Equating $p=\frac{\hbar k}{m}|\phi|^2 dx$ can't be right since it's a finite quantity equal to an infinitesimal. Though in this particular situation the equation $j=v|\phi|^2$ kind-of holds (instead of the actual current, $j=\frac{\hbar}{2im}\left(\phi^* \frac{d\phi}{dx}-\phi \frac{d\phi^*}{dx}\right)$), here you must add the currents of left- and right-going particles to get $j=0$.

The right approach to this problem needs a fundamental re-think of what we mean by force in this context, and indeed in all of quantum mechanics, where energy is a far more fundamental concept than force (which becomes merely the gradient of the potential). Suppose the wall slipped to the left a small amount $\Delta x$, over a long time. What would be the work done by the particle on the wall? This work would then have to come from the particle's (purely kinetic) energy. How would that change with the slight enlargement of the box?