So I have this equation from cosmology giving $H_0 t$ as a function of $a$:

\begin{equation} \int_0^a \frac{da}{\left( \frac{\Omega_{\text{rad,0}}}{a^2} + \frac{\Omega_{\text{m,0}}}{a} +\Omega_{\Lambda\text{,0}} a^2\right)^{1/2}}=H_0 t \end{equation} I can plot it on a log-log scale like this:

ParametricPlot[{Log10[NIntegrate[(or0/a^2 + om0/a + ol0 a^2)^(-1/2), {a, 0, a1}]], Log10[a1]}, 
{a1, 0, 10},
Exclusions -> None,
Frame -> True,
FrameLabel -> {"Log[H0 t]", "Log[a]"},
BaseStyle -> {FontSize -> 16},
PlotRange -> All,
FrameStyle -> Directive[Thick, Black],
FrameTicksStyle -> Directive[Thin, Black],
PlotStyle -> Black,
Axes -> False,
ImageSize -> Large]

which gives this nice plot after throwing out some errors that say

"NIntegrate::nlim: a = a1 is not a valid limit of integration.":

enter image description here

I want to plot the log of the derivative of $a$ with respect to $t$, $\log\dot{a}$, versus $\log(H_0 t)$. How can I do this?? I've tried several things but none of them seem close to the best way and I can't get it to work. Thanks!

  • $\begingroup$ Could you include the numeric values for or0, om0, and ol0? It would make testing easier. $\endgroup$
    – Pillsy
    Apr 29, 2017 at 2:08
  • $\begingroup$ yeah sure: they are or0=9*^-5, om0=0.31, ol0=0.69-(9*^-5) (so they add up to 1). Also H0 is 2.20373*10^-18 per second if that helps. Thanks for your help!! $\endgroup$
    – Ern
    Apr 29, 2017 at 2:11

1 Answer 1


Starting with $H_0 t = \int_0^a f(x)dx$, we take the derivative w.r.t. time, apply the chain rule and the Leibniz integral rule to obtain $$H_0 = \frac{d}{dt} \int_0^a f(x)dx = \frac{da}{dt} \frac{d}{da} \int_0^a f(x)dx = \dot{a} f(a) \;.$$ So, $\dot{a} = H_0/f(a)\;$. Now in MMA we can follow your previous work and obtain

    {Ωr, Ωm, ΩΛ, h0} = 
         {9.0 10^-5, 0.31, .69 - Ωr, 2.20373 10^-18};
    f[a_] := 1/Sqrt[Ωr/a^2 + Ωm/a + ΩΛ a^2]

    logAdot[a_] := Log10[h0/f[a]];
    logH0t[a_] := Log10[NIntegrate[f[λ], {λ, 0, a}]];

    ParametricPlot[{logH0t[a], Log10[a]}, {a, 1/10000, 10},
        Frame -> True, 
        FrameLabel -> {"Log[H0 t]", "Log[a]"},
        PlotRange -> All, ImageSize -> 500]

    ParametricPlot[{logH0t[a], logAdot[a]}, {a, 1/10000, 10},
        Frame -> True, 
        FrameLabel -> {"Log[H0 t]", 
       "Log[\!\(\*OverscriptBox[\(a\), \(•\)]\)]"},
        PlotRange -> All, ImageSize -> 500]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.