#8972: Inversion and fraction fields for power series rings
--------------------------+-------------------------------------------------
   Reporter:  SimonKing   |       Owner:  AlexGhitza                       
       Type:  defect      |      Status:  needs_review                     
   Priority:  major       |   Milestone:  sage-4.4.2                       
  Component:  algebra     |    Keywords:  power series ring, fraction field
     Author:  Simon King  |    Upstream:  N/A                              
   Reviewer:              |      Merged:                                   
Work_issues:              |  
--------------------------+-------------------------------------------------

Comment(by SimonKing):

 It was worth it!

 First, I found one division bug for Laurent series left, which is now
 fixed (and doc tested):
 {{{
 sage: L.<x> = LaurentSeriesRing(ZZ)
 sage: 1/(2+x)
 1/2 - 1/4*x + 1/8*x^2 - 1/16*x^3 + 1/32*x^4 - 1/64*x^5 + 1/128*x^6 -
 1/256*x^7 + 1/512*x^8 - 1/1024*x^9 + 1/2048*x^10 - 1/4096*x^11 +
 1/8192*x^12 - 1/16384*x^13 + 1/32768*x^14 - 1/65536*x^15 + 1/131072*x^16 -
 1/262144*x^17 + 1/524288*x^18 - 1/1048576*x^19 + O(x^20)
 }}}
 This used to result in an error.

 Second, I added more doc tests (and inserted my name to the author list).

 Third, the new timings for sqrt are fully competitive (even very slightly
 faster than before), and we still have the bug fix:
 {{{
 Loading Sage library. Current Mercurial branch is: powerseries
 sage: P.<t> = QQ[[]]
 sage: p = 9 - 33*t - 13*t^2 - 155*t^3 - 429*t^4 - 137*t^5 + 170*t^6 +
 81*t^7 - 132*t^8 + 179*t^9 + O(t^10)
 sage: p.sqrt()
 3 - 11/2*t - 173/24*t^2 - 5623/144*t^3 - 174815/1152*t^4 -
 8187925/20736*t^5 - 12112939/9216*t^6 - 7942852751/1492992*t^7 -
 1570233970141/71663616*t^8 - 12900142229635/143327232*t^9 + O(t^10)
 sage: timeit('q = p.sqrt()')
 25 loops, best of 3: 13.2 ms per loop
 sage: timeit('q = (p^2).sqrt()')
 25 loops, best of 3: 13.5 ms per loop
 sage: timeit('q = (p^4).sqrt()')
 25 loops, best of 3: 14.5 ms per loop
 sage: PZ = ZZ[['t']]
 sage: timeit('q = (PZ(p)^2).sqrt()')
 25 loops, best of 3: 16.4 ms per loop
 sage: p = 9 - 33*t - 13*t^2 - 155*t^3 - 429*t^4 - 137*t^5 + 170*t^6 +
 81*t^7 - 132*t^8 + 179*t^9
 sage: timeit('q = p.sqrt()')
 25 loops, best of 3: 20.6 ms per loop
 sage: timeit('q = (p^2).sqrt()')
 25 loops, best of 3: 21.7 ms per loop
 }}}

 The trick is that I do ``s*a.__invert__()`` instead of ``s/a``, where
 ``s`` and ``a`` are power series. This helps, because (after a little
 change) the invert method returns a power series whenever possible -- and
 since I know that ``a.valuation()>=0``, I can use fast multiplication of
 power series rather than slow multiplication of Laurent series.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8972#comment:16>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to