Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
add comment

1 Answer

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

Clear[r,f,y];
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
add comment

Your Answer

 
discard

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.