Possible bug report: Incorrect SymbolicSeries expansion (spurious 1/x term)

71 views
Skip to first unread message

TBK

unread,
Apr 9, 2021, 10:33:07 AM4/9/21
to sage-devel
To Whom it May Concern:

Per the "Reporting Bugs" procedure, I am emailing sage-devel@ with a suspected bug. I am happy to open a TRAC ticket, if appropriate.

I'm getting some seemingly incorrect series expansions. In particular, adding a constant is sometimes introducing an $x^{-1}$ term instead of an $x^0$ term. I have included below a fairly minimal repro. Sage correctly expands `(1-sqrt(1-x))/x`. However, sage insists that adding `123` introduces a `123*x^-1` term. Using `taylor()`, I get the expected expansion in both cases. 

This seems obviously incorrect, but I am new to sage so apologize if this is just pilot error. I looked for existing threads on power series bugs. The closest I found was this message asserting that the combinatorial species code has long been riddled with bugs. If this is a bug, is taylor() believed to be less bug-riddled?


Repro:
{{{
    sage: ((1-sqrt(1-x))/x + 0).series(x,3)                                                  
    1/2 + 1/8*x + 1/16*x^2 + Order(x^3)  # correct
    sage: ((1-sqrt(1-x))/x + 123).series(x,3)                                                
    123*x^(-1) + 1/2 + 1/8*x + 1/16*x^2 + Order(x^3)  # ???
# taylor() correctly expands both
    sage: taylor((1-sqrt(1-x))/x + 0,x,0,2)                                                  
    1/16*x^2 + 1/8*x + 1/2 
    sage: taylor((1-sqrt(1-x))/x + 123,x,0,2)                                                
    1/16*x^2 + 1/8*x + 247/2 
}}}

Version:
    │ SageMath version 9.2, Release Date: 2020-10-24                     │
    │ Using Python 3.8.5. Type "help()" for help.                        │
 OS: macOS Catalina (10.15.7) (64-bit x86)

Best,
Thomas


Vincent Delecroix

unread,
Apr 9, 2021, 11:09:33 AM4/9/21
to sage-...@googlegroups.com
Thanks for the bug report.

If you know how to proceed, please open a ticket and post the url here.

- series goes through the ginac library (which is full of bugs and we
are trying to get rid off it)
- taylor goes through maxima which is much more reliable

The sympy library offers a nice alternative for symbolic computations.

Best
Vincent

Le 09/04/2021 à 16:01, TBK a écrit :
> To Whom it May Concern:
>
> Per the "Reporting Bugs" procedure
> <https://doc.sagemath.org/html/en/developer/trac.html#reporting-bugs>, I am
> emailing sage-devel@ with a suspected bug. I am happy to open a TRAC
> ticket, if appropriate.
>
> I'm getting some seemingly incorrect series expansions. In particular,
> adding a constant is sometimes introducing an $x^{-1}$ term instead of an
> $x^0$ term. I have included below a fairly minimal repro. Sage correctly
> expands `(1-sqrt(1-x))/x`. However, sage insists that adding `123`
> introduces a `123*x^-1` term. Using `taylor()`, I get the expected
> expansion in both cases.
>
> This seems obviously incorrect, but I am new to sage so apologize if this
> is just pilot error. I looked for existing threads on power series bugs.
> The closest I found was this message
> <https://groups.google.com/g/sage-devel/c/_rB24fZSHKs/m/XneaemQ4AgAJ> asserting
> that the combinatorial species code has long been riddled with bugs. If
> this is a bug, is taylor() believed to be less bug-riddled?
>
>
> *Repro:*
> {{{
> sage: ((1-sqrt(1-x))/x + 0).series(x,3)
>
> 1/2 + 1/8*x + 1/16*x^2 + Order(x^3) # correct
> sage: ((1-sqrt(1-x))/x + 123).series(x,3)
>
> 123*x^(-1) + 1/2 + 1/8*x + 1/16*x^2 + Order(x^3) # ???
> # taylor() correctly expands both
> sage: taylor((1-sqrt(1-x))/x + 0,x,0,2)
>
> 1/16*x^2 + 1/8*x + 1/2
> sage: taylor((1-sqrt(1-x))/x + 123,x,0,2)
>
> 1/16*x^2 + 1/8*x + 247/2
> }}}
>
> *Version:*
> │ SageMath version 9.2, Release Date: 2020-10-24 │
> │ Using Python 3.8.5. Type "help()" for help. │
> *OS*: macOS Catalina (10.15.7) (64-bit x86)
>
> Best,
> Thomas
>
>

Dima Pasechnik

unread,
Apr 9, 2021, 11:29:26 AM4/9/21
to sage-devel
On Fri, Apr 9, 2021 at 4:09 PM Vincent Delecroix
<20100.d...@gmail.com> wrote:
>
> Thanks for the bug report.
>
> If you know how to proceed, please open a ticket and post the url here.
>
> - series goes through the ginac library (which is full of bugs and we
> are trying to get rid off it)

more precisely, it's our fork of ginac, pynac, that is buggy, and it
has diverged from ginac quite a bit,
so it's unfair to blame ginac, the original upstream;
unfortunately the people who used to develop pynac have more or less
left the project.
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/710d3756-f93a-731e-b945-a23b48fe9fe8%40gmail.com.

dmo...@deductivepress.ca

unread,
Apr 11, 2021, 12:53:29 AM4/11/21
to sage-devel
Thanks for reporting the bug. It is now trac ticket #31645, and I expect to upload a fix soon.

Tom Kneeland

unread,
Apr 12, 2021, 12:15:54 PM4/12/21
to sage-...@googlegroups.com
Thank you all for the speedy turnaround on this! In particular:
 
Vincent and Dima: Thank you for the informative 'code archaeology' and helpful pointers 
Dave: Thank you for filing (and fixing!) #31645

Best,
Thomas

You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/av4L3qQZl0o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/31abf163-7770-4d24-bd17-a95fcb7486d8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages