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, 14 Feb 2019 19:12:20 +0100how to substitute several variables on both sides of the equation?https://ask.sagemath.org/question/45465/how-to-substitute-several-variables-on-both-sides-of-the-equation/This is my worksheet:
https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share
I would like to substitute
V == 4*pi*p_ges/U
in line 36 in the equation
SR.symbol('p_ges') == p_ges_rhs
but those variables are spread out over both sides of the equation, and i am clueless as to how to convince sage that this is a good idea. :-) How can I transform this equation in this way? Do i need to do this manually and re-write p_1 -p_4 accordingly?Thu, 14 Feb 2019 18:20:04 +0100https://ask.sagemath.org/question/45465/how-to-substitute-several-variables-on-both-sides-of-the-equation/Answer by tmonteil for <p>This is my worksheet:
<a href="https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share">https://cocalc.com/share/f7766c5e-2f4...</a></p>
<p>I would like to substitute </p>
<pre><code>V == 4*pi*p_ges/U
</code></pre>
<p>in line 36 in the equation </p>
<pre><code> SR.symbol('p_ges') == p_ges_rhs
</code></pre>
<p>but those variables are spread out over both sides of the equation, and i am clueless as to how to convince sage that this is a good idea. :-) How can I transform this equation in this way? Do i need to do this manually and re-write p_1 -p_4 accordingly?</p>
https://ask.sagemath.org/question/45465/how-to-substitute-several-variables-on-both-sides-of-the-equation/?answer=45466#post-id-45466You will have to struggle with wildcards, see examples on the page:
https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/expression.html#sage.symbolic.expression.Expression.match
If the substitution involves both right-hand side and left-hand side of the equation `expr`, first put everything on a single side:
e = expr.rhs() - expr.lhs() == 0
or
e = expr.rhs() / expr.lhs() == 1
Thu, 14 Feb 2019 19:12:20 +0100https://ask.sagemath.org/question/45465/how-to-substitute-several-variables-on-both-sides-of-the-equation/?answer=45466#post-id-45466