Adding zero to an expression and avoiding simplification

asked 8 years ago

NahsiN gravatar image

updated 8 years ago

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?

Preview: (hide)

Comments

But after a substitution those two terms are always going to add to zero, right?

paulmasson gravatar imagepaulmasson ( 8 years ago )

Yes as they should. But when expressions are of the form Ex=12(Exe(ikx)+E+xe(ikx))e(iωt)+12(¯E+xe(ikx)+¯Exe(ikx))e(iωt) and Ey=12(Eye(ikx)+E+ye(ikx))e(iωt)+12(¯E+ye(ikx)+¯Eye(ikx))e(iωt). This can yield to two different expressions for pol_y that might seem different at first but are equivalent.

NahsiN gravatar imageNahsiN ( 8 years ago )