#14403: Symbolic charpoly broken
-----------------------------+--------------------------
       Reporter:  nbruin     |         Owner:  burcin
           Type:  defect     |        Status:  new
       Priority:  major      |     Milestone:  sage-5.11
      Component:  symbolics  |    Resolution:
       Keywords:             |     Merged in:
        Authors:             |     Reviewers:
Report Upstream:  N/A        |   Work issues:
         Branch:             |  Dependencies:
       Stopgaps:             |
-----------------------------+--------------------------

Comment (by gagern):

 OK, here is an attempt to address this.

 I modified the `charpoly` method to always use a unique variable name. I
 found no ready-to-use utility function to achieve this, but I expect there
 might be, so if you know one please let me know and I'll update my code.
 So far I simply append numbers to the letter `x` until the resulting
 string is not among the list of variable names used inside the matrix. The
 resulting variable name will ''always'' be used for the cached polynomial,
 and will ''by default'' be used for the returned polynomial.

 If the caller overrides the variable name, there is no check to ensure
 that this name does not conflict with the names used in the matrix. I'm
 unsure myself whether I'd consider this behavior a bug or a feature, i.e.
 what intended behavior for that case should be. If you want I can add a
 piece of code to perform that check before the `change_variable_name`
 call, and throw an error on conflicting variable names.

 I've kept the `expression.polynomial(None, ring=SR[var])` approach, and
 not used the `expression.coefficient(var, i)` version suggested in the
 ticket report. Instead, I adjusted the conversion of expressions to
 polynomials to only treat those variable powers as possible monomials
 where the variable itself corresponds to one of the variables from the
 target ring. All other expressions are treated as coefficients, even if
 they are powers of a symbolic variable. This avoids the conversion to
 integers for these cases, and hence the error mentioned in the ticket.
 This fix might be useful to other applications as well.

--
Ticket URL: <http://trac.sagemath.org/ticket/14403#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to