-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathtanh_quad.html
377 lines (332 loc) · 10.2 KB
/
tanh_quad.html
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<html>
<head>
<title>
TANH_QUAD - A Rapidly Converging Quadrature Rule.
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
TANH_QUAD <br> A Rapidly Converging Quadrature Rule.
</h1>
<hr>
<p>
<b>TANH_QUAD</b>
is a FORTRAN90 library which
sets up the tanh quadrature scheme and related rules.
</p>
<p>
These schemes typically have two parameters, <b>N</b> the
(truncated) order, and <b>H</b>, a discretization size.
To construct a family of quadrature rules, it is typical to
ensure that H goes to zero as N goes to infinity. Sometimes
this is done by fixing the value of the product N*H, and sometimes
in other ways.
</p>
<p>
The <b>tanh</b> quadrature scheme approximates the integral
<pre>
Integral ( -1 <= X <= 1 ) F(X) dx
</pre>
by
<pre>
Sum ( -N <= I <= N ) W(i) * F ( X(i) )
</pre>
where Kahaner, Moler and Nash suggest choosing N freely, and then
taking H as
<pre>
H = pi * sqrt ( 2 / N ) - ( 1 / N ).
</pre>
and
<pre>
X(i) = tanh(i*H/2)
</pre>
and
<pre>
W(i) = H / 2 / cosh(I*H/2) / cosh(I*H/2)
</pre>
</p>
<p>
This rule has some unusual properties. In particular, it is not
exact for any polynomial; it can't even integrate the function f(x)=1
exactly. But while it is not <i>exact</i>, it can be highly <i>accurate</i>,
that is, for relatively low values of <b>N</b> and for a wide range of
integrals, the estimate will have a very low error, and as <b>N</b> increases,
the error can decrease exponentially.
</p>
<p>
The <b>tanh-sinh</b> quadrature scheme approximates the integral
<pre>
Integral ( -1 <= X <= 1 ) F(X) dx
</pre>
by
<pre>
Sum ( -N <= I <= N ) W(i) * F ( X(i) )
</pre>
where Bailey suggests parameterizing by an integer M, with
<pre>
N = 8 * 2^M,
H = 1 / 2^M,
N * H = 8.
</pre>
and
<pre>
Ti = i * H,
X(i) = tanh(pi/2*sinh(Ti))
</pre>
and
<pre>
W(i) = H * ( pi / 2 ) * cosh(Ti) / cosh^2(pi/2*sinh(Ti))
</pre>
</p>
<p>
Quadrature rules can be transformed from the [-1,1] interval to the interval [a,b]
by using the <b>rule_adjust</b> routine.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>TANH_QUAD</b> is available in
<a href = "../../cpp_src/tanh_quad/tanh_quad.html">a C++ version</a> and
<a href = "../../f_src/tanh_quad/tanh_quad.html">a FORTRAN90 version</a> and
<a href = "../../m_src/tanh_quad/tanh_quad.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../f_src/chebyshev1_rule/chebyshev1_rule.html">
CHEBYSHEV1_RULE</a>,
a FORTRAN90 program which
can compute and print a Gauss-Chebyshev type 1 quadrature rule.
</p>
<p>
<a href = "../../f_src/chebyshev2_rule/chebyshev2_rule.html">
CHEBYSHEV2_RULE</a>,
a FORTRAN90 program which
can compute and print a Gauss-Chebyshev type 2 quadrature rule.
</p>
<p>
<a href = "../../f_src/gegenbauer_rule/gegenbauer_rule.html">
GEGENBAUER_RULE</a>,
a FORTRAN90 program which
can compute and print a Gauss-Gegenbauer quadrature rule.
</p>
<p>
<a href = "../../f_src/gen_hermite_rule/gen_hermite_rule.html">
GEN_HERMITE_RULE</a>,
a FORTRAN90 program which
can compute and print a generalized Gauss-Hermite quadrature rule.
</p>
<p>
<a href = "../../f_src/gen_laguerre_rule/gen_laguerre_rule.html">
GEN_LAGUERRE_RULE</a>,
a FORTRAN90 program which
can compute and print a generalized Gauss-Laguerre quadrature rule.
</p>
<p>
<a href = "../../f_src/hermite_rule/hermite_rule.html">
HERMITE_RULE</a>,
a FORTRAN90 program which
can compute and print a Gauss-Hermite quadrature rule.
</p>
<p>
<a href = "../../f_src/int_exactness/int_exactness.html">
INT_EXACTNESS</a>,
a FORTRAN90 program which
checks the polynomial exactness
of a 1-dimensional quadrature rule for a finite interval.
</p>
<p>
<a href = "../../f_src/intlib/intlib.html">
INTLIB</a>,
a FORTRAN90 library which
contains a variety
of routines for numerical estimation of integrals in 1D.
</p>
<p>
<a href = "../../f_src/jacobi_rule/jacobi_rule.html">
JACOBI_RULE</a>,
a FORTRAN90 program which
can compute and print a Gauss-Jacobi quadrature rule.
</p>
<p>
<a href = "../../f_src/laguerre_rule/laguerre_rule.html">
LAGUERRE_RULE</a>,
a FORTRAN90 program which
can compute and print a Gauss-Laguerre quadrature rule.
</p>
<p>
<a href = "../../f_src/legendre_rule/legendre_rule.html">
LEGENDRE_RULE</a>,
a FORTRAN90 program which
computes a Gauss-Legendre quadrature rule.
</p>
<p>
<a href = "../../f_src/quadrule/quadrule.html">
QUADRULE</a>,
a FORTRAN90 library which
defines quadrature rules for 1D domains.
</p>
<p>
<a href = "../../f_src/quadpack/quadpack.html">
QUADPACK</a>,
a FORTRAN90 library which
contains a variety of routines for
numerical estimation of integrals in 1D.
</p>
<p>
<a href = "../../datasets/quadrature_rules/quadrature_rules.html">
QUADRATURE_RULES</a>,
a dataset directory which
contains sets of files that define quadrature
rules over various 1D intervals or multidimensional hypercubes.
</p>
<p>
<a href = "../../f_src/test_int/test_int.html">
TEST_INT</a>,
a FORTRAN90 library which
contains a number of functions that may be used as test integrands for
quadrature rules in 1D.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
David Bailey, Jonathan Borwein,<br>
Experimental Mathematics: Examples, Methods and Implications,<br>
Notices of the American Mathematical Society,<br>
Volume 52, Number 5, pages 502-514.
</li>
<li>
David Bailey, Karthik Jeyabalan, Xiaoye Li,<br>
A Comparison of Three High-Precision Quadrature Schemes,<br>
Experimental Mathematics,<br>
Volume 14, Number 3, pages 317-329.
</li>
<li>
David Kahaner, Cleve Moler, Steven Nash,<br>
Numerical Methods and Software,<br>
Prentice Hall, 1989,<br>
ISBN: 0-13-627258-4,<br>
LC: TA345.K34.
</li>
<li>
Charles Schwartz,<br>
Numerical Integration of Analytic Functions,<br>
Journal of Computational Physics,<br>
Volume 4, Number 1, June 1969, pages 19-29.
</li>
<li>
William Squire,<br>
An Eficient Iterative Method for Numerical Evaluation of Integrals
Over a Semi-infinite Range,<br>
International Journal for Numerical Methods in Engineering,<br>
Volume 10, Number 2, 1976, pages 478-484.
</li>
<li>
William Squire,<br>
A Quadrature Method for Finite Intervals,<br>
International Journal for Numerical Methods in Engineering,<br>
Volume 10, Number 3, 1976, pages 708-712.
</li>
<li>
William Squire,<br>
In Defense of Linear Quadrature Rules,<br>
Computers and Mathematics with Applications,<br>
Volume 7, Number 2, 1981, pages 147-149.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "tanh_quad.f90">tanh_quad.f90</a>, the source code.
</li>
<li>
<a href = "tanh_quad.sh">tanh_quad.sh</a>,
commands to compile the source code.
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "tanh_quad_prb.f90">tanh_quad_prb.f90</a>,
a sample calling program.
</li>
<li>
<a href = "tanh_quad_prb.sh">tanh_quad_prb.sh</a>,
commands to compile and run the sample program.
</li>
<li>
<a href = "tanh_quad_prb_output.txt">tanh_quad_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>MIDPOINT_RULE</b> computes a variant of the midpoint quadrature rule.
</li>
<li>
<b>RULE_ADJUST</b> maps a quadrature rule from [A,B] to [C,D].
</li>
<li>
<b>TANH_H_TO_N</b> computes N as a function of H and TOL.
</li>
<li>
<b>TANH_M_TO_H</b> computes H as a function of M.
</li>
<li>
<b>TANH_N_TO_H</b> computes N as a function of H for the tanh rule.
</li>
<li>
<b>TANH_RULE</b> computes a tanh quadrature rule.
</li>
<li>
<b>TANH_SINH_H_TO_N</b> computes N as a function of H and TOL for the tanh-sinh rule.
</li>
<li>
<b>TANH_SINH_RULE</b> computes a tanh-sinh quadrature rule.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
<li>
<b>TRAP_RULE</b> computes a trapezoid quadrature rule.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../f_src.html">
the FORTRAN90 source codes</a>.
</p>
<hr>
<i>
Last revised on 08 January 2009.
</i>
<!-- John Burkardt -->
</body>
<!-- Initial HTML skeleton created by HTMLINDEX. -->
</html>