Find the work done against the force If there is a force $\mathbf F(x)=ax\hat i$ and an object is moving from $x_2>0$ to $x_1>0$ in the opposite direction of force. Then work could be calculated as follows
$$\int_{x_2}^{x_1} -F(x)\cdot\text dx$$ 
the negative sign is because the direction between $\mathbf F(x)$ and $\text dx$ are anti-parallel
$$-\int_{x_2}^{x_1} ax\cdot\text dx$$
$$-a(\frac{x_1^2-x_2^2}{2})$$
since $x_1 < x_2$, therefore $x_1^2<x_2^2$
so
$$x_1^2-x_2^2 < 0$$
and
$$-a(\frac{x_1^2-x_2^2}{2})>0$$
So my calculation shows that the work done in going against the force is positive, which is absolutely wrong. 
 A: 
the negative sign is because the direction between $\mathbf F(x)$ and $\text dx$ are anti-parallel

Here is the mistake. Your issue is in putting the negative sign into your integral. If $x_2>x_1$, then the sign of $\text d x$ is already negative. You don't need to explicitly say what the sign of $\text dx$ is. The sign of the infinitesimal is encoded in the limits of integration. Therefore, the work done by the force is just $$\int_{x_2}^{x_1}F\cdot\text dx$$
Additionally I will point out a minor flaw in terminology. There is no "work done against a force". Your calculations are showing that you are just calculating the work done by your force. That is all it is. Forces do work, and the work done by a force does not depend on the presence of other forces (assuming you already know the path the object takes due to all forces acting on it). You don't need to add the complexity of saying doing "work against a force". It is confusing, because I thought you were interested in looking at the work you would have to do to move the object against this force, but this was not what you were looking at. It is much less confusing just to say "what is the work done by this force?"
A: You can either say work done by the force is $\int_{x2}^{x1} F(x)dx$ (as Aaron Stevens says, this is always correct regardless of the direction of motion), or equivalently you can say work done against the force is $-\int_{x2}^{x1} F(x)dx$. Since work done by the force is negative, then work done against the force is positive i.e. your answer is correct.
