Weird power series bug

56 views
Skip to first unread message

Viviane Pons

unread,
Dec 11, 2020, 4:16:33 AM12/11/20
to Sage devel
Dear all,

I discovered a weird bug on power series when computing the inverse of a serie. Look at this.

This computation gives the expected result

sage: L.<z> = LazyPowerSeriesRing(QQ)                                          
sage: f = 1 - z - z^2                                                          
sage: b = ~f                                                                    
sage: b.compute_coefficients(10)                                                
sage: b                                                                        
1 + z + 2*z^2 + 3*z^3 + 5*z^4 + 8*z^5 + 13*z^6 + 21*z^7 + 34*z^8 + 55*z^9 + 89*z^10 + O(x^11)

But not this one:

sage: L.<z> = LazyPowerSeriesRing(QQ)                                          
sage: f = 1 - z - z^2                                                          
sage: f.compute_coefficients(10)                                                
sage: f                                                                        
1 - z - z^2 + O(x^11)
sage: b = ~f                                                                    
sage: b.compute_coefficients(10)                                                
sage: b                                                                        
1 + z^1 + z^2 + z^3 + ...

Another example with Catalan numbers

sage: L.<z> = LazyPowerSeriesRing(QQ)     
sage: C = L()                                                                  
sage: C.define(1 + z*C*C)                                                      
sage: Cinv = ~C                                                                
sage: Cinv.compute_coefficients(10); Cinv                                      
1 - z - z^2 - 2*z^3 - 5*z^4 - 14*z^5 - 42*z^6 - 132*z^7 - 429*z^8 - 1430*z^9 - 4862*z^10 + O(x^11)

sage: C = L()                                                                  
sage: C.define(1 +z*C*C)                                                        
sage: C.compute_coefficients(10);C                                              
1 + z + 2*z^2 + 5*z^3 + 14*z^4 + 42*z^5 + 132*z^6 + 429*z^7 + 1430*z^8 + 4862*z^9 + 16796*z^10 + O(x^11)
sage: Cinv = ~C                                                                
sage: Cinv.compute_coefficients(10);Cinv                                        
1 + z^1 + z^2 + z^3 + ...

How Come??

This is Sage 9.2. I haven't tried on other versions

Frédéric Chapoton

unread,
Dec 11, 2020, 5:03:59 AM12/11/20
to sage-devel
Salut,
Le code sur les espèces est connu pour être farci de bugs, et personne ne s'en est préoccupé depuis très longtemps.
cf https://trac.sagemath.org/ticket/30727
Fred

Martin R

unread,
Dec 11, 2020, 2:26:46 PM12/11/20
to sage-devel
I am planning to organize sagespeciesdays for February, with making lazy power series sane as a subgoal.  It would be extremely motivating if some people put themselves into the CC field of the ticket Frédéric pointed out, to signal interest.

Best wishes,

Martin

Kwankyu Lee

unread,
Dec 11, 2020, 6:59:52 PM12/11/20
to sage-devel
Hi,

Meanwhile, lazy Laurent series ring is also available.

sage: L.<z> = LazyLaurentSeriesRing(QQ)                                                                                    
sage: f = 1 - z - z^2                                                                                                      
sage: b = ~f                                                                                                               
sage: b.coefficient(10)                                                                                                    
89
sage: b                                                                                                                    
1 + z + 2*z^2 + 3*z^3 + 5*z^4 + 8*z^5 + 13*z^6 + ...
sage: C = L.series(lambda s,n: (1 + z*s^2)[n], valuation=0)                                                                
sage: C.coefficient(10)                                                                                                    
16796
sage: C                                                                                                                    
1 + z + 2*z^2 + 5*z^3 + 14*z^4 + 42*z^5 + 132*z^6 + ...


Samuel Lelievre

unread,
Dec 11, 2020, 7:44:15 PM12/11/20
to sage-devel
2020-12-11 19:26:46 UTC, Martin:
I am planning to organize sagespeciesdays for February,
with making lazy power series sane as a subgoal.  It would be
extremely motivating if some people put themselves into
the CC field of the ticket Frédéric pointed out, to signal interest.

Suggestion: open a stream on zulip for people to register.
Reply all
Reply to author
Forward
0 new messages