As @J.M. said, NIntegrate
doesn't work when the integrand is non-numerical. You also must specify numerical bounds. You can build a function that returns a result for arbitrarily specified numerical constants as follows
Your code:
f = Exp[-Sqrt[x^2 + y^2 + z^2]/λ]*Cos[π*x/a]*Cos[π*y/b]*Cos[π*z/c];
d = Laplacian[f, {x, y, z}, "Cartesian"] // Simplify;
ren = -2/Sqrt[x^2 + y^2 + z^2];
s = d + ren;
My code:
sFcn[x_, y_, z_, a_, b_, c_, λ_] = s;
J[a_, b_, c_, λ_] :=
NIntegrate[
sFcn[x, y, z, a, b, c, λ], {x, 0, 1}, {y, 0, 1}, {z, 0,
1}];
Example execution:
J[1, 1, 1, 1]
-2.36029
The reason it works is that the constants are all numerical when NIntegrate
is finally called. If you insist on non-numerical input, e.g. J[a, 1, 1, 1]
, you will get the error again (NIntegrate::inumr).
λ
,NIntegrate[]
won't work. $\endgroup$sFcn[x_, y_, z_, a_, b_, c_, λ_] = s;
andJ[a_, b_, c_, λ_] := NIntegrate[ sFcn[x, y, z, a, b, c, λ], {x, 0, 1}, {y, 0, 1}, {z, 0, 1}]
$\endgroup$