SPH Approximation of different functions:
In this example we discretized a linear and a quadratic polynomial as well as a trigonometric function using SPH with the cubic spline kernel [KBST19, KBST22]. The left plot shows the particle sampling pattern while the right plot shows the exact functions and their SPH approximations. To compute the SPH approximations the function values are sampled along the red line in the left plot. That means that for each point on the line the neighbors are determined and the SPH approximation formula is applied:
$$\langle f(x,y) \rangle = \sum_j \frac{m_j}{\rho_j} f(x_j,y_j) W_{ij}$$
Linear function:
$$f(x,y) = \frac12 (x+y)$$
Quadratic_function:
$$f(x,y) = \frac12 (x^2+y^2)1$$
Trigonometric function:
$$f(x,y) = \sin(5 x) \cos(3y)$$
Shepard filter
The SPH approximation of a fluid quantity is errorprone if the particle neighborhood is only partially filled. To consider this in the computation the smoothing kernel can be corrected by a factor $s_i$:
$$\tilde {W}_{ij} = s_i W_{ij} = \frac{1}{\sum_k \frac{m_k}{\rho_k} W_{ik}} W_{ij}.$$
References
 [KBST19] Dan Koschier, Jan Bender, Barbara Solenthaler, Matthias Teschner. Smoothed Particle Hydrodynamics for PhysicallyBased Simulation of Fluids and Solids. Eurographics Tutorial, 2019
 [KBST22] Dan Koschier, Jan Bender, Barbara Solenthaler, Matthias Teschner. A Survey on SPH Methods in Computer Graphics. Computer Graphics Forum, 2022
