<html>#2398: Multipole: Default (midpoint) integration method incorrectly implemented, yielding wrong results... especially with m=odd modes
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Zach Etienne</td></tr>
<tr><td style='text-align:right'>   Status:</td><td>open</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'>  Version:</td><td></td></tr>
<tr><td style='text-align:right'>     Type:</td><td>bug</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>major</td></tr>
<tr><td style='text-align:right'>Component:</td><td>EinsteinToolkit thorn</td></tr>
</table>

<p>Comment (by Roland Haas):</p>
<p>I dug a bit deeper and it turns out the lower convergence order reported in <code>repos/einsteinanalysis/Multipole/test/test_22/test_midpoint_convergence_order..asc</code> is a bit of a red herring. The order is indeed lower for the coded up midpoint rule if given an arbitrary polynomial (which the code to compute order uses), however the physics code does not use an arbitrary polynomial but instead a function of the form <code>f(theta) = sin(theta) g(theta)</code> in which case (adjusting for double counting in <code>phi</code>) the convergence order of the coded up “midpoint” rule actually happens to be 2. This is because the code happens to implement a rule:</p>
<div class="codehilite"><pre><span></span>int(f, x) = f(x_0)*dx/2 + sum(f(x_i)*dx,i=1..N-1)) + f(x_N)*dx/2
</pre></div>


<p>ie a midpoint rule for the interval [x_{1/2},x_{N-1/2}] with just Riemann sums using lower / upper values for the endpoints x_0 and x_N (with incorrect weights but since the contribution is always 0 this does not matter). This also turns out to be exactly the formula for the trapezoidal rule in the theta direction.</p>
<p>So, looking at this now, I would say:</p>
<ol>
<li>in the theta direction, given the currently fixed evaluation points<code>x_i = i * pi/ntheta</code> (used in other places of Multipole than just integration so possibly not so straightforward to change) the code does as good as it can. Depending on the point of view one takes it either implements a strange midpoint rule with Riemann sum endcaps (and incorrect weights) or the trapezoidal rule (with the same incorrect weights).</li>
<li>integration in phi is off because it double counts the phi=0=2pi point. A fix there is to reduce the integration range to “&lt; ny” (phi is “y”). This seems to be source of convergence failure.</li>
</ol>
<p>So, since in the phi direction, for periodic data, the trapezoidal rule and midpoint rule are identical and, as explained above, the “midpoint” rule implemented in the theta direction, for the case of a sin(theta) factor pre
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2398/multipole-default-midpoint-integration'>https://bitbucket.org/einsteintoolkit/tickets/issues/2398/multipole-default-midpoint-integration</a></p>
</html>