# Nested NIntegrate - NIntegrate::inum: - error

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?

-

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
*)

-
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 – Dr. belisarius Feb 21 '13 at 8:29