• Nenhum resultado encontrado

4.8 Cosmological distance calculations

4.8.3 Interpolation

Thegivalues computed by Algorithm4.15are used to acquire an approximation of the integral for a given upper limit — redshift of a given object. Of course, the redshift should be in the range thatgi sequence spans.

Linear interpolation

Using two pointsgaandgcof the interpolant, that correspond to abscissæzaand zcrespectively, can be used to compute the integralgm in equation (2.6) for an upper limitzmof a midpoint:zm ∈[za, zc].

The formula is

gm =ga+(zmza) (gcga)

zcza (4.20)

http://www.astro.ucla.edu/~wright/CosmoCalc.htmlas of September 11, 2015.

CHAPTER 4. IMPLEMENTATION METHODOLOGY An implementation should check ifzmis in the accepted range (extrapolation is not supported as the user was free to select any upper limit) and find the closest points lying in the left and right ofzm. As the intervals between the points of the interpolating function are equal in length it is easy to find the indices of the points by simple division: letm˜ be the index of the point between za and zc

suppose it is an integer, then

˜

m = zmaxzm

zstep (4.21)

If it is actually an integerthen no interpolation is needed andgm is returned.

Else, the indices of the points closest to it are easily found by the floor and ceiling functions:

a=bm

c=dme˜ ==m˜<Z c=a+ 1

(4.22)

Quadratic interpolation

Linear interpolation requires many points to be accurate, but more importantly, the approximation error can have a systematic behaviour: if the second derivative of function we’re estimating is never zeroed in an interval, and the second derivative is not zero, then it will always overestimate or underestimate the real value.

This is true for the distance measures in cosmology. E.g. luminosity or line–

of–sight comoving distance are increasing functions with respect to redshift and therefor true for the integral we are called to compute — see comoving distance curve in Figure 5.10. Better interpolation methods can be used. For “well–

behaved”, smooth curves like the one we approximate, quadratic interpolation is sufficient (see Figure4.2) and considerably faster than elaborate methods like splines(Kokkotas,2014).

a rare case due to the limited values ofgiand the approximate representation of real numbers in computers

with the exception ofangular diameter distance

4.8. Cosmological distance calculations

ga

gb g

c

gm

Figure 4.2 Quadratic interpolation using parabolas (blue) is more accurate than linear interpolation (red) in approximating a curve (black.)

The formula of quadratic interpolation can be easily produced. Let

y=c0+c1x+c2x2 (4.23) the equation of a parabola to pass through the three points

(za, ga) (zb, gb) (zc, gc)

which are successive, meaning that ifsis the constant interval, then

zbza=s=zczb and zcza = 2s (4.24) We derivec0, c1andc3 by manipulating the following equations:

ga=c0+c1za+c2za2 (4.25) gb =c0+c1zb+c2zb2 (4.26) gc=c0+c1zc+c2z2c (4.27)

CHAPTER 4. IMPLEMENTATION METHODOLOGY Combining equations (4.25) to (4.27),

(4.26)−(4.25) ⇒ c1+c2(za+zb) = gbga

zbza

(4.24)

c1+c2(za+zb) = gbga

s (4.28)

(4.27)−(4.26) ⇒ · · · ⇒ c1+c2(zb+zc) = gcgb

s (4.29)

(4.29)−(4.28) ⇒ c2(zcza) = gc−2gb+ga

s ⇒ (4.30)

(4.24)

c2 = ga−2gb+gc

2s2 (4.31)

(4.28) ⇒ c1 = gbga

sc2(za+zb) (4.32) (4.25) ⇒ c0 =gac1zac2z2a (4.33) Equations (4.31) to (4.33) define the parabola that will be used to approximate the function for a given redshift close to the abscissæ of the three points.

As in linear interpolation, an implementation should check if the requested redshift lies in the interpolation range, and find the indicesa,bandc. An obvious choice is to take the three points closest to the requested redshift. Two of them are the ones immediately left and right found in the manner we described in

§4.8.3. If(zm, gm)is the request point, then

˜

m= zmaxzm zstep a=bm

b=dme˜ ==m˜<Z b =a+ 1

(4.34)

The third point could be the one with index eithera−1orb+ 1depending on which is closer tozm: m˜ closer toaorbrespectively.

Also, treatment for the extreme values is required: ifacorresponds to the first interpolant point (a= 1) orbto the last (b = n2), there is only one valid choice for the third point. The Algorithm4.16demonstrates our implementation for the quadratic interpolation.

4.8. Cosmological distance calculations

Algorithm 4.16:QuadraticInterpolation

Input :redshiftzm,interpolationstep, the outputg of Algorithm4.15 Output :comoving distance for the given redshift

1 if z = 0then return0

2 if z <0orz > zmaxthen returnNaN

3 posstepzm

4 a ← bposc

5 b ← dpose

6 if a=bthen

7 valuega

8 else

9 if

posa < 12orb =ip_points

anda,0then

10 cb

11 ba

12 aa−1

13 elsecb+ 1

14 c2ga−2g2stepb+g2 c

15 c1gstepbgac2(za+zb)

16 c0gaza(c1+c2za)

17 valuec0+c1zm+c2zm2

18 return Hc

0 ×value

Experience never errs; it is only your judgments that err by promis- ing themselves effects such as are not caused by your experiments.

Leonardo da Vinci, from Jean Paul Richter (1888), “The Notebooks of Leonardo da Vinci”

5

Numerical experiments

Outline of chapter

5.1 Experimental time complexity . . . 86 5.2 Fast Bootstrap Median . . . 94 5.3 Distance Calculator . . . 98 5.4 DEUSS MSTs . . . 106

5.1. Experimental time complexity

5.1 Experimental time complexity

Finding the MST for dense graphs can be challenging concerning the computa- tional resources. The complete graph as a worst–case scenariois perfect for verifying time and space complexity: the two algorithms as implemented by us can work on complete graphs while non–complete graphs cannot be handled by CompletePrim §4.4.

By setting the metric to be Euclidean for the numerical experiment, we can also study the Delaunay tetrahedralization optimization while the Kruskal and Prim algorithms are unaffected.

Summarizing, three methods for producing MSTs of complete graphs are provided by MoravaPack and their average time complexity will be measured:

Complete Kruskal : compute all edges and use Kruskal’s algorithm

DT+Kruskal : compute the Delaunay tetrahedralization and use the output’s edges as an input for Kruskal’s algorithm

Complete Prim : use Prim’s algorithm to operate on graph’s vertices with Euclidean norm as the metric.

No documento A user – friendly M inimum S panning T ree (páginas 100-106)