# Arbitrary Sampling Fourier Transform and Its Applications in Magnetic Field Forward Modeling
## 2 Methods
### 1d As-ft  
One-dimensional Fourier forward transform and inverse transform can be expressed as [35]:  
\[\left\{\begin{array}{l}F(k_{x})=\int_{-\infty}^{\infty}f(x)e^{-ik_{x}x}dx\\ f(x)=\frac{1}{2\pi}\int_{-\infty}^{\infty}F(k_{x})e^{ik_{x}x}dk_{x}\end{array} \right.. \tag{1}\]  
where \(k_{x}\) represents the wavenumbers in the direction of \(x\). \(f(x)\) is a spatial domain function and \(F(k_{x})\) is a wavenumber domain function. \(f(x)\) and \(F(k_{x})\) are each other's Fourier transform functions.  
Discretize the forward transform integral in the Equation (1)  
\[F(k_{x})=\sum_{j=1}^{M}\int_{f_{j}}f(x)e^{-ik_{x}x}dx. \tag{2}\]  
where \(M\) represents the number of elements and \(e_{j}\) represents the \(j\)th element.  
The interpolation function of the AS-FT algorithm in this paper can be linear, quadratic, cubic, or higher-order. The higher the degree of the interpolation function, the stronger the ability of a polynomial function to approximate complex function, and the higher the calculation accuracy of the integral is. This section takes quadratic shape-function interpolation as an example to introduce the arbitrary Fourier transform algorithm. A quadratic interpolation shape function is used in the element. Suppose that the coordinates of three nodes in any element are \(x_{1}\), \(x_{2}\), and \(x_{3}\), and \(x_{2}\) is the midpoint, which meets \(x_{1}+x_{3}=2x_{2}\). The nodes in the element are shown in Figure 1:  
The values on each node are \(f(x_{1}),f(x_{2}),f(x_{3})\), respectively. \(f(x)\) can be expressed by a quadratic shape function [36]  
\[f(x)=N_{1}f(x_{1})+N_{2}f(x_{2})+N_{3}f(x_{3}), \tag{3}\]  
Figure 1: Schematic diagram of elements and nodes in the element.  
where,  
\[\begin{array}{l}N_{1}=\frac{(x-x_{2})(x-x_{2})}{(x_{1}-x_{2})(x_{1}-x_{3})}\\ N_{2}=\frac{(x-x_{1})(x-x_{3})}{(x_{2}-x_{1})(x_{2}-x_{3})}\\ N_{3}=\frac{(x-x_{1})(x-x_{2})}{(x_{3}-x_{1})(x_{3}-x_{2})}\end{array} \tag{4}\]  
Therefore, Equation (2) can be rewritten as  
\[F(k_{x})=\sum_{j=1}^{M}\big{[}\int_{x_{1}}^{x_{3}}N_{1}f(x_{1})e^{-ik_{x}x}dx+ \int_{x_{1}}^{x_{3}}N_{2}f(x_{2})e^{-ik_{x}x}dx+\int_{x_{1}}^{x_{3}}N_{3}f(x_{3} )e^{-ik_{x}x}dx\big{]}. \tag{5}\]  
Let \(W_{1}=\int_{x_{1}}^{x_{3}}N_{1}e^{-ik_{x}x}dx\), \(W_{2}^{0}=\int_{x_{1}}^{x_{3}}N_{2}dx\) and \(W_{3}=\int_{x_{1}}^{x_{3}}N_{3}e^{-ik_{x}x}dx\) be the node coefficients of the Fourier transform in the element; then the Equation (5) is abbreviated as  
\[F(k_{x})=\sum_{j=1}^{M}[f(x_{1})W_{1}+f(x_{2})W_{2}+f(x_{3})W_{3}]. \tag{6}\]  
When the wavenumber \(k_{x}\) is not equal to 0, the Fourier transform node coefficients in the element can be obtained by substituting Equation (4); see Appendix A Equations (A1)-(A3) for details.  
When the wavenumber \(k_{x}\) is equal to 0, \(W_{1}^{0}=\int_{x_{1}}^{x_{3}}N_{1}dx\), \(W_{2}^{0}=\int_{x_{1}}^{x_{3}}N_{2}dx\), \(W_{3}^{0}=\int_{x_{1}}^{x_{2}}N_{3}dx\) can be integrated to obtain the node coefficient of the Fourier transform at zero wavenumbers as  
\[\begin{cases}W_{1}^{0}=\frac{1}{6}(x_{3}-x_{1})\\ W_{2}^{0}=\frac{5}{3}(x_{3}-x_{1})\\ W_{3}^{0}=\frac{1}{6}(x_{3}-x_{1})\end{cases}. \tag{7}\]  
The final result of the 1D Fourier transform can be obtained by adding up the semi-analytical expressions of different elements. Notably, when the spatial domain and frequency domain partitions are unchanged, the Fourier transform node coefficients \(W_{1}\), \(W_{2}\), \(W_{3}\), \(W_{1}^{0}\), \(W_{2}^{0}\), and \(W_{3}^{0}\) are unchanged. Calculating and storing the Fourier transform coefficients in advance can reduce repeated calculations and improve the algorithm's efficiency, which is also one of the advantages of this algorithm.  
In addition, because the forward and inverse transform have the same form, the final expression result of the inverse Fourier transform is similar to the forward transform expression, so it will not be introduced.