mwt5345 / class_ede_v2

Modified version of CLASS to work with EDE models.
13 stars 11 forks source link

Optimise shooting for z_c by making it smooth.... #1

Closed ThomasTram closed 1 year ago

ThomasTram commented 1 year ago

The current implementation require the precision setting back_integration_stepsize to be decreased by 10. This makes the background quite slow, especially since the background needs to be computed many times during shooting. This is exacerbated by the fact that the background is not parallelised.

The reason for this is that the code only allows for a discrete set of redshift values z_c, namely the ones for which background quantities has been computed, whereas the target value is a parameter varied in an MCMC run and thus assumed able to take any values. It is currently solved by "snapping" the target z-value to the grid such that the "zero-function" of the shooting method at least has a solution.

I propose the following solution: Instead of using just the redshift corresponding to the point in the background table having the maximum value fmax, take the neighbouring points as well. Then a parabola can be fitted to the the three points, and the maximum point and value can be extracted. Now z_c can vary smoothly in between z_bins, and no snapping is required! The precision setting can be reduced again, and the speedup is of the order 10!

Just for reference, here is the Mathematica notebook for the interpolating polynomial:

p = InterpolatingPolynomial[{{xm, fm}, {xj, fj}, {xp, fp}}, x]
dp = Simplify[D[p, x]]
sol = Solve[dp == 0, x]
x0 = FullSimplify[x /. sol[[1]]]
fmax = FullSimplify[p /. x -> x0]

Print[CForm[x0]]
Print[CForm[fmax]]