The answer is actually (1/3)As^3+(1/2)Bs^2
Actually there is work done by an external force (pointing toward the left) in order to compress the spring in the first place. The force and direction of motion are in the same direction. See if that helps it come out right for you. The spring will do work to move the cart, starting at some position -s like you said and moving towards 0, so you should integrate from -s to 0 to calculate the work done by the spring as it is released.
Firstly, well done noting that the force on the cart and the displacement of the cart point in opposite directions.
Secondly, your bounds should not be from zero to [itex]-s[/itex] but from zero to [itex]s[/itex]. This is because [itex]s[/itex] represents a displacement from equilibrium, not a particular point on the ruler. It is not important that you travelled from a specific location [itex]x_1[/itex] to [itex]x_2[/itex]. Rather, this equation wants you to input the distance [itex]s[/itex] that was traveled.
I'm not real up-to-speed on these kinds of problems, so pardon me for that. But you have an equation F = As2 + Bs. So what that tells me is that as s gets larger, the force gets larger. So in compressing the spring, which you are doing, s should be getting larger. So why are you integrating from 0 to -s. Wouldn't that be stretching the spring, not compressing it?
Oh so in the standard F=kx, the x is the distance? Not the position? That makes so much more sense. Thanks.
Separate names with a comma.