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.
Answer
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!
Comments
Post a Comment