ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 04 Feb 2016 14:38:43 +0100How do I back substitute in output.https://ask.sagemath.org/question/32422/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.Wed, 03 Feb 2016 00:46:32 +0100https://ask.sagemath.org/question/32422/how-do-i-back-substitute-in-output/Comment by tmonteil for <p>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.</p>
https://ask.sagemath.org/question/32422/how-do-i-back-substitute-in-output/?comment=32428#post-id-32428Can you provide a sample code of how you construct all your variables ?Wed, 03 Feb 2016 11:53:57 +0100https://ask.sagemath.org/question/32422/how-do-i-back-substitute-in-output/?comment=32428#post-id-32428Comment by KevinGilbert for <p>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.</p>
https://ask.sagemath.org/question/32422/how-do-i-back-substitute-in-output/?comment=32443#post-id-32443var ('xia','yia',...)
xab = xia - xib
yab = yia - yib
This goes on, then rab2 = xab*xab + yab*yab, 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.Thu, 04 Feb 2016 14:38:43 +0100https://ask.sagemath.org/question/32422/how-do-i-back-substitute-in-output/?comment=32443#post-id-32443