Quote by Archit Patke
According to work  mechanical energy theorem ,
W = K(final)  K(initial) + U(final)  U(initial) . . . . (1)
as we define Potential energy as negative of work done by conservative force and assuming that the only force in this situation is Spring force then ,
W(spring) = K(final)  K(initial)
As work done is calculated by finding component of spring force in direction of displacement. How can we say that U(final)  U(initial) applies for all possible conditions of extension of spring as displacement may not be in direction of force ?
Spring force = 0.5kx^{2}

Welcome to PF!
First of all, your equation (1) defines the external work done by/on a system. If no energy is added or lost (Wext = 0), Kf + Uf = Ki + Ui.
Second, your question is not clear. What do you mean when you say U(final)  U(initial) applies? U(final)  U(initial) is not a mathematical statement.
Finally, your statement: Spring force = 0.5kx
^{2} is not correct. F = kx.
AM