Possible error for Simpson's Rule in RSI diffraction relizations?

Issue #24 new
Former user created an issue

As has been pointed in the original comment, This paper introduces the way of using Simpson's Rule to improve the accuracy:

F. Shen and A. Wang, “Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula,” Appl. Opt., vol. 45, no. 6, pp. 1102–1110, 2006.

The correct coefficients of Simpson rule should be

$\frac{1}{3}[1, 4, 2, 4, 2, ... 2, 4, 1]$

but by using the following code,

       if precise:
            # matrix W para integracion simpson
            a = [2, 4]
            num_rep = int(round((nx) / 2) - 1)

            b = array(a * num_rep)
            W = concatenate(((1, ), b, (2, 1))) / 3.

            if float(nx) / 2 == round(nx / 2):  # es par
                i_central = num_rep + 1
                W = concatenate((W[:i_central], W[i_central + 1:]))
        else:
            W = 1

the final coefficients would be

$\frac{1}{3}[1, 2, 4, 2,4, ... 2, 4, 2, 1]$

This will give relative different results. I'm not sure whther this is an error or it's because of my misunstanding on this method?

Comments (0)

  1. Log in to comment