Abstract
Some time ago, someone gave me the next solution:
$$U=-\int \vec{m}\small{(x)}\times \vec{B}(x)dV$$ $$\vec{F}=-\nabla U$$
In other stack site I’ve asked, how to solve it numerically, and one user pointed that formulas are wrong, because $U$ is a number, not a field, and, hence, gradient operation can’t be applied to it.
I surely know that force is a negative gradient of potential energy, so the second formula is true.
Also, magnetic moment times magnetic inductance gives joules, i.e. potential energy. If I just multiply $\vec{m}$ at some point by $\vec{B}$ at the same point, I will have the potential energy value $U$ at that point. What is the purpose of the volume integral, then in the formula above?
Question
If I have magnetic moment and magnetic inductance values at every point of space, how can I find a force at every point of space?
My try
Okay, force is gradient of potential energy with minus sign, it’s for sure.
$$\vec{F}=-\nabla U$$
Magnetic moment times magnetic inductance gives something in joules units, it is energy, for sure. Relation between Force, i.e. Newtons and Energy, i.e. Joules is
$$N=\dfrac{J}{m}$$
Newtons equals Joules per meter. Nabla operator gives also “meters” in denominator:
$$\nabla=\dfrac{d\phi}{dx}+ \dfrac{d\phi}{dy}+ \dfrac{d\phi}{dz}$$
As I pointed in the question, I mentioned above, I will find force not at every point of some volume, because it is impossible, but at points with some step. For example for volume 1m*1m*1m I will find values with step, say, 100mm, i.e. 10 points in a row, and $10^3$ in total.
I will have known magnetic moment and magnetic inductance value for each point.
What if I will find energy at a point as just
$$U(x_0,y_0,z_0)= |\vec{m}\small{(x_0,y_0,z_0)}|* |\vec{B}(x_0,y_0,z_0)| * cos\theta$$
And then F as
$$\vec{F}(x_0,y_0,z_0)=\dfrac{U(x_0+k,y_0,z_0)-U(x_0,y_0,z_0)}{k}\vec{i}+ \dfrac{U(x_0,y_0+k,z_0)-U(x_0,y_0,z_0)}{k}\vec{j}+ \dfrac{U(x_0,y_0,z_0+k)-U(x_0,y_0,z_0)}{k}\vec{k}$$
Where k is step, i.e. 0.1 m. But it will not give a vector value...