The solution of a differential equation contains the forward model and the inverse problem. The finite element method (FEM) and the iterative approach based on FEM are extensively used to solve varied differential equations. Although FEM could obtain an accurate solution, the shortcoming of the approach is the high computational costs. This paper proposes an improved finite-element neural network (FENN) embedding a FEM in a neural network structure for solving the forward model while a conjugate gradient (CG) method is employed as the learning algorithm. Taking the 3-D magnetic field analysis in magnetic flux leakage (MFL) testing as an example, the comparison between CG algorithm and the gradient descent (GD) algorithm is presented. The vector plot of magnetic field intensity is obtained, and the vertical components of magnetic flux density are respectively analyzed. The iterative approach based on FENN and parallel radial wavelet basis function neural network is also adopted to solve the inverse problem. This approach iteratively adjusts weights of the inverse network to minimize the error between the measured and predicted values of MFL signals. The forward and inverse results indicate that FENN and the iterative approach are feasible methods with rapidness, accuracy and stability associated with 3-D different equations in MFL testing.Index Terms-Conjugate gradient (CG) algorithm, finite-element method (FEM), finite-element neural network (FENN), forward model, inverse problem, magnetic flux leakage (MFL) testing.