Solving a problem regarding a block sliding down a ramp A body of mass $5×10^{-3} kg$ is launched up a ramp making a $30°$ angle with the horizontal, and it takes twice as much time to slide down than it took to get to the top, find coefficient of friction ($\mu$).
Anyway to solve one of the steps involved finding acceleration
$$g \sin(x) - \mu g\cos(x) = a$$ (for descent)
$$g \sin(x) + \mu g\cos(x) = a$$ (for ascent)
I don't understand how (for ascent) the components can be added when friction will always act in direction opposite to motion, please elaborate
 A: For both ascent and descent the positive axis for displacement, velocity and acceleration is taken as down the slope. So $a$ is positive in both cases. (We expect the value of $a$ to be different for ascent and descent so you should use different symbols to distinguish them - eg by writing $a_1, a_2$ or  $a_u,a_d$.)
The component of gravity  $g\sin(x)$ always acts down the slope so it positive both for ascent and descent.
Friction opposes (the tendency towards) relative motion between the surfaces in contact. So on the ascent (motion upwards) friction $\mu g\cos(x)$ points down the slope - it is positive. On the descent (motion downwards) friction points up the slope - so it is negative. Its magnitude does not change, only its direction, so we do not need to use different symbols.
A: Friction does not always act in direction opposite to motion. When car accelerates, nothing can act on it but friction force acting on wheels. Or when you move on your legs it is friction force which gives you acceleration.
A: Friction opposes the actual or impending motion of the body it acts upon. The effect can at first seem counter-intuitive.  For example, when your foot (or a wheel) pushes on the ground to move forwards, to oppose the foot (or wheel) slipping backwards friction acts forward, pushing you forward (or rotating the wheel).
In this case there is no rotational motion, so friction acts to oppose the translational motion of the body. Treating the body as a rigid body, there is no energy loss due to heating effect effects.
Define the unit vector $ \hat j$ as pointing down the ramp.  The body of mass $m$ is given an initial velocity up the ramp at the start of the ascent.
For the ascent $m \vec a =  \mu \, m \, g\, cos(\theta) \hat j  + m\,g\, sin(\theta) \hat j$.
For the descent $m \vec a = - \mu \, m \, g\, cos(\theta) \hat j  + m\,g\, sin(\theta) \hat j$.
The component of the force of gravity is always in the positive $\hat j$ direction (down the ramp).  The force of friction is in the positive $\hat j$ direction during the ascent (down the ramp) and in the negative $\hat j$ direction during the descent (up the ramp).
