So I've been trying to evaluate the following integral in Mathematica 8.0 Student version:

opsnum[a_, ω_] := (c^5*(3*10^25))/ℏ*
      NIntegrate[ρ[y, ω]/
        Hubble[y, ω]*(1/Hubble[z, ω])^3, {y, 
        a, ∞}, {z, a, y}]


    Hubble[z_, ω_] := 
 H0 Sqrt[ΩM (1 + z)^3 + Ωγ (1 + 
      z)^4 + ΩΛ ((1 + 
       z)^(3*(1 + ω)))]

χ[a_, ω_] := 
 NIntegrate[c/Hubble[z, ω], {z, a, ∞}]
ρ[a_, ω_] := (3*Matter[a, ω])/(
 4 π*(χ[a, ω])^3)

My problem is that this refuses to converge, and gives me an NIntegrate::inumr error, due to the nested integral nature of the function. Furthermore, I cannot think of another definition for the function as it relies on the cube of an integral which has limits different from the limits of the total integrand, of which it is a part.

Anyone got any ideas? I would be eternally grateful!

  • $\begingroup$ You've got undefined terms, so NIntegrate can't evaluate; that's what inumr means. A simpler example is NIntegrate[a, {t, 0, 1}]. $\endgroup$ Commented Dec 10, 2012 at 19:49
  • $\begingroup$ sorry, I meant to include that the variables are defined in my table, which is where the function's values are displayed. $\endgroup$
    – Gokotai
    Commented Dec 10, 2012 at 20:01
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – chris
    Commented Dec 10, 2012 at 20:15
  • $\begingroup$ You get that error because some or all of your variables don't have a numerical value. I don't know what you mean by saying that they are defined in your table, but apparently they weren't defined at the time of execution of the NIntegrate. Please provide more details about what you were doing. $\endgroup$ Commented Dec 10, 2012 at 21:25

1 Answer 1


The NIntegrates should be combined into one call:

NIntegrate[\[Rho][ y, \[Omega]]*(c/Hubble[z, \[Omega]])^3, {y, a, \[Infinity]}, {z, a, y}]

Otherwise, the inner integral remains in symbolic form when the outer integral is run.

  • $\begingroup$ Hiya, thanks for that. I tried that as well and I still get an inumr error. Is that I've tried reversing the order of integration as well in desperation, but to no avail. $\endgroup$
    – Gokotai
    Commented Dec 10, 2012 at 21:28
  • $\begingroup$ Make sure that both your rho function and Hubble function are defined in the following way: functionname[x_?NumericQ] := function goes here $\endgroup$
    – Guillochon
    Commented Dec 10, 2012 at 22:33
  • $\begingroup$ Hiya, all my numbers have been defined in a previous cell, and I have a seperate cell that specifies my loops and/or iterators as part of the ParallelTable command. $\endgroup$
    – Gokotai
    Commented Dec 10, 2012 at 22:48
  • $\begingroup$ Add ?NumericQ after each of the arguments in the declaration of Hubble and rho, as I described in my previous comment. $\endgroup$
    – Guillochon
    Commented Dec 11, 2012 at 0:00
  • $\begingroup$ Hi Guillochon, I tried that too but now it gives me a different error - slwcon. I increased the working precision but it still does this. Any advice on how to circumvent this? Thanks for the tips by the way! $\endgroup$
    – Gokotai
    Commented Dec 11, 2012 at 1:41

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.