# How to use the "variable" command to define formula?

Dear all lammps users.
Here part of the commands are following:

compute a mobile reduce sum c_ss[1]
compute b mobile reduce sum c_ss[2]
compute c mobile reduce sum c_ss[3]
compute d mobile reduce sum c_ss[4]
compute e mobile reduce sum c_ss[5]
compute f mobile reduce sum c_ss[6]
Now I want to use the “variable” command to define the formula {(a-b)^2+(b-c)^2+(c-a)^2+6*(d^2+e^2+f^2)}*0.5, what should I do.

Dear all lammps users.
Here part of the commands are following:
compute a mobile reduce sum c_ss[1]
compute b mobile reduce sum c_ss[2]
compute c mobile reduce sum c_ss[3]
compute d mobile reduce sum c_ss[4]
compute e mobile reduce sum c_ss[5]
compute f mobile reduce sum c_ss[6]

​what you are doing here is *very* inefficient. you can do the same
operation with just ​one compute reduce sum command.

Now I want to use the "variable" command to define the formula {(a-b)^2+
(b-c)^2+(c-a)^2+6*(d^2+e^2+f^2)}*0.5, what should I do.

​study the documentation for the variable command very carefully. it is
very detailed and has ​examples same as the compute reduce documentation.

axel.