Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in a simple series expansion #38868

Open
2 tasks done
fchapoton opened this issue Oct 27, 2024 · 9 comments
Open
2 tasks done

bug in a simple series expansion #38868

fchapoton opened this issue Oct 27, 2024 · 9 comments

Comments

@fchapoton
Copy link
Contributor

fchapoton commented Oct 27, 2024

Steps To Reproduce

sage: var('t')
sage: v = -125/24*e^(-5*t)/t - 8/3*e^(-4*t)/t^2 - 3/2*e^(-3*t)/t^3 - e^(-2*t)/t^4 - e^(-t)/t^5 + 1/t^5; v
-125/24*e^(-5*t)/t - 8/3*e^(-4*t)/t^2 - 3/2*e^(-3*t)/t^3 - e^(-2*t)/t^4 - e^(-t)/t^5 + 1/t^5
sage: v.series(t,2)
54/5 + (-3731/90)*t + Order(t^2)
sage: v.series(t,4)
54/5 + (-29849/720)*t + 139459/1680*t^2 + (-2305729/20160)*t^3 + Order(t^4)
sage: v.series(t,6)
54/5 + (-29849/720)*t + 139459/1680*t^2 + (-1537153/13440)*t^3 + 43947619/362880*t^4 + (-10845131/103680)*t^5 + Order(t^6)

Expected Behavior

answer should be correct up to the required order.

Actual Behavior

last term is always wrong

Additional Information

No response

Environment

  • OS: Ubuntu 24.04
  • Sage Version: 10.5.beta8

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@mantepse
Copy link
Collaborator

mantepse commented Oct 27, 2024

u=t

@S17A05
Copy link
Member

S17A05 commented Oct 28, 2024

#37368 had similar issues, though I'm not sure whether these are related

@fchapoton
Copy link
Contributor Author

fchapoton commented Oct 28, 2024

if needed, I can provide many similar examples. The smallest is

-e^(-5*t)/t - 4*e^(-t)/t^5 + 6*e^(-2*t)/t^5 - 4*e^(-3*t)/t^5 + e^(-4*t)/t^5 + 1/t^5

Failure seems to happen only but systematically in complicated enough cases.

@fchapoton
Copy link
Contributor Author

fchapoton commented Oct 28, 2024

a simplified failing case

sage: g=-e^(-2*t) - e^(-t)/t^3
sage: bool(g.series(t,2)==g.series(t,4).series(t,2))
True
sage: g=-e^(-2*t) - e^(-t)/t^4
sage: bool(g.series(t,2)==g.series(t,4).series(t,2))
False

Note that this works in GiNaC 1.8.7 using ginsh

> series(-exp(-2*t) - exp(-t)/t^4,t==0,2);
(-1)*t^(-4)+1*t^(-3)+(-1/2)*t^(-2)+1/6*t^(-1)+(-25/24)+241/120*t+Order(t^2)
> series(-exp(-2*t) - exp(-t)/t^4,t==0,4);
(-1)*t^(-4)+1*t^(-3)+(-1/2)*t^(-2)+1/6*t^(-1)+(-25/24)+241/120*t+(-1441/720)*t^2+6721/5040*t^3+Order(t^4)

@mantepse
Copy link
Collaborator

mantepse commented Oct 28, 2024

Worse:

sage: g = e^(t) - e^(t)/t^6
sage: g.series(t, 1)
(-1)*t^(-6) + (-1)*t^(-5) + (-1/2)*t^(-4) + (-1/6)*t^(-3) + 1 + Order(t)
sage: g.series(t, 2)
(-1)*t^(-6) + (-1)*t^(-5) + (-1/2)*t^(-4) + (-1/6)*t^(-3) + (-1/24)*t^(-2) + 1 + 1*t + Order(t^2)

@maxale
Copy link
Contributor

maxale commented Oct 31, 2024

Is it related by any chance to the bug in taylor() reported at https://ask.sagemath.org/question/79842 ?

@fchapoton
Copy link
Contributor Author

I do not think so. The method series is handled by pynac/ginac, but taylor is done by maxima.

@fchapoton
Copy link
Contributor Author

Worse:

sage: g = e^(t) - e^(t)/t^6
sage: g.series(t, 1)
(-1)*t^(-6) + (-1)*t^(-5) + (-1/2)*t^(-4) + (-1/6)*t^(-3) + 1 + Order(t)
sage: g.series(t, 2)
(-1)*t^(-6) + (-1)*t^(-5) + (-1/2)*t^(-4) + (-1/6)*t^(-3) + (-1/24)*t^(-2) + 1 + 1*t + Order(t^2)

This also works fine in GiNaC V1.8.7

@fchapoton
Copy link
Contributor Author

fchapoton commented Oct 31, 2024

many fixes have been made to the series code in ginac, see

https://www.ginac.de/ginac.git/?p=ginac.git&a=search&h=HEAD&st=commit&s=series

Our ginac code base is an old and very obsolete version. The copyright statements are saying 2008.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants