Which could serve the purpose except that periodicity disappears at the beginning of the curve: the well becomes deeper than what it should be. How can I enforce periodicity on the fitting function?
I actually need to use the Fourier series because I will repeat the process on much smoother potentials. I have tried Fourier series to fit another more wiggling potential and the same problem occurred; the first well became deeper.
Interpolation works fantastically but I need the fitting function itself because I need to calculate Hamiltonian matrix elements. After using Interpolation it is possible to perform integration and differentiation on the InterpolatingFunction, but it is not possible to do that when combining the InterpolatingFunction with other expressions.