# Integrate vs NIntegrate

**URL:** <https://community.wolfram.com/t/integrate-vs-nintegrate/7386>\
**Category:** Questions\
**Tags:** calculus\
**Created:** [December 5, 2015, 11:41am UTC](https://community.wolfram.com/t/integrate-vs-nintegrate/7386 "2015-12-05T11:41:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mangriokamran](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mangriokamran](https://community.wolfram.com/u/mangriokamran)\
**Post date:** [December 5, 2015, 11:41am UTC](https://community.wolfram.com/t/integrate-vs-nintegrate/7386/1 "2015-12-05T11:41:42Z")

</div>

Why do Integrate and NIntegrate give different values for the same integral ???

```
In[7]:= Integrate[
  Exp[(Cos[\[Pi] x] - 1)/(2 \[Pi])] Cos[6*\[Pi]*x], {x, 0, 1}] // N

Out[7]= -3.97146*10^-10

In[8]:= NIntegrate[
 Exp[(Cos[\[Pi] x] - 1)/(2 \[Pi])] Cos[6*\[Pi]*x], {x, 0, 1}]

Out[8]= 3.01079*10^-10

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [December 5, 2015, 1:26pm UTC](https://community.wolfram.com/t/integrate-vs-nintegrate/7386/2 "2015-12-05T13:26:24Z")

</div>

The two results are very close to each other. If you calculate

```
a = Integrate[
   Exp[(Cos[\[Pi] x] - 1)/(2 \[Pi])] Cos[6*\[Pi]*x], {x, 0, 1}];
N[a]
N[a, 16]

```

you will see somewhat different results. This is probably due to the different methods used by N[a] and N[a,16].  
I understand that N[a] uses machine precision from the start, and the precision can degrade quite a bit.  
N[a,16] imposes that the end result has 16 accurate digits, and chooses the starting precision for that goal.  
It seems that NIntegrate in this case is more precise than N[Integrate] at machine precision.

---

<div class="post-metadata">

**Author:** ![mangriokamran](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mangriokamran](https://community.wolfram.com/u/mangriokamran)\
**Post date:** [December 5, 2015, 2:12pm UTC](https://community.wolfram.com/t/integrate-vs-nintegrate/7386/3 "2015-12-05T14:12:12Z")

</div>

Thanks a lot. Yes, you are right. I was confused by the negative and positive signs. But , when I quit local kernel (or restart mathematica) and Evaluate the two integrals then Integrate and NIntegrate give the same the same value.
