#13645: better input handling for solve()
---------------------------------+------------------------------------------
       Reporter:  llpamies       |         Owner:  burcin      
           Type:  defect         |        Status:  needs_review
       Priority:  trivial        |     Milestone:  sage-5.9    
      Component:  symbolics      |    Resolution:              
       Keywords:                 |   Work issues:              
Report Upstream:  N/A            |     Reviewers:              
        Authors:  Burcin Erocal  |     Merged in:              
   Dependencies:                 |      Stopgaps:              
---------------------------------+------------------------------------------

Comment (by ppurka):

 Here is an example code which can convert the polynomial to a symbolic
 expression.
 {{{
 #!python
 R.<y,z> = RR[]
 a = y^2 + 2 * z^2

 is_Polynomial(a)  # test for polynomial a
 False

 is_MPolynomial(a) # test for multinomial a
 True

 va = a.variables()
 vSR = map(SR, va)
 aSR = a.subs({_x: _xs for _x,_xs in zip(va, vSR)})

 type(aSR)
 <type 'sage.symbolic.expression.Expression'>

 solve(aSR, *vSR)
 ([y == -I*sqrt(2)*z, y == I*sqrt(2)*z], [1, 1])
 }}}
 This can be done internally in the solve function.


 There is only one problem to this approach. Polynomial rings can be over
 other fields, for instance finite fields, too. The output of solve in this
 case doesn't really make much sense because it loses the information that
 the elements are in finite fields.
 {{{
 sage: F.<b> = GF(4)
 sage: R.<y,z> = F[]
 sage: a = y^2 + b* z^2
 sage: type(a)
 <type
 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
 sage: is_MPolynomial(a)
 True

 sage: va = a.variables()
 sage: vSR = map(SR, va)
 sage: aSR = a.subs({_x: _xs for _x,_xs in zip(va, vSR)})
 sage: type(aSR)
 <type 'sage.symbolic.expression.Expression'>
 sage: aSR
 y^2 + b*z^2
 sage: solve(aSR, *vSR)
 ([y == -sqrt(-b)*z, y == sqrt(-b)*z], [1, 1])

 sage: aSR.coeffs(z)
 [[y^2, 0], [b, 2]]
 sage: type(aSR.coeffs(z)[1][0])
 <type 'sage.symbolic.expression.Expression'>
 }}}

 So, we need some test to check whether the polynomial is defined only over
 reals or complexes.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13645#comment:7>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to