一般・特殊関数ライブラリ 使用例



[ 簡単な説明 ]

一般・特殊関数ライブラリの使用例です。

プログラム・ソース("test2.c")           top (先頭に戻る)
/*	test2.c		*/
#include	<stdio.h>
#include	"sslib.h"

int main(void)
{
	double a, w;

	for(a = 0.; a <= 10.; a++)	printf("cube root(%4.1f) = %22.15e\n", a, cbrt(a));
	printf("  x          besj0           besj1\n");
	for(a = 0.; a <= 10.; a++)	printf("%4.1f    %14.7e  %14.7e\n", a, besj0(a), besj1(a));
	printf("  x          besy0           besy1\n");
	for(a = 1.; a <= 10.; a++)	printf("%4.1f    %14.7e  %14.7e\n", a, besy0(a), besy1(a));
	printf("  x          besi0           besi1\n");
	for(a = 0.; a <= 10.; a++)	printf("%4.1f    %14.7e  %14.7e\n", a, besi0(a), besi1(a));
	printf("  x          besk0           besk1\n");
	for(a = 1.; a <= 10.; a++)	printf("%4.1f    %14.7e  %14.7e\n", a, besk0(a), besk1(a));
	printf("  x          erfnc\n");
	for(a = 0.; a <= 5.; a += 0.5)	printf("%4.1f    %14.7e\n", a, erfnc(a));
	printf("  x          gammaf\n");
	for(a = 0.5; a <= 5.; a += 0.5)	printf("%4.1f    %14.7e\n", a, gammaf(a));
	printf("  x        legend(p2(x))   legend(p10(x))\n");
	for(a = 0.; a <= 1.; a += 0.1)	printf("%4.1f    %14.7e  %14.7e\n", a, legend(a, 2), legend(a, 10));
	printf("  k*k        k            k(k)            e(k)\n");
	for(a = 0.; a <= 1.01; a += 0.1)
	{
		w = sqrt(a);
		printf("%4.1f   %14.7e  %14.7e  %14.7e\n", a, w, celi1(w, 1.e-6), celi2(w, 1.e-6));
	}

	return 1;
}

出力結果           top (先頭に戻る)
cube root( 0.0) =  0.000000000000000e+00
cube root( 1.0) =  1.000000000000000e+00
cube root( 2.0) =  1.259921049894873e+00
cube root( 3.0) =  1.442249570307408e+00
cube root( 4.0) =  1.587401051968200e+00
cube root( 5.0) =  1.709975946676697e+00
cube root( 6.0) =  1.817120592832140e+00
cube root( 7.0) =  1.912931182772389e+00
cube root( 8.0) =  2.000000000000000e+00
cube root( 9.0) =  2.080083823051904e+00
cube root(10.0) =  2.154434690031884e+00
  x          besj0           besj1
 0.0     1.0000000e+00   0.0000000e+00
 1.0     7.6519769e-01   4.4005059e-01
 2.0     2.2389078e-01   5.7672481e-01
 3.0    -2.6005195e-01   3.3905896e-01
 4.0    -3.9714981e-01  -6.6043328e-02
 5.0    -1.7759678e-01  -3.2757914e-01
 6.0     1.5064526e-01  -2.7668386e-01
 7.0     3.0007928e-01  -4.6828237e-03
 8.0     1.7165081e-01   2.3463635e-01
 9.0    -9.0333613e-02   2.4531179e-01
10.0    -2.4593577e-01   4.3472746e-02
  x          besy0           besy1
 1.0     8.8256962e-02  -7.8121282e-01
 2.0     5.1037568e-01  -1.0703245e-01
 3.0     3.7684999e-01   3.2467441e-01
 4.0    -1.6940746e-02   3.9792571e-01
 5.0    -3.0851762e-01   1.4786314e-01
 6.0    -2.8819468e-01  -1.7501034e-01
 7.0    -2.5949741e-02  -3.0266724e-01
 8.0     2.2352149e-01  -1.5806046e-01
 9.0     2.4993670e-01   1.0431458e-01
