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.Mon, 22 Oct 2012 19:26:25 +0200Filtering an expression: keeping only term with even powerhttps://ask.sagemath.org/question/9456/filtering-an-expression-keeping-only-term-with-even-power/In the expression
$$
x^2 y^2+x y^2+x^3y + 5 x^4 y^4
$$
I would like to keep only the term where the variables have even power
$$
x^2y^2+5 x^4 y^4
$$
Is there a way to do it?
I look into this [post](http://ask.sagemath.org/question/1747/extract-terms-from-a-sum?answer=2598#2598).
But once I get the operands, I don't see how to analyze the variable exponent.Nicolas Essis-BretonMon, 22 Oct 2012 19:26:25 +0200https://ask.sagemath.org/question/9456/Extract terms from a sumhttps://ask.sagemath.org/question/9295/extract-terms-from-a-sum/Is there some way to programmatically extract the first, second, third, and so on terms from a sum of symbolic terms (or equivalently, turn such a sum into the list of its summands)? For example, after
sage: A,B,C = var('A'), var('B'), var('C')
sage: F = A*B+C; F
A*B + C
Is there some method you can call on F to extract A*B (or C)? This would be useful especially for displaying sage in LaTeX via sageTeX when a formula that is the sum of 4 terms (say) runs over the margin and has to be split up somehow. I would also be interested in a workaround in sageTeX that would allow you to flexibly insert a linebreak in a formula under the circumstances that the formula generated by Sage got too long for a line.
heatkernelWed, 05 Sep 2012 00:05:14 +0200https://ask.sagemath.org/question/9295/