Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a differential equation that looks like this:

 DSolve[(D[R[r, t], t])^2/(2*c) - (G*M1[r, z])/(
   c^2*R[r, t]) - (λ*(R[r, t])^2)/3 - E1[r] == 0, ... "boundary conditions etc go here"]

I need to get R[r, t] using my values of E1[r] and M1[r]. However, my M1[r] is defined as:

M1[r_] :=  NIntegrate[(1 + f*Exp[-(r/y)^2])*(r)^2, r]

Herein lies the problem. I realise that DSolve uses Integrate internally, but the function I want it to solve has an NIntegrate in it and this causes problems. I'm not sure how else to evaluate an error function.

Any ideas?

share|improve this question
This gives a solution in terms of an unresolved integral. Eventually. DSolve[(D[R[r, t], t])^2/(2*c) - (G*M1[r, z])/(c^2* R[r, t]) - (\[Lambda]*(R[r, t])^2)/3 - E1[r] == 0, R[r, t], t] – Daniel Lichtblau Feb 9 '13 at 22:33
What is the definition of f in your function M1[r_]? a unknown function? – can Feb 13 '15 at 7:51

Not knowing what the actual differential equation is, I can only point out one obvious problem: you should define

M1[r_] = Integrate[(1 + f*Exp[-(r/y)^2])*(r)^2, r]

instead of using := NIntegrate because you seem to be looking for an indefinite integral there. For numerical integration you have to specify integration limits. The Clear is just added for safety before I define the function with = so that the integral will be done at that time, once and for all.

share|improve this answer
Wrapping the integral in Block[{r,f,y}, ...] would work, also, and limit the impact on the rest of the notebook. – rcollyer Feb 8 '13 at 21:41
For all I know, f in the question could in fact have a value - so it may be a moot point... – Jens Feb 8 '13 at 21:52
True, very true. – rcollyer Feb 8 '13 at 22:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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