1
$\begingroup$

I am facing a problem with integrating a function. I have to integrate the function "bit by bit". This is the smallest working example that shows the problem:

n = 25;
dz = 1300/n;
pBF = FunctionInterpolation[
       Piecewise[{{9890/3, 500 <= z <= 800}}], 
       {z, 0, 1300}, InterpolationOrder -> 1
      ];
data = Prepend[0]@Table[Integrate[pBF[z] z, {z, (j - 1) dz, j dz}], {j, n}];
Data = Accumulate[data];
DataInt = Interpolation[Table[{k dz, Data[[k + 1]]}, {k, 0, n}], InterpolationOrder -> 1]

Insted of creating an InterpolatingFunction Mathematica prints the two error messages:

Integrate::ilim: Invalid integration variable or limit(s) in {0.026557142857,0,52}. NIntegrate::itraw: Raw object 0.026557142857142856` cannot be used as an iterator.

The strange thing with this is the fact that when I look at the data-points in a ListPlot the function should not be hard to interpolate. The picture shows the ListPlot.scatter plot of calculated data obtained from ListPlo

$\endgroup$

1 Answer 1

1
$\begingroup$

I solved the problem by using NIntegrate and defining the AccuracyGoal and the MinRecursion option for this function.

data2 = Prepend[0]@
   Table[NIntegrate[pBF[z] z, {z, (j - 1) dz, j dz}, 
     MinRecursion -> 9, AccuracyGoal -> 5], {j, n}];

The interpolation is also working as seen in the picture:
Interpolation of Data

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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