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 function, Dx[s] (defined in a module) which I can plot:

Plot[Dx[s], {s, 0, GetLatticeLength[]}]

enter image description here

However if I try to integrate it, I get nothing:

NIntegrate[Dx[s], {s, 2, 3}]
NIntegrate[Dx[s], {s, 2, 3}]

Note that the function has quite complicated form with many If-statements, hence can't be easily represented symbolically (e.g. Dx[a]). Still, for any numerical value I tried it gives a definite answer. Also, it seems from the plot that there are no wild singularities etc.

Why doesn't NIntegrate work? Shouldn't it be just numerical evaluation of the integrand? I mean, the plot works, why shouldn't NIntegrate work as well?

share|improve this question
1  
Try to change the definition (or redefine it as) to Dx[a_?NumericQ]:= ... –  belisarius Oct 25 '13 at 11:41
    
Dear Belisarius, thanks, it worked! –  Slava Oct 25 '13 at 11:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.