#7644: generic power series reversion
-----------------------------+----------------------------------------------
   Reporter:  was            |       Owner:  AlexGhitza         
       Type:  enhancement    |      Status:  needs_review       
   Priority:  major          |   Milestone:  sage-4.6.1         
  Component:  algebra        |    Keywords:  lagrange, reversion
     Author:  Niles Johnson  |    Upstream:  N/A                
   Reviewer:                 |      Merged:                     
Work_issues:                 |  
-----------------------------+----------------------------------------------
Changes (by newvalueoldvalue):

  * author:  niles => Niles Johnson


Old description:

> From this [http://groups.google.com/group/sage-
> support/browse_thread/thread/34fdf02add8100b6 sage-support] thread: Make
> the following work over any base ring:
> {{{
> sage: R.<x> = QQ[[]]
> sage: f = 1/(1-x) - 1; f
> x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11 + x^12
> + x^13 + x^14 + x^15 + x^16 + x^17 + x^18 + x^19 + O(x^20)
> sage: g = f.reversion(); g
> x - x^2 + x^3 - x^4 + x^5 - x^6 + x^7 - x^8 + x^9 - x^10 + x^11 - x^12
> + x^13 - x^14 + x^15 - x^16 + x^17 - x^18 + x^19 + O(x^20)
> sage: f(g)
> x + O(x^20)
> }}}
>
> Matt Bainbridge says about power series reversion, which uses pari in
> some cases, and maybe isn't there in others:
> {{{
> Its easy enough to code this in sage.  This seems to work over any
> field:
>

> def ps_inverse(f):
>    if f.prec() is infinity:
>        raise ValueError, "series must have finite precision for
> reversion"
>    if f.valuation() != 1:
>        raise ValueError, "series must have valuation one for
> reversion"
>    t = parent(f).gen()
>    a = 1/f.coefficients()[0]
>    g = a*t
>    for i in range(2, f.prec()):
>        g -=  ps_coefficient((f + O(t^(i+1)))(g),i)*a*t^i
>    g += O(t^f.prec())
>    return g
>
> def ps_coefficient(f,i):
>    if i >= f.prec():
>        raise ValueError, "that coefficient is undefined"
>    else:
>        return f.padded_list(f.prec())[i]
> }}}

New description:

 From this [http://groups.google.com/group/sage-
 support/browse_thread/thread/34fdf02add8100b6 sage-support] thread: Make
 the following work over any base ring:
 {{{
 sage: R.<x> = QQ[[]]
 sage: f = 1/(1-x) - 1; f
 x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11 + x^12
 + x^13 + x^14 + x^15 + x^16 + x^17 + x^18 + x^19 + O(x^20)
 sage: g = f.reversion(); g
 x - x^2 + x^3 - x^4 + x^5 - x^6 + x^7 - x^8 + x^9 - x^10 + x^11 - x^12
 + x^13 - x^14 + x^15 - x^16 + x^17 - x^18 + x^19 + O(x^20)
 sage: f(g)
 x + O(x^20)
 }}}

 Matt Bainbridge says about power series reversion, which uses pari in some
 cases, and maybe isn't there in others:
 {{{
 Its easy enough to code this in sage.  This seems to work over any
 field:


 def ps_inverse(f):
    if f.prec() is infinity:
        raise ValueError, "series must have finite precision for
 reversion"
    if f.valuation() != 1:
        raise ValueError, "series must have valuation one for
 reversion"
    t = parent(f).gen()
    a = 1/f.coefficients()[0]
    g = a*t
    for i in range(2, f.prec()):
        g -=  ps_coefficient((f + O(t^(i+1)))(g),i)*a*t^i
    g += O(t^f.prec())
    return g

 def ps_coefficient(f,i):
    if i >= f.prec():
        raise ValueError, "that coefficient is undefined"
    else:
        return f.padded_list(f.prec())[i]
 }}}

 == Apply ==

  1. [attachment:trac_7644_reversion_lagrange_2.2.patch]

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7644#comment:8>
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