fn_Elementary (初等関数)
種別: 関数 (SADHelp functions の Elementary-functions) / フォルダ: 10_math_data / ラティスなし
何を見る例か
Sin Cos Tan ArcSin ArcCos ArcTan Sinh Cosh Tanh ArcSinh ArcCosh ArcTanh Exp Log Sqrt と定数 Degree。実数の値を式の値と比べ、定義域の外 (負の Log、$|x|>1$ の ArcSin、負の Sqrt) の複素数の扱いを見る。
スクリプト
Sin[1.] ArcSin[.5] ArcTan[2.] ArcTan[1.,-1.] Sinh[1.] ArcCosh[2.] ArcTanh[.5] Exp[1.5] Log[10.] Sqrt[2.] Sin[30*Degree]
Log[-1.] ArcSin[2.] Sqrt[-4.] ArcCosh[.5] ArcTanh[2.] Exp[I*Pi/3]
$FORM="S17.15" で 15 桁出し、R: の行を表にした。引数は実数 (1.) にする (整数のままだと Sin[1] は記号式のまま)。
結果の読み方
R:名前=値 の行が実数の値。最後の 6 行 (LogNeg= 以降) は定義域の外の例で、複素数は (実部+虚部 I) の形で出る。
物理・解析式
定義どおりの式。逆双曲線関数は $\mathrm{arcsinh}\,x=\ln(x+\sqrt{x^2+1})$、$\mathrm{arccosh}\,x=\ln(x+\sqrt{x^2-1})$、$\mathrm{arctanh}\,x=\frac12\ln\frac{1+x}{1-x}$。
ArcTan[x,y] は Mathematica と同じ引数の順で、$\mathrm{atan2}(y,x)$ を返す ($\arg(x+iy)$)。
| 項目 | 式の値 (Python math) | gs | pysad | gs の相対差 | pysad の相対差 (参照値が 0 の行は絶対差) |
|---|---|---|---|---|---|
| $\sin 1$ | 0.841470984808 | .841470984807896 | .841470984807896 | 6.6e-16 | 6.6e-16 |
| $\cos 1$ | 0.540302305868 | .54030230586814 | .54030230586814 | 4.1e-16 | 4.1e-16 |
| $\tan 1$ | 1.55740772465 | 1.557407724654902 | 1.557407724654902 | 1.4e-16 | 1.4e-16 |
| $\arcsin .5=\pi/6$ | 0.523598775598 | .523598775598299 | .523598775598299 | 2.1e-16 | 2.1e-16 |
| $\arccos .5=\pi/3$ | 1.0471975512 | 1.047197551196598 | 1.047197551196598 | 2.1e-16 | 2.1e-16 |
| $\arctan 2$ | 1.10714871779 | 1.10714871779409 | 1.10714871779409 | 4.0e-16 | 4.0e-16 |
ArcTan[1,-1] = $\mathrm{atan2}(-1,1)$ |
-0.785398163397 | -.785398163397448 | -.785398163397448 | 4.2e-16 | 4.2e-16 |
| $\sinh 1$ | 1.17520119364 | 1.175201193643801 | 1.175201193643801 | 3.8e-16 | 3.8e-16 |
| $\cosh 1$ | 1.54308063482 | 1.543080634815244 | 1.543080634815244 | 1.4e-16 | 1.4e-16 |
| $\tanh 1$ | 0.761594155956 | .761594155955765 | .761594155955765 | 1.5e-16 | 1.5e-16 |
| $\mathrm{arcsinh}\,1=\ln(1+\sqrt2)$ | 0.88137358702 | .881373587019543 | .881373587019543 | 0.0e+00 | 0.0e+00 |
| $\mathrm{arccosh}\,2=\ln(2+\sqrt3)$ | 1.31695789692 | 1.316957896924817 | 1.316957896924817 | 3.4e-16 | 3.4e-16 |
| $\mathrm{arctanh}\,.5=\frac12\ln3$ | 0.549306144334 | .549306144334055 | .549306144334055 | 2.0e-16 | 2.0e-16 |
| $e^{1.5}$ | 4.48168907034 | 4.481689070338064 | 4.481689070338064 | 2.0e-16 | 2.0e-16 |
| $\ln 10$ | 2.30258509299 | 2.302585092994046 | 2.302585092994046 | 0.0e+00 | 0.0e+00 |
| $\sqrt2$ | 1.41421356237 | 1.414213562373095 | 1.414213562373095 | 1.6e-16 | 1.6e-16 |
Degree $=\pi/180$ |
0.0174532925199 | .017453292519943 | .017453292519943 | 1.7e-14 | 1.7e-14 |
| $\sin(30°)$ | 0.5 | .5 | .5 | 0.0e+00 | 0.0e+00 |
複素数 (どちらも同じ値): $\ln(-1)=i\pi$、$\arcsin 2=\pi/2+1.3170\,i$、$\sqrt{-4}=2i$、$e^{i\pi/3}=0.5+0.8660\,i$。
ArcCosh[.5] は $-1.0472\,i$ ($=-i\pi/3$。$\arccos .5=\pi/3$ の分枝で符号が負、K64 の符号を pysad が合わせたもの)。ArcTanh[2.] は数学的には複素数だが、gs も pysad も NaN。
gs と pysad の比較
実数の 18 値は、gs と pysad が表示した全桁で一致 (○)。複素数の例は、ArcSin[2.] の虚部の末尾 1 桁 (gs ...816、pysad ...817) と、ArcCosh[.5] の実部 (gs は丸め誤差の -5.55E-17、pysad は 0) が違う。
未確認・限界
大きな引数 (オーバーフロー、桁落ち)、Tan の極の近傍、複素引数の双曲線関数は試していない (Exp[1000.] は var_Constants で INF を確認)。