## 2 Mathematical Foundations
### Inversion Method  
Once the EGMS model has been defined, the calculation of the potential generated by a point current source is given by (4). In this section, the inverse problem of setting the constants associated with the chosen model will be addressed. Focusing on the EGMS model, from the BRL measurements using a device as shown in Figure 1, it is possible to find the parameters associated with each layer of the model. Indeed, from BRL measurements, the values \(\phi_{A,B}^{meas}\left(z\right)\) are available so that they represent the values that must be reproduced by the proposed soil model. From the EGMS model, \(\phi_{A,B}(z;\left\{C_{i1},C_{i2},\beta_{i}\right\}_{i=1\ldots N})\) is obtained, where \(\left\{C_{i1},C_{i2},\beta_{i}\right\}_{i=1\ldots N}\) represents the parameters associated with each layer, with N being the number of layers considered. This is sometimes referred to as the objective function. Points A and B in Figure 1 correspond to indices \(i\) and \(j\) in expression (4), where A is the source point and B is the field point where the potential will actually be evaluated. The model parameters can be found by an algorithm that minimizes  
\[\chi^{2}=\left[\phi_{A,B}^{meas}(z)-\phi_{A,B}(z;\left\{C_{i1},C_{i2},\beta_{i }\right\}_{i=1\ldots N})\right]^{2} \tag{6}\]In this work, a code written in MatLab (2023b) has been used, employing the fmin-search minimization routine operating on (6) according to the Nelder-Mead simplex algorithm. To achieve this, an initial set of model parameters is used to apply the direct method, calculating the theoretical value of the potential. The model parameters in the set are adjusted by approximately 5% of their value in successive iterations until an optimal set of parameters is obtained that minimizes (6) according to the established tolerance values.  
This procedure allows the parameters that define the function that represents the electrical conductivity in each layer to be obtained. Note that conductivity is non-continuous piecewise in general, since no supplementary conditions have been imposed on the interfaces. The variable conductivity model proposed here in each layer is only an approximation somewhat closer to the real world than the well-known HCMS. Nevertheless, it is possible to add conditions to the parameters in the minimization process described above to ensure that the discontinuity at the interfaces is the minimum possible. Such models will be classified as quasi-continuous models. The Lagrange multipliers method can be used to force continuity of conductivity at interfaces by expanding (6) to  
\[\begin{array}{l}\chi^{2}=[\vartheta_{A,B}^{meas}(z)-\phi_{A,B}(z;\{C_{i1},C_ {i2},\beta_{i}\}_{i=1...N})]^{2}+\\ \sum\limits_{i=1...N-1}\lambda_{i}\cdot(\sigma_{i}(\{C_{i1},C_{i2},\beta_{i} \};z_{i})-\sigma_{i+1}(\{C_{i+11},C_{i+12},\beta_{i+1}\};z_{i}))^{2}\end{array} \tag{7}\]  
where \(\lambda_{i}\) stands for the Lagrange multiplier whose number is equal to the number of interfaces, \(\sigma_{i}\) and \(\sigma_{i+1}\) are the conductivities on both sides of the interface \(i\), and \(z_{i}\) takes the value of the interface depth. This will not always improve the results obtained with the associated non-continuous model, although it is obvious that if the real conductivity behaves like a continuous EGMS model, continuity will arise by itself.