0
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ 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] $\endgroup$ Feb 9, 2013 at 22:33
  • $\begingroup$ What is the definition of f in your function M1[r_]? a unknown function? $\endgroup$
    – Enter
    Feb 13, 2015 at 7:51

1 Answer 1

5
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Wrapping the integral in Block[{r,f,y}, ...] would work, also, and limit the impact on the rest of the notebook. $\endgroup$
    – rcollyer
    Feb 8, 2013 at 21:41
  • 1
    $\begingroup$ For all I know, f in the question could in fact have a value - so it may be a moot point... $\endgroup$
    – Jens
    Feb 8, 2013 at 21:52
  • $\begingroup$ True, very true. $\endgroup$
    – rcollyer
    Feb 8, 2013 at 22:06

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.