# How do I back substitute in output.

I define three points (xia,yia,zia,xib...), the vectors xab,yab,zab,xcb.. , the distances rab2 and rcb2, the dot product, the angle a-b-c and then the energy of bending the angle - e. I take the derivative of e with respect to xia and I get a long output in terms of xia-xib, xic-xib and so on. I want to condense the output by using all the previous defines. I normally would do this by hand doing string replacements in emacs. Tedious and error prone. Is there a command or script that will do the back substitution. Simplify dies with out of memory errors and is not really what I am trying to do. I had the same problem in Mathmatica and never found a good solution.

Can you provide a sample code of how you construct all your variables ?

var ('xia','yia',...) xab = xia - xib yab = yia - yib This goes on, then rab2 = xab

xab + yabyab, eventually you get the cosine of the angle in terms of the dot product and the distances, convert the cosine to an angle. Very standard geometry. The derivative of the energy with respect to xia is correct, but the output is so cluttered you can not see the form of the expression and it is then hard to factor, hard to show to students and not what you would use for programming.