# Plotting results of NIntegrate with variable integration limit

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.

• Only related tangentially, but these kinds of cosmological integrals always caused me annoyances. – evanb May 1 '15 at 19:35

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: 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!

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