10.0     5.5671168e-02   2.4901542e-01
  x          besi0           besi1
 0.0     1.0000000e+00   0.0000000e+00
 1.0     1.2660658e+00   5.6515910e-01
 2.0     2.2795853e+00   1.5906369e+00
 3.0     4.8807926e+00   3.9533702e+00
 4.0     1.1301922e+01   9.7594651e+00
 5.0     2.7239872e+01   2.4335642e+01
 6.0     6.7234407e+01   6.1341937e+01
 7.0     1.6859391e+02   1.5603910e+02
 8.0     4.2756412e+02   3.9987313e+02
 9.0     1.0935884e+03   1.0309147e+03
10.0     2.8157167e+03   2.6709883e+03
  x          besk0           besk1
 1.0     4.2102448e-01   6.0190723e-01
 2.0     1.1389410e-01   1.3986588e-01
 3.0     3.4739504e-02   4.0156431e-02
 4.0     1.1159676e-02   1.2483499e-02
 5.0     3.6910984e-03   4.0446134e-03
 6.0     1.2439943e-03   1.3439197e-03
 7.0     4.2479573e-04   4.5418250e-04
 8.0     1.4647070e-04   1.5536922e-04
 9.0     5.0881312e-05   5.3637018e-05
10.0     1.7780062e-05   1.8648774e-05
  x          erfnc
 0.0     0.0000000e+00
 0.5     5.2049970e-01
 1.0     8.4270105e-01
 1.5     9.6610492e-01
 2.0     9.9532252e-01
 2.5     9.9959284e-01
 3.0     9.9997774e-01
 3.5     9.9999923e-01
 4.0     9.9999998e-01
 4.5     1.0000000e+00
 5.0     1.0000000e+00
  x          gammaf
 0.5     1.7724540e+00
 1.0     1.0000000e+00
 1.5     8.8622700e-01
 2.0     1.0000000e+00
 2.5     1.3293405e+00
 3.0     2.0000000e+00
 3.5     3.3233512e+00
 4.0     6.0000000e+00
 4.5     1.1631729e+01
 5.0     2.4000000e+01
  x        legend(p2(x))   legend(p10(x))
 0.0    -5.0000000e-01  -2.4609375e-01
 0.1    -4.8500000e-01  -1.2212500e-01
 0.2    -4.4000000e-01   1.2907203e-01
 0.3    -3.6500000e-01   2.5147635e-01
 0.4    -2.6000000e-01   9.6839064e-02
 0.5    -1.2500000e-01  -1.8822861e-01
 0.6     4.0000000e-02  -2.4366275e-01
 0.7     2.3500000e-01   8.5805796e-02
 0.8     4.6000000e-01   3.0052980e-01
 0.9     7.1500000e-01  -2.6314562e-01
 1.0     1.0000000e+00   1.0000000e+00
  k*k        k            k(k)            e(k)
 0.0    0.0000000e+00   1.5707963e+00   1.5707963e+00
 0.1    3.1622777e-01   1.6124413e+00   1.5307576e+00
 0.2    4.4721360e-01   1.6596233e+00   1.4890348e+00
 0.3    5.4772256e-01   1.7138894e+00   1.4453631e+00
 0.4    6.3245553e-01   1.7775194e+00   1.3993921e+00
 0.5    7.0710678e-01   1.8540747e+00   1.3506439e+00
 0.6    7.7459667e-01   1.9495677e+00   1.2984280e+00
 0.7    8.3666003e-01   2.0753631e+00   1.2416706e+00
 0.8    8.9442719e-01   2.2572052e+00   1.1784899e+00
 0.9    9.4868330e-01   2.5780906e+00   1.1047741e+00
 1.0    1.0000000e+00   1.6470993e+06   7.8539816e-01