Numerical integration - singularity
7 views (last 30 days)
Show older comments
I have discrete datas of a function and I would like to evaluate its integral. I can produce infinite number of points for my function. I attach the plot of the function here.

I used two approaches. First i used "trapz" function and secondly I used "griddedInterpolant" or "interp1" with "spline" and "cubic" methods to be able to use the quadgk and Integral function(I used absError and relError as well). Both of these approaches produce significant error, and it does not matter if I use 10k or 10million points, the error is the same!
someone suggested to use vpa, but if drastically reduces speed and even with 10k points the error did not reduce.
Also when i use vpaintegral instead of integral, i get the error about using wrong arguments.
When I do the same for a function smoother than this one, my code works and the error is less (compared to analytical result) so i am nearly sure that my code is correct and the problem is related to the shape of this function
I would appreciate any help.
2 Comments
David Hill
on 14 Jul 2021
Based on the graph, it should not be a time consuming integration. Provide your code.
David Goodmanson
on 16 Jul 2021
Hi MQ,
Could you provide the function that produces the singularity? From the plot, the function does not look all that singular.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!