forked from johannesgerer/jburkardt-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hermite_test_int.html
565 lines (523 loc) · 15.7 KB
/
hermite_test_int.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
<html>
<head>
<title>
HERMITE_TEST_INT - Quadrature Tests for Infinite Intervals
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
HERMITE_TEST_INT <br> Quadrature Tests for Infinite Intervals
</h1>
<hr>
<p>
<b>HERMITE_TEST_INT</b>
is a C++ library which
defines integration problems over infinite intervals of the form (-oo,+oo).
</p>
<p>
The test integrands would normally be used to testing one
dimensional quadrature software. It is possible to invoke a
particular function by index, or to try out all available functions,
as demonstrated in the sample calling program.
</p>
<p>
For a given integrand function f(x), the problem is to estimate
<pre>
I(f) = integral ( -oo < x < +oo ) w(x) * f(x) dx
</pre>
</p>
<p>
We consider three variations of the problem, depending on the
form of the weight factor w(x):
<ul>
<li>
<b>option</b> = 0, the unweighted integral:
<pre>
Integral ( -oo < x < +oo ) f(x) dx
</pre>
</li>
<li>
<b>option</b> = 1, the physicist weighted integral:
<pre>
Integral ( -oo < x < +oo ) exp(-x*x) f(x) dx
</pre>
<li>
<b>option</b> = 2, the probabilist weighted integral:
<pre>
Integral ( -oo < x < +oo ) exp(-x*x/2) f(x) dx
</pre>
</li>
</ul>
</p>
<p>
For option 0, the test integrands have the form:
<ol>
<li>
f1(x) = exp(-x*x) * cos(2*omega*x);
</li>
<li>
f2(x) = exp(-x*x);
</li>
<li>
f3(x) = exp(-px)/(1+exp(-qx));
</li>
<li>
f4(x) = sin ( x^2 );
</li>
<li>
f5(x) = 1 / (1+x^2) sqrt (4+3x^2) );
</li>
<li>
f6(x) = exp(-x*x) * x^m;
</li>
<li>
f7(x) = x^2 cos(x) exp(-x*x);
</li>
<li>
f8(x) = sqrt ( 1 + x * x / 2 ) * exp(-x*x/2);
</li>
</ol>
</p>
<p>
For option 1, the test integrands have the form:
<ol>
<li>
f1(x) = cos(2*omega*x);
</li>
<li>
f2(x) = 1
</li>
<li>
f3(x) = exp(x*x) * exp(-px)/(1+exp(-qx));
</li>
<li>
f4(x) = exp(x*x) * sin ( x^2 );
</li>
<li>
f5(x) = exp(x*x) * 1 / (1+x^2) sqrt (4+3x^2) );
</li>
<li>
f6(x) = x^m;
</li>
<li>
f7(x) = x^2 cos(x);
</li>
<li>
f8(x) = sqrt ( 1 + x * x / 2 ) * exp(+x*x/2);
</li>
</ol>
</p>
<p>
For option 2, the test integrands have the form:
<ol>
<li>
f1(x) = exp(-x*x/2) * cos(2*omega*x);
</li>
<li>
f2(x) = exp(-x*x/2);
</li>
<li>
f3(x) = exp(+x*x/2) * exp(-px)/(1+exp(-qx));
</li>
<li>
f4(x) = exp(+x*x/2) * sin ( x^2 );
</li>
<li>
f5(x) = exp(+x*x/2) * 1 / (1+x^2) sqrt (4+3x^2) );
</li>
<li>
f6(x) = exp(-x*x/2) * x^m;
</li>
<li>
f7(x) = x^2 cos(x) exp(-x*x/2);
</li>
<li>
f8(x) = sqrt ( 1 + x * x / 2 );
</li>
</ol>
</p>
<p>
The library includes not just the integrand, but also the exact value
of the integral (or, typically, an estimate of this value), and
a title for the problem.
Thus, for each integrand function, several routines are supplied. For
instance, for function #1, we have the routines:
<ul>
<li>
<b>P01_FUN</b> evaluates the integrand for problem 1.
</li>
<li>
<b>P01_EXACT</b> returns the estimated integral for problem 1.
</li>
<li>
<b>P01_TITLE</b> returns a title for problem 1.
</li>
</ul>
So once you have the calling sequences for these routines, you
can easily evaluate the function, or integrate it on the
appropriate interval, or compare your estimate of the integral
to the exact value.
</p>
<p>
Moreover, since the same interface is used for each function,
if you wish to work with problem 5 instead, you simply change
the "01" to "05" in your routine calls.
</p>
<p>
If you wish to call <i>all</i> of the functions, then you
simply use the generic interface, which requires you to specify
the problem number as an extra input argument:
<ul>
<li>
<b>P00_FUN</b> evaluates the integrand for any problem.
</li>
<li>
<b>P00_EXACT</b> returns the exact integral for any problem.
</li>
<li>
<b>P00_TITLE</b> returns a title for any problem.
</li>
</ul>
</p>
<p>
Some demonstration routines are built in for simple quadrature methods:
<ul>
<li>
<b>P00_GAUSS_HERMITE</b> uses a Gauss-Hermite quadrature formula;
</li>
<li>
<b>P00_MONTE_CARLO</b> uses a Monte Carlo scheme, with
sample points selected according to the standard
normal probability distribution;
</li>
<li>
<b>P00_TURING</b> applies a simple equally spaced method of
Turing.
</li>
</ul>
</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>HERMITE_TEST_INT</b> is available in
<a href = "../../c_src/hermite_test_int/hermite_test_int.html">a C version</a> and
<a href = "../../cpp_src/hermite_test_int/hermite_test_int.html">a C++ version</a> and
<a href = "../../f77_src/hermite_test_int/hermite_test_int.html">a FORTRAN77 version</a> and
<a href = "../../f_src/hermite_test_int/hermite_test_int.html">a FORTRAN90 version</a> and
<a href = "../../m_src/hermite_test_int/hermite_test_int.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../cpp_src/hermite_exactness/hermite_exactness.html">
HERMITE_EXACTNESS</a>,
a C++ program which
tests the polynomial exactness of Gauss-Hermite quadrature rules.
</p>
<p>
<a href = "../../cpp_src/hermite_rule/hermite_rule.html">
HERMITE_RULE</a>,
a C++ program which
can compute and print a Gauss-Hermite quadrature rule.
</p>
<p>
<a href = "../../cpp_src/laguerre_test_int/laguerre_test_int.html">
LAGUERRE_TEST_INT</a>,
a C++ library which
defines test integrands for quadrature rules
for estimating the integral of a function with density exp(-x)
over the interval [0,+oo).
</p>
<p>
<a href = "../../datasets/quadrature_rules_hermite_physicist/quadrature_rules_hermite_physicist.html">
QUADRATURE_RULES_HERMITE_PHYSICIST</a>,
a dataset directory which
contains Gauss-Hermite quadrature rules, for integration
on the interval (-oo,+oo), with weight function exp(-x^2).
</p>
<p>
<a href = "../../datasets/quadrature_rules_hermite_probabilist/quadrature_rules_hermite_probabilist.html">
QUADRATURE_RULES_HERMITE_PROBABILIST</a>,
a dataset directory which
contains Gauss-Hermite quadrature rules, for integration
on the interval (-oo,+oo), with weight function exp(-x^2/2).
</p>
<p>
<a href = "../../datasets/quadrature_rules_hermite_unweighted/quadrature_rules_hermite_unweighted.html">
QUADRATURE_RULES_HERMITE_UNWEIGHTED</a>,
a dataset directory which
contains Gauss-Hermite quadrature rules, for integration
on the interval (-oo,+oo), with weight function 1.
</p>
<p>
<a href = "../../cpp_src/test_int/test_int.html">
TEST_INT</a>,
a C++ library which
defines test integrands for 1D quadrature rules.
</p>
<p>
<a href = "../../cpp_src/test_int_2d/test_int_2d.html">
TEST_INT_2D</a>,
a C++ library which
defines test integrands for 2D quadrature rules.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
Philip Davis, Philip Rabinowitz,<br>
Methods of Numerical Integration,<br>
Second Edition,<br>
Dover, 2007,<br>
ISBN: 0486453391,<br>
LC: QA299.3.D28.
</li>
<li>
Prem Kythe, Michael Schaeferkotter,<br>
Handbook of Computational Methods for Integration,<br>
Chapman and Hall, 2004,<br>
ISBN: 1-58488-428-2,<br>
LC: QA299.3.K98.
</li>
<li>
Robert Piessens, Elise deDoncker-Kapenga,
Christian Ueberhuber, David Kahaner,<br>
QUADPACK: A Subroutine Package for Automatic Integration,<br>
Springer, 1983,<br>
ISBN: 3540125531,<br>
LC: QA299.3.Q36.
</li>
<li>
William Squire,<br>
Comparison of Gauss-Hermite and Midpoint Quadrature with Application
to the Voigt Function,<br>
in Numerical Integration:
Recent Developments, Software and Applications,<br>
edited by Patrick Keast, Graeme Fairweather,<br>
Reidel, 1987, pages 337-340,<br>
ISBN: 9027725144,<br>
LC: QA299.3.N38.
</li>
<li>
Arthur Stroud, Don Secrest,<br>
Gaussian Quadrature Formulas,<br>
Prentice Hall, 1966,<br>
LC: QA299.4G3S7.
</li>
<li>
Alan Turing,<br>
A Method for the Calculation of the Zeta Function,<br>
Proceedings of the London Mathematical Society,<br>
Volume 48, 1943, pages 180-197.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "hermite_test_int.cpp">hermite_test_int.cpp</a>,
the source code;
</li>
<li>
<a href = "hermite_test_int.hpp">hermite_test_int.hpp</a>,
the include file;
</li>
<li>
<a href = "hermite_test_int.sh">hermite_test_int.sh</a>,
commands to compile the source code;
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "hermite_test_int_prb.cpp">hermite_test_int_prb.cpp</a>,
the calling program;
</li>
<li>
<a href = "hermite_test_int_prb.sh">hermite_test_int_prb.sh</a>,
commands to compile, link and run the calling program;
</li>
<li>
<a href = "hermite_test_int_prb_output.txt">hermite_test_int_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>HERMITE_COMPUTE</b> computes a Gauss-Hermite quadrature rule.
</li>
<li>
<b>HERMITE_INTEGRAL</b> returns the value of a Hermite polynomial integral.
</li>
<li>
<b>HERMITE_RECUR</b> finds the value and derivative of a Hermite polynomial.
</li>
<li>
<b>HERMITE_ROOT</b> improves an approximate root of a Hermite polynomial.
</li>
<li>
<b>I4_FACTORIAL2</b> computes the double factorial function.
</li>
<li>
<b>P00_EXACT</b> returns the exact integral for any problem.
</li>
<li>
<b>P00_FUN</b> evaluates the integrand for any problem.
</li>
<li>
<b>P00_GAUSS_HERMITE</b> applies a Gauss-Hermite quadrature rule.
</li>
<li>
<b>P00_MONTE_CARLO</b> applies a Monte Carlo procedure to Hermite integrals.
</li>
<li>
<b>P00_PROBLEM_NUM</b> returns the number of test integration problems.
</li>
<li>
<b>P00_TITLE</b> returns the title for any problem.
</li>
<li>
<b>P00_TURING</b> applies the Turing quadrature rule.
</li>
<li>
<b>P01_EXACT</b> returns the exact integral for problem 1.
</li>
<li>
<b>P01_FUN</b> evaluates the integrand for problem 1.
</li>
<li>
<b>P01_TITLE</b> returns the title for problem 1.
</li>
<li>
<b>P02_EXACT</b> returns the exact integral for problem 2.
</li>
<li>
<b>P02_FUN</b> evaluates the integrand for problem 2.
</li>
<li>
<b>P02_TITLE</b> returns the title for problem 2.
</li>
<li>
<b>P03_EXACT</b> returns the exact integral for problem 3.
</li>
<li>
<b>P03_FUN</b> evaluates the integrand for problem 3.
</li>
<li>
<b>P03_TITLE</b> returns the title for problem 3.
</li>
<li>
<b>P04_EXACT</b> returns the estimated integral for problem 4.
</li>
<li>
<b>P04_FUN</b> evaluates the integrand for problem 4.
</li>
<li>
<b>P04_TITLE</b> returns the title for problem 4.
</li>
<li>
<b>P05_EXACT</b> returns the estimated integral for problem 5.
</li>
<li>
<b>P05_FUN</b> evaluates the integrand for problem 5.
</li>
<li>
<b>P05_TITLE</b> returns the title for problem 5.
</li>
<li>
<b>P06_EXACT</b> returns the exact integral for problem 6.
</li>
<li>
<b>P06_FUN</b> evaluates the integrand for problem 6.
</li>
<li>
<b>P06_PARAM</b> gets or sets parameters for problem 6.
</li>
<li>
<b>P06_TITLE</b> returns the title for problem 6.
</li>
<li>
<b>P07_EXACT</b> returns the exact integral for problem 7.
</li>
<li>
<b>P07_FUN</b> evaluates the integrand for problem 7.
</li>
<li>
<b>P07_TITLE</b> returns the title for problem 7.
</li>
<li>
<b>P08_EXACT</b> returns the exact integral for problem 8.
</li>
<li>
<b>P08_FUN</b> evaluates the integrand for problem 8.
</li>
<li>
<b>P08_TITLE</b> returns the title for problem 8.
</li>
<li>
<b>R8_ABS</b> returns the absolute value of an R8.
</li>
<li>
<b>R8_EPSILON</b> returns the R8 roundoff unit.
</li>
<li>
<b>R8_GAMMA</b> evaluates Gamma(X) for a real argument.
</li>
<li>
<b>R8_HUGE</b> returns a "huge" R8.
</li>
<li>
<b>R8VEC_DOT_PRODUCT</b> computes the dot product of a pair of R8VEC's.
</li>
<li>
<b>R8VEC_NORMAL_01_NEW</b> returns a unit pseudonormal R8VEC.
</li>
<li>
<b>R8VEC_REVERSE</b> reverses the elements of an R8VEC.
</li>
<li>
<b>R8VEC_SUM</b> returns the sum of an R8VEC.
</li>
<li>
<b>R8VEC_UNIFORM_01_NEW</b> returns a new unit pseudorandom R8VEC.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../cpp_src.html">
the C++ source codes</a>.
</p>
<hr>
<i>
Last revised on 31 July 2010.
</i>
<!-- John Burkardt -->
</body>
</html>