# How to do numerical integration  from data set?

**URL:** <https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060>\
**Category:** Questions\
**Tags:** calculus, numerical-computation\
**Created:** [April 24, 2014, 5:50pm UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060 "2014-04-24T17:50:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukeaschutzenhofer](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@lukeaschutzenhofer](https://community.wolfram.com/u/lukeaschutzenhofer)\
**Post date:** [April 24, 2014, 5:50pm UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/1 "2014-04-24T17:50:35Z")

</div>

How to do numerical integration from a data set?

---

<div class="post-metadata">

**Author:** ![dreiss](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss/32/29094_2.png) [@dreiss](https://community.wolfram.com/u/dreiss)\
**Post date:** [April 24, 2014, 7:04pm UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/2 "2014-04-24T19:04:31Z")

</div>

Look up **Interpolation** and **NIntegrate**. Here is an example:

```auto
fun = Interpolation[{{0, 0}, {0.1, .3}, {0.5, .6}, {1, -.2}, {2, 3}}]

NIntegrate[fun[x], {x, 0, 2}]

```

---

<div class="post-metadata">

**Author:** ![lehinp](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/lehinp/32/8056_2.png) [@lehinp](https://community.wolfram.com/u/lehinp)\
**Post date:** [April 26, 2014, 9:49am UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/3 "2014-04-26T09:49:16Z")

</div>

Strongly related SE thread: [How to integrate functions of linearly interpolated data?](http://mathematica.stackexchange.com/q/18863/280)

---

<div class="post-metadata">

**Author:** ![lukeaschutzenhofer](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@lukeaschutzenhofer](https://community.wolfram.com/u/lukeaschutzenhofer)\
**Post date:** [May 19, 2014, 1:28am UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/4 "2014-05-19T01:28:10Z")

</div>

When I integrate using the definite integral symbol in conjunction with the N symbol I get a small complex numerical in addition to the correct answer. What does that mean and what action is necessary.  
Luke

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [May 19, 2014, 2:48am UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/5 "2014-05-19T02:48:11Z")

</div>

Use the Chop command.

[http://reference.wolfram.com/mathematica/ref/Chop.html](http://reference.wolfram.com/mathematica/ref/Chop.html)

Or you can use Re to get the real part of the complex number.

---

<div class="post-metadata">

**Author:** ![brucem](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/brucem/32/26319_2.png) [@brucem](https://community.wolfram.com/u/brucem)\
**Post date:** [May 19, 2014, 5:02pm UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/6 "2014-05-19T17:02:16Z")

</div>

What it means is that during the calculation there were two complex intermediate results whose imaginary components almost cancelled.

If the calculation were done with exact numbers (Integers and Rationals), the imaginary components would have exactly cancelled.

---

<div class="post-metadata">

**Author:** ![lukeaschutzenhofer](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@lukeaschutzenhofer](https://community.wolfram.com/u/lukeaschutzenhofer)\
**Post date:** [May 20, 2014, 2:48pm UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/7 "2014-05-20T14:48:23Z")

</div>

How do I import excell data to mathematica and inverse

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [May 20, 2014, 2:55pm UTC](https://community.wolfram.com/t/how-to-do-numerical-integration-from-data-set/2060/8 "2014-05-20T14:55:51Z")

</div>

Please see these examples in the documentation.

[  
http://reference.wolfram.com/mathematica/howto/ImportASpreadsheet.html](http://reference.wolfram.com/mathematica/howto/ImportASpreadsheet.html)  
[http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html](http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html)
