0
$\begingroup$

I have an interpolated function that was based on a list of data points taken from a csv

s = Import["C:\\data.csv"];
power = s[[All, {1, 2}]];
interpower = Interpolation[power, InterpolationOrder -> 1];

The graph of the interpolated function looks very much like a ListLinePlot of the data points :

enter image description here

Now I need to integrate this interpolated function in such a way that everything below x-axis would be considered positive. Of course regular integration takes everything below x-axis as negative values. Simple inversion of negative data points increases the result of integration since resolution isn't good enough. I tried to apply Abs[] to the interpolated function which made it look like this:

enter image description here

It seems like just what I need but now the problem is that if I try to integrate this function:

result = Integrate[Abs[interpower[x]], {x, 0, 0.0004}]

It gives the following result:

enter image description here

This is of no use to me because I need just a number as my result. Is there a way I could solve this problem?

$\endgroup$
2
$\begingroup$

If all you need is a number, you should use NIntegrate, not Integrate. The former is for numerical integration, the latter for symbolic integration.

$\endgroup$
  • $\begingroup$ Thank you very much! This helped. NIntegrate is the answer. $\endgroup$ – space bobcat Sep 12 '16 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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