Problem1The purpose of this assignment was to investigate the scaling of the error as a function of the number of intervals used. Below is a link to a program that integrates the function using both integration formulas in the same run. It uses the trick of using a previously calculated integral when doubling the number of intervals.Solution program [openint.f90] A) Non-singular integrandThese are results along with lines with slope 2 and 3. The expected error scaling for small h is confirmed. Note that there are small deviations from the linear behavior for the largest h, showing the presence of higher-order corrections to the scaling.![]() B) Singular integrand![]() The exponent can be extracted by plottng the logarithm of the error versus log(h) [or log(N) or n]. ![]() ![]()
alpha=1/2, 1st order: slope = 0.49983
2nd order: slope = 0.50003
alpha=3/4, 1st order: slope = 0.24996
2nd order: slope = 0.25001
This is in very good agreement with the expectation; slope=1-alpha.
C) Almost singular integrand![]() The figure below shows results using alpha=1/2 and epsilon=0.00001. ![]() The lines show the expected slopes 1/2 (for h much larger than epsilon) 2 (for h much less than epsilon with 1st-order formula) and 3 (for h much less than epsilon with second-order formula). |
Problem 2Solution program [inertia.f90] A run for the case of the 5 cm sphere with a 1 cm inner cylinder, made of copper and gold, respectively, gave the following results (average and errors of Ix and Iz after each 10^5 step bin, stopping when the relative error of both quantities is less than eps=0.001):
1 0.0047045734 NaN 0.0049770784 0.0000000000
2 0.0047070661 0.0000017626 0.0049626889 0.0000101749
3 0.0047234163 0.0000134015 0.0049655108 0.0000071639
4 0.0047133494 0.0000133053 0.0049550252 0.0000105513
5 0.0047077014 0.0000117822 0.0049545036 0.0000084539
6 0.0047021198 0.0000110619 0.0049462451 0.0000103182
7 0.0047012592 0.0000095150 0.0049481774 0.0000090233
8 0.0046955375 0.0000098975 0.0049449019 0.0000084690
9 0.0046920539 0.0000093909 0.0049416094 0.0000081429
10 0.0046938560 0.0000086230 0.0049441229 0.0000077068
11 0.0046944982 0.0000078630 0.0049461666 0.0000072721
12 0.0046958480 0.0000073227 0.0049493473 0.0000073288
13 0.0046938449 0.0000070280 0.0049500340 0.0000067971
14 0.0046933723 0.0000065419 0.0049494446 0.0000063371
15 0.0046948479 0.0000062699 0.0049514169 0.0000062140
16 0.0046935844 0.0000060040 0.0049492709 0.0000061851
17 0.0046934146 0.0000056532 0.0049491679 0.0000058221
18 0.0046938952 0.0000053596 0.0049498738 0.0000055413
19 0.0046936391 0.0000050836 0.0049495672 0.0000052581
20 0.0046936416 0.0000048294 0.0049494278 0.0000049970
21 0.0046939780 0.0000046112 0.0049500226 0.0000047944
Since there are fluctuations also in the statistical errors, the number of
bins needed to achieve this accuracy will vary somewhat.
|