1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// This is part of SLEEF, written by Naoki
// Shibata. http://shibatch.sourceforge.net
// The code in this file is distributed under the Creative Commons
// Attribution 4.0 International License.
//
#define N 15 // Degree of equation
#define S 150 // Number of samples for phase 1
#define L 0 // Number of high precision coefficients
#define P 0.37
#define MIN 0.0 // Min argument
#define MAX (M_PI/2) // Max argument
#define PMUL 2 // The form of polynomial is y = x^(PADD+PMUL*0) + x^(PADD+PMUL*1) + ...
#define PADD 3
void TARGET(mpfr_t ret, mpfr_t a) { // The function to approximate
mpfr_sin(ret, a, GMP_RNDN);
mpfr_sub(ret, ret, a, GMP_RNDN); // ret = sin(a) - a
}
void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); }
#define N 15
#define S 150
#define L 0
#define MIN 0.0
#define MAX (M_PI/2)
void TARGET(mpfr_t ret, mpfr_t a) { // cos(x) - 1
mpfr_t x;
mpfr_init(x);
mpfr_cos(ret, a, GMP_RNDN);
mpfr_set_ld(x, 1, GMP_RNDN);
mpfr_sub(ret, ret, x, GMP_RNDN);
mpfr_clear(x);
}
void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); }
#define PMUL 2
#define PADD 2
//#define FIXCOEF0 (-0.5)
// for xsincospi4_u05
#define N 13
#define S 150
#define L 2
#define P 0.9
#define MIN 0.0
#define MAX 1.0
#define PMUL 2
#define PADD 1
void TARGET(mpfr_t ret, mpfr_t a) {
mpfr_t x, y;
mpfr_inits(x, y, NULL);
mpfr_const_pi(x, GMP_RNDN);
mpfr_set_d(y, 1.0/4, GMP_RNDN);
mpfr_mul(x, x, y, GMP_RNDN);
mpfr_mul(x, x, a, GMP_RNDN);
mpfr_sin(ret, x, GMP_RNDN);
mpfr_clears(x, y, NULL);
}
void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); }
// for xsincospi4_u05
#define N 13
#define S 150
#define L 2
#define MIN 0.0
#define MAX 1.0
void TARGET(mpfr_t ret, mpfr_t a) { // cos(x) - 1
mpfr_t x, y;
mpfr_inits(x, y, NULL);
mpfr_const_pi(x, GMP_RNDN);
mpfr_set_d(y, 1.0/4, GMP_RNDN);
mpfr_mul(x, x, y, GMP_RNDN);
mpfr_mul(x, x, a, GMP_RNDN);
mpfr_cos(ret, x, GMP_RNDN);
mpfr_set_ld(x, 1, GMP_RNDN);
mpfr_sub(ret, ret, x, GMP_RNDN);
mpfr_clears(x, y, NULL);
}
void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); }
#define PMUL 2
#define PADD 2
// running
#define N 31
#define S 100
#define P 1.7
#define L 0
#define MIN 0.0
#define MAX (M_PI/4)
#define PMUL 2
#define PADD 1
void TARGET(mpfr_t ret, mpfr_t a) { mpfr_tan(ret, a, GMP_RNDN); }
void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); }
#define FIXCOEF0 1.0
// running
#define N 20
#define S 110
#define L 2
#define MIN 1 //0.75
#define MAX 1.5
#define PMUL 2
#define PADD 1
void TARGET(mpfr_t ret, mpfr_t a) { mpfr_log(ret, a, GMP_RNDN); }
void CFUNC(mpfr_t frd, mpfr_t fra) {
mpfr_t tmp, one;
mpfr_inits(tmp, one, NULL);
mpfr_set_d(one, 1, GMP_RNDN);
mpfr_add(tmp, fra, one, GMP_RNDN);
mpfr_sub(frd, fra, one, GMP_RNDN);
mpfr_div(frd, frd, tmp, GMP_RNDN);
mpfr_clears(tmp, one, NULL);
}
#define FIXCOEF0 2.0
void
void
//#define FIXCOEF2 0.5
// running
#define N 45
#define S 100
#define P 1.55
#define L 2
#define MIN 0.0
#define MAX 1.0
#define PMUL 2
#define PADD 1
void TARGET(mpfr_t ret, mpfr_t a) { mpfr_atan(ret, a, GMP_RNDN); }
void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); }
#define FIXCOEF0 1.0