Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I set the output precision of the following statement to 10 decimal places? I was looking through the documentation, and for some reason, all I could find was Accuracy[] or Precision[].

f[x_] := E^Cos[x]
NIntegrate[f[x], {x, 0, 2*Pi}]

Which, by default, evaluates to:


Thank you for your time.

share|improve this question
This is all in the documentation: N, guides to numerical precision, presentation of numbers using NumberForm. Please at least make some effort with the documentation. – Verbeia Mar 28 '12 at 3:56
@Verbeia I was looking through the documentation, and for some reason, all I could find was Accuracy[] or Precision[] but nothing like what Artes mentioned. – Oliver Spryn Mar 28 '12 at 3:58
It is helpful to mention this in your question, so we know what you've tried. Anyway, the documentation for Precision links to the tutorial I mentioned and to the guide page that mentions PrecisionGoal and AccuracyGoal. It was all one click away. – Verbeia Mar 28 '12 at 4:04
Thank you Verbeia. I will keep this in mind! – Oliver Spryn Mar 28 '12 at 4:06
It's notable that the documentation for Precision links only indirectly through the tutorials to NumberForm. The direct links are only Accuracy, RealExponent, N, Chop, SetPrecision, MachineNumberQ, MachinePrecision, PrecisionGoal, WorkingPrecision, ExactNumberQ, NumberMarks. IMO, it'a a lot to go trawling through when looking for this answer. – Reb.Cabin Mar 31 '12 at 0:07
up vote 6 down vote accepted
NIntegrate[f[x], {x, 0, 2*Pi}, WorkingPrecision -> 15, PrecisionGoal -> 10]
share|improve this answer
Oh yeah! Just what I needed. Thank you, Artes! – Oliver Spryn Mar 28 '12 at 3:56

The number of digits displayed for machine reals can also be controlled via a setting in the preferences dialog. Under Appearance > Formatting > Numbers, change the value for Number of digits displayed in output:

In[4]:= f[x_] := E^Cos[x]
In[5]:= NIntegrate[f[x], {x, 0, 2*Pi}]

Out[5]= 7.954926521

Note that this doesn't affect arbitrary-precision numbers, which show the digits appropriate for their precisions (shown in these examples after the backticks):

In[6]:= 1.23456789`4

Out[6]= 1.235

In[7]:= 1.23456789`14

Out[7]= 1.2345678900000
share|improve this answer

If you just want "10 decimal places" - you already have them and more. Mathematica just displays shorter version. You get your answer on default with 16 significant digits, - use NumberForm to see it:

f[x_] := E^Cos[x]
NumberForm[NIntegrate[f[x], {x, 0, 2*Pi}], 100]

I intentionally exaggerated with 100 digit precision so you can see where the default digits are cut off. Also if SHIFT+ENTER (evaluate) your answer/number (output cell), you will see it again - your 16 digits appear in the input and shorten in the output:

In[1]:= 7.954926521012846`

Out[1]= 7.95493
share|improve this answer

Use in the following way also.

 SetPrecision[NIntegrate[f[x], {x, 0, 2*Pi}], 15]
share|improve this answer

Your Answer


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.