I need to perform an integration. There is one particular value, which may be very small that is showing up as 0.. Is there any command in Mathematica 9 that will give me the very small value instead of 0.?

enter image description here

  • 2
    $\begingroup$ Chop, Round, Floor. But after re-reading I see you are using NumberForm. Why? Get rid of it unless you have some special (cosmetic) reason for using it. $\endgroup$ Jul 2 '14 at 10:58
  • 4
    $\begingroup$ isnt he asking how to not chop the result? $\endgroup$
    – george2079
    Jul 2 '14 at 13:00
  • $\begingroup$ @george2079 you have a point! ARIJIT, while you get a display of 0., Mathematica still knows about the correct value, but does not display all digits. Can you post your code as code, not just as image? Then we should be able to help you more easily. This Q&A might give you a starting point: mathematica.stackexchange.com/questions/3736/… $\endgroup$
    – Yves Klett
    Jul 2 '14 at 13:52
  • 1
    $\begingroup$ Please post code that can be copied instead of images of code. $\endgroup$
    – Michael E2
    Jul 2 '14 at 15:35

The problem seems to be that the values are very small, smaller than can be represented by a machine numbers. Perhaps NIntegrate decides the answer is zero. You can use arbitrary-precision numbers, which you can do with the WorkingPrecision option, to get nonzero values.

a2 = 525/10;
u = 2*i - 1/2;
u1 = u*Pi/2;
u2 = u1/a2;
u4 = -1/5^2;
  BesselJ[2, 2 x] BesselJ[2, u2 x] x Exp[u4 x^2], {x, 0, Infinity}, 
  AccuracyGoal -> 20, WorkingPrecision -> 20], {i, 5}]
  { 3.9132803101634619543*10^-153338638, 
  • $\begingroup$ Wow 10^_1533...you have my vote $\endgroup$
    – ubpdqn
    Jul 2 '14 at 16:52
  • $\begingroup$ @ubpdqn Yeah, it's hard to imagine a number that small being used. $\endgroup$
    – Michael E2
    Jul 2 '14 at 17:12

I have interpreted this question as per george2079s comment. I think this may a case of "asking too much" but I defer to numerical experts.


   BesselJ[2, 2 x] BesselJ[2, us[[1]] x] x Exp[u4 x^2]], {x, 0, s}, 
  PlotRange -> {-0.003, 0.003}], {s, {5, 10, 20, 30, 40, 50}}]

enter image description here

Then testing for small upper limits (noting failure of convergence methods). I rewrote the code (and hope I have not made a mistake):

a2 = 52.5;
u4 = -1/25;
us = # Pi/(2 a2) & /@ (2 #1 - 0.5 & /@ Range[5])
fun[y_, t_] := 
 NIntegrate[BesselJ[2, 2 x] BesselJ[2, y x] x Exp[u4 x^2], {x, 0, t}, 
  AccuracyGoal -> 20]


Grid[Quiet[{#2, fun[#1, #2]} & @@@ Tuples[ {us, Range[10, 50, 10]}]]]

enter image description here


Extended comment (this question will probably get closed as a duplicate in any case).

As a (presumably) new user the best way to wean yourself of procedural constructs like For is to begin using Table. There are other ways to do things in Mathematica but the transition from For to Table is probably the easiest and most intuitive to begin with.

enter image description here

In that code Quiet is used to suppress a warning about lack of convergence. Note that I changed u4 to make it a real. Chop is used to treat very small numbers below a cut off -- in this case below 10^-7 as zero. You can also use functions like Map.

enter image description here

In both cases above I'm sticking with the way you have set up the problem rather than re-writing. Objective is to show alternatives to For keeping the body essentially the same.

Finally there is no need to use Print to get the output:

enter image description here


Not the answer you're looking for? Browse other questions tagged or ask your own question.