1
$\begingroup$

I have tried to use NIntegrate with variable limits and compute the following

(*parameters*)
Ωm = 1.0;
ΩΛ = 0.0;
Ωk = 
  1 - Ωm - ΩΛ;

(*Integral with variable limits*)
 A[a_?NumericQ] := (5 Ωm)/
       2 ((Ωm a^-3 + ΩΛ + \
    Ωk a^-2)^(1/2)) NIntegrate[
        1/(x (Ωm x^-3 + ΩΛ + \
    Ωk x^-2)^(1/2))^3, {x, 10^-7, a}];

   (*plotting data giving values to `a`*)
  Plot2 = ListLinePlot[A[a], {a, 0.1, 1}, PlotRange -> {0, 1}, 
          AxesOrigin -> {0, 0}]

I supposed that A[a] was "free" until ListLinePlot give values to a, but no.

Another problem is that NIntegrate is not working here, the plot at the end looks like y=x.

$\endgroup$
1
  • $\begingroup$ Only related tangentially, but these kinds of cosmological integrals always caused me annoyances. $\endgroup$
    – evanb
    Commented May 1, 2015 at 19:35

1 Answer 1

1
$\begingroup$

You are almost there. You only missed to create the list that you want to plot. Here are your definitions:

  (*parameters*)
Ωm = 1.0;
ΩΛ = 0.0;
Ωk = 
  1 - Ωm - ΩΛ;

(*Integral with variable limits*)
A[a_?NumericQ] := (5 Ωm)/
    2 ((Ωm a^-3 + ΩΛ + \
Ωk a^-2)^(1/2)) NIntegrate[
    1/(x (Ωm x^-3 + ΩΛ + \
Ωk x^-2)^(1/2))^3, {x, 10^-7, a}];

Here is the list with the structure {a, int}:

  lst = Table[{a, A[a]}, {a, 0.1, 1, 0.05}]

and then one should plot the list, rather than the function:

 Plot2 = ListLinePlot[lst, PlotRange -> {0, 1}, AxesOrigin -> {0, 0}]

which returns the image below:

enter image description here

You could also do it as follows skipping the list stage:

Plot[A[a], {a, 0.1, 1}, PlotRange -> {0, 1}, AxesOrigin -> {0, 0}]

The returned image is identical to the one above.

Have fun!

$\endgroup$
4
  • $\begingroup$ Thanks. But the plot looks like y=x, right? I suppose the problem is inside the integration. $\endgroup$ Commented Apr 30, 2015 at 16:26
  • $\begingroup$ OK, new problem. NIntegrate is not integrating, it only evaluates the limit "a" and makes the table. $\endgroup$ Commented Apr 30, 2015 at 21:47
  • 1
    $\begingroup$ That's because your integral is equal to a. $\endgroup$
    – LLlAMnYP
    Commented Apr 30, 2015 at 23:01
  • $\begingroup$ Solved problem. $\endgroup$ Commented May 1, 2015 at 10:18

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.