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 the problem quite similar as in: Nested NIntegrate I define two functions:

r[x_] := Evaluate[q[x] /. NDSolve[{q'[t] == 0.0001 + (-1 + I*1 + q[t])*q[t],q[0] == 0}, q, 
                                  {t, 0, 50}]]

fn[k_?NumericQ] := Exp[8*NIntegrate[r[s]*Exp[2*beta*1] + 8*r[s], {s, 0, k}]]

beta=1

When I want to know the value of:

NIntegrate[fn[k], {k, 0, 5}]

I obtain following error:

NIntegrate::inum: "Integrand fn[k] is not numerical at {k} = {0.03978659976289378`}."

Adding ?NumericQ to r[k_] I obtain error:

NIntegrate::inumr: "The integrand fn[k] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,5}}"

What do I wrong?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Make your integrand numeric!

r[x_] := q[x] /.NDSolve[{q'[t] == 0.0001 + (-1 + I*1 + q[t])*q[t], q[0] == 0}, q, {t, 0, 50}][[1]]
beta = 1;
fn[k_?NumericQ] := Exp[8*NIntegrate[r[s]*Exp[2*beta*1] + 8*r[s], {s, 0, k}]]
NIntegrate[fn[k], {k, 0, 5}]
(*
5.07423 + 0.0503328 I
*)
share|improve this answer
    
I still get an error :NIntegrate::inumr: "The integrand fn[k] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,5}}. " –  Agnieszka Feb 21 '13 at 8:00
    
Sorry, that's works, but the only difference which I see is a definition of r[x]. What means at the end of it [[1]]? (I'm not very good in Mathematica) –  Agnieszka Feb 21 '13 at 8:07
    
@Agnieszka Take a look at Part[] in the help –  belisarius Feb 21 '13 at 8:29
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.