How do I back substitute in output.

asked 2016-02-03 00:46:32 +0200

KevinGilbert gravatar image

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.

edit retag flag offensive close merge delete

Comments

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

tmonteil gravatar imagetmonteil ( 2016-02-03 11:53:57 +0200 )edit

var ('xia','yia',...) xab = xia - xib yab = yia - yib This goes on, then rab2 = xabxab + 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.

KevinGilbert gravatar imageKevinGilbert ( 2016-02-04 14:38:43 +0200 )edit