• No se han encontrado resultados

CAPÍTULO II. Marco teórico – metodológico

3. Marco metodológico

In deciding which algorithm to use for a given subdomain accuracy is always a priority. The accuracy decision is a strictly binary decision: either an algorithm is considered sufficiently accurate in a given subdomain or it is not, and the margin by which the required tolerance is exceeded is irrelevant. If two or more algorithms meet the minimum requirements then a decision is based on speed, and only the relative speed of the competing methods matters. If the speed difference is small then the location of the boundary between the regions where different algorithms are used is not critical and can be chosen for simplicity. If the speed difference is great then clearly the faster algorithm is used up to its accuracy limit. Therefore speed boundaries may often be less sharply defined than accuracy ones.

The issues of speed and accuracy are discussed in detail below.

Analytical estimates of accuracy limits

This topic has already received some discussion in section 3.4.2 in connection with the asymptotic expansion. Many of those comments can be applied to the Taylor series, but there are a few differences.

Theoretically arbitrary accuracy is possible with the Taylor series because it is a convergent series. However due to the finite precision of the computer there is an upper limit to accuracy obtainable (using standard arithmetic operations), and further accuracy may be lost in roundoff errors associated with intermediate calculations. To illustrate the latter point, if the internal arithmetic is performed with pbinary digits of precision, and the leading binary digit in the largest single term in the Taylor series is 2m, then at best an error in that term of order 2m−p may be assumed. If the final result (the complete Taylor sum) has leading digit 2n (obviously m n) then the relative error is 2(m−p)−n. In other words at best mn binary digits of accuracy have been lost and can not be retrieved. Ifm−nis large the effect of accumulation of roundoff errors may be insignificant.

If we confine the use of the Taylor series to values for which m−n = 0, i.e. demand that the result is accurate to the precision of the individual calculations, the radius of applicability of the series is unnecessarily restricted. In practice it was found that the Taylor series remained competitive in terms of speed if double precision was used internally (p= 48 on a PC) while single precision was required in the output (24 binary digits6). In fact the speed penalty for

performing internal calculations with double rather than single precision is almost negligible, and the series only becomes slow for large|z|because more terms are required.

The following discussion will concentrate on the function (3.14), and (3.15) can be analysed in a similar fashion.

The first step is to obtain a simple first order approximation to the function. The Taylor series does not provide a suitable estimate, but because we are dealing with reasonably large radii the first term in the asymptotic expansion gives a good estimate. For |z| ≥ 2.74 this estimate is within 10%. If we call this estimateE we can write

Z z i∞ ew2erfw+ 1 w√πdw'E= 1 4√πz2.

Next we need to identify and estimate the magnitude of the largest term. Let this betLwhere Lis the largestnfor which

¯ ¯ ¯ tn tn−1 ¯ ¯

¯>1. From the Taylor series (3.19) we havetL= (4z2)

L+1 L! 2√π(2L+2)!. Also ¯ ¯ ¯ tn tn−1 ¯ ¯

¯= (n+1n/|2)(z2|n+1), from whichLis the solution toL+3

2+21L = ¯

¯z2¯¯rounded down to

the next lowest integer.

Finally the number of lost binary digits of accuracy is (m−n) = log2

¯

¯tL

E ¯

¯, and by solving the above equations and plotting the result against¯¯z¯it was found that an excellent empirical

fit7 to the theoretical accuracy limit was given by the relation

(m−n) = 1.440¯¯z2¯¯+ 0.582.

With a maximum loss of 24 binary digits being tolerated we obtain|z|max= 4.03 as the accuracy limit for the Taylor series (3.19). This agreed well with numerical accuracy experiments, with the exception that it was somewhat conservative in the first octant where the leading term in the asymptotic expansion becomes (3.27), and notE.

Testing of accuracy

The analytical accuracy limits were used as a guideline, particularly in making decisions about reasonable tolerances to seek, and in identifying where to focus the numerical experimentation effort. All final decisions regarding accuracy limits were based on numerical comparisons between methods.

In section 3.4.2 four different methods of evaluation of the Green functions were derived. It was assumed that each method, being quite distinct from the others, would have an error unrelated to those of the other methods. Therefore in comparing the results of the different algorithms if any two (or more) were consistently in agreement to a specified tolerance in a given region of the computational domain then both (or all of) those methods could be considered accurate to at least that tolerance in that region.

For this to work the regions of accuracy for each algorithm must overlap, which of course is desirable anyway. There will however inevitably be regions where only one method is of sufficient

accuracy. Most notably near the origin only the Taylor series is of sufficient accuracy, but its accuracy can not be verified by comparison with other methods. It is obvious though from the form of the Taylor series that if it meets accuracy requirements at large radii it will also meet these requirements at small radii.

In testing accuracy the relevant region of the complex domain was divided into a fine grid of points, so that local minima of the function could be identified. Accuracy was based on relative error, so that near local minima of the functions correspondingly smaller absolute errors were demanded. Also tolerances were applied separately to real and imaginary parts of the function values.

Contour plots of digits of agreement between algorithms were produced to assist in choosing suitable subdomains for the use of each algorithm.

Speed considerations

General comments can be made about the typical speed characteristics of each algorithm. The rational function approximation, which involves a fixed number of operations, always of the same type, has approximately constant speed regardless of where it is evaluated. The main purpose of the rational function approximation was to fill in the middle ground between the asymptotic expansion and the Taylor series where neither of the latter were of sufficient accuracy. To achieve this a large number of terms were required, and hence it is often the slower of the three methods. The computational time for the Taylor series and asymptotic expansion depend mainly on the number of terms requiring evaluation, since the evaluation time for each term is approximately constant. Both series are truncated as soon as convergence to the specified tolerance is achieved, and since the magnitudes of the terms in both series are functions of the radius|z|it is not surprising to find that the computational speed for each series is essentially also a function of |z|. The Taylor series becomes slower as|z| increases, while the asymptotic expansion becomes quicker.

This information is helpful in giving guidelines for testing speed. For example the boundary between the Taylor series and the rational function approximation is an example of a boundary based on speed. Because double precision is used for internal calculations the range of accuracy of the Taylor series is quite large, but at the same time it converges very slowly at larger radii, until it is no longer competitive for speed compared with the rational function approximation.

Decisions involving speed were made on the basis of testing on a PC. It was assumed that the relative performance of the various algorithms would be similar on different computers.

The Green function evaluations accounted for most of the running time of the panel method program, so optimising them for speed was considered to be of utmost importance. Various other factors were considered in seeking to reduce the calculation times, some of which will be listed here.

nificant effect on speed. In particular both the rational function approximation and the asymptotic expansion involve the evaluation of two sums. Using the asymptotic expansion as an example we have the sum indicated in equation (3.25) or (3.26), and another sum implicit in the additional term (3.27) or (3.28). In the first octant the second of these sums is dominant, so if it is calculated first the absolute error used to determine convergence of the first sum will be larger and fewer terms will be needed.

In general it was found that evaluating the real and imaginary parts of the functions separately using real arithmetic was quicker than using complex arithmetic. In view of the priority given to speed this was done at the expense of conciseness and readability of the program.

Numerous “tricks” in setting out calculations can be used to improve speed, such as the recursive evaluation of powers ofzand series coefficients (particularly as the latter involves factorials), or the use of multiplication by z−2 in the asymptotic expansion instead of

division byz2.

Documento similar