0

On the subject of adaptive trapezoidal subdivision (see this and this), I need to solve a problem where evaluating f(x) takes a lot of time, so I need to do it the least number of times possible.

Searching on SO I found this answer: https://stackoverflow.com/a/29837372/261010

Rather than considering the error in each subinterval separately, more advanced codes compute the total error over all the subintervals and refine until the total error is below the desired threshold. Subintervals are chosen for refinement according to their contribution to the total error, with larger errors being refined first. Typically a priority queue is used to quickly chose the subinterval for refinement.

What does this mean exactly? How does the priority queue help in this scenario? How many subintervals can be considered "larger"?

abenci
  • 8,422
  • 19
  • 69
  • 134
  • I’m not sure what you’re asking. Do you understand what a priority queue is, and what it’s normally used for? – Sneftel Aug 29 '20 at 08:34
  • How do I define the subintervals with larger errors? How I do it with a priority queue? – abenci Aug 29 '20 at 08:36
  • You do not need a priority queue if you use as refinement condition that the error of a sub-interval has to be proportional to the sub-interval, as it is done in the cited code. This gives the same final sub-division independent of the order that the sub-intervals are examined. – Lutz Lehmann Aug 29 '20 at 09:22
  • 1
    See also https://math.stackexchange.com/questions/3728179/saving-nodes-in-iterative-adaptive-simpson-quadrature-method-matlab/3728664#3728664 for a related problem with visualization. – Lutz Lehmann Aug 29 '20 at 09:31
  • 1
    What the priority queue approach allows to achieve is a sequence of subdivisions with falling total error that are optimal for their estimated total error. For that the sorting measure has to be the estimated error of the sub-interval divided by the interval length. – Lutz Lehmann Aug 29 '20 at 10:31
  • Side note: Never use trapezoidal quadrature, always go for midpoint. – Nico Schlömer Aug 30 '20 at 11:04
  • @Lutz, please try to add an answer. I'm not happy with what I got so far. In my specific case, I'm trying to minimize the angles between one interval segment and the contiguous one. – abenci Aug 30 '20 at 17:39
  • I do not quite understand what you mean with "angles between one interval segment and the contiguous one". The geometry of the graph critically depends on the scale of the function, or in other words, there is no natural "Euclidean" connection between the domain and range scale. What is wrong with using Richardson extrapolation for the error estimate? – Lutz Lehmann Aug 30 '20 at 18:17
  • @NicoSchlömer : Are there any striking examples for that claim? Apart from one less function evaluation and that the first error term has the opposite sign, what other large differences are there between the methods? In the adaptive scheme there is no re-use of previously computed values, splitting a segment requires 2 new values while in the trapezium method one only needs 1 new value. – Lutz Lehmann Aug 30 '20 at 18:21
  • I'm drawing geometric shapes at 1:1 scale, so the angle/smoothness of the segments is a good estimate. – abenci Aug 31 '20 at 06:20
  • @LutzLehmann The upper bound for the first error term is _half_, see https://math.stackexchange.com/q/603830/36678. – Nico Schlömer Aug 31 '20 at 09:23
  • @NicoSchlömer : While it is said that one should care about factors of 2, the difference is not that big for such a radical/forceful claim. And it is only true for the equidistant scheme. What about the adaptive scheme using the same number of function evaluations? – Lutz Lehmann Aug 31 '20 at 09:43
  • @LutzLehmann Given any intricate quadrature scheme and a weird one-point integration scheme that "shouldn't" work, one can always find a function that is better integrated by the weird scheme. That's why, in general, all results in quadrature restrict the space of functions, mostly in terms of smoothness. If you know nothing about the function you integrate, anything can happen. Also, the error terms I linked are local errors, so it doesn't matter much if the scheme is adaptive or not. The local error of midpoint has a sharper error bound. If you can choose, why throw that away? – Nico Schlömer Aug 31 '20 at 10:24
  • @NicoSchlömer : Because, as I said before, subdividing under midpoint requires two new function values, while trapezium only requires one. Thus the comparison by function evaluations. Now one can reuse the existing point under midpoint usefully by trisecting the segment, so that the old value is the required value for the middle interval. This might then be again competitive. // What is the "weird scheme"? Adaptive-grid/mesh methods are quite standard. – Lutz Lehmann Aug 31 '20 at 10:56

1 Answers1

2

The priority queue is not used to compute the error in each interval. Instead, it’s used to track which interval currently has the largest error, so the algorithm can refine it. This pattern with a priority queue is used in many so-called “greedy” algorithms, such as Dijkstra search and Prim’s algorithm.

Sneftel
  • 40,271
  • 12
  • 71
  • 104
  • Sounds hard, I've checked Wikipedia for all the algorithms you mentioned and the descriptions are very generic. Do you know where I can learn more about these algorithms for my specific scenario? – abenci Aug 29 '20 at 09:50
  • Try Cormen’s *Introduction to Algorithms*. – Sneftel Aug 29 '20 at 11:35