1 | initial version |
It can be simplified to sum( c*ddfor dd, c in P.dict().items() if sum(dd) <= N )
.
2 | No.2 Revision |
It can be simplified to sum(
.c*ddfor c*dd for dd, c in P.dict().items() if sum(dd) <= N )
3 | No.3 Revision |
It can be simplified to sum( c*dd for dd, c in
.P.dict().items() P if sum(dd) <= N )
4 | No.4 Revision |
It can be simplified to sum( c*dd for
.dd, c c,t in P if sum(dd) <= t.degree().<= N )
5 | No.5 Revision |
It can be simplified to sum(
.c*dd c*t for c,t in P if t.degree().<= N )
6 | No.6 Revision |
It can be simplified to sum( c*t for c,t in P if
.t.degree().<= t.degree() <= N )
7 | No.7 Revision |
It Here is a condensed version of @slelievre's answer.
We can be simplified to iterate over the dictionary items for
in a simpler way.sum( c*t P
For example:
sage: sum((c*t for
c,tc, t in P if t.degree() <=N )N), P.parent().zero()).
Note how we start the sum at the zero polynomial.
With this, the zero polynomial is truncated to itself rather than to the integer zero.
8 | No.8 Revision |
Here is a condensed version of @slelievre's answer.
We can iterate over the dictionary items for P
in a simpler way.
For example:
sage: sum((c*t for c, t in P if t.degree() <= N), P.parent().zero())
Note how we start the sum at the zero polynomial.
With this, polynomials without terms of degree <= N give the zero polynomial is truncated to itself rather than to polynomial, not the integer zero.