1 |
|
---|
2 | using System;
|
---|
3 |
|
---|
4 | namespace alglib
|
---|
5 | {
|
---|
6 | public class nearunityunit
|
---|
7 | {
|
---|
8 | public static double log1p(double x)
|
---|
9 | {
|
---|
10 | double result = 0;
|
---|
11 | double z = 0;
|
---|
12 | double lp = 0;
|
---|
13 | double lq = 0;
|
---|
14 |
|
---|
15 | z = 1.0+x;
|
---|
16 | if( (double)(z)<(double)(0.70710678118654752440) | (double)(z)>(double)(1.41421356237309504880) )
|
---|
17 | {
|
---|
18 | result = Math.Log(z);
|
---|
19 | return result;
|
---|
20 | }
|
---|
21 | z = x*x;
|
---|
22 | lp = 4.5270000862445199635215E-5;
|
---|
23 | lp = lp*x+4.9854102823193375972212E-1;
|
---|
24 | lp = lp*x+6.5787325942061044846969E0;
|
---|
25 | lp = lp*x+2.9911919328553073277375E1;
|
---|
26 | lp = lp*x+6.0949667980987787057556E1;
|
---|
27 | lp = lp*x+5.7112963590585538103336E1;
|
---|
28 | lp = lp*x+2.0039553499201281259648E1;
|
---|
29 | lq = 1.0000000000000000000000E0;
|
---|
30 | lq = lq*x+1.5062909083469192043167E1;
|
---|
31 | lq = lq*x+8.3047565967967209469434E1;
|
---|
32 | lq = lq*x+2.2176239823732856465394E2;
|
---|
33 | lq = lq*x+3.0909872225312059774938E2;
|
---|
34 | lq = lq*x+2.1642788614495947685003E2;
|
---|
35 | lq = lq*x+6.0118660497603843919306E1;
|
---|
36 | z = -(0.5*z)+x*(z*lp/lq);
|
---|
37 | result = x+z;
|
---|
38 | return result;
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | public static double expm1(double x)
|
---|
43 | {
|
---|
44 | double result = 0;
|
---|
45 | double r = 0;
|
---|
46 | double xx = 0;
|
---|
47 | double ep = 0;
|
---|
48 | double eq = 0;
|
---|
49 |
|
---|
50 | if( (double)(x)<(double)(-0.5) | (double)(x)>(double)(0.5) )
|
---|
51 | {
|
---|
52 | result = Math.Exp(x)-1.0;
|
---|
53 | return result;
|
---|
54 | }
|
---|
55 | xx = x*x;
|
---|
56 | ep = 1.2617719307481059087798E-4;
|
---|
57 | ep = ep*xx+3.0299440770744196129956E-2;
|
---|
58 | ep = ep*xx+9.9999999999999999991025E-1;
|
---|
59 | eq = 3.0019850513866445504159E-6;
|
---|
60 | eq = eq*xx+2.5244834034968410419224E-3;
|
---|
61 | eq = eq*xx+2.2726554820815502876593E-1;
|
---|
62 | eq = eq*xx+2.0000000000000000000897E0;
|
---|
63 | r = x*ep;
|
---|
64 | r = r/(eq-r);
|
---|
65 | result = r+r;
|
---|
66 | return result;
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | public static double cosm1(double x)
|
---|
71 | {
|
---|
72 | double result = 0;
|
---|
73 | double xx = 0;
|
---|
74 | double c = 0;
|
---|
75 |
|
---|
76 | if( (double)(x)<(double)(-(0.25*Math.PI)) | (double)(x)>(double)(0.25*Math.PI) )
|
---|
77 | {
|
---|
78 | result = Math.Cos(x)-1;
|
---|
79 | return result;
|
---|
80 | }
|
---|
81 | xx = x*x;
|
---|
82 | c = 4.7377507964246204691685E-14;
|
---|
83 | c = c*xx-1.1470284843425359765671E-11;
|
---|
84 | c = c*xx+2.0876754287081521758361E-9;
|
---|
85 | c = c*xx-2.7557319214999787979814E-7;
|
---|
86 | c = c*xx+2.4801587301570552304991E-5;
|
---|
87 | c = c*xx-1.3888888888888872993737E-3;
|
---|
88 | c = c*xx+4.1666666666666666609054E-2;
|
---|
89 | result = -(0.5*xx)+xx*xx*c;
|
---|
90 | return result;
|
---|
91 | }
|
---|
92 | }
|
---|
93 | }
|
---|