ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 11 Feb 2017 10:48:28 -0600Adding zero to an expression and avoiding simplificationhttp://ask.sagemath.org/question/36556/adding-zero-to-an-expression-and-avoiding-simplification/Hi, I have an expression of the form
`pol_y = chi_yyyy*Ey*Ey*Ey + (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex - (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex + (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex`
Now the last two terms add 0 to the expression. The goal is to substitute complicated expressions for Ey, Ex (complex quantities) and compare the results of two different reformulations (with and without the 0 terms). So for my work, I need the last two terms to be there but sagemath is simplifying this expression automatically. How do I avoid this?Fri, 10 Feb 2017 16:34:49 -0600http://ask.sagemath.org/question/36556/adding-zero-to-an-expression-and-avoiding-simplification/Comment by NahsiN for <p>Hi, I have an expression of the form</p>
<p><code>pol_y = chi_yyyy*Ey*Ey*Ey + (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex - (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex + (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex</code></p>
<p>Now the last two terms add 0 to the expression. The goal is to substitute complicated expressions for Ey, Ex (complex quantities) and compare the results of two different reformulations (with and without the 0 terms). So for my work, I need the last two terms to be there but sagemath is simplifying this expression automatically. How do I avoid this?</p>
http://ask.sagemath.org/question/36556/adding-zero-to-an-expression-and-avoiding-simplification/?comment=36569#post-id-36569Yes as they should. But when expressions are of the form $E_x =
\frac{1}{2} \, {\left({{E}_x^-} e^{\left(i \, k x\right)} + {E_x^+}
e^{\left(-i \, k x\right)}\right)} e^{\left(i \, \omega t\right)} +
\frac{1}{2} \, {\left(\overline{{E_x^+}} e^{\left(i \, k x\right)} +
\overline{{{E}_x^-}} e^{\left(-i \, k x\right)}\right)} e^{\left(-i \,
\omega t\right)}$ and $ E_y = \frac{1}{2} \, {\left({{E}_y^-} e^{\left(i \, k x\right)} + {E_y^+}
e^{\left(-i \, k x\right)}\right)} e^{\left(i \, \omega t\right)} +
\frac{1}{2} \, {\left(\overline{{E_y^+}} e^{\left(i \, k x\right)} +
\overline{{{E}_y^-}} e^{\left(-i \, k x\right)}\right)} e^{\left(-i \,
\omega t\right)}$.
This can yield to two different expressions for pol_y that might seem different at first but are equivalent.Sat, 11 Feb 2017 10:48:28 -0600http://ask.sagemath.org/question/36556/adding-zero-to-an-expression-and-avoiding-simplification/?comment=36569#post-id-36569Comment by paulmasson for <p>Hi, I have an expression of the form</p>
<p><code>pol_y = chi_yyyy*Ey*Ey*Ey + (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex - (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex + (chi_yyxx + chi_yxyx + chi_yxxy)*Ey*Ex*Ex</code></p>
<p>Now the last two terms add 0 to the expression. The goal is to substitute complicated expressions for Ey, Ex (complex quantities) and compare the results of two different reformulations (with and without the 0 terms). So for my work, I need the last two terms to be there but sagemath is simplifying this expression automatically. How do I avoid this?</p>
http://ask.sagemath.org/question/36556/adding-zero-to-an-expression-and-avoiding-simplification/?comment=36559#post-id-36559But after a substitution those two terms are always going to add to zero, right?Fri, 10 Feb 2017 20:15:01 -0600http://ask.sagemath.org/question/36556/adding-zero-to-an-expression-and-avoiding-simplification/?comment=36559#post-id-36559