Accuracy of atanh on complex arguments
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend
Hướng nghiên cứu
Start with the complex atanh implementation in math/private/base/base-functions.rkt around line 104, then compare it with the Chez implementation in src/ChezScheme/s/5_3.ss around lines 761 and 412. Evaluate the cited tiny, ordinary, huge, and near-1 complex cases, and establish whether the improvement should use a math/base algorithm or the Chez primitive.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
While adding complex numbers to WebRacket I have found a potential problem
in the math/base implementation of atanh. When called with complex
arguments, the accuracy isn't as good as Chez Scheme.
For the complex case the implementation of atanh in math/base uses:
(* 0.5 (- (log (+ 1.0 x)) (log (- 1.0 x))))
This is mathematically correct, but not numerically stable.
The problem is how to improve the situation?
Option 1) improve the implementation in math/base.
Option 2) figure out how to call the Chez Scheme primitive atanh.
The section below was produced by Codex when I asked it examine the
accuracy of atanh on complex numbers.
Note: There might be similar problems with asinh and and acosh.
/Jens Axel
Codex:
For math/base, complex accuracy is not uniformly good. It uses the direct formula at [base-functions.rkt (line 104)](/Users/soegaard/Dropbox/GitHub/racket/racket/share/pkgs/math-lib/math/private/base/base-functions.rkt:104):
(* 0.5 (- (log (+ 1.0 x)) (log (- 1.0 x))))That is mathematically right, but numerically fragile.
Measured against a 4096-bit bigfloat reference:
Region | math/base max-component error -- | -- ordinary random [-10,10]^2 | median 5 ulp, p95 27 ulp, worst 23515 ulp tiny complex inputs | often loses the real part entirely near 1+iε | very good, usually 0-1 ulp huge complex inputs | often loses the small real part entirelyExamples:
z = 1e-20+1e-20i ref 1e-20+1e-20i math/base 0.0+1e-20i
z = 1e100+0.0i
ref 1e-100+1.5707963267948966i
math/base 0.0+1.5707963267948966i
The Chez source-level cflatanh at 5_3.ss (line 761) is much more accuracy-oriented: it uses Kahan-style formulas and, when log1p is available through fllog1+ (line 412), it preserves those tiny real parts. In my model of that path, ordinary/tiny cases were typically 0-1 ulp.
But Chez has its own weak spot near z = 1+iε: it adds rho ≈ 2.98e-154 to |imag|, so for ε << rho it clamps the behavior:
z = 1.0+1e-300i
ref 345.73433753938684+0.7853981633974483i
math/base 345.7343375393868 +0.7853981633974483i
Chez model 177.09910463306602+0.7853981633974483iSo: math/base is okay for many ordinary complex values, excellent near 1+iε, but poor when the result has a very small nonzero real component. Chez’s complex algorithm is generally better for cancellation/overflow, except around the guarded branch point near 1.
- Ngôn ngữ chính
- Racket
- Star
- 40
- Fork
- 32
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 racket/math
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Wishlist: flzero?Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
-
Shallow / Optional typesĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Issue tương tự
-
md/asciidoc/csv: an explicit `encoding="utf-8"` keeps a leading BOM, the auto-detect path drops itĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
docling-project/docling#4846 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/sessions comp/dashboard comp/desktop comp/gateway comp/tui duplicate P2 sweeper:risk-session-state type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NousResearch/hermes-agent#138914 · 1 bình luận ·
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 62/100
mozilla/experimenter#17760 ·
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 76/100
huggingface/huggingface_hub#5169 ·
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 62/100
Maintainer thường phản hồi trong vòng 1 ngày