# Difficulty in deciding when to apply work-energy theorem [closed]

I was trying to do a certain question in physics and the answer I was obtaining was different than the actual answer I don't know why?
Two blocks A and B of the same mass connected with a spring are placed on a rough inclined plane, which makes an angle $$\theta$$ with horizontal. What minimum velocity should be given to A up the incline so that B just moves?
This is how I tried to do it. The force required to move B up the incline is $$kx$$ where x is elongation and k is spring constant. we know that spring force is greater than $$mg(sin\theta+\mu cos\theta)$$. And we can use work-energy theorem to figure out velocity. $$0.5*k*x^2=0.5*mv^2$$ where $$0.5*k*x^2$$ is work done by spring force. and when you count all the chickens $$v$$ turns out to be $$\sqrt{km}(gsin\theta+\mu gcos\theta)$$. Which apparently is the wrong answer. And the correct answer apparently is $$\sqrt{(3m)/k}(gsin\theta+\mu gcos\theta).$$ I have no idea what I did wrong. Can somebody help? is there something wrong with the WOrk energy theorem, or what? If the body is just about to move, then the net force on body(b) is zero, we just need a little push. Also all the initial kinetic energy of body(a) will be used, since body(b) in the end is very close to rest. $$mgsin{\theta}+\mu{mg}cos{\theta}=kx$$ Using work-energy principle. $$\frac{1}{2}mv_{i}^2=\sum{W}$$ $$\frac{1}{2}mv_{i}^2=mgsin{\theta}x+\frac{1}{2}kx^2+\mu{mg}cos{\theta}x$$ $$\frac{1}{2}mv_{i}^2=\frac{1}{2}kx^2+kx^2$$ $$v_{i}=x\sqrt{\frac{3k}{m}}$$ Substitute x and rest is solvable.