観察日記 2010-02-22
Math モジュール仕様の方針
It is good to decide the policy of Math. Please choice: 1) Math is still just a wrapper of libm 2) Math is (aims to be) platform-independent math module (though it is very similar to libm's API) I choose #2. I also want Math module to work with complex and
rational as much as their support is reasonable.matz.
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/28212
21:10:01
やったー matz の了解を得た
21:10:12拍子抜けするほどあっさりだったな
21:10:25おめでとうございます
というわけで、Math は環境非依存な動きをすることになりました。テストしやすくていいですね。もっとも、どの仕様に追従するかを決める必要はあるわけですが、
あ、プラットフォーム依存ぽいのは lgamma(-inf) か
SUSv3 によるとー
{mame} If x is ±Inf, +Inf shall be returned.
本当?こんなグラフなのに?
http://ja.wikipedia.org/wiki/%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB:Gamma.png
lgamma(x) == log(fabs(tgamma(x))) か
ガンマ関数は統計力学などで使いませんか?
http://science6.2ch.net/test/read.cgi/math/1244472177/
{hermit_} ガンマ関数って一体に何に使うでござる [text/html]
Math.lgamma(-inf) #=> inf は mrkn さんから見て普通?
ふつうじゃない気がするなぁ
lim_{x->-∞} Γ(x) を考えるんだ
これですが、良く考えてグラフを見たら、「振動する」っていう簡単な答えが出ました
tgamma(x) (x -> -inf) が振動なら lgamma(x) (x-> -inf) は不定ですね
Math::DivideByZeroError, Math::DomainError などを導入させてくれるなら,
Mathematica と数学に従って定義できると思います
そうすれば殆どのケースで C99 と同じになると思うけど
http://www.wolframalpha.com/input/?i=ArcTanh%5B1.0%5D 注: ∞
http://www.wolframalpha.com/input/?i=ArcTanh%5B1%5D 注: indeterminate
ArcTanh[1.0] != ArcTanh[1] である点に注意
lgamma(-inf)はindeterminateだなぁ。というわけで、どうするか引き続き議論中