<div>Hi,</div><div> </div><div>02.06.2018, 01:50, "Matthias Naaf via GiNaC-list" <ginac-list@ginac.de>:</div><div> <div>> I've just hit an unexpected behavior of the ex.ldegree() method in my</div><div>> application. The problem is that ldegree() gives 0 before and 1 (the</div><div>> expected value) after calling expand() on the expression. I did not</div><div>> expect this, as the tutorial says that degree() and ldegree() "work</div><div>> reliably on non-expanded input polynomials".</div><div> </div><div>The tutorial is misleading. The only reason why one could claim that [l]degree()</div><div>"works reliably" with non-expanded inputs is that the program won't crash.</div><div>Proof: try this in ginsh:</div><div> </div><div>ldegree(x*(x^2-1) - x^2*(x - 1), x)</div><div> </div><div>The code [1] does not expect different terms to cancel each other, hence the problem</div><div> </div><div>[1] https://www.ginac.de/ginac.git/?p=ginac.git;a=blob;f=ginac/add.cpp;h=25de6cd2e889555f52aeccae2b263c4ccc2f74a5;hb=refs/heads/master#l279</div><div> </div><div>> A small running example and its output are attached. The expression is</div><div>> the one I encountered in my application. This looks like a bug to me, or</div><div>> is it necessary to call expand() before using ldegree()?</div><div> </div><div>One should expand the expression before using degree(), ldegree(), coeff()</div><div> </div><div>Best regards,</div><div>Alexey</div></div>