I had many problems because I was adding a complex external force to my system and had always errors with it. I realized then that LAMMPS does not interpret well the function power "^" of my forces (at least in the LAMMPS version that I have). For checking the problem, I defined the next variables:
variable prueba equal "-(2)^2"
variable prueba2 equal "-(2^2)"
variable prueba3 equal "-2^2"
And what it prints is
This was very strange for me, as I would expect to get the value "-4" in all cases and makes it quite messy for adding complex equations. I do not know if this is already fixed, but if it is not, hope it is helpful for developers.