Numerical integration - singularity
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
David Hill
2021-7-14
Based on the graph, it should not be a time consuming integration. Provide your code.
David Goodmanson
2021-7-16
Hi MQ,
Could you provide the function that produces the singularity? From the plot, the function does not look all that singular.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!