A Taylor expansion differentiates without simplifying, so sin(x)/x to 11 terms runs out of memory
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #2302 của @Rafael-SOWNet — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp
- Lĩnh vực
- performance
Hướng nghiên cứu
Start with Sources/AngouriMath/Functions/Series.cs, especially SingleTaylorExpansionTerms and MultivariableTaylorExpansionTerms. Reproduce the reported Taylor(sin(x) / x, 11, ("x", 1)) case and compare the derivative growth and runtime. Done means the requested expansion completes efficiently without computing and discarding an extra term; the expected behavior at x = 0 needs triage.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
MathS.Series.Taylor on master (87a0eff), with the heap capped at 4 GB:
| Answered | |
|---|---|
Taylor(sin(x) / x, 7, ("x", 1)) |
36 421 characters, 1.4 s |
Taylor(sin(x) / x, 9, ("x", 1)) |
2 039 500 characters, 87 s |
Taylor(sin(x) / x, 11, ("x", 1)) |
OutOfMemoryException in SingleTaylorExpansion after 89 s |
Taylor(sin(x) / x, 11, ("x", 0)) |
OutOfMemoryException after 42 s; without the cap, on an earlier build, the process passed 35 GB before it was killed |
Taylor(sin(x) / x, 4, ("x", 0)) |
NaN + NaN + NaN / 2! + NaN / 3! |
The cause is in SingleTaylorExpansionTerms: each derivative is taken from the previous one as it stands (currExpr = currExpr.Differentiate(exprVariable)), and only the term built from it is simplified. For a quotient the tree grows about eightfold per step:
| k | nodes of the k-th derivative, as differentiated | simplified before the next step |
|---|---|---|
| 1 | 11 | 11 |
| 3 | 122 | 33 |
| 5 | 2 647 | 47 |
| 7 | 110 799 | 69 |
| 9 | 7 797 110 | 87 |
Simplifying each derivative before taking the next gives the 11 terms at x = 1 in 0.85 s. Two smaller points in the same place:
SingleTaylorExpansionchecksterms.Count >= termCountonly after the iterator has produced the next term, so one derivative more than is kept (the largest) is taken, substituted and simplified, then dropped.MultivariableTaylorExpansionhas the same order.MultivariableTaylorExpansionTermsdifferentiates the partial derivatives unsimplified in the same way.
What it should have done: answer Taylor(sin(x) / x, 11, ("x", 1)) in about a second. At x = 0, sin(x) / x has no value, so every coefficient is NaN; the expansion should say that once (the step-simplified loop above answers NaN), or expand the continuous extension 1 - x^2/6 + x^4/120 - ..., which is a choice for triage, instead of differentiating ten times to print a sum of NaNs.
Found while building a Taylor-polynomial view for browser demos of the library.
- Ngôn ngữ chính
- C#
- Star
- 832
- Fork
- 79
- Merge trung bình
- 1 giờ 12 phút
- Pull request đã merge (30 ngày)
- 518
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ASC-Community/AngouriMath
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ASC-Community/AngouriMath#2220 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Opinions wanted
Độ khó 4/5 Hơn một tuần Mức phù hợp với người mới 15/100
ASC-Community/AngouriMath#2319 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
ASC-Community/AngouriMath#2298 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The kernel under WebAssembly: 1.26 MB Brotli over the bare runtime, and 0.2 s to the first SimplifyĐang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 48/100
ASC-Community/AngouriMath#2296 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
ASC-Community/AngouriMath#2293 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ASC-Community/AngouriMath
Issue tương tự
-
bug untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
CarlosAdrianM/Nesto#610 ·
-
area/resource-registry status/triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
Altinn/altinn-auth#4821 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
a11y community:contribution
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
microsoft/fluentui-blazor#5590 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug mcp small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày