<div dir="ltr">Best one I think:<br><div><br><a href="http://www.intmath.com/integration/6-simpsons-rule.php">http://www.intmath.com/integration/6-simpsons-rule.php</a><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 17, 2015 at 1:50 PM, Bill Spitzak <span dir="ltr"><<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>This was based on looking up Simpson's integration on the web, from the wikipedia page and another page I found.<br><br></div><div>It cuts the samples into sets of 3, with an overlap of 1. Each set then weighs 1,4,1 in the average, to simulate the weight of the control points of a cubic curve. Since the overlapping samples of 1 add to 2 this results in 1,4,2,4,2,...4,1 as the weights.  As there are two points per set and the total weight is 1+4+1=6, you divide the full sum by 6/2 = 3.<br><br></div><div>It appears this implementation attempted to overlap them by 2, resulting in weights of 1,5,6,...6,5,1. However this is very close to a flat average of all the points. Also this is a total of 6 for every point so the divisor should be 6, but it was left at 3.<br><br></div><div>Based on my reading the new version is correct. However I have not been able to see any visible difference in the filtering even if I reduce the number of samples to 3.<br><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 17, 2015 at 10:21 AM, Oded Gabbay <span dir="ltr"><<a href="mailto:oded.gabbay@gmail.com" target="_blank">oded.gabbay@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On Thu, Dec 17, 2015 at 8:20 PM, Oded Gabbay <<a href="mailto:oded.gabbay@gmail.com" target="_blank">oded.gabbay@gmail.com</a>> wrote:<br>
> On Sat, Dec 12, 2015 at 8:06 PM,  <<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>> wrote:<br>
>> From: Bill Spitzak <<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>><br>
>><br>
>> Simpsons uses cubic curve fitting, with 3 samples defining each cubic. This<br>
>> makes the weights of the samples be in a pattern of 1,4,2,4,2...4,1, and then<br>
>> dividing the result by 3.<br>
>><br>
>> The previous code was using weights of 1,2,6,6...6,2,1 which produced about 2x<br>
>> the correct value, as it was still dividing by 3. The filter normalization<br>
>> removed this error. Also this is effectively a linear interpolation except for<br>
>> the ends.<br>
>> ---<br>
>>  pixman/pixman-filter.c | 11 +++++++----<br>
>>  1 file changed, 7 insertions(+), 4 deletions(-)<br>
>><br>
>> diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c<br>
>> index 15f9069..7c1da0d 100644<br>
>> --- a/pixman/pixman-filter.c<br>
>> +++ b/pixman/pixman-filter.c<br>
>> @@ -204,11 +204,14 @@ integral (pixman_kernel_t reconstruct, double x1,<br>
>>         {<br>
>>             double a1 = x1 + h * i;<br>
>>             double a2 = x2 + h * i;<br>
>> +           s += 4 * SAMPLE(a1, a2);<br>
>> +       }<br>
>><br>
>> -           s += 2 * SAMPLE (a1, a2);<br>
>> -<br>
>> -           if (i >= 2 && i < N_SEGMENTS - 1)<br>
>> -               s += 4 * SAMPLE (a1, a2);<br>
>> +       for (i = 2; i < N_SEGMENTS; i += 2)<br>
>> +       {<br>
>> +           double a1 = x1 + h * i;<br>
>> +           double a2 = x2 + h * i;<br>
>> +           s += 2 * SAMPLE(a1, a2);<br>
>>         }<br>
>><br>
>>         s += SAMPLE (x1 + width, x2 + width);<br>
>> --<br>
>> 1.9.1<br>
>><br>
>> _______________________________________________<br>
>> Pixman mailing list<br>
>> <a href="mailto:Pixman@lists.freedesktop.org" target="_blank">Pixman@lists.freedesktop.org</a><br>
>> <a href="http://lists.freedesktop.org/mailman/listinfo/pixman" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/pixman</a><br>
><br>
> You say:<br>
><br>
> "The filter normalization removed this error. Also this is effectively<br>
> a linear interpolation except for the ends."<br>
><br>
> So if the error was removed, why is this change needed ? I can see it<br>
> is more accurate (similar to the Simpson equation), but it also causes<br>
> the code to run over the loop twice.<br>
><br>
> Do you have some example we can see the difference ?<br>
><br>
><br>
>     Oded<br>
<br>
</div></div>OK, now I see that in the next patch, you reduce the samples from 128<br>
to 16, so we are now running less iterations.<br>
I still would be happy to see an example with my own eyes where this<br>
makes a difference.<br>
<span><font color="#888888"><br>
        Oded<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>